Merge branch 'main' into t3/payroll-net-pay-kernel
This commit is contained in:
commit
90d34585fd
27 files changed
+578
-151
No files matched your search
Generated
+2
-2
@@ -788,7 +788,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "bookspec-checker"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.swaits.com/swaits/bookspec?rev=b61fa50d68f280c048de9c0bcebf7c54d3e8f329#b61fa50d68f280c048de9c0bcebf7c54d3e8f329"
|
||||
source = "git+https://git.swaits.com/swaits/bookspec?rev=6d85d8b90f8702d26e5ed17e8e400cb0a9f13864#6d85d8b90f8702d26e5ed17e8e400cb0a9f13864"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"include_dir",
|
||||
@@ -801,7 +801,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "bookspec-runner"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.swaits.com/swaits/bookspec?rev=b61fa50d68f280c048de9c0bcebf7c54d3e8f329#b61fa50d68f280c048de9c0bcebf7c54d3e8f329"
|
||||
source = "git+https://git.swaits.com/swaits/bookspec?rev=6d85d8b90f8702d26e5ed17e8e400cb0a9f13864#6d85d8b90f8702d26e5ed17e8e400cb0a9f13864"
|
||||
dependencies = [
|
||||
"bookspec-checker",
|
||||
"serde_json",
|
||||
|
||||
@@ -2313,7 +2313,7 @@ fn mcp_receipts_always_required_when_threshold_is_zero() {
|
||||
/// `books.cash_flow` with no accounts passed reads the roles from
|
||||
/// `[books]` in wanderbooks.toml (BS-statement-3): the expense the owners
|
||||
/// paid through 2100 is borrowed from them and spent on its date, each
|
||||
/// line with `on_behalf` (D-42, rule 11); repaying the advance is
|
||||
/// line with `on_behalf` (D-42, BS-statement-3 statement 16); repaying the advance is
|
||||
/// financing; a loan to a member is investing; the statement is the direct
|
||||
/// method's, and it foots.
|
||||
#[test]
|
||||
|
||||
@@ -33,8 +33,8 @@ num-rational = "0.4"
|
||||
toml = "1"
|
||||
# The specification lives in its own repository (P13 step 6, D-34, D-65),
|
||||
# pinned to a commit.
|
||||
bookspec-checker = { git = "https://git.swaits.com/swaits/bookspec", rev = "b61fa50d68f280c048de9c0bcebf7c54d3e8f329" }
|
||||
bookspec-runner = { git = "https://git.swaits.com/swaits/bookspec", rev = "b61fa50d68f280c048de9c0bcebf7c54d3e8f329" }
|
||||
bookspec-checker = { git = "https://git.swaits.com/swaits/bookspec", rev = "6d85d8b90f8702d26e5ed17e8e400cb0a9f13864" }
|
||||
bookspec-runner = { git = "https://git.swaits.com/swaits/bookspec", rev = "6d85d8b90f8702d26e5ed17e8e400cb0a9f13864" }
|
||||
ledger-package = { path = "../ledger-package" }
|
||||
ledger-import = { path = "../ledger-import" }
|
||||
ledger-store = { path = "../ledger-store" }
|
||||
|
||||
@@ -681,24 +681,24 @@ fn signed(side: Side, amount: Decimal) -> Decimal {
|
||||
enum Bucket {
|
||||
/// Operating balance-sheet lines (prepaids, payables, ...), the
|
||||
/// receivables control aside: classed per entry by the structure of
|
||||
/// the entry's operating lines (rule 5), with `Receivables`, `Income`
|
||||
/// the entry's operating lines (BS-statement-3 statement 7), with `Receivables`, `Income`
|
||||
/// and `GuaranteedPayments`.
|
||||
Operating,
|
||||
/// The receivables control account: classed with `Operating`. Apart
|
||||
/// because what a member or lender collects of it for the company is
|
||||
/// a receipt on its behalf (rule 11), and another operating asset
|
||||
/// a receipt on its behalf (BS-statement-3 statement 16), and another operating asset
|
||||
/// handed over is not.
|
||||
Receivables,
|
||||
/// Operating revenue and expense lines other than interest and
|
||||
/// guaranteed payments: classed with `Operating`. Apart from it
|
||||
/// because only these can a member pay for through equity (rule 11),
|
||||
/// because only these can a member pay for through equity (BS-statement-3 statement 16),
|
||||
/// and after it so cash and lenders settle balance-sheet lines first.
|
||||
Income,
|
||||
/// Guaranteed payments to members (tax category
|
||||
/// `guaranteed_payments`): classed with `Operating`. Apart because a
|
||||
/// member never pays their own guaranteed payment for the company:
|
||||
/// one charged to what the company owes them is accrued, not paid
|
||||
/// (rule 11).
|
||||
/// (BS-statement-3 statement 16).
|
||||
GuaranteedPayments,
|
||||
/// Operating: a line on an `interest_income` account, class (b) (ASC
|
||||
/// 230-10-45-25(b)), whatever else the entry settles.
|
||||
@@ -717,14 +717,14 @@ enum Bucket {
|
||||
Equity(String),
|
||||
/// A `financing_accounts` liability, by code.
|
||||
Borrowing(String),
|
||||
/// A liability a distribution was declared to (rule 2: distributions
|
||||
/// A liability a distribution was declared to (BS-statement-3 statement 3: distributions
|
||||
/// payable), by code: its payment is a distribution paid (ASC
|
||||
/// 230-10-45-15(a)), never a supplier's.
|
||||
Declared(String),
|
||||
}
|
||||
|
||||
/// One line of an entry, or one part of a line split between sections
|
||||
/// (the bill split, rule 12), tagged with its place on the statement.
|
||||
/// (the bill split, BS-statement-3 statement 17), tagged with its place on the statement.
|
||||
#[derive(Clone, Debug)]
|
||||
struct Part {
|
||||
account: AccountId,
|
||||
@@ -755,12 +755,12 @@ struct Roles<'a> {
|
||||
receivables: Option<AccountId>,
|
||||
member_of: HashMap<AccountId, usize>,
|
||||
members: Vec<String>,
|
||||
/// Liabilities a distribution was declared to (rule 2).
|
||||
/// Liabilities a distribution was declared to (BS-statement-3 statement 3).
|
||||
declared: BTreeSet<AccountId>,
|
||||
/// The registered fixed assets' depreciation expense accounts (rule 8).
|
||||
/// The registered fixed assets' depreciation expense accounts (BS-statement-3 statement 13).
|
||||
depreciation: BTreeSet<AccountId>,
|
||||
/// What moves money with a party, for resolving an entry's party
|
||||
/// shares to amounts (rule 5's payments to governments).
|
||||
/// shares to amounts (BS-statement-3 statement 8's payments to governments).
|
||||
money: crate::parties::MoneyAccounts,
|
||||
}
|
||||
|
||||
@@ -854,7 +854,7 @@ impl<'a> Roles<'a> {
|
||||
self.cost.contains(&id) || (self.investing.contains(&id) && !self.accum.contains(&id))
|
||||
}
|
||||
|
||||
/// Where a balance-sheet account falls (rule 2): its section and kind.
|
||||
/// Where a balance-sheet account falls (BS-statement-3 statement 3): its section and kind.
|
||||
fn place(&self, a: &Account) -> (Flow, Bucket) {
|
||||
if self.cash.contains(&a.id) {
|
||||
(Flow::Cash, Bucket::Operating)
|
||||
@@ -878,7 +878,7 @@ impl<'a> Roles<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Rule 4: the kind an entry's revenue and expense lines go to when it
|
||||
/// BS-statement-3 statement 5: the kind an entry's revenue and expense lines go to when it
|
||||
/// credits a registered cost account (property) or an investing
|
||||
/// account (the lowest code it credits); `None` otherwise.
|
||||
fn disposal(&self, basis: &JournalEntry) -> Result<Option<Bucket>, LedgerError> {
|
||||
@@ -1026,7 +1026,7 @@ fn declared_payables(
|
||||
/// account.
|
||||
type KindOrder = (u8, u8, String);
|
||||
|
||||
/// Rule 12 (D-35): a bill whose entry debits an investing asset carries
|
||||
/// BS-statement-3 statement 17 (D-35): a bill whose entry debits an investing asset carries
|
||||
/// that part, equipment first, to its payables lines and to its payments,
|
||||
/// so the payment is an investing outflow (ASC 230-10-45-13(c)). A bill
|
||||
/// posts to the general-expenses control today, so this is empty until a
|
||||
@@ -1143,7 +1143,7 @@ struct Analysed<'a> {
|
||||
basis: &'a JournalEntry,
|
||||
parts: Vec<Part>,
|
||||
/// Its cash flows on the statement: each section's cash (constructive
|
||||
/// cash included, rule 11; it nets to zero within the entry, so they
|
||||
/// cash included, BS-statement-3 statement 16; it nets to zero within the entry, so they
|
||||
/// still sum to the entry's cash), and what no cash settled.
|
||||
flows: EntryFlows<Decimal>,
|
||||
/// Per section, the kinds with cash, in kind order.
|
||||
@@ -1159,7 +1159,7 @@ struct KindCash {
|
||||
/// company's behalf.
|
||||
cash: Decimal,
|
||||
/// Of `cash`, what a member or lender paid or received for the company
|
||||
/// (rule 11).
|
||||
/// (BS-statement-3 statement 16).
|
||||
on_behalf: Decimal,
|
||||
}
|
||||
|
||||
@@ -1168,9 +1168,9 @@ struct KindWork {
|
||||
bucket: Bucket,
|
||||
/// Its net movement, debit-positive.
|
||||
moved: Decimal,
|
||||
/// The entry's cash it took (rule 3).
|
||||
/// The entry's cash it took (BS-statement-3 statement 4).
|
||||
cash: Decimal,
|
||||
/// What a member or lender settled of it for the company (rule 11).
|
||||
/// What a member or lender settled of it for the company (BS-statement-3 statement 16).
|
||||
on_behalf: Decimal,
|
||||
}
|
||||
|
||||
@@ -1185,9 +1185,9 @@ impl KindWork {
|
||||
}
|
||||
}
|
||||
|
||||
/// Rule 11 (D-42), one pass: the kinds `source` picks pay for, or receive
|
||||
/// BS-statement-3 statement 16 (D-42), one pass: the kinds `source` picks pay for, or receive
|
||||
/// for, the kinds `uses` picks, by `kernel::constructive`, each in kind
|
||||
/// order (sections in rule 3's order, operating first).
|
||||
/// order (sections in BS-statement-3 statement 4's order, operating first).
|
||||
fn on_behalf(
|
||||
kinds: &mut [Vec<KindWork>; 3],
|
||||
way: OnBehalf,
|
||||
@@ -1259,9 +1259,9 @@ fn analyse<'a>(
|
||||
let amount = line.amount.amount;
|
||||
let pl = !a.account_type.is_balance_sheet();
|
||||
let (flow, bucket) = if pl {
|
||||
// Rule 4: a disposal's gains and losses are investing, except
|
||||
// BS-statement-3 statement 5: a disposal's gains and losses are investing, except
|
||||
// interest, received or paid, which is operating in any entry
|
||||
// (ASC 230-10-45-16(b), 45-17(d)) and its own class (rule 5).
|
||||
// (ASC 230-10-45-16(b), 45-17(d)) and its own class (BS-statement-3 statement 7).
|
||||
let interest = match a.tax_category.as_deref() {
|
||||
Some("interest_income") => Some(Bucket::InterestReceived),
|
||||
Some("interest_expense") => Some(Bucket::InterestPaid),
|
||||
@@ -1287,7 +1287,7 @@ fn analyse<'a>(
|
||||
accum: roles.accum.contains(&line.account),
|
||||
bucket,
|
||||
};
|
||||
// Rule 12: the investing part of a bill's payables line.
|
||||
// BS-statement-3 statement 17: the investing part of a bill's payables line.
|
||||
if !pl
|
||||
&& flow == Flow::Operating
|
||||
&& let Some((inv, kind)) = splits.parts.get(&(basis.id(), i))
|
||||
@@ -1340,7 +1340,7 @@ fn analyse<'a>(
|
||||
on_behalf: Decimal::ZERO,
|
||||
})
|
||||
.collect();
|
||||
// Rule 3: the section's cash among its kinds, in kind order (the
|
||||
// BS-statement-3 statement 4: the section's cash among its kinds, in kind order (the
|
||||
// convention again, within the section).
|
||||
if !cash.flows[k].is_zero() {
|
||||
let movements: Vec<Decimal> = work[k].iter().map(|w| w.moved).collect();
|
||||
@@ -1357,7 +1357,7 @@ fn analyse<'a>(
|
||||
}
|
||||
}
|
||||
}
|
||||
// Rule 11 (D-42): what no cash settled, a member or a lender paid (or
|
||||
// BS-statement-3 statement 16 (D-42): what no cash settled, a member or a lender paid (or
|
||||
// received) for the company. A financing liability pays for operating
|
||||
// and investing kinds; a member's equity only for revenue and expense
|
||||
// (property a member contributes is noncash, ASC 230-10-50-4). Either
|
||||
@@ -1366,7 +1366,7 @@ fn analyse<'a>(
|
||||
// handed over in kind is noncash). Never interest or guaranteed
|
||||
// payments: those are the lender's or the member's own charge, accrued
|
||||
// into what the company owes them, paid to no one. A reversal mirrors
|
||||
// its root (rule 6): what the root paid, it receives back.
|
||||
// its root (BS-statement-3 statement 11): what the root paid, it receives back.
|
||||
let lender = |k: usize, b: &Bucket| k == 2 && matches!(b, Bucket::Borrowing(_));
|
||||
let member =
|
||||
|k: usize, b: &Bucket| k == 2 && matches!(b, Bucket::Member(_) | Bucket::Equity(_));
|
||||
@@ -1390,7 +1390,7 @@ fn analyse<'a>(
|
||||
noncash: [Decimal::ZERO; 3],
|
||||
};
|
||||
let mut kinds: [Vec<KindCash>; 3] = Default::default();
|
||||
// Cash in and out of investing and financing, for rule 7.
|
||||
// Cash in and out of investing and financing, for BS-statement-3 statement 12.
|
||||
let (mut inflow, mut outflow) = (Decimal::ZERO, Decimal::ZERO);
|
||||
for (k, ws) in work.into_iter().enumerate() {
|
||||
for w in ws {
|
||||
@@ -1413,7 +1413,7 @@ fn analyse<'a>(
|
||||
}
|
||||
}
|
||||
}
|
||||
// Rule 7: the exchange inside investing and financing, account by
|
||||
// BS-statement-3 statement 12: the exchange inside investing and financing, account by
|
||||
// account (accumulated depreciation and gains and losses left out).
|
||||
let mut net: BTreeMap<AccountId, Decimal> = BTreeMap::new();
|
||||
for p in &parts {
|
||||
@@ -1496,7 +1496,7 @@ fn negated(f: &EntryFlows<Decimal>) -> EntryFlows<Decimal> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Rule 6: pair each entry with its reversal when both are in the period,
|
||||
/// BS-statement-3 statement 11: pair each entry with its reversal when both are in the period,
|
||||
/// walking each chain from its root, so a reversal of a reversal is shown
|
||||
/// (review item 1). A pair nets only when its flows, kinds and exchange
|
||||
/// are exact negatives (review item 8); otherwise both are shown.
|
||||
@@ -1542,7 +1542,7 @@ fn pairs(kept: &[Analysed<'_>]) -> HashSet<EntryId> {
|
||||
paired
|
||||
}
|
||||
|
||||
/// A line's or disclosure's label (rule 6): never from the sign.
|
||||
/// A line's or disclosure's label (BS-statement-3 statement 11): never from the sign.
|
||||
fn label(ledger: &Ledger, a: &Analysed<'_>) -> String {
|
||||
let id = a.entry.id();
|
||||
match a.entry.reversal_of() {
|
||||
@@ -1559,7 +1559,7 @@ fn label(ledger: &Ledger, a: &Analysed<'_>) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Rule 5: the class of one kind of an entry's operating cash, from the
|
||||
/// BS-statement-3 statement 7: the class of one kind of an entry's operating cash, from the
|
||||
/// direction of its root's cash: interest received or paid by its own
|
||||
/// lines (whatever else the entry settles); everything else by the
|
||||
/// structure of the entry's other operating lines. A payment's part that
|
||||
@@ -1622,7 +1622,7 @@ fn class_of(
|
||||
})
|
||||
}
|
||||
|
||||
/// Rule 5: the accounts of an entry's other operating lines (not
|
||||
/// BS-statement-3 statement 7: the accounts of an entry's other operating lines (not
|
||||
/// interest), whose structure classes its operating cash.
|
||||
fn operating_accounts<'a>(
|
||||
roles: &Roles<'a>,
|
||||
@@ -1652,7 +1652,7 @@ const PAY: [&str; 4] = [
|
||||
"pension_profit_sharing",
|
||||
];
|
||||
|
||||
/// Rule 5: of an operating payment the structure put in another class,
|
||||
/// BS-statement-3 statement 8: of an operating payment the structure put in another class,
|
||||
/// what went to a government, as (the government's size, everyone
|
||||
/// else's), from the entry's party shares (its chain root's: a reversal
|
||||
/// takes its original's). A party is a government if it has the
|
||||
@@ -1708,7 +1708,7 @@ fn government_part(
|
||||
Ok((!ours.is_zero()).then_some((ours, theirs)))
|
||||
}
|
||||
|
||||
/// Rule 5: `amount` split as `ours` to `theirs`, the government's part
|
||||
/// BS-statement-3 statement 8: `amount` split as `ours` to `theirs`, the government's part
|
||||
/// rounded half to even to the base currency's places, the rest the
|
||||
/// other's: the two always sum to `amount`.
|
||||
fn split_part(
|
||||
@@ -1770,7 +1770,7 @@ fn codes<'p>(
|
||||
/// 2. An entry MUST contribute to the body only its cash, applied to the
|
||||
/// sections moving against it in the order operating, investing,
|
||||
/// financing, each up to its own movement (CONVENTION: the order),
|
||||
/// and what a member or lender paid or received for it (rule 11),
|
||||
/// and what a member or lender paid or received for it (BS-statement-3 statement 16),
|
||||
/// which nets to zero within the entry; what neither settled is
|
||||
/// disclosed, never reported as cash.
|
||||
/// 3. The revenue and expense lines of an entry crediting a registered
|
||||
@@ -1828,7 +1828,7 @@ pub fn cash_flow(
|
||||
let closings = ledger.closing_entry_ids();
|
||||
let in_period = |d: NaiveDate| d >= params.start && d <= params.end;
|
||||
|
||||
// Rules 1, 3, 4: every non-closing entry in the period.
|
||||
// BS-statement-3 statements 2, 4 and 5: every non-closing entry in the period.
|
||||
let mut kept: Vec<Analysed<'_>> = Vec::new();
|
||||
for entry in ledger.posted_entries() {
|
||||
if in_period(entry.date()) && !closings.contains(&entry.id()) {
|
||||
@@ -1838,7 +1838,7 @@ pub fn cash_flow(
|
||||
let paired = pairs(&kept);
|
||||
let places = ledger.base_currency().allocation_places();
|
||||
|
||||
// Rule 5: the body, one line per entry, section and kind.
|
||||
// BS-statement-3 statement 6: the body, one line per entry, section and kind.
|
||||
type Sorted = (KindOrder, NaiveDate, EntryId, CashFlowLine);
|
||||
let mut body: [Vec<Sorted>; 3] = Default::default();
|
||||
let mut totals = [Decimal::ZERO; 3];
|
||||
@@ -1861,7 +1861,7 @@ pub fn cash_flow(
|
||||
{
|
||||
let inflow = (*amount > Decimal::ZERO) != a.flip;
|
||||
// The kind's cash, by caption: one piece, or two when a
|
||||
// payment went partly to a government (rule 5).
|
||||
// payment went partly to a government (BS-statement-3 statement 8).
|
||||
let mut pieces = Vec::new();
|
||||
if *section == CashFlowSection::Operating {
|
||||
let class = class_of(&roles, a, bucket, inflow)?;
|
||||
@@ -1937,7 +1937,7 @@ pub fn cash_flow(
|
||||
{
|
||||
sorted.sort_by(|x, y| (&x.0, x.1, x.2).cmp(&(&y.0, y.1, y.2)));
|
||||
*out = sorted.into_iter().map(|(_, _, _, l)| l).collect();
|
||||
// Rule 9: each section's total is its lines (the pairs net to
|
||||
// BS-statement-3 statement 14: each section's total is its lines (the pairs net to
|
||||
// zero).
|
||||
let mut sum = Decimal::ZERO;
|
||||
for l in out.iter() {
|
||||
@@ -1952,7 +1952,7 @@ pub fn cash_flow(
|
||||
}
|
||||
}
|
||||
|
||||
// Rule 7: noncash investing and financing activities.
|
||||
// BS-statement-3 statement 12: noncash investing and financing activities.
|
||||
let mut noncash_disclosures = Vec::new();
|
||||
for a in kept.iter().filter(|a| !paired.contains(&a.entry.id())) {
|
||||
let r = a.flows.noncash;
|
||||
@@ -2002,7 +2002,7 @@ pub fn cash_flow(
|
||||
let operating_reconciliation = reconcile(&roles, &kept, &paired, totals[0])?;
|
||||
let warnings = warnings(&roles, &kept, &paired)?;
|
||||
|
||||
// Rule 9: the cash accounts' balances, and the footing.
|
||||
// BS-statement-3 statement 14: the cash accounts' balances, and the footing.
|
||||
let (mut cash_beginning, mut cash_ending) = (Decimal::ZERO, Decimal::ZERO);
|
||||
for e in ledger.posted_entries() {
|
||||
for l in e.lines() {
|
||||
@@ -2046,7 +2046,7 @@ pub fn cash_flow(
|
||||
})
|
||||
}
|
||||
|
||||
/// Rule 8: net cash from operating = NI + G + X + W, over every kept entry
|
||||
/// BS-statement-3 statement 13: net cash from operating = NI + G + X + W, over every kept entry
|
||||
/// (netted pairs included: they sum to zero), checked against the
|
||||
/// operating section.
|
||||
fn reconcile(
|
||||
@@ -2303,7 +2303,7 @@ mod tests {
|
||||
s.parse().unwrap()
|
||||
}
|
||||
|
||||
/// Rule 5's split of a payment between a government and the rest:
|
||||
/// BS-statement-3 statement 8's split of a payment between a government and the rest:
|
||||
/// the government's part rounded half to even, the rest exact, a
|
||||
/// whole government payment untouched.
|
||||
#[test]
|
||||
@@ -2319,7 +2319,7 @@ mod tests {
|
||||
}
|
||||
|
||||
proptest::proptest! {
|
||||
/// Rule 5: the two parts always sum to the payment, the
|
||||
/// BS-statement-3 statement 8: the two parts always sum to the payment, the
|
||||
/// government's within half a cent of its exact share, a payment
|
||||
/// and its reversal split as mirrors.
|
||||
#[test]
|
||||
|
||||
@@ -1328,7 +1328,7 @@ pub fn constructive<T: Amount>(
|
||||
/// and financing balance-sheet accounts (each account netted first; both
|
||||
/// non-negative); `inflow` and `outflow` are the cash those two sections
|
||||
/// took in and paid out (both non-negative; constructive cash included,
|
||||
/// rule 11). Cash in settles credits and cash out settles debits; what's
|
||||
/// BS-statement-3 statement 16). Cash in settles credits and cash out settles debits; what's
|
||||
/// left of the smaller side was exchanged:
|
||||
/// `max(0, min(debits - outflow, credits - inflow))`.
|
||||
///
|
||||
@@ -2242,7 +2242,7 @@ mod tests {
|
||||
assert_eq!(exchanged(0i64, 1000, 500, 0), Some(0));
|
||||
// A cash purchase: cash out covers every debit.
|
||||
assert_eq!(exchanged(1000i64, 0, 0, 1000), Some(0));
|
||||
// Equipment a lender paid for (rule 11): 1,000 borrowed in, 1,000
|
||||
// Equipment a lender paid for (BS-statement-3 statement 16): 1,000 borrowed in, 1,000
|
||||
// spent out, nothing exchanged.
|
||||
assert_eq!(exchanged(1000i64, 1000, 1000, 1000), Some(0));
|
||||
}
|
||||
|
||||
@@ -216,8 +216,14 @@ pub(crate) fn new_schedule(
|
||||
months: s.months,
|
||||
balance_account: account(&s.balance_account),
|
||||
pl_account: account(&s.pl_account),
|
||||
convention: ScheduleConvention::parse(&s.convention)
|
||||
.unwrap_or_else(|| panic!("{what}: schedule convention {:?}", s.convention)),
|
||||
// A schedule that names no convention takes the engine's method for
|
||||
// new schedules (BS-prepaid-2): wanderbooks spreads new schedules by
|
||||
// the day (D-11, D-37).
|
||||
convention: match s.convention.as_deref() {
|
||||
Some(c) => ScheduleConvention::parse(c)
|
||||
.unwrap_or_else(|| panic!("{what}: schedule convention {c:?}")),
|
||||
None => ScheduleConvention::Daily,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +364,8 @@ impl<'a> Books<'a> {
|
||||
&what,
|
||||
);
|
||||
if let Some(c) = &a.tax_category {
|
||||
took(self.store.set_account_tax(account, Some(c), None), &what);
|
||||
let percent = a.deductible_percent.as_deref().map(|p| exact(p, &what));
|
||||
took(self.store.set_account_tax(account, Some(c), percent), &what);
|
||||
}
|
||||
}
|
||||
let first = ex
|
||||
|
||||
@@ -58,6 +58,8 @@ pub(crate) fn check(b: &Books<'_>, x: &Expect) -> Option<&'static str> {
|
||||
"code",
|
||||
&["rename_account", "set_tax_category"],
|
||||
);
|
||||
only(x.key.is_some(), "key", &["setting"]);
|
||||
only(x.role.is_some(), "role", &["role_account"]);
|
||||
only(x.name.is_some(), "name", &["rename_account"]);
|
||||
only(x.category.is_some(), "category", &["set_tax_category"]);
|
||||
only(x.account.is_some(), "account", &["add_account"]);
|
||||
@@ -144,6 +146,9 @@ pub(crate) fn check(b: &Books<'_>, x: &Expect) -> Option<&'static str> {
|
||||
"invoice_numbers" => check_invoice_numbers(b, x),
|
||||
"draft_state" => check_draft_state(b, x),
|
||||
"evidence" => check_evidence(b, x),
|
||||
"setting" => check_setting(b, x),
|
||||
"role_account" => check_role_account(b, x),
|
||||
"tax_summary" => check_tax_summary(b, x),
|
||||
q => {
|
||||
let &(_, by) = FORMAT_QUERIES
|
||||
.iter()
|
||||
|
||||
@@ -25,11 +25,12 @@ impl Books<'_> {
|
||||
("attach_receipt", e.attach_receipt.is_some()),
|
||||
("discard_draft", e.discard_draft.is_some()),
|
||||
("assign_role", e.assign_role.is_some()),
|
||||
("set_setting", e.set_setting.is_some()),
|
||||
];
|
||||
match kinds.iter().filter(|(_, given)| *given).collect::<Vec<_>>()[..] {
|
||||
[(kind, _)] => kind,
|
||||
_ => panic!(
|
||||
"{} event {n}: an event is one of lines, reverses, close, bill, invoice, write_off, payment, settlement, recovery, run_depreciation, dispose_asset, run_schedules, register_schedule, post_draft, set_draft_state, attach_receipt, discard_draft or assign_role",
|
||||
"{} event {n}: an event is one of lines, reverses, close, bill, invoice, write_off, payment, settlement, recovery, run_depreciation, dispose_asset, run_schedules, register_schedule, post_draft, set_draft_state, attach_receipt, discard_draft, assign_role or set_setting",
|
||||
self.ex.id
|
||||
),
|
||||
}
|
||||
@@ -827,6 +828,22 @@ impl Books<'_> {
|
||||
// account before it writes anything (BS-ledger-19).
|
||||
self.store.assign_role(&a.role, Some(account))
|
||||
}
|
||||
"set_setting" => {
|
||||
let s = e.set_setting.as_ref().expect("checked: a setting");
|
||||
// The books' own journaled command: the fact and who decided
|
||||
// it are kept in the journal (BS-ledger-9).
|
||||
let change = Change {
|
||||
key: engine_setting_key(&s.key).to_string(),
|
||||
value: Some(Value::String(s.value.clone())),
|
||||
};
|
||||
let source = Source {
|
||||
decided_by: s.decided_by.clone(),
|
||||
decided_on: date(&s.decided_on, what),
|
||||
citation: None,
|
||||
note: None,
|
||||
};
|
||||
self.store.change_settings(&[change], &source).map(|_| ())
|
||||
}
|
||||
other => unreachable!("{other} is no event"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,10 @@ pub(crate) fn every_bookspec_example_holds() {
|
||||
("party_tin_last4", 5),
|
||||
("iif_lines", 1),
|
||||
("iif_changes", 1),
|
||||
("iif_line_ending", 1),
|
||||
("setting", 1),
|
||||
("role_account", 1),
|
||||
("tax_summary", 1),
|
||||
("period", 6),
|
||||
("day", 1),
|
||||
("calendar_year", 1),
|
||||
@@ -162,17 +166,19 @@ pub(crate) fn every_bookspec_example_holds() {
|
||||
// of BS-arap-2 (documents-kept-apart), -7, -8, -9, -10 (compare-exactly),
|
||||
// -11 (recovery-movement), -12 (net-of-expected-discount), -13
|
||||
// (net-against-the-deposit) and -14 (apportion-across-the-lines),
|
||||
// BS-prepaid-2's equal-months and BS-ledger-20's refuse (each option's
|
||||
// example, so no allow-list grows), BS-entry-6's check-only-when-posting
|
||||
// and BS-ledger-17's reversal-needs-its-own (wanderbooks refuses a line on
|
||||
// a header as it is added, and a reversal needs no evidence of its own),
|
||||
// and BS-period-4's allow-partial-overlap, BS-1099-2's
|
||||
// carry-the-last-amount and BS-partner-8's nowhere (wanderbooks nests
|
||||
// periods, refuses a year whose threshold it does not know, and keeps
|
||||
// the full TIN outside the books).
|
||||
// BS-prepaid-2's equal-months, BS-prepaid-4's cent rule and BS-ledger-20's
|
||||
// refuse (each option's example, so no allow-list grows), BS-entry-6's
|
||||
// check-only-when-posting and BS-ledger-17's reversal-needs-its-own
|
||||
// (wanderbooks refuses a line on a header as it is added, and a reversal
|
||||
// needs no evidence of its own), BS-format-5's file place, -6's one
|
||||
// fiscal year, -8's closes-written and -4's platform line ending,
|
||||
// BS-ledger-21's round-per-account, BS-period-4's allow-partial-overlap,
|
||||
// BS-1099-2's carry-the-last-amount and BS-partner-8's nowhere
|
||||
// (wanderbooks nests periods, refuses a year whose threshold it does not
|
||||
// know, and keeps the full TIN outside the books).
|
||||
assert_eq!(
|
||||
skipped.len(),
|
||||
16,
|
||||
"the sixteen unpicked-option examples: {skipped:?}"
|
||||
22,
|
||||
"the twenty-two unpicked-option examples: {skipped:?}"
|
||||
);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ pub(crate) use std::path::{Path, PathBuf};
|
||||
pub(crate) use chrono::{Datelike, NaiveDate};
|
||||
pub(crate) use ledger_core::calendar::{PeriodDefaults, period_defaults};
|
||||
pub(crate) use ledger_core::parties::{Basis, MoneyAccounts};
|
||||
pub(crate) use ledger_core::settings::{Company, Source};
|
||||
pub(crate) use ledger_core::settings::{Change, Company, Source};
|
||||
pub(crate) use ledger_core::tax_capital::TaxCapitalRow;
|
||||
pub(crate) use ledger_core::{
|
||||
AccountType, AssetId, BillFields, CashFlowParams, CashFlowSection, CashFlowStatement, CloseTo,
|
||||
@@ -55,8 +55,8 @@ pub(crate) use ledger_core::{
|
||||
InstrumentId, InstrumentKind, InvoiceFields, Ledger, LedgerError, MemberCapital, MemberClose,
|
||||
Money, NewAsset, NewSchedule, PartyId, PartyMember, PartyShare, PaymentAccounts,
|
||||
ReconcilingKind, Role, ScheduleConvention, ScheduleId, ScheduleKind, Share, Side, Terms,
|
||||
TinFacts, TinType, VendorId, W9Facts, cash_flow, members_equity, profit_and_loss_for_period,
|
||||
trial_balance_as_of, vendor_1099_report,
|
||||
TinFacts, TinType, VendorId, W9Facts, cash_flow, control_account, members_equity,
|
||||
profit_and_loss_for_period, tax_summary, trial_balance_as_of, vendor_1099_report,
|
||||
};
|
||||
pub(crate) use ledger_store::{DepreciationRun, DisposalPreview, Store, StoreError};
|
||||
pub(crate) use ledger_vault::{Tin, Vault};
|
||||
@@ -74,6 +74,7 @@ pub(crate) use books::*;
|
||||
pub(crate) use check::check;
|
||||
pub(crate) use common::*;
|
||||
pub(crate) use queries::assets::*;
|
||||
pub(crate) use queries::book::*;
|
||||
pub(crate) use queries::commands::*;
|
||||
pub(crate) use queries::dates::*;
|
||||
pub(crate) use queries::documents::*;
|
||||
|
||||
@@ -110,10 +110,14 @@ impl Books<'_> {
|
||||
let mut m = JsonMap::new();
|
||||
let mut total = Decimal::ZERO;
|
||||
for (d, amount) in &plan {
|
||||
m.insert(d.to_string(), Value::String(figure(*amount)));
|
||||
// The plan's own amounts are already whole units of the
|
||||
// currency (BS-prepaid-1, -4): a yen schedule's month is 333,
|
||||
// not 333.00, and a dollar schedule's 33.33. Printed as they
|
||||
// stand, never padded to the cent.
|
||||
m.insert(d.to_string(), Value::String(amount.to_string()));
|
||||
total += *amount;
|
||||
}
|
||||
m.insert("total".to_string(), Value::String(figure(total)));
|
||||
m.insert("total".to_string(), Value::String(total.to_string()));
|
||||
Ok(Value::Object(m))
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
use crate::*;
|
||||
|
||||
/// The engine's key for a bookspec setting key (`SETTING_KEYS`): the
|
||||
/// engine's own settings carry the `company.` prefix. A key the schema
|
||||
/// admits and this map lacks is a gap in the adapter, so it panics.
|
||||
pub(crate) fn engine_setting_key(bookspec_key: &str) -> &'static str {
|
||||
match bookspec_key {
|
||||
"fiscal_year_start" => "company.fiscal_year_start",
|
||||
other => panic!("the adapter maps no engine key for the bookspec setting {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
impl Books<'_> {
|
||||
/// A `setting` query (BS-ledger-9): the value the books keep, with who
|
||||
/// decided it and when. The books hold their settings in the journal
|
||||
/// (wanderbooks' pick, facts-in-the-books), so a replay reaches them.
|
||||
pub(crate) fn answer_setting(&self, q: &Query) -> Result<Value, Refusal> {
|
||||
let rule = RuleId::new(Area::Ledger, 9);
|
||||
let key = q.key.as_deref().ok_or_else(|| self.missing("key"))?;
|
||||
let recorded = self
|
||||
.l()
|
||||
.settings()
|
||||
.get(engine_setting_key(key))
|
||||
.ok_or_else(|| {
|
||||
Refusal::new(rule.clone(), format!("no setting {key:?} in the books"))
|
||||
})?;
|
||||
let value = match &recorded.value {
|
||||
Value::String(s) => s.clone(),
|
||||
other => other.to_string(),
|
||||
};
|
||||
Ok(json_figures([
|
||||
("value".to_string(), value),
|
||||
("decided_by".to_string(), recorded.source.decided_by.clone()),
|
||||
(
|
||||
"decided_on".to_string(),
|
||||
recorded.source.decided_on.to_string(),
|
||||
),
|
||||
]))
|
||||
}
|
||||
|
||||
/// A `role_account` query (BS-ledger-18): the account a control role
|
||||
/// posts to, read from the books' own journaled assignment.
|
||||
pub(crate) fn answer_role_account(&self, q: &Query) -> Result<Value, Refusal> {
|
||||
let rule = RuleId::new(Area::Ledger, 18);
|
||||
let role = q.role.as_deref().ok_or_else(|| self.missing("role"))?;
|
||||
let control = control_account(role)
|
||||
.ok_or_else(|| Refusal::new(rule.clone(), format!("{role:?} is no control role")))?;
|
||||
let account = self
|
||||
.l()
|
||||
.role_account(control)
|
||||
.and_then(|id| self.l().chart().get(id))
|
||||
.map(|a| a.code.clone())
|
||||
.unwrap_or_else(|| "unassigned".to_string());
|
||||
Ok(json_figures([("account".to_string(), account)]))
|
||||
}
|
||||
|
||||
/// A `tax_summary` query (BS-ledger-21): each category's deductible
|
||||
/// amount, as `tax::tax_summary` figures it (one rounding, on the
|
||||
/// category's exact total: wanderbooks' pick, round-once-on-the-total).
|
||||
pub(crate) fn answer_tax_summary(&self, q: &Query) -> Result<Value, Refusal> {
|
||||
let rule = RuleId::new(Area::Ledger, 21);
|
||||
let (from, to) = self.q_period(q)?;
|
||||
let summary = tax_summary(self.l(), from, to, None).map_err(|e| engine_refusal(rule, e))?;
|
||||
let mut out = JsonMap::new();
|
||||
for line in summary
|
||||
.income
|
||||
.iter()
|
||||
.chain(&summary.cost_of_goods)
|
||||
.chain(&summary.deductions)
|
||||
.chain(&summary.separately_stated)
|
||||
{
|
||||
out.insert(line.category.clone(), Value::String(figure(line.tax)));
|
||||
}
|
||||
Ok(Value::Object(out))
|
||||
}
|
||||
}
|
||||
|
||||
/// Check one `setting` expectation (BS-ledger-9): the value, who decided it
|
||||
/// and when, as the books keep them.
|
||||
pub(crate) fn check_setting(b: &Books<'_>, x: &Expect) {
|
||||
let ex = b.ex;
|
||||
undated(ex, x);
|
||||
exactly(
|
||||
ex,
|
||||
x,
|
||||
&["decided_by", "decided_on", "value"]
|
||||
.map(String::from)
|
||||
.into(),
|
||||
);
|
||||
let got = b
|
||||
.answer(&x.query())
|
||||
.unwrap_or_else(|e| panic!("{}: setting refused ({})", ex.id, e.reason));
|
||||
let got = got.as_object().expect("a setting answers figures");
|
||||
for (k, want) in x.figures(&ex.id) {
|
||||
assert_eq!(
|
||||
got.get(k).and_then(Value::as_str),
|
||||
Some(want.as_str()),
|
||||
"{}: setting {k}",
|
||||
ex.id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Check one `role_account` expectation (BS-ledger-18): the code the role's
|
||||
/// account has in the books.
|
||||
pub(crate) fn check_role_account(b: &Books<'_>, x: &Expect) {
|
||||
let ex = b.ex;
|
||||
undated(ex, x);
|
||||
exactly(ex, x, &["account".to_string()].into());
|
||||
let got = b
|
||||
.answer(&x.query())
|
||||
.unwrap_or_else(|e| panic!("{}: role_account refused ({})", ex.id, e.reason));
|
||||
let got = got.as_object().expect("a role account answers figures");
|
||||
for (k, want) in x.figures(&ex.id) {
|
||||
assert_eq!(
|
||||
got.get(k).and_then(Value::as_str),
|
||||
Some(want.as_str()),
|
||||
"{}: role_account {k}",
|
||||
ex.id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Check one `tax_summary` expectation (BS-ledger-21): each category's
|
||||
/// deductible amount, by category key.
|
||||
pub(crate) fn check_tax_summary(b: &Books<'_>, x: &Expect) {
|
||||
let ex = b.ex;
|
||||
let (from, to) = period(ex, x);
|
||||
assert!(
|
||||
from <= to,
|
||||
"{}: tax_summary from {from} after to {to}",
|
||||
ex.id
|
||||
);
|
||||
let got = b
|
||||
.answer(&x.query())
|
||||
.unwrap_or_else(|e| panic!("{}: tax_summary refused ({})", ex.id, e.reason));
|
||||
let got = got.as_object().expect("a tax summary answers figures");
|
||||
for (k, want) in x.figures(&ex.id) {
|
||||
assert_eq!(
|
||||
got.get(k).and_then(Value::as_str),
|
||||
Some(want.as_str()),
|
||||
"{}: tax_summary {k}",
|
||||
ex.id
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,29 @@ impl Books<'_> {
|
||||
.collect(),
|
||||
))
|
||||
}
|
||||
"iif_line_ending" => {
|
||||
// The file's own bytes: every line break is CR LF
|
||||
// (wanderbooks' pick, cr-lf), every one a bare LF, or a mix
|
||||
// of the two, which is neither. The engine has no notion of
|
||||
// a host, so the example's `setup.host_line_ending` is not
|
||||
// read here.
|
||||
let text = iif.text.as_str();
|
||||
let lf = text.matches('\n').count();
|
||||
let crlf = text.matches("\r\n").count();
|
||||
let ending = if lf == 0 {
|
||||
"none"
|
||||
} else if lf == crlf {
|
||||
"cr-lf"
|
||||
} else if crlf == 0 {
|
||||
"lf"
|
||||
} else {
|
||||
"mixed"
|
||||
};
|
||||
Ok(json_figures([(
|
||||
"line_ending".to_string(),
|
||||
ending.to_string(),
|
||||
)]))
|
||||
}
|
||||
_ => Ok(Value::Array(
|
||||
iif.changes
|
||||
.iter()
|
||||
@@ -53,7 +76,7 @@ impl Books<'_> {
|
||||
|
||||
/// The formats appendix's queries, and the test (another crate's) that
|
||||
/// checks them against the engine.
|
||||
pub(crate) const FORMAT_QUERIES: [(&str, &str); 2] = [
|
||||
pub(crate) const FORMAT_QUERIES: [(&str, &str); 3] = [
|
||||
(
|
||||
"iif_lines",
|
||||
"ledger-package the_bookspec_iif_example_matches_the_engine",
|
||||
@@ -62,6 +85,10 @@ pub(crate) const FORMAT_QUERIES: [(&str, &str); 2] = [
|
||||
"iif_changes",
|
||||
"ledger-package the_bookspec_iif_example_matches_the_engine",
|
||||
),
|
||||
(
|
||||
"iif_line_ending",
|
||||
"ledger-core the_runner_reports_every_claimed_rule_green",
|
||||
),
|
||||
];
|
||||
|
||||
/// A refused format query (BS-format-10): the appendix and the day, no
|
||||
@@ -98,6 +125,16 @@ pub(crate) fn check_format_shape(ex: &Example, x: &Expect) {
|
||||
assert_eq!(r.len(), 3, "{}: iif_changes row {r:?}", ex.id);
|
||||
}
|
||||
}
|
||||
("iif_line_ending", Values::Figures(f)) => {
|
||||
assert!(
|
||||
matches!(
|
||||
f.get("line_ending").map(String::as_str),
|
||||
Some("cr-lf" | "lf")
|
||||
),
|
||||
"{}: iif_line_ending is cr-lf or lf: {f:?}",
|
||||
ex.id
|
||||
);
|
||||
}
|
||||
(q, _) => panic!("{}: {q}: values of the wrong shape", ex.id),
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::*;
|
||||
|
||||
pub(crate) mod assets;
|
||||
pub(crate) mod book;
|
||||
pub(crate) mod commands;
|
||||
pub(crate) mod dates;
|
||||
pub(crate) mod documents;
|
||||
@@ -93,6 +94,9 @@ impl Books<'_> {
|
||||
"invoice_numbers" => self.answer_invoice_numbers(q),
|
||||
"draft_state" => self.answer_draft_state(q),
|
||||
"evidence" => self.answer_evidence(q),
|
||||
"setting" => self.answer_setting(q),
|
||||
"role_account" => self.answer_role_account(q),
|
||||
"tax_summary" => self.answer_tax_summary(q),
|
||||
"run" => self.answer_run(q),
|
||||
"disposal" => self.answer_disposal(q),
|
||||
"depreciation_schedule" => self.answer_depreciation_schedule(q),
|
||||
@@ -127,7 +131,7 @@ impl Books<'_> {
|
||||
.map(|a| Value::String(format!("{} {}", a.code, a.name)))
|
||||
.collect(),
|
||||
)),
|
||||
"iif_lines" | "iif_changes" => self.answer_iif(q),
|
||||
"iif_lines" | "iif_changes" | "iif_line_ending" => self.answer_iif(q),
|
||||
"rename_account" | "add_account" | "set_tax_category" => self.answer_command(q),
|
||||
other => Err(Refusal::new(
|
||||
RuleId::new(Area::Ledger, 1),
|
||||
|
||||
@@ -18,6 +18,14 @@
|
||||
//! product rule with no such list takes no sub-number, and has no
|
||||
//! statements (those are bookspec's).
|
||||
//!
|
||||
//! A bare `Rule n` or `rule n` is refused in a file that is the cash-flow
|
||||
//! statement's or a party's throughout, and elsewhere on a line that
|
||||
//! cites `BS-statement-3` or `BS-partner-3`: bookspec unit S-C8 dropped
|
||||
//! those two records' old labels, which had drifted from the statements'
|
||||
//! positions, and a reference is now `BS-statement-3 statement k` (or
|
||||
//! `BS-partner-3 statement k`). An ordinary use of the word, with no
|
||||
//! number or away from a citation, is not a label.
|
||||
//!
|
||||
//! A reference may be a list ("statements 5, 11 and 13"), a range
|
||||
//! ("statements 27-30"), parenthesised, wrapped across lines behind a
|
||||
//! comment prefix, backticked after the id (`` `BS-asset-1` statements
|
||||
@@ -35,12 +43,68 @@ fn repo_root() -> PathBuf {
|
||||
/// How many references the scan must find, at least: exactly the number
|
||||
/// found when it was last set, so none can vanish silently. Raise it, in
|
||||
/// the same commit, when references are added; it never falls.
|
||||
const CHECKED_FLOOR: usize = 361;
|
||||
const CHECKED_FLOOR: usize = 515;
|
||||
|
||||
/// The tracked file this check does not scan: its own self-tests quote
|
||||
/// the forms it refuses.
|
||||
const SELF: &str = "crates/ledger-core/tests/bookspec/sub_refs.rs";
|
||||
|
||||
/// The files that are the cash-flow statement's or a party's throughout.
|
||||
/// BS-statement-3 and BS-partner-3 used to open their statements with
|
||||
/// "Rule n" labels that drifted from their positions; bookspec unit S-C8
|
||||
/// dropped them, and every reference is now a position. A numbered
|
||||
/// "rule n" in one of these files is that old label, so it is refused
|
||||
/// even when the line does not name the record. Elsewhere a bare label is
|
||||
/// refused only beside a citation of one of those two records, so an
|
||||
/// ordinary use of the word ("this rule holds", "the run rule 0.02") is
|
||||
/// left alone.
|
||||
const OLD_LABEL_FILES: &[&str] = &[
|
||||
"crates/ledger-core/src/cashflow.rs",
|
||||
"crates/ledger-core/tests/spec_cash_flow.rs",
|
||||
"crates/ledger-core/tests/spec_reports.rs",
|
||||
"crates/ledger-core/src/parties.rs",
|
||||
"crates/ledger-core/tests/spec_parties.rs",
|
||||
"crates/ledger-core/tests/spec_party_totals.rs",
|
||||
"crates/ledger-core/src/shares.rs",
|
||||
"crates/ledger-core/src/k1.rs",
|
||||
"crates/ledger-cli/tests/spec_parties.rs",
|
||||
"crates/ledger-cli/tests/spec_party_totals.rs",
|
||||
];
|
||||
|
||||
/// The byte offsets of bare old labels: `Rule n`, `rule n`, `rules n`,
|
||||
/// with a number after. A label straight after a bookspec id
|
||||
/// ("BS-arap-2 rule 3") is the id scan's finding, not this one's.
|
||||
fn bare_old_labels(flat: &str) -> Vec<usize> {
|
||||
let chars: Vec<char> = flat.chars().collect();
|
||||
let offsets: Vec<usize> = flat.char_indices().map(|(b, _)| b).collect();
|
||||
let mut out = Vec::new();
|
||||
for i in 0..chars.len() {
|
||||
if i > 0 && is_id_char(chars[i - 1]) {
|
||||
continue;
|
||||
}
|
||||
if chars[i] != 'r' && chars[i] != 'R' {
|
||||
continue;
|
||||
}
|
||||
let head: String = chars[i..(i + 4).min(chars.len())].iter().collect();
|
||||
if head != "rule" && head != "Rule" {
|
||||
continue;
|
||||
}
|
||||
let mut j = i + 4;
|
||||
if matches!(chars.get(j), Some('s' | 'S')) {
|
||||
j += 1;
|
||||
}
|
||||
// At least one space, then a number.
|
||||
let start = j;
|
||||
while chars.get(j) == Some(&' ') {
|
||||
j += 1;
|
||||
}
|
||||
if j > start && chars.get(j).is_some_and(|c| c.is_ascii_digit()) {
|
||||
out.push(offsets[i]);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The parts a record has: its statements, invariants and scenarios.
|
||||
#[derive(Clone, Copy, Default)]
|
||||
struct Parts {
|
||||
@@ -271,6 +335,8 @@ fn scan(text: &str, at: &str, parts: &BTreeMap<String, Parts>) -> (usize, Vec<St
|
||||
let (flat, starts) = flatten(text);
|
||||
let mut checked = 0usize;
|
||||
let mut problems = Vec::new();
|
||||
// The offsets of old labels the id scan already reports.
|
||||
let mut consumed: BTreeSet<usize> = BTreeSet::new();
|
||||
let mut hits: Vec<(usize, &str)> = ["BS-", "WB-"]
|
||||
.iter()
|
||||
.flat_map(|prefix| flat.match_indices(prefix).map(|(pos, _)| (pos, *prefix)))
|
||||
@@ -359,6 +425,9 @@ fn scan(text: &str, at: &str, parts: &BTreeMap<String, Parts>) -> (usize, Vec<St
|
||||
let (nums, end) = number_list(&rest, i + 1);
|
||||
let shown: String = rest[word_from..end].iter().collect();
|
||||
if !new {
|
||||
if let Some(b) = offsets.get(word_from) {
|
||||
consumed.insert(pos + 3 + b);
|
||||
}
|
||||
problems.push(format!(
|
||||
"{at}:{line}: {id} {shown}: the old vocabulary; say `statement`, `invariant` or `scenario` k, as bookspec numbers its parts"
|
||||
));
|
||||
@@ -399,6 +468,36 @@ fn scan(text: &str, at: &str, parts: &BTreeMap<String, Parts>) -> (usize, Vec<St
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
// A bare old label: `Rule 11` or `rule 11` for a record that numbers
|
||||
// its parts by position. Refused in a file that is the cash-flow
|
||||
// statement's or a party's throughout, and elsewhere only beside a
|
||||
// BS-statement-3 or BS-partner-3 citation on the same line, so
|
||||
// ordinary uses of the word ("this rule holds", "the run rule 0.02")
|
||||
// are not caught.
|
||||
let scoped = OLD_LABEL_FILES.contains(&at);
|
||||
let lines: Vec<&str> = text.lines().collect();
|
||||
for pos in bare_old_labels(&flat) {
|
||||
if consumed.contains(&pos) {
|
||||
continue;
|
||||
}
|
||||
let line = line_at(&starts, pos);
|
||||
let beside = lines
|
||||
.get(line - 1)
|
||||
.is_some_and(|l| l.contains("BS-statement-3") || l.contains("BS-partner-3"));
|
||||
if scoped || beside {
|
||||
let shown: String = flat[pos..]
|
||||
.chars()
|
||||
.take_while(|c| {
|
||||
c.is_ascii_alphanumeric() || c.is_ascii_whitespace() || matches!(c, '\'' | ',')
|
||||
})
|
||||
.take(24)
|
||||
.collect();
|
||||
problems.push(format!(
|
||||
"{at}:{line}: {}: a bare old rule label; a record numbers its parts by position, so say `BS-statement-3 statement k` or `BS-partner-3 statement k`",
|
||||
shown.trim()
|
||||
));
|
||||
}
|
||||
}
|
||||
(checked, problems)
|
||||
}
|
||||
|
||||
@@ -633,3 +732,66 @@ pub(crate) fn product_rule_parts_are_the_numbered_lists_of_their_claims() {
|
||||
assert_eq!(problems_in("WB-ledger-15").len(), 0);
|
||||
assert_eq!(problems_in("the INVARIANT 2 of kernel::settle").len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub(crate) fn a_bare_old_rule_label_is_refused_in_a_cash_flow_or_party_file() {
|
||||
let parts = all_parts();
|
||||
let cashflow = "crates/ledger-core/src/cashflow.rs";
|
||||
let parties = "crates/ledger-core/src/parties.rs";
|
||||
// In a file that is the record's throughout, a bare label fails even
|
||||
// when its line does not name the record.
|
||||
for text in [
|
||||
"/// Rule 11: what a member or lender paid",
|
||||
" // rule 5's classes",
|
||||
"/// BS-statement-3 statement 16, the old Rule 11",
|
||||
"/// Rules 1, 3 and 4",
|
||||
] {
|
||||
assert_eq!(scan(text, cashflow, &parts).1.len(), 1, "{text:?}");
|
||||
}
|
||||
assert_eq!(scan("/// rule 2: the target", parties, &parts).1.len(), 1);
|
||||
assert_eq!(
|
||||
scan(
|
||||
"/// rule 2: the target",
|
||||
"crates/ledger-core/tests/spec_party_totals.rs",
|
||||
&parts
|
||||
)
|
||||
.1
|
||||
.len(),
|
||||
1
|
||||
);
|
||||
// Elsewhere, a label beside a citation fails.
|
||||
assert_eq!(
|
||||
problems_in("BS-statement-3 statement 16; rule 11 was its old label").len(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
problems_in("BS-partner-3 statement 7; rule 2 was its old label").len(),
|
||||
1
|
||||
);
|
||||
// Ordinary uses of the word are not labels: no number, a number that
|
||||
// is not a label, or a bare label far from any citation.
|
||||
assert_eq!(scan("/// this rule holds", cashflow, &parts).1.len(), 0);
|
||||
assert_eq!(
|
||||
scan("/// the rules of the books", parties, &parts).1.len(),
|
||||
0
|
||||
);
|
||||
assert_eq!(
|
||||
scan("/// the run rule 0.02 / 0.00", "docs/testing.md", &parts)
|
||||
.1
|
||||
.len(),
|
||||
0
|
||||
);
|
||||
assert_eq!(
|
||||
scan("/// rule 11 is not cited here", "docs/testing.md", &parts)
|
||||
.1
|
||||
.len(),
|
||||
0
|
||||
);
|
||||
// The new form passes; a bare label straight after an id is the id
|
||||
// scan's finding, reported once.
|
||||
assert_eq!(
|
||||
scan("/// BS-statement-3 statement 16", cashflow, &parts),
|
||||
(1, vec![])
|
||||
);
|
||||
assert_eq!(problems_in("BS-statement-3 rule 16").len(), 1);
|
||||
}
|
||||
@@ -280,9 +280,9 @@ fn defect1_reversed_contributions_foot_regression() {
|
||||
/// members paid):
|
||||
/// - Operating: the members paid #1 85.00, #2 12.97, #3 99.00, #6 7.49,
|
||||
/// #21 216.40, #7 129.00 and #20 46.38 (the prepaid domain) for the
|
||||
/// company through 2100, each borrowed and spent on its date (rule 11):
|
||||
/// company through 2100, each borrowed and spent on its date (BS-statement-3 statement 16):
|
||||
/// 85.00 + 12.97 + 99.00 + 7.49 + 216.40 + 129.00 + 46.38 = 596.24, so
|
||||
/// −596.24, all class (d). #9 and its reversal #22 net out (rule 6).
|
||||
/// −596.24, all class (d). #9 and its reversal #22 net out (BS-statement-3 statement 11).
|
||||
/// The card's #10 and #23 moved no cash and 2050 is not financing: no
|
||||
/// line. Nothing else moved cash through an operating account.
|
||||
/// - Investing: every asset was contributed as property the members
|
||||
@@ -1062,7 +1062,7 @@ fn an_expense_a_member_paid_into_capital_is_contributed_and_spent() {
|
||||
/// D-42 keeps property a member already owned noncash (ASC 230-10-50-4:
|
||||
/// no cash moved, to anyone): a laptop and its service plan contributed
|
||||
/// (Dr Equipment 1,000, Dr Prepaid 60 / Cr Capital 1,060). Only revenue
|
||||
/// and expense lines can a member pay for through capital (rule 11), so
|
||||
/// and expense lines can a member pay for through capital (BS-statement-3 statement 16), so
|
||||
/// nothing is constructive: no line; disclosed 1,060 (the laptop 1,000
|
||||
/// exchanged for capital); the prepaid's 60 reconciled as other noncash.
|
||||
#[test]
|
||||
@@ -1228,7 +1228,7 @@ fn a_payment_made_for_the_company_and_its_reversal_net() {
|
||||
assert!(cf.noncash_disclosures.is_empty());
|
||||
}
|
||||
|
||||
/// Rule 11, part paid by the company and part by a member, in one entry
|
||||
/// BS-statement-3 statement 16, part paid by the company and part by a member, in one entry
|
||||
/// (Dr Supplies 100 / Cr Cash 40 / Cr 2100 60): the cash settles 40
|
||||
/// (50-5), the member the other 60, so operating −100 with 60 on the
|
||||
/// company's behalf, financing +60: the same as the two entries apart.
|
||||
@@ -1264,7 +1264,7 @@ fn part_paid_by_a_member_and_a_refund_a_member_received() {
|
||||
assert!(cf.noncash_disclosures.is_empty());
|
||||
}
|
||||
|
||||
/// Rule 11's CONVENTION, pinned: what a lender or the members' account
|
||||
/// BS-statement-3 statement 16's CONVENTION, pinned: what a lender or the members' account
|
||||
/// pays for goes to operating balance-sheet lines before revenue and
|
||||
/// expense, so a member's capital (which can pay only for revenue and
|
||||
/// expense) is left the expenses. Supplies 100 and a prepaid 50, paid 50
|
||||
@@ -1314,7 +1314,7 @@ fn a_lender_pays_balance_sheet_lines_first_and_a_customer_pays_a_member() {
|
||||
assert!(cf.noncash_disclosures.is_empty());
|
||||
}
|
||||
|
||||
/// Rule 11's exceptions: interest charged into a loan (Dr Interest
|
||||
/// BS-statement-3 statement 16's exceptions: interest charged into a loan (Dr Interest
|
||||
/// expense 25 / Cr Bank loan 25) and a guaranteed payment credited to what
|
||||
/// the company owes a member (Dr Guaranteed payments 300 / Cr 2100) are
|
||||
/// the lender's and the member's own charges, paid to no one: noncash.
|
||||
@@ -1674,7 +1674,7 @@ fn interest_paid_with_principal_splits_by_section() {
|
||||
|
||||
/// ASC 230-10-45-12(a) and 45-16(b): collecting a 1,000 loan the company
|
||||
/// made, with 40 interest: the principal is investing, the interest
|
||||
/// (tax category interest_income) stays operating, class (b): rule 4's
|
||||
/// (tax category interest_income) stays operating, class (b): BS-statement-3 statement 5's
|
||||
/// exception.
|
||||
#[test]
|
||||
fn interest_collected_with_a_loan_stays_operating() {
|
||||
@@ -2320,7 +2320,7 @@ fn two_kinds_of_one_class_are_one_line() {
|
||||
}
|
||||
|
||||
/// Interest is operating in any entry (ASC 230-10-45-17(d), 45-25(e)),
|
||||
/// even one that disposes of equipment, where rule 4 makes the other
|
||||
/// even one that disposes of equipment, where BS-statement-3 statement 5 makes the other
|
||||
/// revenue and expense lines investing. Equipment (cost 1,000) handed to
|
||||
/// the bank against 1,000 of the loan, with 50 interest paid in cash (Dr
|
||||
/// 2500 1,000, Dr 6200 50 / Cr 1500 1,000, Cr cash 50): operating −50,
|
||||
@@ -2352,7 +2352,7 @@ fn interest_paid_in_a_disposal_stays_operating() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Rule 4 for an investing account: selling a 1,000 note receivable (an
|
||||
/// BS-statement-3 statement 5 for an investing account: selling a 1,000 note receivable (an
|
||||
/// `investing_accounts` account) for 1,200 (Dr cash 1,200 / Cr 1250 1,000,
|
||||
/// Cr gain 200). Receipts from sales of other entities' debt instruments
|
||||
/// are investing (ASC 230-10-45-12(a)), the whole proceeds: investing
|
||||
@@ -2388,7 +2388,7 @@ fn an_investments_gain_is_investing() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Rule 6, three levels down: A ← B ← C ← D with A before February. B and
|
||||
/// BS-statement-3 statement 11, three levels down: A ← B ← C ← D with A before February. B and
|
||||
/// C pair (walking from the root); D, a reversal of the reinstatement, is
|
||||
/// shown alone, labelled as the reversal it is ("Reversal of #C — …"),
|
||||
/// never "Reinstatement", under A's kind with its own sign: −300.
|
||||
@@ -2411,12 +2411,12 @@ fn a_reversal_three_levels_down_is_labelled_a_reversal() {
|
||||
assert_eq!(line.reverses, Some(c));
|
||||
}
|
||||
|
||||
/// Rule 3's CONVENTION, pinned: an entry's cash goes to the sections
|
||||
/// BS-statement-3 statement 4's CONVENTION, pinned: an entry's cash goes to the sections
|
||||
/// moving against it in the order operating, investing, financing. Supplies
|
||||
/// 100 and a vehicle 1,000 for 600 cash, Member A putting in the other 500
|
||||
/// as capital (Dr 6000 100, Dr 1520 1,000 / Cr cash 600, Cr 3000 500):
|
||||
/// operating takes its 100 first, investing the other 500; the vehicle's
|
||||
/// 500 for capital is noncash (property for capital, rule 11: capital pays
|
||||
/// 500 for capital is noncash (property for capital, BS-statement-3 statement 16: capital pays
|
||||
/// constructively only for revenue and expense, and the supplies were
|
||||
/// already paid in cash), disclosed (investing +500, financing −500). Had
|
||||
/// the member's 500 been a loan through 2100 (financing), it would have
|
||||
@@ -2464,7 +2464,7 @@ fn cash_goes_to_the_sections_in_order() {
|
||||
assert!(cf.noncash_disclosures.is_empty());
|
||||
}
|
||||
|
||||
/// Rule 5's CONVENTION, pinned: within a section the cash goes to its
|
||||
/// BS-statement-3 statement 10's CONVENTION, pinned: within a section the cash goes to its
|
||||
/// kinds in kind order (members in their order, then other equity, then
|
||||
/// borrowing). 500 cash and 100 of the loan repaid for 400 from Member A
|
||||
/// and 200 from Member B (Dr cash 500, Dr 2500 100 / Cr 3000 400, Cr 3001
|
||||
@@ -2495,7 +2495,7 @@ fn cash_goes_to_a_sections_kinds_in_order() {
|
||||
assert_eq!(cf.noncash_disclosures[0].exchanged, x("100.00"));
|
||||
}
|
||||
|
||||
/// Rule 12: a bill payment reversed in the period unpays the bill again.
|
||||
/// BS-statement-3 statement 17: a bill payment reversed in the period unpays the bill again.
|
||||
/// Equipment 1,000 on a bill (restored as a later version would journal
|
||||
/// it), paid on Feb 20 and the payment reversed on Feb 21: the payment
|
||||
/// and its reversal drop out, and the 1,000 still owed at the end of
|
||||
@@ -2668,8 +2668,8 @@ mod random {
|
||||
/// depreciation, disposals (cash, on account, gain, loss, before any
|
||||
/// depreciation, the loss on a revenue or an expense account), loans in
|
||||
/// and out with interest, transfers, debt to equity, a fee withheld;
|
||||
/// and what a member or lender pays or receives for the company (rule
|
||||
/// 11, D-42): an expense into capital, a prepaid through 2100, part
|
||||
/// and what a member or lender pays or receives for the company (BS-statement-3 statement
|
||||
/// 16, D-42): an expense into capital, a prepaid through 2100, part
|
||||
/// cash and part a member's, a refund to a member, a customer paying a
|
||||
/// member, a member paying the card, revenue a member kept, and the
|
||||
/// shapes that stay noncash: interest charged into the loan, equipment
|
||||
@@ -2738,7 +2738,7 @@ mod random {
|
||||
|
||||
/// Templates whose entries are pure: their cash settles every section
|
||||
/// they move (or they move no cash and no section), or a member or
|
||||
/// lender settles it all for the company (rule 11), whether 2100 is
|
||||
/// lender settles it all for the company (BS-statement-3 statement 16), whether 2100 is
|
||||
/// financing or not.
|
||||
const PURE: [u8; 21] = [
|
||||
0, 2, 3, 5, 7, 8, 12, 14, 15, 16, 17, 18, 19, 22, 24, 25, 26, 27, 28, 31, 32,
|
||||
@@ -2852,7 +2852,7 @@ mod random {
|
||||
}
|
||||
}
|
||||
|
||||
/// Rule 11 for a whole entry, independently of the engine: no cash
|
||||
/// BS-statement-3 statement 16 for a whole entry, independently of the engine: no cash
|
||||
/// line, and every line either a source (2100 or 2500 when financing;
|
||||
/// a member's capital) or a use on the other side; capital pays or
|
||||
/// receives only revenue and expense; a liability pays for any
|
||||
@@ -2888,7 +2888,7 @@ mod random {
|
||||
|
||||
/// For pure books, each section's total is minus the movement of its
|
||||
/// accounts over the entries that touch cash (plan P3's wording), or
|
||||
/// that a member or lender settled whole for the company (rule 11).
|
||||
/// that a member or lender settled whole for the company (BS-statement-3 statement 16).
|
||||
pub fn model_sections(
|
||||
model: &Model,
|
||||
a: NaiveDate,
|
||||
@@ -2898,7 +2898,7 @@ mod random {
|
||||
let mut out = [0i64; 3];
|
||||
for (_, d, lines, mirrored) in model.iter().filter(|(_, d, _, _)| *d >= a && *d <= e) {
|
||||
let _ = d;
|
||||
// A reversal mirrors its root (rule 6): judged by the root's
|
||||
// A reversal mirrors its root (BS-statement-3 statement 11): judged by the root's
|
||||
// shape, its lines flipped back.
|
||||
let root: Vec<(&str, Side, i64)> = lines
|
||||
.iter()
|
||||
@@ -3138,7 +3138,7 @@ proptest! {
|
||||
}
|
||||
}
|
||||
|
||||
/// Rule 2 (P3 seam review): a distribution declared to a liability that
|
||||
/// BS-statement-3 statement 3 (P3 seam review): a distribution declared to a liability that
|
||||
/// holds only distributions (Dr capital / Cr 2400 Distributions Payable)
|
||||
/// and paid later is a distribution paid, financing (ASC
|
||||
/// 230-10-45-15(a)), under the payable's kind; the declaration is an
|
||||
@@ -3198,7 +3198,7 @@ fn a_distribution_declared_then_paid_is_a_distribution_paid() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Rule 8 (P3 seam review): a disposal's lines on the asset's
|
||||
/// BS-statement-3 statement 13 (P3 seam review): a disposal's lines on the asset's
|
||||
/// depreciation expense account (the days a month's run posted past the
|
||||
/// disposal, credited back) are depreciation on the reconciliation, not
|
||||
/// gain or loss, so its depreciation line is the P&L's depreciation
|
||||
@@ -3252,7 +3252,7 @@ fn a_disposals_depreciation_credit_back_is_depreciation() {
|
||||
/// (d). So is a penalty paid to a tax agency on any account. The same
|
||||
/// account paid to a lawyer stays (d), and so does a fee with no payee
|
||||
/// named (nothing says it went to a government). A reversal in the next
|
||||
/// period takes its original's class (rule 6), and a refund from a
|
||||
/// period takes its original's class (BS-statement-3 statement 11), and a refund from a
|
||||
/// government is a receipt, untouched: (c).
|
||||
#[test]
|
||||
fn a_payment_to_a_government_is_other_operating() {
|
||||
|
||||
@@ -2536,7 +2536,7 @@ proptest! {
|
||||
let credits = |qs: &[i64]| qs.iter().map(|q| (-q).max(0)).sum::<i64>();
|
||||
let debits = |qs: &[i64]| qs.iter().map(|q| (*q).max(0)).sum::<i64>();
|
||||
let mut fin = 0i64;
|
||||
// Rule 2: a liability left operating that only entries debiting
|
||||
// BS-statement-3 statement 3: a liability left operating that only entries debiting
|
||||
// nothing but equity credit, through the end, holds distributions
|
||||
// declared: financing, after the loan.
|
||||
let declared = |code: &str| {
|
||||
@@ -2577,7 +2577,7 @@ proptest! {
|
||||
}
|
||||
}
|
||||
let fi_all = fi.iter().sum::<i64>() + declared_fi.iter().sum::<i64>();
|
||||
// Rule 3: operating, then financing (no investing here).
|
||||
// BS-statement-3 statement 4: operating, then financing (no investing here).
|
||||
let take = |left: i64, m: i64| {
|
||||
if left > 0 && m < 0 {
|
||||
left.min(-m)
|
||||
@@ -2594,7 +2594,7 @@ proptest! {
|
||||
let mut kinds: Vec<i64> = fi.iter().chain(&declared_fi).copied().collect();
|
||||
if to_fin > 0 { settle(&mut kinds, to_fin, false) } else { settle(&mut kinds, -to_fin, true) }
|
||||
fi.copy_from_slice(&kinds[..3]);
|
||||
// Rule 11: the loan pays, then receives; then capital.
|
||||
// BS-statement-3 statement 16: the loan pays, then receives; then capital.
|
||||
if designate {
|
||||
let paid = credits(&fi[2..]).min(debits(&op));
|
||||
fi[2] += paid;
|
||||
|
||||
@@ -21,7 +21,7 @@ zip = "9.0.1"
|
||||
workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
bookspec-checker = { git = "https://git.swaits.com/swaits/bookspec", rev = "b61fa50d68f280c048de9c0bcebf7c54d3e8f329" }
|
||||
bookspec-checker = { git = "https://git.swaits.com/swaits/bookspec", rev = "6d85d8b90f8702d26e5ed17e8e400cb0a9f13864" }
|
||||
proptest = "1"
|
||||
tempfile = "3"
|
||||
toml = "1"
|
||||
@@ -332,7 +332,17 @@ appendix: the file line by line and its changes, derived by hand);
|
||||
(`iif_declares_accounts_by_role_and_balances_every_transaction`,
|
||||
`iif_without_as_of_is_as_of_today_and_ties_to_the_trial_balance`),
|
||||
`mcp_journeys.rs` (`mcp_import_export`,
|
||||
`the_default_period_never_shortens_the_iif_or_the_package`).
|
||||
`the_default_period_never_shortens_the_iif_or_the_package`); bookspec
|
||||
examples `format-cr-lf-on-an-lf-platform` and
|
||||
`format-platform-line-ending-on-an-lf-platform` (BS-format-4),
|
||||
`format-docnum-is-the-entry-id` and `format-docnum-is-the-files-place`
|
||||
(BS-format-5), `format-everything-through-as-of-spans-years` and
|
||||
`format-one-fiscal-year-holds-its-year` (BS-format-6),
|
||||
`format-closes-left-out` and `format-closes-written` (BS-format-8) and
|
||||
`format-no-customer-or-vendor-name` (BS-format-9), run by
|
||||
`every_bookspec_example_holds` and
|
||||
`the_runner_reports_every_claimed_rule_green`; the line ending is asked by
|
||||
the iif_line_ending query (the adapter's answer_iif), which reads the file's own bytes: cr-lf when every line break is CR LF, lf when every one is a bare LF, mixed when it is neither. The engine has no notion of a host, so the adapter does not use an example's host_line_ending setup.
|
||||
|
||||
### Product rules
|
||||
|
||||
|
||||
@@ -191,12 +191,15 @@ None.
|
||||
`check_assign_role`, `Ledger::check_renumber_account` (an assigned role
|
||||
frees its code); the control guard and `Ledger::control_check` (B-38).
|
||||
**Checked:** `ledger-core` `tests/spec_roles.rs`, `tests/spec_documents.rs`;
|
||||
`ledger-store` replay of `role.assigned`; bookspec example
|
||||
`ledger-store` replay of `role.assigned`; bookspec examples
|
||||
`ledger-a-role-on-a-header-or-wrong-typed-account-is-refused` (BS-ledger-19,
|
||||
the option picked: the receivables role on a header account and the payables
|
||||
role on a postable revenue account are refused through `Store::assign_role`
|
||||
and `Ledger::check_assign_role`'s `ControlAccountMismatch`, and the chart is
|
||||
as it was), run by
|
||||
as it was) and `ledger-a-role-assignment-is-a-fact-in-the-books`
|
||||
(BS-ledger-18, the option picked: the receivables role assigned to 1300 is
|
||||
journaled by `Store::assign_role`, read back by the `role_account` query
|
||||
from the books alone, and found again by the store's replay), run by
|
||||
`every_bookspec_example_holds` and
|
||||
`the_runner_reports_every_claimed_rule_green`.
|
||||
|
||||
@@ -235,7 +238,12 @@ per check, 2,000 by hand, with posts between records and every record
|
||||
checked to change no figure or entry;
|
||||
`the_fiscal_year_stays_under_closed_periods`); `ledger-cli`
|
||||
`tests/spec_kept.rs`; Lean `Step.record_changes_no_figure`,
|
||||
`Reachable.records`; fuzz `fuzz_settings_replay`.
|
||||
`Reachable.records`; fuzz `fuzz_settings_replay`; bookspec example
|
||||
`ledger-a-setting-is-a-fact-in-the-books` (the option picked: the owner's
|
||||
fiscal-year change is journaled by `Store::change_settings` with who decided
|
||||
it and when, read back by the setting query, and the trial balance before
|
||||
and after is the same), run by `every_bookspec_example_holds` and
|
||||
`the_runner_reports_every_claimed_rule_green`.
|
||||
|
||||
### Product rules
|
||||
|
||||
@@ -317,14 +325,22 @@ bookspec `examples/rename-changes-no-amount.toml`.
|
||||
**Pick:** warn versus refuse: CHOICE (Pub. 583: "the law does not require any specific kind of records"; the owner, 2026-10-20: warn by default, header accounts exempt, the first company set to refuse at the P3 cutover). A category's deductible amount rounds once, on the category total: CHOICE (the owner, 2026-11-07, D-67). The arithmetic is `kernel::deductible_amount`, so Kani proves the one rounding and the bridge carries it to `Decimal`.
|
||||
|
||||
**Enforced:** `kernel::deductible_amount` (`tax::tax_summary`'s one
|
||||
rounding). **Checked:** `ledger-core`
|
||||
rounding; the bookspec `tax_summary` query answers its lines by category).
|
||||
**Checked:** `ledger-core`
|
||||
`tests/tax.rs` (the rounding: `a_category_rounds_its_deductible_amount_once_not_per_account`,
|
||||
`a_category_rounds_once_across_different_percents`); Kani
|
||||
`deductible_amount_rounds_once`, `deductible_amount_refuses_overflow`;
|
||||
bridge `deductible_amount_agrees`; Lean `bookspec/lean/Bookspec/Deductible.lean`
|
||||
(`Deductible.near`, `Deductible.tie_away_pos`, `Deductible.tie_away_neg`, `Deductible.sign`, `Deductible.neg`, `Deductible.of_sum`,
|
||||
`Deductible.per_account_differs`, `Deductible.scale_books`, `Deductible.scale_percents`: the one rounding, at any
|
||||
number of accounts and any sizes); bookspec `examples/tax-category-required.toml`.
|
||||
number of accounts and any sizes); bookspec `examples/tax-category-required.toml`
|
||||
and the two BS-ledger-21 examples
|
||||
`ledger-a-categorys-deductible-amount-rounds-once` (the option picked:
|
||||
two accounts of 1.01 at 50% give 1.01, the exact sum rounded once) and
|
||||
`ledger-a-categorys-deductible-amount-rounds-per-account` (the other option:
|
||||
0.51 + 0.51 = 1.02), whose `tax_summary` query is `tax::tax_summary`, run by
|
||||
`every_bookspec_example_holds` and
|
||||
`the_runner_reports_every_claimed_rule_green`.
|
||||
|
||||
### Product rules
|
||||
|
||||
|
||||
@@ -38,7 +38,19 @@ Rules: B-16.
|
||||
`daily_plans_pin_month_end_clamping`,
|
||||
`prop_daily_plan_sums_exactly_and_lands_on_month_ends`,
|
||||
`prop_monthly_even_plan_is_unchanged`; `ledger-cli`
|
||||
`mcp_daily_schedule`.
|
||||
`mcp_daily_schedule`; bookspec examples
|
||||
`schedule-daily-deferred-revenue`,
|
||||
`schedule-daily-small-first-and-last-month`,
|
||||
`schedule-equal-months-give-each-month-the-same-share` (each names no
|
||||
convention, so it takes the pick, and starts mid-month where daily and
|
||||
equal months differ; the equal-months one also names BS-prepaid-3's
|
||||
start-on-any-day), `schedule-equal-months-start-on-the-first`,
|
||||
`prepaid-a-new-yen-schedule-rounds-to-whole-yen` (BS-prepaid-4's minor
|
||||
unit: 333, 333 and 334 yen) and
|
||||
`prepaid-a-yen-schedule-under-the-cent-rule-keeps-cents` (the other
|
||||
option: 333.33, 333.33 and 333.34), run by
|
||||
`every_bookspec_example_holds` and
|
||||
`the_runner_reports_every_claimed_rule_green`.
|
||||
|
||||
### Product rules
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ assets and liabilities-plus-equity at every date.
|
||||
|
||||
**Pick (BS-statement-7):** `constructive`, the owner, 2026-10-20, D-42
|
||||
|
||||
**Claims:** partly (bookspec's record states rules 1-12; the picks and the product surface are below)
|
||||
**Claims:** partly (bookspec's record has 18 statements; the picks and the product surface are below)
|
||||
|
||||
**Pick:** the direct method; an entry's cash allocated to its sections in the order operating, investing, financing (CONVENTION, the ASC silent, disclosed); within a section, the cash split among its kinds in the order the rest of the section's kinds, interest received, interest paid (CONVENTION, as the engine splits it); what a member or a lender pays or receives for the company presented as constructive cash, borrowed (or contributed) and spent (the owner, D-42, 2026-10-20, revising D-35's first point); a payment shared between a government and others split by their resolved shares, the government's part rounded half to even to the base currency's places and the rest exact (CONVENTION); payroll entries keep their (d) class whoever they name (CONVENTION).
|
||||
|
||||
**Enforced:** `profit_and_loss_for_period`; `cashflow::cash_flow` (with
|
||||
`kernel::entry_flows`, `apply_cash`, `constructive`, `exchanged`),
|
||||
`role_problems`, `foot`; `Ledger::reversal_chain` (rule 6's chains);
|
||||
`role_problems`, `foot`; `Ledger::reversal_chain` (BS-statement-3 statement 11's chains);
|
||||
`ledger_package::cash_flow_for` (the server, the
|
||||
package and the viewer). **Checked:** Lean `statements_add_up`,
|
||||
`cashflow_sections_sum_to_cash_change`, `entry_flows_sum`,
|
||||
@@ -57,13 +57,13 @@ package and the viewer). **Checked:** Lean `statements_add_up`,
|
||||
`apply_cash_mirrors`, `apply_cash_spends_exactly`,
|
||||
`exchanged_is_bounded`, `constructive_nets_to_zero`,
|
||||
`constructive_mirrors`; `prop_period_pnl_partitions`,
|
||||
`prop_cash_flow_laws` (5,000 cases, reversals of reversals, rule 11's
|
||||
`prop_cash_flow_laws` (5,000 cases, reversals of reversals, BS-statement-3 statement 16's
|
||||
shapes), `prop_pure_entries_sections_are_movements`; regressions
|
||||
`defect1_reversed_contributions_foot_regression`,
|
||||
`defect1_two_member_llc_first_year_regression`,
|
||||
`defect1_two_member_llc_as_of_march_18_regression` (and bookspec
|
||||
`cash-flow.*`, `cash-flow.paid-on-the-companys-behalf` for rule 11,
|
||||
`cash-flow.government-fees` for rule 5's governments);
|
||||
`cash-flow.*`, `cash-flow.paid-on-the-companys-behalf` for BS-statement-3 statement 16,
|
||||
`cash-flow.government-fees` for BS-statement-3 statement 8's governments);
|
||||
`disposal_proceeds_all_investing`,
|
||||
`an_expense_a_member_paid_is_borrowed_and_spent`,
|
||||
`reimbursing_a_member_is_a_repayment_of_borrowing`,
|
||||
@@ -137,7 +137,7 @@ as payroll.
|
||||
`a_bill_payment_carries_its_bills_split`,
|
||||
`a_government_selling_services_is_a_supplier`.
|
||||
|
||||
**WB-statement-3** Rule 11's wanderbooks limits, from what the books
|
||||
**WB-statement-3** BS-statement-3 statement 16's wanderbooks limits, from what the books
|
||||
cannot tell: a lender's or member's own charge credited to what the
|
||||
company owes them, other than interest and guaranteed payments (a card's
|
||||
annual fee, rent a member charges), reads as paid for the company, so
|
||||
|
||||
@@ -77,21 +77,21 @@ Quotes are short; the rest is paraphrase.
|
||||
- **230-10-45-4** (EY p. 5): the statement explains the change in the
|
||||
total of cash, cash equivalents and restricted cash. ASU 2016-18 struck
|
||||
its old sentence on the totals at the beginning and end of the period
|
||||
(gone from the current text). → rule 1: the cash accounts are all of
|
||||
(gone from the current text). → BS-statement-3 statement 2: the cash accounts are all of
|
||||
them. (50-7 and 50-8, EY pp. 5-6, 30: the nature of restrictions, and
|
||||
the balance-sheet lines that hold the total when there are several.)
|
||||
- **230-10-45-5** (EY p. 5): purchases and sales of cash equivalents are
|
||||
cash management, and transfers among cash, cash equivalents and
|
||||
restricted cash "are not reported as cash flow activities". → rule 1: a
|
||||
restricted cash "are not reported as cash flow activities". → BS-statement-3 statement 2: a
|
||||
transfer between two cash accounts is no flow.
|
||||
- **230-10-45-12(c)** (EY p. 41; ASU 2016-15 p. 25): investing inflows
|
||||
include "Receipts from sales of property, plant, and equipment and other
|
||||
productive assets". → rule 4.
|
||||
productive assets". → BS-statement-3 statement 5.
|
||||
- **230-10-45-13(c)** (EY p. 41; ASU 2016-15 p. 12): investing outflows
|
||||
include payments "at the time of purchase or soon before or after
|
||||
purchase" for PP&E; generally only those are investing, and incurring
|
||||
debt directly to the seller is a financing transaction whose later
|
||||
principal payments are financing. → rule 12 (the bill split), and the
|
||||
principal payments are financing. → BS-statement-3 statement 17 (the bill split), and the
|
||||
limit BS-statement-3 records.
|
||||
- **230-10-45-14(a)** (EY p. 42): financing inflows include "Proceeds from
|
||||
issuing equity instruments". **45-15(a)**: financing outflows include
|
||||
@@ -101,8 +101,8 @@ Quotes are short; the rest is paraphrase.
|
||||
- **230-10-45-16(a), (b)** (EY p. 43): operating inflows include "Cash
|
||||
receipts from sales of goods or services", including collections of
|
||||
receivables from customers arising from those sales; and interest and
|
||||
dividends received. 45-16(c): all other operating receipts. → rule 5,
|
||||
rule 4's exception.
|
||||
dividends received. 45-16(c): all other operating receipts. → BS-statement-3 statement 7,
|
||||
statement 5's exception.
|
||||
- **230-10-45-17** (EY pp. 43-44): operating outflows: payments for goods
|
||||
for resale (a), "Cash payments to other suppliers and employees for
|
||||
other goods or services" (b), "Cash payments to governments for taxes,
|
||||
@@ -111,7 +111,7 @@ Quotes are short; the rest is paraphrase.
|
||||
under (c); 45-25 names them a class.) Quotes (b) and (c) checked
|
||||
2026-10-22 against EY's guide as retrieved that day (SHA-256
|
||||
`de9224a9e3ec7ef771e7ee076f99471ee727308c3dedb2df20ea1ee4e285fbdb`,
|
||||
page 43). → rule 5: a payment to a government, decided by its payee or
|
||||
page 43). → BS-statement-3 statement 8: a payment to a government, decided by its payee or
|
||||
a taxes-and-licenses account, is (g), not (d).
|
||||
- **230-10-45-22, 45-22A** (EY pp. 44-45, the same copy): a receipt or
|
||||
payment with "aspects of more than one class of cash flows" is
|
||||
@@ -121,7 +121,7 @@ Quotes are short; the rest is paraphrase.
|
||||
basis of the nature of the underlying cash flows" and classify each
|
||||
"in financing, investing, or operating activities"; only what "cannot
|
||||
be separated by source or use" goes by the predominant source or use
|
||||
(45-22A). → rule 5: a payment shared between a government and a
|
||||
(45-22A). → BS-statement-3 statement 8: a payment shared between a government and a
|
||||
supplier is split by the parties' resolved shares, each part classed
|
||||
by its payee (the paragraph names the three activities; reading it for
|
||||
45-25's classes too is a CONVENTION).
|
||||
@@ -130,46 +130,46 @@ Quotes are short; the rest is paraphrase.
|
||||
"three months or less"; amounts due on demand count) may be reported
|
||||
net, and even then need not be. **230-10-45-26** (EY p. 13): otherwise
|
||||
investing and financing inflows and outflows are reported separately,
|
||||
"proceeds of borrowings ... separately from repayments of debt". → rule
|
||||
5: gross lines, members' advances and their repayments apart.
|
||||
"proceeds of borrowings ... separately from repayments of debt". → BS-statement-3
|
||||
statements 6-10: gross lines, members' advances and their repayments apart.
|
||||
- **230-10-45-24** (EY p. 15; ASU 2016-18 pp. 4-5): the statement reports
|
||||
net cash from operating, investing and financing activities and "the
|
||||
net effect of those flows" on cash, "in a manner that reconciles
|
||||
beginning and ending totals". → rule 9, the footing.
|
||||
beginning and ending totals". → BS-statement-3 statement 14, the footing.
|
||||
- **230-10-45-25** (EY p. 8; ASU 2016-15 p. 10): entities "are encouraged
|
||||
to report major classes of gross cash receipts and gross cash payments";
|
||||
those that do "shall, at a minimum, separately report" (a) cash
|
||||
collected from customers, (b) interest and dividends received, (c) other
|
||||
operating cash receipts, (d) cash paid to employees and other suppliers,
|
||||
(e) interest paid, (f) income taxes paid, (g) other operating cash
|
||||
payments. → rule 5, the operating classes; the direct method is a
|
||||
payments. → BS-statement-3 statement 7, the operating classes; the direct method is a
|
||||
choice the standard encourages, not one it requires.
|
||||
- **230-10-45-28** (EY p. 10; DART 3.1): the indirect method adjusts net
|
||||
income to remove (a) deferrals and accruals of operating receipts and
|
||||
payments, such as changes in receivables and payables, and (b) items
|
||||
with no operating cash effect, including those "whose cash effects are
|
||||
related to investing or financing cash flows, such as gains or losses on
|
||||
sales of property, plant, and equipment". → rule 8's G and W.
|
||||
sales of property, plant, and equipment". → BS-statement-3 statement 13's G and W.
|
||||
- **230-10-45-29** (EY p. 7; DART 3.1): the reconciliation of net income
|
||||
to operating cash is required with either method; it "shall separately
|
||||
report all major classes of reconciling items", at a minimum the
|
||||
changes in operating receivables, inventory and payables.
|
||||
- **230-10-45-30** (EY p. 8; DART 3.1): with the direct method, that
|
||||
reconciliation "shall be provided in a separate schedule." → rule 8.
|
||||
reconciliation "shall be provided in a separate schedule." → BS-statement-3 statement 13.
|
||||
- **230-10-50-3** (EY p. 47): investing and financing activities that
|
||||
"affect recognized assets or liabilities but that do not result in cash
|
||||
receipts or cash payments in the period shall be disclosed", narrative
|
||||
or in a schedule. → rule 7.
|
||||
or in a schedule. → BS-statement-3 statement 12.
|
||||
- **230-10-50-4** (EY p. 47): its examples, among them: "converting debt to equity";
|
||||
acquiring assets by assuming directly related liabilities; obtaining a
|
||||
right-of-use asset for a lease liability (the old "capital lease"
|
||||
wording, replaced); receiving a gift of an asset; exchanging noncash
|
||||
assets or liabilities for others (also a beneficial interest obtained
|
||||
in a securitization, not listed here). → rule 7's exchange inside one
|
||||
in a securitization, not listed here). → BS-statement-3 statement 12's exchange inside one
|
||||
section.
|
||||
- **230-10-50-5** (EY p. 47): "Some transactions are part cash and part
|
||||
noncash; only the cash portion shall be reported in the statement of
|
||||
cash flows." → rule 3.
|
||||
cash flows." → BS-statement-3 statement 4.
|
||||
- **230-10-50-6** (EY p. 47): with only a few noncash transactions, they
|
||||
may be on the same page as the statement; otherwise elsewhere, clearly
|
||||
referenced to it. → the printed statement's noncash schedule.
|
||||
@@ -184,9 +184,9 @@ Quotes are short; the rest is paraphrase.
|
||||
not specify, an entity first considers principles for similar
|
||||
transactions "and then consider[s] nonauthoritative guidance from other
|
||||
sources"; practices not in the Codification are nonauthoritative
|
||||
(sources include accounting textbooks, handbooks and articles). → rule
|
||||
11: the Codification does not address payments made on the entity's
|
||||
behalf (below), so this is where firm guidance comes in; rule 11
|
||||
(sources include accounting textbooks, handbooks and articles). → BS-statement-3 statement
|
||||
16: the Codification does not address payments made on the entity's
|
||||
behalf (below), so this is where firm guidance comes in; BS-statement-3 statement 16
|
||||
follows it (D-42), a choice the standard leaves open, not a requirement
|
||||
of any paragraph.
|
||||
|
||||
@@ -196,9 +196,9 @@ Also read there, for the design (not authoritative, 105-10-05-3):
|
||||
after purchase are investing, "soon" read by the SEC staff as three
|
||||
months or less; the change in payables in the reconciliation leaves
|
||||
out payables for investing; the noncash disclosure is the liability
|
||||
that remains unpaid at the period's end). → rule 12.
|
||||
that remains unpaid at the period's end). → BS-statement-3 statement 17.
|
||||
- Payments a third party makes, or cash it receives, on the entity's
|
||||
behalf (rule 11, D-42). No ASC paragraph addresses them: PwC Viewpoint,
|
||||
behalf (BS-statement-3 statement 16, D-42). No ASC paragraph addresses them: PwC Viewpoint,
|
||||
Financial statement presentation 6.9.3 ("ASC 230 does not address these
|
||||
situations"); KPMG Handbook, Statement of cash flows (March 2026)
|
||||
Q8.3.10 ("Topic 230 does not directly address"); BDO Blueprint,
|
||||
@@ -249,7 +249,7 @@ Also read there, for the design (not authoritative, 105-10-05-3):
|
||||
- **KPMG Q8.3.10** accepts a noncash presentation (citing 50-3) for
|
||||
property and equipment a lender pays for.
|
||||
|
||||
→ rule 11 (D-42): constructive receipt and disbursement for what a
|
||||
→ BS-statement-3 statement 16 (D-42): constructive receipt and disbursement for what a
|
||||
member (through the members' financing account, or capital for an
|
||||
expense) or a lender pays or receives for the company; noncash for
|
||||
property a member already owned (50-4) and for the seller's own credit
|
||||
|
||||
+12
-12
@@ -943,7 +943,7 @@ doesn't count them.
|
||||
## P3: cash flow (defect 1, 2026-10-20)
|
||||
|
||||
The statement of cash flows was rebuilt by the direct method (BS-statement-3, D-35), and what a member or a lender pays for the company shown as
|
||||
cash borrowed and spent (D-42, rule 11). Built, reviewed twice, `just
|
||||
cash borrowed and spent (D-42, BS-statement-3 statement 16). Built, reviewed twice, `just
|
||||
check` and `just prove`; no mutation run (D-33): what P12 must cover is at
|
||||
the end.
|
||||
|
||||
@@ -964,13 +964,13 @@ the end.
|
||||
its paragraph in the test's doc comment): disposals at a gain, a loss
|
||||
and before any depreciation (`disposal_proceeds_all_investing`); a sale
|
||||
on an IOU (disclosed, flagged, with the fix); property contributed;
|
||||
what a member or lender pays or receives for the company (D-42, rule
|
||||
11): an expense through Due to Members, equipment a bank paid for, an
|
||||
what a member or lender pays or receives for the company (D-42,
|
||||
BS-statement-3 statement 16): an expense through Due to Members, equipment a bank paid for, an
|
||||
expense paid into capital, a financing card, part cash and part a
|
||||
member's, a refund to a member, a customer paying a member, a payment
|
||||
made for the company and its reversal (in the period and alone, a
|
||||
prepaid and equipment too), the reimbursement, the uses' order (rule
|
||||
11's convention); and what stays noncash: property a member owned (with
|
||||
prepaid and equipment too), the reimbursement, the uses' order (BS-statement-3 statement
|
||||
16's convention); and what stays noncash: property a member owned (with
|
||||
members configured and without), the seller's credit (flagged), interest
|
||||
and guaranteed payments charged to a creditor, a fee withheld on a
|
||||
contra-liability. From the second review: odd shapes (two cash accounts
|
||||
@@ -992,11 +992,11 @@ the end.
|
||||
(`operating_cash_is_classed_kind_by_kind`) and kept operating in a
|
||||
disposal; a loss on disposal on a revenue-typed or an expense-typed
|
||||
account; an investment sold at a gain; a reversal three levels down;
|
||||
and both of rule 3's conventions pinned (the sections' order, the kinds'
|
||||
and both of BS-statement-3 statement 4's conventions pinned (the sections' order, the kinds'
|
||||
order).
|
||||
- **Properties, 5,000 cases each** (`CF_CASES`, default 5,000, about 16 s):
|
||||
`prop_cash_flow_laws` over random books of 33 templates (every shape
|
||||
the rule names, rule 11's included) and reversals of any earlier entry,
|
||||
the statement names, BS-statement-3 statement 16's included) and reversals of any earlier entry,
|
||||
reversals included: the sections are the change in cash and the
|
||||
model's; each section is its lines and kinds; the reconciliation is
|
||||
operating; an entry's lines are its cash, what was handled for it
|
||||
@@ -1007,11 +1007,11 @@ the end.
|
||||
`prop_pure_entries_sections_are_movements`: for pure entries, each
|
||||
section is minus its accounts' movement over the entries that touch
|
||||
cash or that a member or lender settled whole for the company (the
|
||||
plan's wording, with rule 11 modelled apart from the engine; review
|
||||
plan's wording, with BS-statement-3 statement 16 modelled apart from the engine; review
|
||||
item 7's definition of pure). The older properties in `spec_reports.rs`
|
||||
are kept with new oracles (financing is the cash part of equity and
|
||||
designated debt plus what the loan or capital paid or received for the
|
||||
company, by an independent model of rules 3 and 11).
|
||||
company, by an independent model of BS-statement-3 statements 4 and 16).
|
||||
- **Bridge:** `entry_flows_agree`, `apply_cash_and_exchanged_agree`,
|
||||
`constructive_agrees`.
|
||||
- **Proofs:** Kani `entry_flows_sum_to_cash`,
|
||||
@@ -1030,17 +1030,17 @@ the end.
|
||||
(docs/verification.md, law 10).
|
||||
- **Sensitivity (P3 review, by hand, no mutation run):** 18 deliberate
|
||||
breaks to `cashflow.rs` and `kernel/` (a dropped reversal
|
||||
flip, no netting, financing read as operating, no rule 4, no exchange
|
||||
flip, no netting, financing read as operating, no BS-statement-3 statement 5's disposal rule, no exchange
|
||||
disclosure, no interest class, no warnings, the bill's payments
|
||||
ignored, the label's depth parity, repeated codes allowed, depreciation
|
||||
disclosed, the sections' or kinds' order reversed, the customer party
|
||||
ignored, accumulated depreciation in the exchange, the interest
|
||||
exception dropped, rule 4 for investing accounts): 17 fail a test (4
|
||||
exception dropped, BS-statement-3 statement 5 for investing accounts): 17 fail a test (4
|
||||
of them only since the review's tests); one is equivalent today
|
||||
(`mirrors` ignoring amounts: every reversal mirrors its original until
|
||||
P4's drafts).
|
||||
- **Sensitivity, second round (after D-42, by hand, no mutation run):**
|
||||
17 breaks to rule 11 and the kernel's `constructive` (no lender pass, no
|
||||
17 breaks to BS-statement-3 statement 16 and the kernel's `constructive` (no lender pass, no
|
||||
member pass, no receipts for the company, a reversal not mirrored, a
|
||||
lender paying for no investing, capital paying for property, receipts
|
||||
for property, receivables not received, guaranteed payments or
|
||||
|
||||
@@ -122,7 +122,7 @@ Each law, and what proves it. Kani harnesses are in
|
||||
1): each entry's cash is applied to the sections moving against it,
|
||||
operating, investing, financing, each up to its own movement; what a
|
||||
member or a lender paid or received for the entry, with no cash
|
||||
account moving (rule 11, D-42), is added as a constructive receipt
|
||||
account moving (BS-statement-3 statement 16, D-42), is added as a constructive receipt
|
||||
and disbursement that nets to zero within the entry; so each entry's
|
||||
flows sum to its cash and what neither settled sums to zero, and
|
||||
operating + investing + financing is exactly the change in the cash
|
||||
@@ -1173,7 +1173,7 @@ Be precise about the claims:
|
||||
- **The cash flow model tags lines per entry with any function** meeting
|
||||
the engine's guarantees (the cash tag follows the account; revenue and
|
||||
expense lines are operating or investing; a reversal takes its
|
||||
original's tags); which tag the engine picks for a line (rule 4's
|
||||
original's tags); which tag the engine picks for a line (BS-statement-3 statement 5's
|
||||
disposals, the bill split, the chain root) is checked by the property
|
||||
and example tests, not proved. A line the engine splits between two
|
||||
sections is two lines in the model, the entry's net unchanged.
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
"type": "git",
|
||||
"subDir": "lean",
|
||||
"scope": "",
|
||||
"rev": "b61fa50d68f280c048de9c0bcebf7c54d3e8f329",
|
||||
"rev": "6d85d8b90f8702d26e5ed17e8e400cb0a9f13864",
|
||||
"name": "bookspec",
|
||||
"manifestFile": "lake-manifest.json",
|
||||
"inputRev": "b61fa50d68f280c048de9c0bcebf7c54d3e8f329",
|
||||
"inputRev": "6d85d8b90f8702d26e5ed17e8e400cb0a9f13864",
|
||||
"inherited": false,
|
||||
"configFile": "lakefile.toml"}],
|
||||
"name": "wanderbooks",
|
||||
|
||||
@@ -9,7 +9,7 @@ packagesDir = ".lake/packages"
|
||||
[[require]]
|
||||
name = "bookspec"
|
||||
git = "https://git.swaits.com/swaits/bookspec"
|
||||
rev = "b61fa50d68f280c048de9c0bcebf7c54d3e8f329"
|
||||
rev = "6d85d8b90f8702d26e5ed17e8e400cb0a9f13864"
|
||||
subDir = "lean"
|
||||
|
||||
[[lean_lib]]
|
||||
|
||||
Reference in new issue
Block a user