docs: sub-references name bookspec's statements, invariants and scenarios

Unit S-E rewrote each `B-n` citation to its bookspec id but kept the
sub-reference after it ("item 7", "rule 11", "INVARIANT 2"). Those
numbers counted parts of the retired rules.md text, so `BS-statement-5
item 7` pointed at finished and abandoned projects, not at the snapshot
it meant. Bookspec numbers a record's parts from 1 as `statement`,
`invariant` and `scenario`; every sub-reference now says so.

The map was built by content, not by position: each old item,
INVARIANT or SCENARIO was read in `git show ca8d676d5^:docs/spec/rules.md`
(the last full rule text), found in the pinned records
(bookspec bc92cf3) and in docs/spec/claims/, and each reference was
read in its context before it was mapped. Where the old numbering still
survives as the "Rule n" labels inside bookspec's statements (the cash
flow, party totals) the new number is that statement's position; where
a record carries the whole rule differently (the asset depreciation, the
IIF file, the arap invariants) the reference follows the content. Where
bookspec keeps no counterpart, the product rule that states it is cited
instead: WB-statement-5 (a project's facts and names), -7 (the snapshot),
WB-arap-4 (the document_standing feature), -8 (the issued PDF), -15 (a
payment event names its line), WB-ledger-15 (BS-ledger-12 is retired).
A reference that had pointed at the wrong part is corrected, for example
the discount-reason references that said BS-arap-6 INVARIANT 2 (a
bound) now say invariant 6 (the discount cap and date).

Only the reference tokens and their sentence change; no paragraph is
reflowed. A reference wrapped across a comment prefix keeps its wrap.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-09 03:30:06 -07:00
1 parent 609e4e6b26
commit e41cc3a161
78 files changed
+298 -302

No files matched your search

+4 -4
View File
@@ -989,7 +989,7 @@ mod paying_on_terms {
/// One deposit settles two invoices of one customer: one entry, one
/// receivable line per invoice, each tagged with its own invoice, and the
/// output names both documents (BS-arap-6 INVARIANTS 1 and 3).
/// output names both documents (BS-arap-6 invariant 3 and WB-arap-15).
#[test]
fn one_payment_settles_two_invoices() {
let mut s = setup("settle-two");
@@ -1046,7 +1046,7 @@ mod paying_on_terms {
}
/// A discount outside the document's terms needs a reason; with one the
/// payment is taken and recorded (BS-arap-6 INVARIANT 2; the terms are S4.3's
/// payment is taken and recorded (BS-arap-6 invariant 6; the terms are S4.3's
/// to journal, so this bill states none).
#[test]
fn late_discount_needs_a_reason() {
@@ -1075,7 +1075,7 @@ mod paying_on_terms {
}
/// A fee posts gross (A-4): the deposit gets the net, the fee its expense,
/// and A/R is credited the gross (BS-arap-6 INVARIANT 1).
/// and A/R is credited the gross (BS-arap-6 invariant 3).
#[test]
fn a_fee_posts_gross_to_receivables_and_net_to_the_bank() {
let mut s = setup("fee-gross");
@@ -1445,7 +1445,7 @@ mod bad_debts {
assert_eq!(check["agrees"], json!(true), "{check}");
}
/// P4b S7: no evidence, no write-off (BS-arap-5 INVARIANT 1): the tool refuses
/// P4b S7: no evidence, no write-off (BS-arap-5 statement 10): the tool refuses
/// with neither or both, and an attachment already filed is linked
/// instead of a new file.
#[test]
+1 -1
View File
@@ -318,7 +318,7 @@ fn annotations_and_searches() {
assert_eq!(answer_of(&r).unwrap()["status"], "ok");
}
/// Plan P6 step 4 and BS-ledger-12 item 5: consolidation never leaves an
/// Plan P6 step 4 and WB-ledger-15 INVARIANT 3: consolidation never leaves an
/// entry the receipt policy covers with no evidence.
#[test]
fn consolidation_never_removes_an_entrys_only_evidence() {
+1 -1
View File
@@ -845,7 +845,7 @@ fn books_p2_served_cut_over_whole() {
),
// An invoice carrying documents_v2's fields (terms: P4b S4.4) and
// its line naming its project (document_line_projects,
// BS-statement-5 item 8).
// BS-statement-5 statement 6).
(
"books.create_invoice",
json!({"customer": "1", "date": "2026-02-10", "terms": "Net 30",
+1 -1
View File
@@ -2419,7 +2419,7 @@ fn cash_flow_reads_its_account_roles_from_the_books_settings() {
}
}
/// BS-statement-3 rule 2: roles that contradict the chart are refused,
/// BS-statement-3 statement 3: roles that contradict the chart are refused,
/// naming the setting and the fix, never a statement on a wrong partition.
#[test]
fn cash_flow_refuses_contradictory_roles() {
+1 -1
View File
@@ -1546,7 +1546,7 @@ fn iif_declares_accounts_by_role_and_balances_every_transaction() {
);
}
/// BS-format-2 item 7 through the server: an entry with lines on both the
/// BS-format-2 statement 7 through the server: an entry with lines on both the
/// receivables and payables control accounts makes `books.export` iif and
/// `books.export_cpa_package` refuse, naming the entry, rather than hand
/// over a file QuickBooks Desktop will not import.
+2 -2
View File
@@ -1,4 +1,4 @@
//! A project's snapshot (BS-statement-5 item 7) in the viewer and from the
//! A project's snapshot (WB-statement-7) in the viewer and from the
//! books server, on the same books: `books.project`'s strings are the
//! figures the viewer's page draws (its `PageFigures` and `Snap`), to the
//! cent, to date, by account, by month with the running net, and for the
@@ -208,7 +208,7 @@ fn a_projects_snapshot_is_the_same_in_the_viewer_and_from_the_server() {
assert_eq!(period["net"], "-722.22", "a refund and costs, no sale");
}
/// BS-statement-5 item 8: a project's invoiced revenue and billed costs,
/// BS-statement-5 statement 6: a project's invoiced revenue and billed costs,
/// made through the books server's own tools, read the same in the viewer
/// (its snapshot, and the invoice's and bill's pages: each line's
/// project) and from the server (books.project, books.get_entry).
+2 -2
View File
@@ -1199,7 +1199,7 @@ fn acquired_date_comes_from_the_acquisition_entry() {
);
}
// ------------------------------- posted and scheduled (BS-asset-1 rule 8)
// ------------------------------- posted and scheduled (BS-asset-1 statement 28)
/// Named regression 1 (the brief's reproduction 1, its figures made up): a
/// $1,440.00 laptop, 36 months, in service 2026-05-15, nothing run. As of
@@ -1501,7 +1501,7 @@ fn dispose_args(x: u64, date: &str, proceeds: &str) -> Value {
/// days, 500.00 (the final depreciation); accumulated 5,500.00, book value
/// 6,500.00, gain 500.00. Afterwards books.asset_schedule ends there, and
/// books.list_assets lists it as gone: not held, every figure 0.00 (it
/// left the books with its disposal; BS-asset-1 rule 8). Before P3 the
/// left the books with its disposal; BS-asset-1 statement 28). Before P3 the
/// schedule showed June 7,000.00, accumulated 12,000.00, book value 0.00.
#[test]
fn a_disposed_asset_lists_what_it_depreciated_through_its_disposal() {
+1 -1
View File
@@ -963,7 +963,7 @@ fn party_totals_for_a_customer_a_member_and_a_prepaid() {
// A prepaid bought with a member's card: an asset, paid through what
// the members advanced. That is money when it is a financing account
// (BS-partner-3 item 5, P3 defect 24); unlisted, Due to Members is a
// (BS-partner-3 statement 7, P3 defect 24); unlisted, Due to Members is a
// promise like any other liability, counted when the member is paid
// back.
let prepaid = |m: &mut Mcp| {
+3 -3
View File
@@ -585,7 +585,7 @@ fn project_to_date_counts_lines_before_the_period() {
assert_eq!(zeta["to_date"]["net"], "3200.00");
}
/// The snapshot's figures (BS-statement-5 item 7), as the viewer shows
/// The snapshot's figures (WB-statement-7), as the viewer shows
/// them: net is the contribution before overhead, margin_pct its share
/// of revenue, to_date.by_account the direct costs by category, and each
/// month's net_to_date the running net, the last being to_date's.
@@ -1202,7 +1202,7 @@ fn l4(
)
}
/// BS-statement-5 item 8: each invoice and bill line takes a project (by
/// BS-statement-5 statement 6: each invoice and bill line takes a project (by
/// name or id); the entry's revenue or expense side is one line per
/// project, the untagged lines' as one, the receivable or payable line
/// and the payments untagged; books.project, profit_and_loss_by_class,
@@ -1408,7 +1408,7 @@ fn a_document_for_a_finished_project_says_so() {
);
}
/// BS-statement-5 items 4 and 8: an invoice line naming an on-spec project is taken
/// BS-statement-5 statements 5 and 6: an invoice line naming an on-spec project is taken
/// and its result asks whether there is now an agreement (a hoped-for
/// payment is no receivable); a bill's cost for one is an expense like any
/// other, so a bill gets no such note.
+4 -4
View File
@@ -203,7 +203,7 @@ pub enum DocStatus {
/// Less than nothing owed: more paid against it than it is for, a
/// credit balance owed back (to the customer on an invoice, by the
/// vendor on a bill). Only in books an earlier version left out of
/// bounds (BS-arap-2 INVARIANT 2); never a receivable or a payable, so
/// bounds (BS-arap-2 invariant 6); never a receivable or a payable, so
/// never aged.
Overpaid,
/// Its own entry stands but carries no line tagged with it (an older
@@ -263,7 +263,7 @@ pub struct DocState {
impl DocState {
/// It owes less than nothing or more than its total: books an earlier
/// version left out of bounds (BS-arap-2 INVARIANT 2; plan P4b.14 item 3),
/// version left out of bounds (BS-arap-2 invariant 6; plan P4b.14 item 3),
/// which the control check lists for attention.
pub fn out_of_bounds(&self) -> bool {
self.outstanding < Decimal::ZERO || self.outstanding > self.total
@@ -1144,8 +1144,8 @@ pub type DocumentPartKey = (Option<crate::AccountId>, Option<crate::ClassId>);
/// GOAL: a document's lines post to their accounts and count toward their
/// projects, and a document whose lines name neither posts exactly
/// as before.
/// SOURCE: BS-statement-5 item 3 (job costing: the revenue and
/// direct costs identified with one job) and item 8 (an
/// SOURCE: BS-statement-5 statement 2 (job costing: the revenue and
/// direct costs identified with one job) and statement 4 (an
/// invoice's or bill's line names its project); BS-arap-3 and plan
/// P4b S4.1 A-10 (every bill line names its account).
/// INVARIANTS:
+2 -2
View File
@@ -11,7 +11,7 @@
//! — and postings go through the normal entry machinery, so every
//! accounting invariant holds.
//!
//! Two figures of accumulated depreciation, never confused (BS-asset-1 rule 8):
//! Two figures of accumulated depreciation, never confused (BS-asset-1 statement 28):
//! what the schedule says is due through a date
//! ([`accumulated_scheduled_through`]) and what the books carry, the runs
//! posted and not reversed ([`crate::Ledger::accumulated_posted`]). Book
@@ -743,7 +743,7 @@ fn schedule_months(asset: &Asset, through: NaiveDate) -> Result<Vec<MonthLine>,
/// (inclusive), exact to the minor unit ([`depreciation_schedule`]): the
/// tools' `accumulated_scheduled_through`. What the books carry is
/// [`crate::Ledger::accumulated_posted`]; the two agree once every month
/// due is posted (BS-asset-1 rule 8).
/// due is posted (BS-asset-1 statement 28).
pub fn accumulated_scheduled_through(
asset: &Asset,
as_of: NaiveDate,
+9 -9
View File
@@ -77,7 +77,7 @@ pub enum OperatingClass {
/// (e) Interest paid.
InterestPaid,
/// (f) Income taxes paid. No tax category marks an entity-level income
/// tax yet, so nothing is filed here (BS-statement-3 rule 5).
/// tax yet, so nothing is filed here (BS-statement-3 statement 7).
IncomeTaxesPaid,
/// (g) Other operating cash payments.
OtherPayments,
@@ -178,7 +178,7 @@ pub struct CashFlowLine {
/// The cash, + in.
pub amount: Decimal,
/// Of `amount`, what a member or a lender paid or received for the
/// company with no cash account moving (BS-statement-3 rule 11, D-42):
/// company with no cash account moving (BS-statement-3 statement 16, D-42):
/// a constructive receipt or payment. Zero for most lines.
pub on_behalf: Decimal,
/// Codes of this kind's accounts the entry moved, sorted.
@@ -295,7 +295,7 @@ pub struct OperatingReconciliation {
pub net_cash_from_operating: Decimal,
}
/// The footing check (BS-statement-3 rule 9).
/// The footing check (BS-statement-3 statement 14).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct CashFlowFooting {
/// Operating + investing + financing.
@@ -440,8 +440,8 @@ pub enum RoleList {
Investing,
}
/// A contradiction among the cash flow account roles (BS-statement-3 rule
/// 2): the statement refuses rather than guess.
/// A contradiction among the cash flow account roles (BS-statement-3 statement
/// 3): the statement refuses rather than guess.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum RoleProblem {
/// An account of the wrong type in a list.
@@ -547,14 +547,14 @@ impl RoleProblem {
}
/// Every contradiction among the cash flow account roles (BS-statement-3
/// rule 2), in a fixed order. Codes the chart lacks are the caller's to
/// statement 3), in a fixed order. Codes the chart lacks are the caller's to
/// report. The one check behind both the statement's refusal and the
/// settings' problems, so the two never drift apart.
///
/// ```text
/// GOAL: the statement's account roles partition the chart, so every
/// account is in exactly one section.
/// SOURCE: BS-statement-3 rule 2 (ASC 230-10-45-10: every cash receipt and
/// SOURCE: BS-statement-3 statement 3 (ASC 230-10-45-10: every cash receipt and
/// payment is investing, financing or operating).
/// INVARIANTS:
/// 1. Cash and investing accounts MUST be assets; financing accounts
@@ -639,7 +639,7 @@ pub fn role_problems(
out
}
/// BS-statement-3 rule 9, on its own so the check is tested directly (it
/// BS-statement-3 statement 14, on its own so the check is tested directly (it
/// cannot fail on posted entries): the sections sum to the change in
/// cash, or nothing is produced.
pub fn foot(sections_sum: Decimal, net_change: Decimal) -> Result<CashFlowFooting, LedgerError> {
@@ -978,7 +978,7 @@ impl<'a> Roles<'a> {
}
/// The liabilities that hold distributions declared by `end` (
/// BS-statement-3 rule 2), among the accounts `open` leaves to be placed: each
/// BS-statement-3 statement 3), among the accounts `open` leaves to be placed: each
/// credited, in the posted entries dated on or before `end` (closes and
/// reversals aside), only by entries whose debits are all to equity (Dr
/// Distributions / Cr Distributions Payable; a corporation's Dr Retained
+8 -8
View File
@@ -505,7 +505,7 @@ pub enum LedgerError {
end: String,
},
/// The statement of cash flows would not foot (BS-statement-3 rule 9):
/// The statement of cash flows would not foot (BS-statement-3 statement 14):
/// an engine error, never output. It cannot happen on balanced books
/// (Lean `cashflow_sections_sum_to_cash_change`); if it does, the
/// engine is wrong, and nothing is shown rather than a wrong figure.
@@ -523,7 +523,7 @@ pub enum LedgerError {
},
/// The cash flow statement's account roles (cash, financing, investing)
/// contradict each other or the chart (BS-statement-3 rule 2). The text
/// contradict each other or the chart (BS-statement-3 statement 3). The text
/// names the setting and says what to change.
#[error("cash flow account roles: {0}")]
CashFlowRoles(String),
@@ -695,13 +695,13 @@ pub enum LedgerError {
SettlementMixedKinds(String),
/// A settlement's documents don't all belong to the one party it
/// names (BS-arap-6 INVARIANT 1).
/// names (BS-arap-6 invariant 4).
#[error("{0} is not {1}'s: a settlement covers one party only")]
SettlementPartiesDiffer(String, u64),
/// A discount needs a reason: none is stated in the document's terms,
/// or it is larger than its terms allow, or it is taken after the
/// discount date (BS-arap-6 INVARIANT 2).
/// discount date (BS-arap-6 invariant 6).
#[error(
"{doc}: the discount of {discount} needs a reason ({because}); pass discount_reason with the payment"
)]
@@ -763,7 +763,7 @@ pub enum LedgerError {
cash: Decimal,
},
/// A settlement's figures can't be exact (BS-arap-6 INVARIANT 1): an
/// A settlement's figures can't be exact (BS-arap-6 invariant 3): an
/// amount too large to add, a negative fee, or a fee that leaves
/// nothing to deposit; a fee above the cash is
/// [`LedgerError::FeeAboveCash`].
@@ -796,7 +796,7 @@ pub enum LedgerError {
},
/// Receivables or payables can't move to an account holding lines
/// that are no document's (BS-arap-2 INVARIANT 1): they would
/// that are no document's (BS-arap-2 statement 12): they would
/// become hand lines on a control account.
#[error(
"account {code} \"{name}\" holds lines no invoice or bill carries (entry {entry} first), \
@@ -843,7 +843,7 @@ pub enum LedgerError {
},
/// A reversal or payment would leave a document owing less than nothing
/// or more than its total at some date (BS-arap-2 INVARIANT 2): the
/// or more than its total at some date (BS-arap-2 invariant 6): the
/// message says which document, when, and what to reverse first.
#[error("{0}")]
DocumentBounds(String),
@@ -882,7 +882,7 @@ pub enum LedgerError {
#[error("{0}")]
InvalidSend(String),
/// A bad debt can't be written off on cash-basis books (
/// BS-arap-5 INVARIANT 3; IRC §166(a); Treas. Reg. §1.166-1(e)): the
/// BS-arap-5 statement 6; IRC §166(a); Treas. Reg. §1.166-1(e)): the
/// invoice was never counted as income, so there is no basis to
/// deduct.
#[error(
+2 -2
View File
@@ -43,7 +43,7 @@ pub enum Leftover {
/// SOURCE: BS-partner-1 (partners share by the agreement; capital accounts
/// carry the allocations), BS-partner-3 (a party's part of an
/// entry), BS-partner-4 (the K-1 worksheet), BS-1099-1 (a payment
/// split by the parties' shares), BS-statement-3 rule 5 (the
/// split by the parties' shares), BS-statement-3 statement 8 (the
/// government's part of a payment), BS-arap-3 (a document line's
/// exact amount).
/// INVARIANTS:
@@ -173,7 +173,7 @@ const MAX_CORRECTION_STEPS: usize = 4096;
/// SOURCE: BS-partner-1 (partners share by the agreement; the largest
/// remainder is the owner's choice, 2026-10-13), BS-partner-3 (a
/// party's part of an entry), BS-partner-4 (the K-1 worksheet's
/// shares), BS-1099-1 (a payment's buckets), BS-statement-3 rule 5
/// shares), BS-1099-1 (a payment's buckets), BS-statement-3 statement 8
/// (the government's part), BS-arap-3 (a document line's exact
/// amount), BS-ledger-1 (a whole number of smallest units).
/// INVARIANTS:
+20 -20
View File
@@ -391,7 +391,7 @@ pub fn net<T: Amount>(lines: impl IntoIterator<Item = (Side, T)>) -> Option<T> {
/// ```text
/// GOAL: an early-payment discount never takes more than its percentage
/// says, in exact money.
/// SOURCE: BS-arap-3 INVARIANT 2, BS-arap-6; plan/served.md
/// SOURCE: BS-arap-3 invariant 2, BS-arap-6; plan/served.md
/// 8.3.13; CHOICE: the gross method, A-8 (the discount is
/// booked when taken, never estimated).
/// INVARIANTS:
@@ -1047,8 +1047,8 @@ pub fn apportion_cumulative<T: Amount>(
Some(())
}
/// Where a line falls on the statement of cash flows (BS-statement-3 rule
/// 2): a cash account, or one of the three sections.
/// Where a line falls on the statement of cash flows (BS-statement-3 statement
/// 3): a cash account, or one of the three sections.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Flow {
/// A cash account: what the statement explains the change in.
@@ -1063,7 +1063,7 @@ pub enum Flow {
impl Flow {
/// The three sections, in the order cash is applied to them (
/// BS-statement-3 rule 3): operating, investing, financing.
/// BS-statement-3 statement 4): operating, investing, financing.
pub const SECTIONS: [Flow; 3] = [Flow::Operating, Flow::Investing, Flow::Financing];
}
@@ -1116,7 +1116,7 @@ pub fn take<T: Amount>(remaining: T, movement: T) -> Option<T> {
/// ```text
/// GOAL: split an entry's cash among the parts it settled, without
/// inventing or losing any.
/// SOURCE: BS-statement-3 rule 3 (ASC 230-10-50-5: only the cash portion
/// SOURCE: BS-statement-3 statement 4 (ASC 230-10-50-5: only the cash portion
/// of a part-cash transaction is a cash flow; the order is a
/// CONVENTION, the ASC is silent).
/// INVARIANTS:
@@ -1143,7 +1143,7 @@ pub fn apply_cash<T: Amount>(cash: T, movements: &[T], applied: &mut [T]) -> Opt
(remaining == T::ZERO).then_some(())
}
/// An entry's cash flows (BS-statement-3 rule 3): the net movement of its
/// An entry's cash flows (BS-statement-3 statement 4): the net movement of its
/// cash lines, applied to the sections moving against it in the order
/// operating, investing, financing, each up to its own movement; what is
/// left of a section's movement is the part no cash settled. `None` when
@@ -1244,7 +1244,7 @@ fn credits_and_debits<T: Amount>(movements: &[T]) -> Option<(T, T)> {
}
/// Which way money a member or a lender handled for the company went
/// (BS-statement-3 rule 11, D-42).
/// (BS-statement-3 statement 16, D-42).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum OnBehalf {
/// Paid for the company: sources credited (borrowed, contributed)
@@ -1258,7 +1258,7 @@ pub enum OnBehalf {
impl OnBehalf {
/// The other way: what an entry's reversal does.
///
/// SOURCE: BS-statement-3 rule 11 (what a member or lender paid or
/// SOURCE: BS-statement-3 statement 16 (what a member or lender paid or
/// received for the company is mirrored by its reversal).
///
/// INVARIANTS:
@@ -1273,7 +1273,7 @@ impl OnBehalf {
/// What a member or a lender paid, or received, for the company with no
/// cash account moving: a constructive receipt and disbursement (
/// BS-statement-3 rule 11, D-42). `sources` are what is left unsettled of the
/// BS-statement-3 statement 16, D-42). `sources` are what is left unsettled of the
/// entry's kinds that can pay or receive for the company (a financing
/// liability, a member's equity), `uses` of the kinds they can pay or
/// receive for, each debit-positive. [`OnBehalf::Paid`]: `amount =
@@ -1289,7 +1289,7 @@ impl OnBehalf {
/// GOAL: show money a member or lender handled for the company as the
/// company's own, borrowed (or contributed) and spent, without
/// inventing or losing a cent.
/// SOURCE: BS-statement-3 rule 11 (D-42; ASC 230 is silent, PwC Viewpoint
/// SOURCE: BS-statement-3 statement 16 (D-42; ASC 230 is silent, PwC Viewpoint
/// FSP 6.9.3.1, Deloitte DART Roadmap 7.2, BDO Blueprint 3.4).
/// INVARIANTS:
/// 1. The parts net to zero: Σ from + Σ to = 0, so the entry's cash
@@ -1322,7 +1322,7 @@ pub fn constructive<T: Amount>(
}
/// How much of an entry is an exchange inside investing and financing
/// that no cash settled (BS-statement-3 rule 7, ASC 230-10-50-4: debt
/// that no cash settled (BS-statement-3 statement 12, ASC 230-10-50-4: debt
/// converted to equity, one asset traded for another). `debits` and
/// `credits` are the net debits and net credits of the entry's investing
/// and financing balance-sheet accounts (each account netted first; both
@@ -1449,7 +1449,7 @@ fn least<T: Amount>(a: T, b: T) -> T {
}
/// What an entry's parties split and what of it counts (BS-partner-3
/// item 3, every case but a close and a reversal, which the caller
/// statement 3, every case but a close and a reversal, which the caller
/// handles: a close is its parties' own-account movement with direction
/// neither, a reversal is [`reverse_target`] of its original's).
///
@@ -1553,7 +1553,7 @@ pub fn party_target<T: Amount>(
})
}
/// A reversal's target from its original's (BS-partner-3 item 3; BS-ledger-5: a
/// A reversal's target from its original's (BS-partner-3 statement 3; BS-ledger-5: a
/// correction is the opposite entry): every amount negated (never to a
/// negative zero), paid and received swapped. An involution. `None` past
/// the type's range.
@@ -2043,12 +2043,12 @@ pub fn basis_figures<T: Amount>(
}
/// A project's unrecovered cost from its tagged revenue and expenses to
/// date: what it would take to be repaid in full (BS-statement-5 item 4).
/// date: what it would take to be repaid in full (BS-statement-5 statement 5).
///
/// ```text
/// GOAL: the "if repaid" figure of work done on spec, from one function
/// the tools, the viewer and bookspec share.
/// SOURCE: BS-statement-5 item 4 (ASC 450-30-25-1: a hoped-for
/// SOURCE: BS-statement-5 statement 5 (ASC 450-30-25-1: a hoped-for
/// payment is a gain contingency, never recorded before it is
/// received; so this is a figure, never a receivable).
/// INVARIANTS:
@@ -2087,7 +2087,7 @@ pub enum Bounds {
/// ```text
/// GOAL: one definition of "a document is never overpaid and never owes
/// more than it is for", at every date, not only at the end.
/// SOURCE: BS-arap-2 INVARIANT 2 (0 <= outstanding(d, D)
/// SOURCE: BS-arap-2 invariant 6 (0 <= outstanding(d, D)
/// <= total(d) at every D); plan/served.md P4b.3 (Bounds).
/// INVARIANTS:
/// 1. Within exactly when every prefix sum of `deltas` is within
@@ -2134,7 +2134,7 @@ fn out_of_bounds<T: Amount>(total: T, running: T) -> Option<(T, bool)> {
/// GOAL: a command never puts a document out of bounds, yet books an
/// earlier version left out of bounds (a void under a payment that
/// stands) take the step that mends them.
/// SOURCE: BS-arap-2 INVARIANT 2, BS-entry-4 (replay accepts what
/// SOURCE: BS-arap-2 invariant 6, BS-entry-4 (replay accepts what
/// was written; the bound is the commands'); plan/served.md
/// P4b.14 item 3 (the remedy: reverse the payment).
/// INVARIANTS:
@@ -2179,7 +2179,7 @@ pub fn bounds_kept<T: Amount>(total: T, before: &[T], after: &[T]) -> Bounds {
mod tests {
use super::*;
/// BS-statement-3 rule 3, by hand. Equipment 1,000 for 300 cash and a
/// BS-statement-3 statement 4, by hand. Equipment 1,000 for 300 cash and a
/// 700 note: investing takes the 300, the note's 700 and the rest of
/// the equipment's are the noncash part.
#[test]
@@ -2225,7 +2225,7 @@ mod tests {
assert_eq!(apply_cash(10, &[-3], &mut out), None);
}
/// The exchange measure (BS-statement-3 rule 7) on the review's
/// The exchange measure (BS-statement-3 statement 12) on the review's
/// hand-checked cases.
#[test]
fn exchanged_matches_the_hand_checked_cases() {
@@ -2247,7 +2247,7 @@ mod tests {
assert_eq!(exchanged(1000i64, 1000, 1000, 1000), Some(0));
}
/// BS-statement-3 rule 11 (D-42), by hand.
/// BS-statement-3 statement 16 (D-42), by hand.
#[test]
fn constructive_pays_and_receives_for_the_company() {
use OnBehalf::{Paid, Received};
+1 -1
View File
@@ -42,7 +42,7 @@
//! to zero, and a reversal's parts are the original's negated (BS-statement-3);
//! * what a member or lender paid or received for the company, with no
//! cash account moving, is split among the kinds it settled, netting to
//! zero, and mirrored by a reversal (BS-statement-3 rule 11);
//! zero, and mirrored by a reversal (BS-statement-3 statement 16);
//! * a party's part of an entry is signed as a line on the party's own
//! account would be, a reversal's is its original's negated, and what of
//! it counts as money or as property never exceeds it (BS-partner-3);
+22 -23
View File
@@ -1368,7 +1368,7 @@ impl Ledger {
/// - SHOULD refuse (RoleAccountHasHandLines), naming the entry
/// - NEVER make a hand line a control account's
/// BECAUSE no command adds an untagged control line (BS-arap-2
/// INVARIANT 1). Replay never refuses (BS-entry-4).
/// invariant 2). Replay never refuses (BS-entry-4).
/// An account the role moves off keeps its documents' lines, and
/// stays guarded while it holds them (Self::control_role_of).
/// ```
@@ -1632,7 +1632,7 @@ impl Ledger {
/// no other: a chart's own account at a role's default code
/// (1200 Equipment, a card at 2000) is anyone's until a document
/// posts there.
/// SOURCE: BS-ledger-8, BS-arap-2 INVARIANT 1.
/// SOURCE: BS-ledger-8, BS-arap-2 statement 9.
/// INVARIANTS:
/// 1. Some(role) when the role is assigned to the account, or the
/// account holds a line tagged with one of the role's documents
@@ -1735,7 +1735,7 @@ impl Ledger {
/// ```text
/// GOAL: no command adds a line on a control account that is no
/// document's; one only takes a legacy one away.
/// SOURCE: BS-arap-2 INVARIANT 1 and item 3 (the
/// SOURCE: BS-arap-2 invariant 2 and statement 11 (the
/// exemption).
/// INVARIANTS:
/// 1. A tagged line passes.
@@ -2284,7 +2284,7 @@ impl Ledger {
/// - NEVER refuse reversing a payment, which only reopens its
/// document
/// BECAUSE 0 <= outstanding <= total at every date (BS-arap-2
/// INVARIANT 2). Replay never refuses (BS-entry-4).
/// invariant 6). Replay never refuses (BS-entry-4).
/// ```
pub fn check_reversal(&self, entry: EntryId, date: NaiveDate) -> Result<(), LedgerError> {
let original = self
@@ -2489,7 +2489,7 @@ impl Ledger {
self.replay_add_line(id, line.account, kernel::flip(line.side), line.amount)?;
// The reversal offsets the original line for line: carry the
// class so divisional P&L nets correctly, and the document so
// it moves by exactly the opposite (BS-arap-2 INVARIANT 3).
// it moves by exactly the opposite (BS-arap-2 invariant 4).
if line.class_id.is_some() {
self.set_line_class(id, idx, line.class_id)?;
}
@@ -3214,7 +3214,7 @@ impl Ledger {
/// ```text
/// GOAL: a run the books record is the entry that posted it, no more
/// and no less, so accumulated_posted is what the books carry.
/// SOURCE: BS-asset-1 rules 6 and 8, BS-asset-3; BS-entry-4 (new commands are bounded; replay checks
/// SOURCE: BS-asset-1 statements 14 and 28, BS-asset-3; BS-entry-4 (new commands are bounded; replay checks
/// only what every journaled run passed:
/// record_depreciation_run).
/// ```
@@ -5771,7 +5771,7 @@ impl Ledger {
/// line per (account, project) part the lines name, the parts
/// naming neither as one (arap::document_parts), each revenue line
/// tagged with its project; the receivable line never (
/// BS-statement-5 item 8).
/// BS-statement-5 statement 6).
/// 2. The receivable line MUST carry the invoice (Origin), in the
/// step that posts it: the invoice starts Open, owing its total.
/// 3. A refusal MUST leave the books unchanged.
@@ -5906,7 +5906,7 @@ impl Ledger {
/// with the vendor (1099s): one line per (account, project) part
/// the lines name, the parts naming neither as one
/// (arap::document_parts), each tagged with its project; the
/// payable line never (BS-statement-5 item 8).
/// payable line never (BS-statement-5 statement 6).
/// 2. The payable line MUST carry the bill (Origin), in the step that
/// posts it.
/// 3. A refusal MUST leave the books unchanged.
@@ -6267,7 +6267,7 @@ impl Ledger {
/// GOAL: every figure about a document (paid, outstanding, status,
/// overdue) is read from its tagged lines, so a reversal, a void
/// or a bounced payment is right by construction.
/// SOURCE: BS-arap-2 (INVARIANTS 1-4), BS-ledger-5, BS-ledger-6, BS-arap-1;
/// SOURCE: BS-arap-2 (invariants 1, 4, 6 and 7), BS-ledger-5, BS-ledger-6, BS-arap-1;
/// ASC 310-10 (receivables), ASC 405-20-40-1 (payables).
/// INVARIANTS:
/// 1. outstanding = the signed sum of every posted line tagged with
@@ -6417,7 +6417,7 @@ impl Ledger {
/// Refuse a step that would move `doc` by `extra` (dated movements)
/// if, at some date, it would then owe less than nothing or more than
/// its total where it didn't before ([`kernel::bounds_kept`];
/// BS-arap-2 INVARIANT 2). Books an earlier version left out of bounds
/// BS-arap-2 invariant 6). Books an earlier version left out of bounds
/// (a void under a payment that stands) take any step that makes no
/// date worse, so the remedy (reversing the payment) is accepted.
fn check_item_bounds(
@@ -6478,7 +6478,7 @@ impl Ledger {
/// The least `doc` owes on any day from `date` on (from its own date,
/// for a date before it): what a payment may be, and what a write-off
/// may be, so no later day ends out of bounds (BS-arap-2
/// INVARIANT 2, BS-arap-5 INVARIANT 1).
/// invariant 6, BS-arap-5 invariant 3).
fn least_owed_from(&self, doc: arap::DocRef, date: NaiveDate) -> Result<Decimal, LedgerError> {
let (doc_date, ..) = self.doc_header(doc)?;
let from = date.max(doc_date);
@@ -7138,7 +7138,7 @@ impl Ledger {
/// 3. 0 < amount <= the least the invoice owes on any day from
/// `date` on (on the day, when nothing later lowers it): a
/// partial write-off is allowed (§1.166-3(a)), and no day may
/// owe less than nothing (BS-arap-2 INVARIANT 2).
/// owe less than nothing (BS-arap-2 invariant 6).
/// 4. The day MUST be in the calendar, in an open period, and not
/// before the invoice.
/// 5. A refusal MUST leave the books unchanged.
@@ -7152,7 +7152,7 @@ impl Ledger {
/// 4. IF it is dated before the invoice or in a closed period:
/// SHOULD refuse.
/// 5. Half paid, the rest written off: Written off, with 50 paid and
/// 50 written off (BS-arap-2 SCENARIO 7).
/// 50 written off (BS-arap-2 scenario 7).
/// ```
pub fn write_off(
&mut self,
@@ -7257,7 +7257,7 @@ impl Ledger {
/// ```text
/// GOAL: a document that should never have existed (a duplicate, the
/// wrong customer) is undone by an opposite entry, never erased.
/// SOURCE: BS-ledger-5, BS-ledger-6, BS-period-2, BS-arap-2 (scenarios 2, 3);
/// SOURCE: BS-ledger-5, BS-ledger-6, BS-period-2, BS-arap-2 (scenarios 2 and 3);
/// plan/served.md P4b.5, P4b.6; ASC 250 (an immaterial error is
/// corrected in the period found).
/// INVARIANTS:
@@ -7325,7 +7325,7 @@ impl Ledger {
/// ```text
/// GOAL: show that receivables and payables equal their documents, and
/// list every line that is no document's.
/// SOURCE: BS-ledger-8, BS-arap-2 INVARIANT 1:
/// SOURCE: BS-ledger-8, BS-arap-2 invariant 1:
/// GL(A, D) = Σ_docs outstanding(d, D) + unattached(A, D).
/// INVARIANTS:
/// 1. balance sums every posted line on the account dated on or
@@ -7561,8 +7561,7 @@ impl Ledger {
}
}
/// Tag the line a new payment event names (plan P4b S6; BS-arap-6
/// INVARIANT 3): line `index` of `entry`, when it is on the role's
/// Tag the line a new payment event names (plan P4b S6; WB-arap-15): line `index` of `entry`, when it is on the role's
/// account, on the side the movement posts, untagged, and for `amount`.
/// Otherwise it stays untagged and the control check lists it; replay
/// never refuses (BS-entry-4).
@@ -7771,7 +7770,7 @@ impl Ledger {
}
/// [`Self::replay_invoice_payment`] with the line a new event names and
/// the discount it took (plan P4b S6; BS-arap-6 INVARIANT 3). A
/// the discount it took (plan P4b S6; WB-arap-15). A
/// line the event names but that can't be matched (no such line, the
/// wrong account or side, or already tagged) stays untagged, and the
/// control check lists it: replay never refuses (BS-entry-4).
@@ -7922,7 +7921,7 @@ impl Ledger {
///
/// ```text
/// GOAL: what each customer owes as of a day, by how overdue.
/// SOURCE: BS-arap-1, BS-arap-2 INVARIANT 5.
/// SOURCE: BS-arap-1, BS-arap-2 invariant 8.
/// INVARIANTS:
/// 1. Each invoice issued by `as_of` that owes something then
/// (Self::doc_state's outstanding) is in exactly one bucket, at
@@ -9311,7 +9310,7 @@ impl Ledger {
///
/// ```text
/// GOAL: a new class under a name no other class has.
/// SOURCE: BS-statement-5 item 1.
/// SOURCE: WB-statement-5.
/// SCENARIOS:
/// 1. IF the name is blank: SHOULD refuse (EmptyClassName).
/// 2. IF it is longer than a line, holds a control character or a
@@ -9333,7 +9332,7 @@ impl Ledger {
///
/// ```text
/// GOAL: one rule for every name a command gives a class.
/// SOURCE: BS-statement-5 item 1; BS-partner-2 (no full TIN).
/// SOURCE: WB-statement-5; BS-partner-2 (no full TIN).
/// SCENARIOS:
/// 1. IF `except` is a class and the name is its own, exactly: SHOULD
/// keep it as stored, unchecked, so a fact-only change never
@@ -9482,7 +9481,7 @@ impl Ledger {
/// ```text
/// GOAL: refuse any project record the books can't take, before a
/// line is written.
/// SOURCE: BS-statement-5 item 1 (and BS-partner-2: no full TIN).
/// SOURCE: WB-statement-5 (and BS-partner-2: no full TIN).
/// SCENARIOS:
/// 1. IF the class doesn't exist: SHOULD refuse (UnknownClass).
/// 2. IF the name is blank, too long, or another class has it
@@ -9561,7 +9560,7 @@ impl Ledger {
}
}
/// A class name as names compare (BS-statement-5 item 1): trimmed, in
/// A class name as names compare (WB-statement-5): trimmed, in
/// lower case (Unicode's, so `Éclair` and `éCLAIR` are one name).
fn fold_class_name(name: &str) -> String {
name.trim().to_lowercase()
+3 -3
View File
@@ -850,7 +850,7 @@ impl PartyField {
}
}
/// Which of a party's totals to report (BS-partner-3 item 4). Not the
/// Which of a party's totals to report (BS-partner-3 statement 5). Not the
/// books' accounting method (`books.accounting_basis`): party totals count
/// what moved, whichever method the books keep.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
@@ -981,7 +981,7 @@ impl MoneyAccounts {
/// ```text
/// GOAL: a card is known from what the books record, and a promise (a
/// gift card sold) or a member's own card is never the company's.
/// SOURCE: BS-partner-3 item 5 (DECISION, owner, 2026-10-20: money is
/// SOURCE: BS-partner-3 statement 7 (DECISION, owner, 2026-10-20: money is
/// cash, cards, the members' financing and loans), BS-1099-1 (payment
/// methods, plan P3 defect 12).
/// INVARIANTS:
@@ -1376,7 +1376,7 @@ pub fn activity_with(
}
let shares = ledger.entry_parties(id);
// The target first: an entry that counts nothing is never
// unresolved for shares that don't fit it (BS-partner-3 item 4).
// unresolved for shares that don't fit it (BS-partner-3 statement 5).
let Ok(t) = crate::shares::target(ledger, id, shares, money) else {
a.unresolved.insert(id);
continue;
+1 -1
View File
@@ -17,7 +17,7 @@
//! is the callers' answer rather than a division by zero.
//! SOURCE: BS-partner-1 (partners share by the agreement; largest
//! remainder), BS-1099-1 (a payment's buckets), BS-statement-3
//! rule 5 (the government's part), BS-arap-3 (a document line's
//! statement 8 (the government's part), BS-arap-3 (a document line's
//! exact amount), BS-ledger-1 (whole smallest units).
//! INVARIANTS:
//! 1. The parts sum to the whole, for every policy.
+9 -9
View File
@@ -968,7 +968,7 @@ fn apply_cash_mirrors() {
/// An accepted entry always has cash flows, and they explain its cash
/// exactly: the sections' cash sums to the entry's cash, and what no cash
/// settled (each section's movement plus its cash) sums to zero
/// (BS-statement-3 rules 3 and 9: the statement foots, entry by entry).
/// (BS-statement-3 statements 4 and 14: the statement foots, entry by entry).
#[kani::proof]
#[kani::unwind(5)]
fn entry_flows_sum_to_cash() {
@@ -1043,7 +1043,7 @@ fn entry_flows_are_bounded() {
/// A reversal's cash flows are its original's, negated, part by part:
/// what lets an entry and its reversal in one period drop out of the
/// statement together (BS-statement-3 rule 6). End to end, on entries of
/// statement together (BS-statement-3 statement 11). End to end, on entries of
/// up to two lines: at three (`NF`) one run went past half an hour at
/// four jobs on a busy machine (2026-10-21), so three lines are proved in
/// two halves, `entry_movements_of_a_reversal_mirror` and
@@ -1228,7 +1228,7 @@ fn any_way() -> kernel::OnBehalf {
}
/// What a member or a lender paid or received for the company (
/// BS-statement-3 rule 11, D-42) invents and loses nothing: the parts net to zero,
/// BS-statement-3 statement 16, D-42) invents and loses nothing: the parts net to zero,
/// so an entry's flows still sum to its cash; each part settles its own
/// movement toward zero, never past it; and as much is settled as can be.
#[kani::proof]
@@ -1276,7 +1276,7 @@ fn constructive_nets_to_zero() {
/// The other way, minus the sources and minus the uses give minus the
/// parts: a reversal of a payment made on the company's behalf mirrors it
/// (BS-statement-3 rule 6), so the two drop out together.
/// (BS-statement-3 statement 11), so the two drop out together.
#[kani::proof]
#[kani::unwind(4)]
fn constructive_mirrors() {
@@ -1320,7 +1320,7 @@ fn any_party_inputs() -> (Option<(i64, i64)>, i64, i64, i64) {
(capital, any_amount(), any_amount(), debits)
}
/// BS-partner-3 items 1-4: the direction is the sign of what counts (paid above
/// BS-partner-3 statements 1-5: the direction is the sign of what counts (paid above
/// zero, received below), neither exactly when nothing counts; cash and
/// in kind each carry the whole's sign and together never exceed it; a
/// money target is all cash; a contribution counts all of itself; a
@@ -1393,7 +1393,7 @@ fn direction_of_is_the_sign() {
kani::cover!(amount == 0, "nothing moved");
}
/// BS-partner-3 item 3 and BS-ledger-5: the target is odd. Negating the lines negates the
/// BS-partner-3 statement 3 and BS-ledger-5: the target is odd. Negating the lines negates the
/// capital movement, the money net and the own-account movement, and the
/// property comes from the other side, so it keeps its size: the result
/// is the original's reverse_target, whenever it isn't the debits fallback
@@ -1837,7 +1837,7 @@ fn basis_figures_laws() {
);
}
/// `kernel::unrecovered_cost` (BS-statement-5 item 4), for every revenue
/// `kernel::unrecovered_cost` (BS-statement-5 statement 5), for every revenue
/// and expense a line could carry: never below zero; the shortfall when
/// expenses exceed revenue, else zero; never above max(expenses, 0) when
/// revenue isn't negative (expenses may be negative: a reimbursement
@@ -1859,7 +1859,7 @@ fn unrecovered_cost_laws() {
kani::cover!(u == 0 && revenue > expenses, "repaid, and more");
}
/// `kernel::running_bounds` (BS-arap-2 INVARIANT 2; the bounds every
/// `kernel::running_bounds` (BS-arap-2 invariant 6; the bounds every
/// document command and reversal checks), for every total and every
/// sequence of up to `N` dated movements a line could carry: it says
/// Within exactly when every running balance is in `0 ..= total`, and
@@ -1899,7 +1899,7 @@ fn bounds_check_matches_definition() {
}
/// `kernel::bounds_kept` (the check every document command and reversal
/// runs, BS-arap-2 INVARIANT 2): on books in bounds at every date it
/// runs, BS-arap-2 invariant 6): on books in bounds at every date it
/// is the definition (`running_bounds` of the books after the step); and
/// whenever it says Within, no running balance after the step is further
/// outside `0 ..= total` than before it, so a step that mends books an
+6 -6
View File
@@ -533,7 +533,7 @@ fn profit_and_loss_counted(
))
}
/// A project's figures (BS-statement-5 item 3): the period's statement and
/// A project's figures (BS-statement-5 statement 2): the period's statement and
/// months, and its figures to date.
#[derive(Clone, Debug)]
pub struct ProjectFigures {
@@ -592,7 +592,7 @@ pub struct ProjectToDate {
impl ProjectToDate {
/// Revenue less expenses: the project's contribution before overhead
/// (BS-statement-5 item 7), since only its own tagged lines count.
/// (WB-statement-7), since only its own tagged lines count.
pub fn net(&self) -> Decimal {
self.revenue - self.expenses
}
@@ -611,11 +611,11 @@ impl ProjectToDate {
}
/// Contribution as a percent of revenue, to one place (half to even), or
/// `None` without revenue to divide by (BS-statement-5 item 7).
/// `None` without revenue to divide by (WB-statement-7).
///
/// ```text
/// GOAL: one margin the tools and the viewer print alike.
/// SOURCE: BS-statement-5 item 7 (revenue less the costs traced
/// SOURCE: WB-statement-7 (revenue less the costs traced
/// to the project, fixed and variable alike: Garrison's segment
/// margin, as a ratio; not Horngren's variable-cost contribution
/// margin; a presentation choice, not GAAP).
@@ -650,7 +650,7 @@ pub const PROJECT_MONTHS: u32 = 240;
/// ```text
/// GOAL: what a project earned and cost, from one function the tools, the
/// viewer and bookspec share, so their figures never drift.
/// SOURCE: BS-statement-5 item 3 (job costing), BS-period-1, BS-statement-3.
/// SOURCE: BS-statement-5 statement 2 (job costing), BS-period-1, BS-statement-3.
/// INVARIANTS:
/// 1. MUST be profit_and_loss_for_period with the project's class: only
/// revenue and expense lines tagged to it, closing entries left out.
@@ -748,7 +748,7 @@ pub fn project_to_date(
/// Every entry with a line tagged to the project (drafts included),
/// newest first (by date, then id), with its project amount: its tagged
/// revenue lines less its tagged expense lines, each on its normal side.
/// A tagged balance-sheet line counts zero (BS-statement-5 item 3).
/// A tagged balance-sheet line counts zero (BS-statement-5 statement 2).
pub fn project_entries(ledger: &Ledger, id: ClassId) -> Vec<(crate::EntryId, Decimal)> {
let mut out: Vec<(NaiveDate, crate::EntryId, Decimal)> = Vec::new();
for eid in 1..ledger.next_entry_id() {
+2 -2
View File
@@ -22,7 +22,7 @@
//! part; DECISION, owner, 2026-10-20: a member's entry counts what
//! moved their capital).
//! DEFINITIONS:
//! target (target(), BS-partner-3 item 3): what the shares split,
//! target (target(), BS-partner-3 statement 3): what the shares split,
//! signed debit-positive as a line on the parties' own account would
//! be (positive: the company paid or gave; negative: it received),
//! with its direction (paid, received, neither) and what of it moved
@@ -317,7 +317,7 @@ pub struct Target {
pub in_kind: Decimal,
/// Which side the parts count on in a party's totals: the direction
/// of the entry's root original (itself, unless it is a reversal), so
/// a reversal nets what it reverses (BS-partner-3 item 4).
/// a reversal nets what it reverses (BS-partner-3 statement 5).
pub counts_as: Direction,
}
+2 -2
View File
@@ -89,9 +89,9 @@ use rust_decimal::Decimal;
/// `[start, end]`: its lines on the asset's depreciation expense account,
/// debit-positive (the depreciation still due through the disposal day,
/// or, negative, what the month's run posted past it, credited back:
/// BS-asset-1 rule 5). With the runs
/// BS-asset-1 statement 9). With the runs
/// (`Ledger::depreciation_posted_between`) it is the asset's depreciation
/// expense in the span, the P&L's and the cash flow's (BS-statement-3 rule 8).
/// expense in the span, the P&L's and the cash flow's (BS-statement-3 statement 13).
/// The disposal entry is the posted entry dated the disposal day that
/// credits the asset's cost account by its cost (`Store::dispose_asset`
/// posts it so).
@@ -364,7 +364,7 @@ pub(crate) fn check_schedule_plan(b: &Books<'_>, x: &Expect) {
}
/// Check one `register_row` expectation: the asset's row of the fixed
/// asset register as of `as_of` (BS-asset-1 rules 7 and 8, BS-asset-3):
/// asset register as of `as_of` (BS-asset-1 statements 23, 24 and 28, BS-asset-3):
/// `acquired` and `in_service` (`YYYY-MM-DD`), `cost`,
/// `accumulated_scheduled` (the schedule's), `accumulated_posted` (what
/// the books carry), `unposted` (the one less the other), `book_value`
@@ -299,7 +299,7 @@ pub(crate) fn check_vendor_1099(b: &Books<'_>, x: &Expect) {
/// The money party shares resolve against: the cash accounts (every
/// asset account but receivables when none are named), the cards and the
/// financing accounts (BS-partner-3 item 5).
/// financing accounts (BS-partner-3 statement 7).
pub(crate) fn party_money(ex: &Example, l: &Ledger) -> MoneyAccounts {
ledger_core::parties::money_accounts(
l,
@@ -368,7 +368,7 @@ pub(crate) fn check_party_part(b: &Books<'_>, x: &Expect) {
/// Check one `party_totals` expectation: what was `paid` to and
/// `received` from the party from `from` through `to` on `basis` (`cash`:
/// money; `all`: money and property in kind), each entry's part on its
/// root original's side (BS-partner-3 item 4); both given.
/// root original's side (BS-partner-3 statement 5); both given.
pub(crate) fn check_party_totals(b: &Books<'_>, x: &Expect) {
let (ex, l) = (b.ex, b.l());
assert!(
+1 -1
View File
@@ -2317,7 +2317,7 @@ proptest! {
}
}
/// BS-partner-3 item 9: party totals and the 1099 worksheet never
/// BS-partner-3 statement 11: party totals and the 1099 worksheet never
/// contradict. For books whose cash accounts are named, whose company
/// card is recorded as a business-card payment method (or that have
/// no card at all: without the method, 2050's name says nothing, so
+1 -1
View File
@@ -798,7 +798,7 @@ fn cash_flow_reconciles_to_change_in_cash() {
// Operating, by the direct method: collected 1,500 (class (a)); paid
// 2,500 for equipment (not a registered asset: operating,
// BS-statement-3 rule 12's limits) and 800 rent (class (d)) = -1,800. Reconciled:
// BS-statement-3 statement 17's limits) and 800 rent (class (d)) = -1,800. Reconciled:
// 3,200 net income - 2,500 increase in AR (4,000 billed - 1,500
// collected) - 2,500 increase in equipment = -1,800.
// Financing: +10,000 owner contribution. Sum = 8,200. Reconciles.
@@ -278,7 +278,7 @@ proptest! {
}
}
/// BS-statement-3 rule 3: the statement of cash flows' per-entry split
/// BS-statement-3 statement 4: the statement of cash flows' per-entry split
/// (`kernel::entry_flows`, Kani `entry_flows_*`) is the same at both
/// instantiations, on balanced and unbalanced lines alike.
#[test]
@@ -325,7 +325,7 @@ proptest! {
);
}
/// BS-statement-3 rule 11: `kernel::constructive` (what a member or
/// BS-statement-3 statement 16: `kernel::constructive` (what a member or
/// lender paid or received for the company; Kani
/// `constructive_nets_to_zero`, `constructive_mirrors`) agrees at both
/// instantiations.
+5 -5
View File
@@ -680,7 +680,7 @@ proptest! {
prop_assert_eq!(scheduled_book_value(a, on).unwrap(), want.book_value);
}
/// BS-asset-1 rule 3 (defect 22), against arithmetic written here: through
/// BS-asset-1 statement 4 (defect 22), against arithmetic written here: through
/// any day k of the life's final month (its d days), accumulated is C +
/// (D − C) × k / d rounded half up to the cent, C the exact charge of
/// the months before (D × each month's days held over its days, over
@@ -719,7 +719,7 @@ proptest! {
}
}
/// BS-asset-1 rule 4 (depreciation_schedule INVARIANT 6; P3 depreciation brief 2.3, R1, R8): through every
/// BS-asset-1 statement 6 (depreciation_schedule INVARIANT 6; P3 depreciation brief 2.3, R1, R8): through every
/// month end of the life, the schedule is the pre-P3 running total
/// (USD, a two-place currency), except where the exact cumulative is a
/// half-cent tie, which the old 28-digit Decimal quotients could round
@@ -937,7 +937,7 @@ proptest! {
proptest! {
#![proptest_config(ProptestConfig::with_cases(256))]
/// BS-statement-5 item 3: for any tags and any period, the projects'
/// BS-statement-5 statement 2: for any tags and any period, the projects'
/// figures plus the untagged lines' are the period's profit and loss
/// (no line counted twice or lost), each through
/// ledger_core::project_figures.
@@ -1002,7 +1002,7 @@ proptest! {
prop_assert_eq!(exp_sum + untagged_exp, all.total_expenses);
}
/// BS-statement-5 item 7: the snapshot's contribution is
/// WB-statement-7: the snapshot's contribution is
/// project_to_date's net, revenue less direct costs, whatever the
/// tags and sides (a refund debits revenue, a reimbursement credits an
/// expense below zero): the accounts sum to the totals, each month's
@@ -1091,7 +1091,7 @@ proptest! {
}
}
/// BS-statement-5 item 3: project_entries codes its own signs, so the
/// BS-statement-5 statement 2: project_entries codes its own signs, so the
/// posted entries' project amounts must sum to project_to_date's net
/// (with no entry dated after the day), whatever the tags, the sides,
/// a tagged balance-sheet line, or drafts beside them.
+2 -2
View File
@@ -1088,8 +1088,8 @@ fn register_of_no_assets_is_empty() {
/// 1,000.00 and June's 10/30: 5,333.33 scheduled. Before P3 the disposed
/// schedule ended in a plug, so the register showed 12,000.00 and 0.00.
/// The same in the life's final month: on 2026-12-15, 11,483.87. Book
/// value is cost less what the books carry (defect 13, BS-asset-1 rule
/// 8): the fixture's runs, January to March, 3,000.00, so 9,000.00.
/// value is cost less what the books carry (defect 13, BS-asset-1 statement
/// 28): the fixture's runs, January to March, 3,000.00, so 9,000.00.
#[test]
fn register_as_of_a_day_before_a_same_month_disposal_is_prorated() {
let (mut l, _, laptop, _) = register_fixture();
+22 -23
View File
@@ -168,7 +168,7 @@ fn s(t: &str) -> String {
t.to_string()
}
/// The laws every statement keeps (BS-statement-3 rules 8 and 9): each
/// The laws every statement keeps (BS-statement-3 statements 13 and 14): each
/// section is its lines, and its kinds; the sections are the change in
/// cash; net income and the reconciling items are operating.
fn foots(cf: &CashFlowStatement) {
@@ -205,7 +205,7 @@ fn no_distribution(cf: &CashFlowStatement) {
/// The minimal reproduction of defect 1. Property contributed (Dr
/// Equipment 2,340 / Cr Capital), the asset registered, the entry reversed
/// the same day. No cash moved, and the entry and its reversal cancel
/// (BS-statement-3 rules 1, 6): every section 0.00, no lines, no
/// (BS-statement-3 statements 2 and 11): every section 0.00, no lines, no
/// disclosures, footing 0 / 0 / 0. Before the fix: investing −2,340.00
/// against a change in cash of 0.00 (the reversal's credit to the
/// equipment account belonged to no section).
@@ -876,7 +876,7 @@ fn a_property_contribution_is_a_noncash_disclosure() {
assert_eq!(n.label, format!("Laptop contributed (#{e})"));
}
/// D-42, BS-statement-3 rule 11 (ASC 230 is silent on a payment a third
/// D-42, BS-statement-3 statement 16 (ASC 230 is silent on a payment a third
/// party makes on the entity's behalf; PwC FSP 6.9.3.1, DART Roadmap 7.2
/// and BDO Blueprint 3.4 present it by substance, as constructive receipt
/// and disbursement). An expense a member pays personally (Dr Supplies
@@ -1011,7 +1011,7 @@ fn equipment_a_lender_paid_for_is_borrowed_and_invested() {
assert_eq!(cf.net_change_in_cash, x("-500.00"));
}
/// The expense-to-capital case (BS-statement-3 rule 11): a member pays a
/// The expense-to-capital case (BS-statement-3 statement 16): a member pays a
/// vendor for the company and the books credit the member's capital (Dr
/// Supplies 80 / Cr Capital — Member A), no cash. The member paid cash to
/// a third party on the company's behalf, as through 2100; only the form
@@ -1150,7 +1150,7 @@ fn equipment_on_the_sellers_credit_stays_noncash_and_flagged() {
assert!(w.message.contains("borrowed and spent"), "{}", w.message);
}
/// BS-statement-3 rule 6 with rule 11: a payment a member made for the
/// BS-statement-3 statement 11 with statement 16: a payment a member made for the
/// company and its reversal, both in February, drop out together (their
/// flows, constructive cash included, are exact negatives: Kani
/// `constructive_mirrors`); no line, no disclosure, no total moves. The
@@ -1351,7 +1351,7 @@ fn interest_and_guaranteed_payments_charged_to_a_creditor_stay_noncash() {
);
}
/// BS-statement-3 rule 6 (BS-ledger-5: a correction undoes what it corrects): an
/// BS-statement-3 statement 11 (BS-ledger-5: a correction undoes what it corrects): an
/// entry and its reversal both in the period drop out of every line and
/// disclosure, and no total moves (their flows are exact negatives, Kani
/// `entry_flows_of_a_reversal_mirror`).
@@ -1390,7 +1390,7 @@ fn an_entry_and_its_reversal_in_the_period_drop_out() {
assert_eq!(cf.net_change_in_cash, before.net_change_in_cash);
}
/// BS-statement-3 rule 6: a reversal shown alone (its original in an
/// BS-statement-3 statement 11: a reversal shown alone (its original in an
/// earlier period) is labelled "Reversal of #N — <N's description>" and
/// listed under its original's kind, never as a distribution (D1-c).
#[test]
@@ -1414,7 +1414,7 @@ fn a_reversal_alone_is_labelled_reversal_of() {
no_distribution(&cf);
}
/// BS-statement-3 rules 4 and 6: a reversal takes its chain root's
/// BS-statement-3 statements 5 and 11: a reversal takes its chain root's
/// sections, class and kind, with its own sign. Reversing January's cash
/// sale at a 300 gain in February: investing −500 under "Proceeds from
/// sales of property and equipment", G +300 (the gain, reversed, is still
@@ -1766,7 +1766,7 @@ fn operating_classes_follow_asc_230_10_45_25() {
/// ASC 230-10-45-28(b): depreciation is an item of net income with no
/// cash effect, a reconciling item; it is not an investing or financing
/// activity, so nothing is disclosed (BS-statement-3 rule 7).
/// activity, so nothing is disclosed (BS-statement-3 statement 12).
#[test]
fn depreciation_is_reconciling_not_disclosed() {
let mut b = funded();
@@ -1862,7 +1862,7 @@ fn operating_reconciliation_ties_to_operating_cash() {
);
}
/// BS-period-1 and BS-statement-3 rule 10: a period close moves earnings into
/// BS-period-1 and BS-statement-3 statement 15: a period close moves earnings into
/// equity; it earns and spends nothing, so it is never in the statement.
#[test]
fn closing_entries_never_appear() {
@@ -1881,7 +1881,7 @@ fn closing_entries_never_appear() {
assert!(!text.contains(&format!("entry: {close},")));
}
/// The period is [start, end] inclusive (BS-statement-3 rule 1): a
/// The period is [start, end] inclusive (BS-statement-3 statement 2): a
/// contribution on the start date is a flow, not opening cash.
#[test]
fn cash_flow_starts_counting_on_the_start_date() {
@@ -1921,8 +1921,7 @@ fn a_transfer_between_cash_accounts_is_not_a_flow() {
assert!(cf.noncash_disclosures.is_empty());
}
/// Review round 2, footing in odd shapes (BS-statement-3 rules 1, 6, 9,
/// 11), by hand:
/// Review round 2, footing in odd shapes (BS-statement-3 statements 2, 11, 14 and 16), by hand:
/// - two cash accounts in one entry, a transfer less its fee (Dr Savings
/// 99, Dr Supplies 1 / Cr Cash 100): only the net, −1, moves cash,
/// operating (d); no investing or financing;
@@ -2217,7 +2216,7 @@ fn financing_lists_each_members_contributions_and_distributions() {
/// "at a minimum" apart from the other classes, so an entry's operating
/// cash is classed kind by kind: its interest lines are (b) or (e)
/// whatever else it settles, the rest by its structure (BS-statement-3
/// rule 5). By hand:
/// statement 7). By hand:
/// - a payment of 900 on a loan the settings leave operating, with 100
/// interest (Dr 2500 900, Dr 6200 100 / Cr cash 1,000): (d) −900 and
/// (e) −100, not (e) −1,000;
@@ -2547,7 +2546,7 @@ fn a_reversed_bill_payment_leaves_the_purchase_unpaid() {
}
// ---------------------------------------------------------------------------
// Role refusals (BS-statement-3 rule 2) and the footing check (rule 9).
// Role refusals (BS-statement-3 statement 3) and the footing check (statement 14).
// ---------------------------------------------------------------------------
fn refused(b: &Books, cash: &[&str], financing: &[&str], investing: &[&str]) -> String {
@@ -2617,7 +2616,7 @@ fn a_registered_asset_account_cannot_be_cash() {
assert!(m.contains("a registered fixed asset's account"), "{m}");
}
/// BS-statement-3 rule 9: any difference between the sections and the
/// BS-statement-3 statement 14: any difference between the sections and the
/// change in cash is an engine error, never a statement.
#[test]
fn foot_refuses_any_difference() {
@@ -3244,7 +3243,7 @@ fn a_disposals_depreciation_credit_back_is_depreciation() {
assert_eq!(cf.cash_from_investing, x("975.00"));
}
/// BS-statement-3 rule 5 (the P3 cutover review's open point 2): ASC
/// BS-statement-3 statement 8 (the P3 cutover review's open point 2): ASC
/// 230-10-45-17(c), "Cash payments to governments for taxes, duties,
/// fines, and other fees or penalties", is not 45-17(b)'s "Cash payments
/// to other suppliers and employees": a state's filing fee booked to an
@@ -3316,7 +3315,7 @@ fn a_payment_to_a_government_is_other_operating() {
assert_eq!((line.class, line.amount), (Some(OtherPayments), x("75.00")));
}
/// BS-statement-3 rule 5: the payee decides on any account, and the tax
/// BS-statement-3 statement 8: the payee decides on any account, and the tax
/// category still does without one: a license on `taxes_licenses` with no
/// party is (g). An entry naming a government and a supplier together
/// (half each) is split by their shares, as ASC 230-10-45-22 has each
@@ -3371,7 +3370,7 @@ fn a_government_payee_moves_a_fee_on_any_account() {
assert_eq!(classes(&cf, shared), [(OtherPayments, x("-100.00"))]);
}
/// BS-statement-3 rule 5: a split by shares that leaves an odd cent rounds
/// BS-statement-3 statement 8: a split by shares that leaves an odd cent rounds
/// the government's part half to even, the supplier's the rest, so the
/// line still sums to the payment; its reversal next month mirrors it to
/// the cent. Fixed amounts split as given.
@@ -3450,7 +3449,7 @@ fn a_shared_government_payment_splits_to_the_cent() {
);
}
/// BS-statement-3 rule 5: a reversal takes its original's payee, so the
/// BS-statement-3 statement 8: a reversal takes its original's payee, so the
/// pair always lands in one class and nets. A state's fee paid in
/// February and reversed in March: (g) both. The books keep a reversal
/// chain's parties one (Ledger::set_entry_parties INVARIANT 5): tagging
@@ -3500,7 +3499,7 @@ fn a_reversal_takes_its_originals_payee() {
assert_eq!(classes(&b), both(ToSuppliersAndEmployees));
}
/// BS-statement-3 rules 5 and 11: a payment shared between a state and an
/// BS-statement-3 statements 8 and 16: a payment shared between a state and an
/// agent that a member paid personally (Dr 6000 137.00 / Cr 2100, the
/// members' financing account) is borrowed and spent, and its spending is
/// split by the parties' shares as a bank payment's is, the part no bank
@@ -3577,7 +3576,7 @@ fn a_shared_government_payment_a_member_paid_splits_both_ways() {
assert_eq!(cf.net_change_in_cash, Decimal::ZERO);
}
/// BS-statement-3 rule 5 (CONVENTION): payroll keeps its structure. Taxes
/// BS-statement-3 statement 9 (CONVENTION): payroll keeps its structure. Taxes
/// withheld from employees and remitted to the tax agency are the
/// employees' pay (45-17(b), "Cash payments to other suppliers and
/// employees"), and the payroll payables mix them with the employer's
@@ -3636,7 +3635,7 @@ fn a_payroll_remittance_to_a_tax_agency_stays_pay() {
assert_eq!(class(employer), Some(OtherPayments));
}
/// BS-statement-3 rule 5: a government selling goods or services is a
/// BS-statement-3 statement 8: a government selling goods or services is a
/// supplier (45-17(b), "for other goods or services"), not 45-17(c)'s
/// taxes, fees or penalties: the post office named with the `vendor`
/// role, postage stays (d). The roles decide, so a post office given the
@@ -1,12 +1,12 @@
//! An invoice's or bill's lines name their projects (BS-statement-5 item
//! 8): the posted entry's revenue or expense side is one line per project,
//! An invoice's or bill's lines name their projects (BS-statement-5 statement
//! 6): the posted entry's revenue or expense side is one line per project,
//! the untagged lines' as one; the receivable or payable line, and the
//! payments, never take one.
//!
//! ```text
//! GOAL: a client project's invoiced revenue and a contractor's billed
//! cost count toward the project, every other figure as before.
//! SOURCE: BS-statement-5 items 3 and 8 (job costing), BS-statement-3 (the
//! SOURCE: BS-statement-5 statements 2 and 6 (job costing), BS-statement-3 (the
//! projects with the untagged lines partition the P&L), BS-1099-1 and
//! BS-partner-3 (1099 and party figures follow the money, not the tags).
//! ```
@@ -170,7 +170,7 @@ fn a_bills_cost_is_one_line_per_project_and_the_payable_none() {
}
/// Reversing a tagged invoice's or bill's entry carries each line's
/// project to the reversal (BS-statement-5 item 3: each line on its normal side), so
/// project to the reversal (BS-statement-5 statement 2: each line on its normal side), so
/// every project nets back to zero; a partial payment, cash against the
/// receivable, moves no project figure.
#[test]
@@ -295,7 +295,7 @@ fn a_line_naming_an_unknown_project_is_refused_whole() {
}
/// Finished and abandoned projects still take a document's lines (BS-statement-5
/// item 5: a late cost, a final invoice).
/// statement 7: a late cost, a final invoice).
#[test]
fn a_finished_project_still_takes_an_invoice() {
let mut b = books();
+14 -14
View File
@@ -110,7 +110,7 @@ impl Books {
}
/// Every control account's tie-out holds: no difference (BS-arap-2
/// INVARIANT 1).
/// invariant 1).
fn ties(&self, on: NaiveDate) {
for c in self.l.control_check(on).unwrap() {
assert_eq!(c.difference, Decimal::ZERO, "{c:?}");
@@ -1067,7 +1067,7 @@ fn out_of_bounds_documents_are_listed_not_aged() {
/// Reversing a legacy hand line takes it off; reversing that reversal
/// would put it back, and is refused: no command adds an untagged control
/// line (BS-arap-2 INVARIANT 1 and item 3; first review of S1).
/// line (BS-arap-2 invariant 2 and statement 11; first review of S1).
#[test]
fn putting_back_a_removed_hand_line_is_refused() {
let mut b = books();
@@ -1204,7 +1204,7 @@ fn a_chain_counts_in_order() {
// Write-offs (plan P4b S7; BS-arap-5)
// ---------------------------------------------------------------------------
/// BS-arap-2 SCENARIO 7 and BS-arap-5 INVARIANT 1: half of an invoice paid, the rest
/// BS-arap-2 scenario 7 and BS-arap-5 invariant 1: half of an invoice paid, the rest
/// written off, reads Written off with 50 paid and 50 written off, and
/// receivables falls by the write-off alone.
#[test]
@@ -1261,7 +1261,7 @@ fn half_paid_rest_written_off_is_written_off() {
assert!(check.iter().all(|c| c.difference.is_zero()));
}
/// BS-arap-5 INVARIANT 3: a cash-basis company never counted the invoice as
/// BS-arap-5 invariant 5: a cash-basis company never counted the invoice as
/// income, so it has no basis to deduct (IRC §166; Treas. Reg.
/// §1.166-1(e)).
#[test]
@@ -1308,7 +1308,7 @@ fn write_off_refused_on_cash_basis() {
);
}
/// BS-arap-5 INVARIANT 1: at most what is owed, a partial write-off allowed
/// BS-arap-5 invariant 2 and statement 3: at most what is owed, a partial write-off allowed
/// (Treas. Reg. §1.166-3(a)); more is refused, naming what is owed, and
/// nothing changes.
#[test]
@@ -1351,7 +1351,7 @@ fn write_off_above_outstanding_refused() {
assert_eq!((st.paid, st.written_off), (cents(4_000), cents(6_000)));
}
/// D-49's same-year recovery, and BS-arap-5 INVARIANT 2: reversing the
/// D-49's same-year recovery, and BS-arap-5 invariant 4: reversing the
/// write-off re-instates the debt (it is not a new movement), and the
/// payment then recorded settles it; a recovery is income, never a
/// payment event.
@@ -1502,7 +1502,7 @@ fn days(b: &Books) -> Vec<NaiveDate> {
proptest! {
#![proptest_config(ProptestConfig::with_cases(256))]
/// BS-arap-2 INVARIANTS 1, 2 and 6 over random histories of creates,
/// BS-arap-2 invariants 1, 6 and 9 over random histories of creates,
/// payments, voids, reversals of any entry and refused hand lines: at
/// every date the control accounts equal their documents (no
/// difference, nothing unattached: no command adds a hand line), each
@@ -1538,9 +1538,9 @@ proptest! {
}
}
/// BS-arap-2 INVARIANT 5: the aging as of a day partitions what the
/// BS-arap-2 invariant 8: the aging as of a day partitions what the
/// documents owe then (in books these commands write, none owes less
/// than nothing). INVARIANT 4 (Store, replay and Snapshot agree) is
/// than nothing). Invariant 7 (Store, replay and Snapshot agree) is
/// ledger-store's `status_is_a_function_of_journal_and_date`.
#[test]
fn aging_partitions_what_documents_owe(ops in prop::collection::vec(arb_op(), 0..30)) {
@@ -1562,7 +1562,7 @@ proptest! {
}
}
/// BS-arap-2 INVARIANT 3: reversing a tagged entry moves its documents by
/// BS-arap-2 invariant 4: reversing a tagged entry moves its documents by
/// exactly the opposite of the entry's own tagged lines from the
/// reversal's day (read from the entry reversed, not from the mirror,
/// so a mirror that lost its tag is caught); reversing that reversal
@@ -1725,7 +1725,7 @@ fn terms_derive_due_dates() {
assert!(Terms::new(TermsKind::NetEom(3_651), None).is_err());
}
/// BS-arap-3 INVARIANT 2: the discount's bound, its date, and the terms that
/// BS-arap-3 invariant 2: the discount's bound, its date, and the terms that
/// cannot carry one.
#[test]
fn discount_bounds_and_late_reason() {
@@ -1795,7 +1795,7 @@ fn discount_bounds_and_late_reason() {
assert_eq!(kernel::discount_max(cents(-1), 200), None);
}
/// BS-arap-3 INVARIANT 3: the canonical spellings read back as they print.
/// BS-arap-3 invariant 3: the canonical spellings read back as they print.
#[test]
fn terms_describe_and_parse_round_trip() {
for text in [
@@ -2286,7 +2286,7 @@ fn bill_on_terms_with_discount() {
}
/// A discount taken after the discount date needs a reason (BS-arap-6
/// INVARIANT 2); a bill with an asset or prepaid line refuses one with the
/// invariant 6); a bill with an asset or prepaid line refuses one with the
/// D-49 remedy, and none of the refusals changes the books.
#[test]
fn late_discount_needs_a_reason() {
@@ -2433,7 +2433,7 @@ fn a_fee_posts_gross_to_receivables_and_net_to_the_bank() {
/// A payment that settles more than one document names its lines in
/// application order, and two applications on one document are refused:
/// each document's bound is one bound (BS-arap-6 INVARIANTS 1 and 2).
/// each document's bound is one bound (BS-arap-6 invariants 4 and 5).
#[test]
fn a_settlement_names_its_lines_and_refuses_a_document_twice() {
use ledger_core::{Application, DocRef, SettleParams};
+1 -1
View File
@@ -1919,7 +1919,7 @@ mod shares {
assert_eq!((a.paid, a.received), (Decimal::ZERO, Decimal::ZERO));
}
/// BS-partner-3 item 3 (capital first): a members' entry counts what
/// BS-partner-3 statement 3 (capital first): a members' entry counts what
/// moved their capital, not other money on it: 300.00 in, 200.00 of it
/// Tobin's capital and 100.00 an expense refunded, is Tobin's 200.00
/// received (cash) and nothing of Morgan's. (Before P3 the 300.00 net
+10 -10
View File
@@ -550,7 +550,7 @@ fn defect14_shares_take_the_partys_side_and_reversals_flip() {
);
}
/// BS-partner-3 item 4: on the member-only entries, basis all is the statement of
/// BS-partner-3 statement 6: on the member-only entries, basis all is the statement of
/// members' equity (contributions and distributions, the same dates), and
/// basis cash is the K-1 worksheet's cash contributions.
#[test]
@@ -655,7 +655,7 @@ fn defect24_an_accrual_through_another_liability_counts_once() {
assert_eq!(b.totals(c, Basis::All), (Decimal::ZERO, d("1200.00")));
}
/// Defect 24 and BS-partner-3 item 6: a credit to what the company owes a party
/// Defect 24 and BS-partner-3 statement 8: a credit to what the company owes a party
/// itself never counts as paying it. A fee on the issuer's own card is a
/// bill from the issuer (counted when the card is paid); a distribution
/// still owed to a member counts when it is paid; equipment bought on the
@@ -778,7 +778,7 @@ fn a_distribution_owed_counts_twice_until_the_members_are_named_its_creditors()
/// again when paid (400.00); now it counts nothing until it is paid, then
/// 200.00, once, on both bases (Helvering v. Price; party_target
/// INVARIANT 2). The statement of members' equity counts it when declared:
/// party totals catch up when it is paid (BS-partner-3 item 4's conditions).
/// party totals catch up when it is paid (BS-partner-3 statement 6's conditions).
#[test]
fn defect24_a_distribution_declared_to_a_payable_counts_once_when_paid() {
let mut b = books();
@@ -829,7 +829,7 @@ fn defect24_a_distribution_declared_to_a_payable_counts_once_when_paid() {
assert_eq!(b.totals(t, Basis::Cash), (d("300.00"), Decimal::ZERO));
}
/// BS-partner-3 item 3: a distribution's cash is the money it paid and its in
/// BS-partner-3 statement 3: a distribution's cash is the money it paid and its in
/// kind the property it gave. Equipment carried at 1,000.00 less 300.00
/// depreciated, and 100.00 in cash, distributed: 100.00 cash and 700.00
/// in kind (it read 800.00 in kind and no cash, the equipment's cost
@@ -868,7 +868,7 @@ fn a_distribution_of_money_and_depreciated_property_splits_by_what_moved() {
assert_eq!(b.resolved(gain).1, vec![part(t, "900.00", "0", "900.00")]);
}
/// Defect 24 and the card rule (BS-partner-3 item 5): a gift card the company
/// Defect 24 and the card rule (BS-partner-3 statement 7): a gift card the company
/// sold is deferred revenue, a promise, though its account's name says
/// "card". It counted as received when sold and again when redeemed
/// (200.00); now once, when the money came in. A card the company pays
@@ -892,7 +892,7 @@ fn defect24_a_gift_card_sold_is_received_once() {
assert_eq!(b.totals(c, Basis::All), (Decimal::ZERO, d("100.00")));
}
/// BS-partner-3 item 5 and `parties::card_accounts` INVARIANTS 1-4: one rule for
/// BS-partner-3 statement 7 and `parties::card_accounts` INVARIANTS 1-4: one rule for
/// what a card is. Before any business card is recorded, the liabilities
/// whose names say "card" but not "gift" (2050 Business Card; never 2410
/// Gift Card Liability), less a member's card's account; once one is
@@ -958,7 +958,7 @@ fn a_card_is_a_recorded_business_card_else_a_liability_named_card() {
assert_eq!(b.resolved(on_2050).0.direction, Direction::Neither);
}
/// BS-partner-3 item 3, case 3: E is the movement of equity other than retained
/// BS-partner-3 statement 3, case 3: E is the movement of equity other than retained
/// earnings, so a members' entry reads as the statement of members' equity
/// reads it. Retained earnings given up for equipment moves no member's
/// capital: neither, as the statement shows no distribution. Retained
@@ -1035,7 +1035,7 @@ fn a_refund_is_received_from_the_vendor() {
assert_eq!(b.totals(v, Basis::Cash), (d("100.00"), d("20.00")));
}
/// BS-partner-3 item 3 (capital first): a mixed contribution is split into money
/// BS-partner-3 statement 3 (capital first): a mixed contribution is split into money
/// and property exactly as the K-1 worksheet splits it (its SCENARIO 3),
/// whichever member the shares list first; an expense a member pays
/// straight to capital is cash, as on the K-1 (k1 INVARIANT 3); a debt
@@ -1168,7 +1168,7 @@ fn a_members_entry_keeps_its_reading_after_they_leave() {
);
}
/// BS-partner-3 item 3, case 1: a period's closing entry moves nothing with
/// BS-partner-3 statement 3, case 1: a period's closing entry moves nothing with
/// anyone: direction neither, its members' part their income allocated
/// (credited to their capital: negative), counted in no total.
#[test]
@@ -1661,7 +1661,7 @@ proptest! {
/// account converted to capital, some through their distributions
/// accounts, some declared to distributions payable and paid later,
/// and reverse some of it later in the year. For each member, over
/// every span from the year's start to any date (BS-partner-3 item 4's
/// every span from the year's start to any date (BS-partner-3 statement 6's
/// conditions hold: a reversal in such a span always has its original
/// in it): basis all is the statement of members' equity's
/// contributions and distributions, but for a distribution declared
+3 -3
View File
@@ -534,7 +534,7 @@ fn a_reversal_nets_a_project_to_zero() {
let entries = project_entries(&b.l, c);
assert_eq!(entries, vec![(r, cents(180_000)), (e, cents(-180_000))]);
// Nothing left on an account, but two lines tagged: it breaks even,
// it isn't untagged (BS-statement-5 item 7).
// it isn't untagged (WB-statement-7).
assert!(t.expenses_by_account.is_empty());
assert_eq!((t.revenue_lines, t.expenses_lines), (0, 2));
assert!(t.any_tagged());
@@ -652,7 +652,7 @@ fn differs_from_names_projects() {
assert_eq!(a.l.differs_from(&before), vec!["projects"]);
}
/// BS-statement-5 item 7: the margin is the contribution's share of
/// WB-statement-7: the margin is the contribution's share of
/// revenue, one place, half to even, and none without revenue.
#[test]
fn contribution_margin_is_one_place_and_none_without_revenue() {
@@ -671,7 +671,7 @@ fn contribution_margin_is_one_place_and_none_without_revenue() {
assert_eq!(pct(Decimal::MAX, cents(1)), None, "never panics");
}
/// BS-statement-5 item 7: each month's net to date opens on the lines
/// WB-statement-7: each month's net to date opens on the lines
/// before the months (a deposit last year) and ends on the net to date;
/// a reimbursement credited above its cost leaves the expense below zero.
#[test]
+2 -2
View File
@@ -2505,9 +2505,9 @@ proptest! {
/// the cash part of the equity and designated-debt movements: each
/// entry's cash applied to the sections moving against it, operating,
/// investing, financing, each up to its own movement (BS-statement-3
/// rule 3), then to the kinds within each section in their order;
/// statement 4), then to the kinds within each section in their order;
/// plus what the loan or a member's capital paid or received for the
/// company (rule 11, D-42): the loan pays for operating lines (the
/// company (statement 16, D-42): the loan pays for operating lines (the
/// balance-sheet ones first) and receives for revenue and expense;
/// capital pays and receives for revenue and expense only. Written
/// here apart from the kernel.
+2 -2
View File
@@ -1444,7 +1444,7 @@ fn lines(ls: &[ledger_core::reports::CashFlowLine]) -> Vec<(String, Decimal)> {
/// amounts borrowed"): borrowing and repayment are separate lines, one
/// per entry, borrowing first (each lender's, by code), then repayments.
/// The software the owner paid personally is borrowed from the owner and
/// spent on its date (BS-statement-3 rule 11, D-42: constructive receipt
/// spent on its date (BS-statement-3 statement 16, D-42: constructive receipt
/// and disbursement). Financing: +100 + 1,000 − 100 − 400 = 600; nothing
/// is disclosed.
#[test]
@@ -1487,7 +1487,7 @@ fn a_loan_the_entity_makes_is_investing_gross() {
assert_eq!(cf.cash_from_investing, dec(-300));
}
/// Oracle: D-42 (BS-statement-3 rule 11; ASC 230 is silent on a payment
/// Oracle: D-42 (BS-statement-3 statement 16; ASC 230 is silent on a payment
/// made on the entity's behalf, PwC FSP 6.9.3.1 and DART Roadmap 7.2
/// present it as constructive receipt and disbursement). The owner paying
/// software personally is cash the company borrowed (financing +100) and
+1 -1
View File
@@ -151,7 +151,7 @@ mod tests {
.unwrap()
}
/// INVARIANT 2's cash flow items (BS-statement-3 rule 12, D-35): a
/// INVARIANT 2's cash flow items (BS-statement-3 statement 17, D-35): a
/// sale of equipment for an IOU is a Todo naming the entry, with the
/// statement's fix; equipment bought on an operating card is Info; a
/// sale for cash asks nothing.
+2 -2
View File
@@ -247,7 +247,7 @@ pub fn build(dir: &Path, today: NaiveDate) -> Result<(), StoreError> {
"Client work",
&ledger_core::ProjectFacts {
// Its invoices' lines and the contractors it pays are tagged
// to it (BS-statement-5 item 8), so its snapshot is its
// to it (BS-statement-5 statement 6), so its snapshot is its
// revenue less its direct costs.
description: Some(
"Design work for the studio's clients: every client invoice, and the contractors who work on it."
@@ -306,7 +306,7 @@ pub fn build(dir: &Path, today: NaiveDate) -> Result<(), StoreError> {
.map(|n| s.add_customer(n))
.collect::<Result<_, _>>()?;
// Work on spec for a customer, hoping they adopt it: its costs are
// expenses, and nothing is receivable (BS-statement-5 item 4).
// expenses, and nothing is receivable (BS-statement-5 statement 5).
let tidepool_started = start + Months::new(13);
let tidepool = s.add_project(
"Tidepool app",
+2 -2
View File
@@ -302,7 +302,7 @@ pub fn detail(ui: &mut Ui, b: &Books, e: &EntryInfo, shell: &mut Shell<'_>) {
ui.add_space(18.0);
// The invoice or bill it records: its lines as the document
// gives them, each project a link (BS-statement-5 item 8).
// gives them, each project a link (BS-statement-5 statement 6).
if let Some(doc) = document_of(b, e.id) {
section(ui, &doc.title);
document_lines(ui, &doc, &class_names, total_w, amt_w, shell);
@@ -756,7 +756,7 @@ mod tests {
/// A tagged line keeps its project tag inside its cell, in a narrow
/// pane too: the name is cut to leave the tag room, so the amounts
/// stay in their columns (an invoice's revenue line and its document
/// line, each tagged; BS-statement-5 item 8).
/// line, each tagged; BS-statement-5 statement 6).
#[test]
fn a_tagged_line_keeps_its_amounts_in_their_column() {
use ledger_core::arap::DocumentLine;
+2 -2
View File
@@ -561,7 +561,7 @@ pub fn show_list(ui: &mut Ui, b: &Books, shell: &mut Shell<'_>) {
}
/// The party's totals with property in kind (basis all, BS-partner-3
/// item 4), when it gave or took any in the period: "With property
/// statement 5), when it gave or took any in the period: "With property
/// contributed or distributed: paid $X, received $Y". None when nothing
/// moved in kind (the cash totals are then the whole story).
pub fn in_kind_text(flow: &crate::books::PartyFlow) -> Option<String> {
@@ -775,7 +775,7 @@ pub fn show_party(ui: &mut Ui, b: &Books, id: PartyId, shell: &mut Shell<'_>) {
r.context_menu(|ui| widgets::copy_item(ui, "Copy amount", &v.to_string()));
}
});
// Basis all (BS-partner-3 item 4): property in kind, when any.
// Basis all (BS-partner-3 statement 5): property in kind, when any.
if let Some(text) = in_kind_text(&flow) {
ui.add_space(6.0);
ui.add(
+2 -2
View File
@@ -1,7 +1,7 @@
//! Projects: every class, with its facts (what it is, where it stands, who
//! it is for), and one project completely: its snapshot (revenue, direct
//! costs, contribution before overhead and its margin, to date or this
//! fiscal year, BS-statement-5 item 7), revenue and costs by month with the
//! fiscal year, WB-statement-7), revenue and costs by month with the
//! running net, costs by category and by account, its entries, documents,
//! decisions and history (BS-statement-5). Every figure is ledger-core's (`project_figures`,
//! `project_to_date`, `project_entries`), the same the server's
@@ -419,7 +419,7 @@ impl Snap {
}
/// The note on contribution: what it counts and what it leaves out.
pub const CONTRIBUTION_NOTE: &str = "Revenue less this project's direct costs: every expense line tagged to it, fixed and variable alike (what management accounting calls a segment margin, not a variable-cost contribution margin). Company overhead that isn't tagged to a project (rent, software, insurance, the owner's time) isn't counted, so a project in the black can still leave the company in the red. A management-accounting view (BS-statement-5 items 2 and 4), not a GAAP figure.";
pub const CONTRIBUTION_NOTE: &str = "Revenue less this project's direct costs: every expense line tagged to it, fixed and variable alike (what management accounting calls a segment margin, not a variable-cost contribution margin). Company overhead that isn't tagged to a project (rent, software, insurance, the owner's time) isn't counted, so a project in the black can still leave the company in the red. A management-accounting view (WB-statement-7), not a GAAP figure.";
/// The snapshot: a header with where it stands to date and the to date /
/// fiscal year switch, then its tiles (`shown`: to date, or for `year`,
+1 -1
View File
@@ -2719,7 +2719,7 @@ mod tests {
// The figures, by hand: the loan (not a financing setting) is an
// operating receipt, 2,500.00; what the members paid personally
// (85.00 and 216.40, 301.40) is borrowed from them through 2100
// and spent (D-42, BS-statement-3 rule 11); the members'
// and spent (D-42, BS-statement-3 statement 16); the members'
// contributions are financing, each named (1,200.00 and 800.00);
// the reimbursement repays 2100 (301.40); the tablet is disclosed
// (630.00), the reversed laptop gone.
+3 -3
View File
@@ -282,7 +282,7 @@ fn fixture(tag: &str) -> Fixture {
let e = pay(&mut s, d(2026, 1, 20), "Old Co", cash, 12_300);
s.set_entry_party(e, Some(old)).unwrap();
s.update_party(old, PartyField::Archived(true)).unwrap();
// What the members advanced is money (BS-partner-3 item 5): Due to
// What the members advanced is money (BS-partner-3 statement 7): Due to
// Shareholders is a financing account; the cash account stays the
// books' (the settings file names both).
journal_settings(
@@ -356,7 +356,7 @@ fn each_partys_totals_are_the_books_numbers() {
// (BS-1099-1); the card's charge is no payment out of cash.
assert_eq!(line.paid, cents(150_000));
assert_eq!(line.undetermined, cents(30_000));
// Party totals count all of it as paid to Sam (BS-partner-3 item 9): the
// Party totals count all of it as paid to Sam (BS-partner-3 statement 11): the
// 1099's buckets, and the card's 200 (no business card is recorded,
// so the worksheet lists it nowhere).
assert_eq!(
@@ -1490,7 +1490,7 @@ fn the_party_page_shows_the_basis_and_in_kind() {
}
/// The viewer's what-for reads a reversal as parties::flow does, the
/// opposite of its original (BS-partner-3 item 3; design §1.4): a member
/// opposite of its original (BS-partner-3 statement 3; design §1.4): a member
/// paying the card from their own funds (Dr card / Cr 2100), tagged with
/// the issuer, then reversed, is nothing on the issuer's page, paid or
/// what for. Its lines alone read as a second payment.
+3 -3
View File
@@ -603,7 +603,7 @@ fn a_long_party_name_keeps_to_its_card() {
}
}
// ------------------------------------------------- the snapshot (BS-statement-5 item 7)
// ------------------------------------------------- the snapshot (WB-statement-7)
/// Books holding one project of `kind`, started `started_on`, with
/// `posts`: (date, debit code, credit code, cents), the line that isn't
@@ -1253,7 +1253,7 @@ proptest::proptest! {
}
}
/// BS-statement-5 item 8: an invoice's or bill's page (its entry's) lists
/// BS-statement-5 statement 6: an invoice's or bill's page (its entry's) lists
/// the document's lines, each project a link that opens it; an untagged
/// line has none. The entry's own lines show the tagged revenue or cost
/// line too.
@@ -1373,7 +1373,7 @@ fn an_invoice_and_a_bill_show_each_lines_project() {
}
/// The demo's "Client work" project carries every client invoice (
/// BS-statement-5 item 8): its revenue to date is the invoices' total, its direct
/// BS-statement-5 statement 6): its revenue to date is the invoices' total, its direct
/// costs the contractors tagged to it.
#[test]
fn the_demos_client_work_counts_every_client_invoice() {
+4 -4
View File
@@ -1813,7 +1813,7 @@ fn iif_refuses_an_undeclared_account() {
);
}
/// iif INVARIANT 8 (BS-format-2 item 7): an entry with a line on one
/// iif INVARIANT 8 (BS-format-2 statement 26): an entry with a line on one
/// accounts receivable account still writes one transaction, and the entry
/// is named to the human so they can add QuickBooks' customer or vendor.
#[test]
@@ -1855,7 +1855,7 @@ fn iif_writes_an_entry_on_one_receivable_or_payable_account() {
assert_eq!(iif.receivable_payable, [e]);
}
/// iif INVARIANT 8 (BS-format-2 item 7): an entry with lines on both the
/// iif INVARIANT 8 (BS-format-2 statement 7): an entry with lines on both the
/// receivables and payables control accounts is refused, naming its id:
/// QuickBooks Desktop records at most one A/R or A/P account a
/// transaction, and splitting the entry would change what it says.
@@ -1912,7 +1912,7 @@ fn iif_refuses_an_entry_on_two_receivable_or_payable_accounts() {
);
}
/// iif INVARIANT 8 (BS-format-2 item 7): two distinct receivable accounts
/// iif INVARIANT 8 (BS-format-2 statement 7): two distinct receivable accounts
/// in one entry are refused too (its `qb_type` decides, whatever the
/// callers call them), and every offending entry is named.
#[test]
@@ -5077,7 +5077,7 @@ fn iif_writes_each_lines_class_and_declares_the_classes_first() {
}
/// iif INVARIANT 9: a class's NAME is written as an account's own level
/// is (BS-format-2 rules 3, 4): plain ASCII, a colon a '-' (a colon starts a
/// is (BS-format-2 statements 10 and 18): plain ASCII, a colon a '-' (a colon starts a
/// subclass, the `!CLASS` header help), trimmed, at most NAME_MAX; names
/// alike ignoring case once written get " (id)", round after round, as
/// accounts get their codes; and each name written differently is a
+4 -4
View File
@@ -31,7 +31,7 @@
//! 6. A section says an invoice's or bill's lines take a project only
//! for books that declared the journal feature
//! `document_line_projects`; for the rest, that they wait for their
//! format upgrade (BS-format-1, BS-statement-5 item 8).
//! format upgrade (BS-format-1, BS-statement-5 statement 6).
//! ```
use crate::settings::Settings;
@@ -186,8 +186,8 @@ pub fn period_rule() -> String {
)
}
/// How an invoice's or bill's lines reach a project (BS-statement-5 item
/// 8), for books that declared the journal feature
/// How an invoice's or bill's lines reach a project (BS-statement-5 statement
/// 6), for books that declared the journal feature
/// `document_line_projects` or not yet (INVARIANT 6).
pub fn document_projects_rule(declared: bool) -> &'static str {
if declared {
@@ -591,7 +591,7 @@ mod tests {
with.contains("books.create_invoice and books.create_bill take class on each line")
);
assert!(!with.contains("takes no project"));
// The owner's decision (BS-statement-5 item 8, D-43): one project or none a
// The owner's decision (BS-statement-5 statement 4, D-43): one project or none a
// line, no percentage split, a shared cost by the allocation
// convention.
assert!(with.contains("Each line names one project or none"));
+1 -1
View File
@@ -78,7 +78,7 @@ fn document_lines(
/// A document's notes, each project once, in the order first named: its
/// late-tag note ([`projects::late_tag_note`]) for a finished or abandoned
/// project, and on an invoice ([`projects::on_spec_invoice_note`]) one for
/// an on-spec project (BS-statement-5 items 4, 5 and 8).
/// an on-spec project (BS-statement-5 statements 5, 6 and 7).
fn document_notes(
ledger: &ledger_core::Ledger,
lines: &[DocumentLine],
+1 -1
View File
@@ -141,7 +141,7 @@ pub(crate) fn settings_problems(ledger: &Ledger, cfg: &Settings) -> Vec<String>
let how = " with books.set_setting";
// The cash flow roles: codes the chart lacks here; the rest is the
// engine's own check, the one the statement refuses on (BS-statement-3
// rule 2), so the two never disagree.
// statement 3), so the two never disagree.
let lists = [
(
ledger_core::RoleList::Cash,
+1 -1
View File
@@ -144,7 +144,7 @@ fn party_document(
}
/// A party-totals `basis` from a tool: "cash" (the default) or "all"
/// (BS-partner-3 item 4); any other word is refused.
/// (BS-partner-3 statement 5); any other word is refused.
fn parse_basis(basis: Option<&str>) -> Result<ledger_core::parties::Basis, String> {
match basis {
None => Ok(ledger_core::parties::Basis::default()),
+2 -2
View File
@@ -144,7 +144,7 @@ fn by_name(ledger: &Ledger) -> Vec<ClassId> {
}
/// The note `books.add_line` and `books.record_payout` give for a line tagged to a finished or
/// abandoned project (BS-statement-5 item 5).
/// abandoned project (BS-statement-5 statement 7).
pub(super) fn late_tag_note(ledger: &Ledger, id: ClassId) -> Option<String> {
let f = ledger.project_facts(id)?;
if !f.status.is_over() {
@@ -162,7 +162,7 @@ pub(super) fn late_tag_note(ledger: &Ledger, id: ClassId) -> Option<String> {
}
/// The note `books.create_invoice` gives for a line naming an on-spec
/// project (BS-statement-5 items 4 and 8): on spec, a hoped-for payment is
/// project (BS-statement-5 statements 5 and 6): on spec, a hoped-for payment is
/// no receivable and no income until received, so an invoice for one
/// means there is now an agreement, or it shouldn't be an invoice.
pub(super) fn on_spec_invoice_note(ledger: &Ledger, id: ClassId) -> Option<String> {
+1 -1
View File
@@ -729,7 +729,7 @@ impl BooksServer {
checked.push(format!("{n} stored files match their SHA-256"));
}
// Receivables and payables equal their documents (BS-arap-2
// INVARIANT 1): an identity, so a difference is an engine error.
// invariant 1): an identity, so a difference is an engine error.
let checks = store
.ledger()
.control_check(chrono::NaiveDate::MAX)
+1 -1
View File
@@ -65,7 +65,7 @@ impl BooksServer {
Some(a) => parse_amount(a)?,
None => owed,
};
// The evidence is the point of a write-off (BS-arap-5 INVARIANT 1): one
// The evidence is the point of a write-off (BS-arap-5 statement 9): one
// of the two, and the preview says so too rather than posting
// without it later.
match (p.upload_id.is_some(), p.existing_attachment_id.is_some()) {
+1 -1
View File
@@ -3764,7 +3764,7 @@ pub struct AgingDocumentOut {
}
/// The aging's account against its documents (the control check, BS-ledger-8,
/// BS-arap-2 INVARIANT 1).
/// BS-arap-2 invariant 1).
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct AgingControlOut {
/// "1200 Accounts Receivable" or "2000 Accounts Payable".
+2 -2
View File
@@ -71,7 +71,7 @@
//! amortization: no counterparty by nature) (one item: Info under
//! suggest, Todo under require; its prompt names
//! books.set_entry_party); each warning of the fiscal year's
//! statement of cash flows (BS-statement-3 rule 12: equipment sold for
//! statement of cash flows (BS-statement-3 statement 17: equipment sold for
//! an IOU, Todo; bought on an operating payable, Info; one per
//! entry, its detail the warning's fix); a filed PDF whose text
//! extraction failed (Todo, one per file: a human must read its
@@ -1342,7 +1342,7 @@ pub fn find_with(
}
// The statement of cash flows' warnings this fiscal year (
// BS-statement-3 rule 12, D-35): equipment sold for an IOU, flagged with its fix
// BS-statement-3 statement 17, D-35): equipment sold for an IOU, flagged with its fix
// (Todo); equipment bought on an operating payable, following how the
// payable is classified (Info). A statement the settings can't give
// (no cash accounts yet) has none.
+1 -1
View File
@@ -19,7 +19,7 @@
//! imported close would zero its period's profit. The file's
//! balances are the trial balance as of as_of without the closes.
//! 3. Every class (project) in the books is declared, and each line
//! carries its class (BS-format-2 rule 8).
//! carries its class (BS-format-2 statements 27 and 28).
//! ```
use chrono::NaiveDate;
+1 -1
View File
@@ -16,7 +16,7 @@
//! 2. The cash flow statement needs at least one cash account, and
//! every code it is given must be in the chart; account lists a call
//! leaves empty default to the settings' roles. It foots, or it is
//! refused (an engine error, never a figure: BS-statement-3 rule 9);
//! refused (an engine error, never a figure: BS-statement-3 statement 14);
//! roles that contradict each other or the chart are refused by the
//! engine, naming the setting, so the viewer and the server refuse
//! alike. Members are named on their contributions and
+9 -9
View File
@@ -127,8 +127,8 @@ fn pnl_depreciation(l: &Ledger, end: NaiveDate) -> Decimal {
pnl_expense(l, "6500", end)
}
/// The members' figures agree on every date as BS-partner-1, BS-partner-3 items 4 and 8
/// and BS-statement-3 rule 11 say: the statement of members' equity and the K-1
/// The members' figures agree on every date as BS-partner-1, BS-partner-3 statements 6 and 10
/// and BS-statement-3 statement 16 say: the statement of members' equity and the K-1
/// worksheet are one roll-forward; party totals on basis all are the
/// statement's contributions, on basis cash the K-1's cash
/// contributions; the cash flow statement's contributions are the K-1's
@@ -178,7 +178,7 @@ fn the_members_figures_agree_on_every_date() {
m.contributions,
k.contributions_cash + k.contributions_property
);
// Party totals (BS-partner-3 item 4).
// Party totals (BS-partner-3 statement 6).
let a = activity(&b, party, end);
assert!(a.unresolved.is_empty(), "{name} {end}: {:?}", a.unresolved);
assert_eq!(a.totals(Basis::All).1, m.contributions, "{name} {end}");
@@ -188,7 +188,7 @@ fn the_members_figures_agree_on_every_date() {
"{name} {end}"
);
assert_eq!(a.received_in_kind, k.contributions_property, "{name} {end}");
// The cash flow (BS-statement-3 rule 11, BS-partner-3 item 8).
// The cash flow (BS-statement-3 statement 16, BS-partner-3 statement 10).
assert_eq!(
kind(
&cf,
@@ -208,7 +208,7 @@ fn the_members_figures_agree_on_every_date() {
// A distribution declared to Distributions Payable is a
// distribution on the statement of members' equity when declared
// and on the cash flow statement and in party totals when paid
// (BS-statement-3 rule 2, BS-partner-3 item 4).
// (BS-statement-3 statement 3, BS-partner-3 statement 6).
distributions_paid -= kind(
&cf,
CashFlowSection::Financing,
@@ -281,7 +281,7 @@ fn the_members_figures_agree_on_every_date() {
dec("2400.00")
);
// Mid-year, the declaration is unpaid: the statement counts it, party
// totals and the cash flow don't yet (BS-partner-3 item 4's second condition).
// totals and the cash flow don't yet (BS-partner-3 statement 6's second condition).
let mid = d("2026-06-30");
assert_eq!(
activity(&b, b.ana, mid).totals(Basis::Cash).0,
@@ -296,7 +296,7 @@ fn the_members_figures_agree_on_every_date() {
);
}
/// BS-statement-3 rule 2, from the seam review: a distribution declared to a
/// BS-statement-3 statement 3, from the seam review: a distribution declared to a
/// liability and paid later is a financing outflow when paid (ASC
/// 230-10-45-15(a)), its declaration a noncash financing activity; before
/// the fix it was "Cash paid to suppliers and employees".
@@ -349,7 +349,7 @@ fn a_distribution_declared_then_paid_is_financing_when_paid() {
);
}
/// BS-partner-3 item 9 and BS-1099-1: for a payee every entry of which names it alone,
/// BS-partner-3 statement 11 and BS-1099-1: for a payee every entry of which names it alone,
/// party totals' paid less received (basis cash) is the 1099 worksheet's
/// paid + excluded card + undetermined + not reportable, less what the
/// worksheet lists as received for something else; and the worksheet
@@ -445,7 +445,7 @@ fn iif_dates(iif: &str) -> Vec<NaiveDate> {
.collect()
}
/// Depreciation is one figure everywhere (BS-asset-1 rule 8, BS-statement-3 rule 8,
/// Depreciation is one figure everywhere (BS-asset-1 statement 28, BS-statement-3 statement 13,
/// BS-partner-4): the P&L's expense, the cash flow reconciliation's add-back, the
/// tax-basis K-1's open item, the IIF's, and the runs plus what the
/// disposal posted; the balance sheet's accumulated depreciation is the
+5 -5
View File
@@ -1717,7 +1717,7 @@ fn one_list_of_cash_accounts_per_package() {
assert_eq!(text(&plain, "1099-worksheet-2026.csv"), tool(&cash));
}
/// BS-format-2 rule 8 (P3 cutover review, open point 1): the
/// BS-format-2 statements 27-30 (P3 cutover review, open point 1): the
/// package's QuickBooks file declares every project as a class and
/// carries each line's project in CLASS; a project name written
/// differently is listed in the warnings and the README, whose IIF line
@@ -1776,7 +1776,7 @@ fn the_package_iif_carries_each_lines_project() {
);
}
/// BS-format-2 rule 8 with BS-statement-5 item 8: an invoice's or a bill's
/// BS-format-2 statement 27 with BS-statement-5 statement 6: an invoice's or a bill's
/// lines carry their projects into CLASS through the entry they post,
/// the revenue or expense line of each project tagged, an untagged
/// part and the receivable or payable line left without a class.
@@ -1921,7 +1921,7 @@ fn the_readme_lists_what_the_iif_writes_differently() {
assert!(!text(&p, "README.txt").contains("Written differently"));
}
/// BS-format-2 rule 7 (P3 review round 2): the file names no customer or vendor
/// BS-format-2 statement 26 (P3 review round 2): the file names no customer or vendor
/// (Intuit states no such need for an IIF journal; QuickBooks Desktop asks
/// for one on a journal entry to accounts receivable or payable, and takes
/// one such account a transaction: sources/intuit-iif.md), so the README
@@ -2022,7 +2022,7 @@ fn the_readme_names_the_entries_on_receivables_and_payables() {
assert!(!text(&p, "README.txt").contains("customer or vendor"));
}
/// BS-format-2 item 7: an entry with lines on both the receivables and
/// BS-format-2 statement 7: an entry with lines on both the receivables and
/// payables control accounts is refused, naming its id, and the package is
/// not built: QuickBooks Desktop records at most one A/R or A/P account a
/// transaction, and splitting the entry would change what it says.
@@ -2481,7 +2481,7 @@ fn the_k1_worksheet_reports_tax_basis_capital() {
/// The CPA package's aging CSVs are the agings, one row per open document
/// and a tie-out line that equals the control account (plan P4b S6,
/// 8.3.10; BS-ledger-8, BS-arap-2 INVARIANT 1).
/// 8.3.10; BS-ledger-8, BS-arap-2 invariant 1).
#[test]
fn the_aging_csvs_tie_to_the_control_check() {
let dir = tempfile::Builder::new()
+1 -1
View File
@@ -152,7 +152,7 @@ pub enum StoreError {
#[error("store not found at {0}")]
NotFound(String),
/// A write-off with no evidence (BS-arap-5 INVARIANT 1): a bad
/// A write-off with no evidence (BS-arap-5 statement 10): a bad
/// debt is deducted on evidence that it is worthless (Treas. Reg.
/// §1.166-2), so the books take the write-off only with its file.
#[error(
+1 -1
View File
@@ -179,7 +179,7 @@ pub const ASSET_BASIS: &str = "asset_basis";
pub const PROJECTS: &str = "projects";
/// Feature: an `invoice.created` or `bill.created` line naming its project
/// (`class_id`, BS-statement-5 item 8). An older version would restore the
/// (`class_id`, BS-statement-5 statement 6). An older version would restore the
/// document without its lines' projects, silently. Its own feature, not
/// `projects`': books that consented to projects before it existed must
/// consent again before a document names one.
+6 -6
View File
@@ -507,7 +507,7 @@ struct AttachRequest<'a> {
}
/// The evidence a bad-debt write-off files (plan P4b S7; BS-arap-5
/// INVARIANT 1): the file that shows the debt is worthless — collection
/// statement 9): the file that shows the debt is worthless — collection
/// correspondence, a bankruptcy notice (Treas. Reg. §1.166-2). Given as
/// bytes to file in the same call, or as an attachment already in the
/// books that is linked to the write-off's entry and its invoice.
@@ -3446,7 +3446,7 @@ impl Store {
}
/// The issued copy of an invoice, filed in the call that issues it
/// (plan P4b S4.3 item 11, A-7; BS-arap-4 item 3): the entry, then
/// (plan P4b S4.3 item 11, A-7; BS-arap-4 invariant 3 and WB-arap-8): the entry, then
/// `invoice.created`, then `receipt.attached` on the entry
/// (`INV-0007.pdf`, `application/pdf`, "Issued invoice"), then
/// `attachment.linked` to the invoice. The server renders the PDF
@@ -3462,7 +3462,7 @@ impl Store {
/// GOAL: the copy sent is kept with the invoice, or nothing is.
/// SOURCE: IRS Pub. 583 (keep invoices); Rev. Proc. 98-25 (the audit
/// trail keeps the record as issued); plan P4b S4.3, 8.3.11;
/// BS-arap-4 item 3.
/// BS-arap-4 invariant 3 and WB-arap-8.
/// INVARIANTS:
/// 1. Every refusal (an unknown customer, an invalid line or due
/// date, a duplicate number, a closed period, a feature the books
@@ -4534,7 +4534,7 @@ impl Store {
/// ```text
/// GOAL: a project in one command, journaled as two events only when
/// it has facts, so a name-only project is a plain class.
/// SOURCE: BS-statement-5 item 1; BS-format-1 (journal feature
/// SOURCE: WB-statement-5; BS-format-1 (journal feature
/// `projects`).
/// INVARIANTS:
/// 1. A refusal journals nothing: the whole record is rehearsed, and
@@ -6848,7 +6848,7 @@ fn document_line_json(l: &DocumentLine) -> Value {
"amount": l.amount.to_string(),
});
// Its project, behind the feature document_line_projects (
// BS-format-1, BS-statement-5 item 8); a line naming none is written as before it.
// BS-format-1, BS-statement-5 statement 6); a line naming none is written as before it.
if let Some(c) = l.class_id {
v["class_id"] = json!(c);
}
@@ -6927,7 +6927,7 @@ fn invoice_fields_json(payload: &mut Value, fields: &arap::InvoiceFields) {
}
/// Add a bill's new fields to its `bill.created` payload, each key only when
/// set. A duplicate's reason is journaled for the record (BS-arap-4 item
/// set. A duplicate's reason is journaled for the record (BS-arap-4 invariant
/// 4); the bill itself keeps none.
fn bill_fields_json(payload: &mut Value, fields: &arap::BillFields) {
if let Some(r) = &fields.vendor_ref {
+3 -4
View File
@@ -1,5 +1,4 @@
//! Documents through the store, at random (BS-arap-2 INVARIANTS 1, 2,
//! 4 and 6; plan P4b.15): histories of invoices, bills, payments (with a
//! Documents through the store, at random (BS-arap-2 invariants 1, 6, 7 and 9; plan P4b.15): histories of invoices, bills, payments (with a
//! payment method and a reference, or none), voids, reversals of any
//! entry, closed months and refused hand lines, run through `Store`, then
//! replayed (the books reopened) and read by a `Snapshot`.
@@ -9,7 +8,7 @@
//! the live books, their replay and a viewer's snapshot agree on
//! every figure, at every date, and the control accounts equal
//! their documents.
//! SOURCE: BS-entry-4 (replay), BS-arap-2 INVARIANTS 1, 2, 4, 6.
//! SOURCE: BS-entry-4 (replay), BS-arap-2 invariants 1, 6, 7 and 9.
//! ```
use chrono::NaiveDate;
@@ -417,7 +416,7 @@ fn agree(live: &Ledger, dir: &Path, docs: &[DocRef]) -> Result<(), TestCaseError
proptest! {
#![proptest_config(ProptestConfig::with_cases(32))]
/// BS-arap-2 INVARIANT 4 (and 1, 2, 6 through the store): a document's
/// BS-arap-2 invariant 7 (and 1, 6, 9 through the store): a document's
/// state is a function of the journal and the day. Half the history,
/// then the books reopened and compared; the rest on the reopened
/// books, compared again.
+7 -8
View File
@@ -377,7 +377,7 @@ fn legacy_reversal_now_counts() {
assert_eq!(trial_balance_json(&again), g["trial_balance"]);
}
/// BS-arap-2 scenario 5 and item 7 in books an earlier version keeps: the
/// BS-arap-2 scenario 5 and WB-arap-4 in books an earlier version keeps: the
/// right payment after the wrong one was reversed waits for the journal
/// feature document_standing (an older version would count both),
/// refused and journaling nothing until the owner's upgrade; a payment
@@ -831,7 +831,7 @@ fn no_new_fields_journals_byte_for_byte() {
}
/// The issued copy is filed with the invoice or nothing is (plan P4b S4.3
/// item 11, A-7; BS-arap-4 item 3): a refusal leaves the journal, the
/// item 11, A-7; BS-arap-4 invariant 3 and WB-arap-8): a refusal leaves the journal, the
/// ledger and the allocators exactly as they were; an issue journals the
/// entry, `invoice.created`, `receipt.attached` on that entry
/// (`INV-0007.pdf`, `application/pdf`, "Issued invoice") and
@@ -1247,8 +1247,7 @@ fn mark_sent_on_void_refused() {
/// A settlement of two invoices, a discount and a processor's fee: one
/// entry whose events name the lines they tag, every figure derived, and
/// the books replaying to the same lines (plan P4b S6; BS-arap-6
/// INVARIANTS 1 and 3).
/// the books replaying to the same lines (plan P4b S6; BS-arap-6 invariant 3 and WB-arap-15).
#[test]
fn a_settlement_names_its_lines_and_replays() {
use ledger_core::{Application, DocRef, Fee, SettleParams};
@@ -1422,7 +1421,7 @@ fn settlement_waits_for_documents_v2() {
/// Legacy payment events carry no `line`, so replay keeps the positional
/// rule: the first untagged control line for the payment's amount, in the
/// order the events come (plan P4b S6; BS-arap-6 INVARIANT 3).
/// order the events come (plan P4b S6; WB-arap-15).
#[test]
fn legacy_payment_events_keep_the_positional_rule() {
use ledger_core::{DocRef, Movement};
@@ -1582,7 +1581,7 @@ fn write_off_waits_for_documents_v2() {
/// A write-off is journaled as its entry and one `invoice.written_off`,
/// and replay derives the same figures and the projection agrees: the
/// invoice reads Written off, the bad-debt expense is on 6990, and the
/// control account still equals its documents (BS-arap-5, BS-arap-2 INVARIANT 1).
/// control account still equals its documents (BS-arap-5, BS-arap-2 invariant 1).
#[test]
fn write_off_replays_and_projects() {
let dir = test_dir("write-off-replay");
@@ -1600,7 +1599,7 @@ fn write_off_replays_and_projects() {
)
.unwrap();
// Half paid, the rest written off: the invoice reads Written off with
// 50 paid and 50 written off (BS-arap-2 SCENARIO 7).
// 50 paid and 50 written off (BS-arap-2 scenario 7).
s.receive_payment(inv, d(2026, 4, 20), cents(5_000), bank)
.unwrap();
let from = journal_len(&dir.0);
@@ -1683,7 +1682,7 @@ fn write_off_replays_and_projects() {
s.verify().unwrap();
}
/// No evidence, no write-off (BS-arap-5 INVARIANT 1; Treas. Reg.
/// No evidence, no write-off (BS-arap-5 statement 10; Treas. Reg.
/// §1.166-2(a)): refused, journaling nothing; an attachment already filed
/// is linked instead, to the entry and the invoice.
#[test]
+1 -1
View File
@@ -1175,7 +1175,7 @@ fn reversing_a_linked_acquisition_still_opens_and_verifies() {
Store::open(&dir).unwrap().verify().unwrap();
}
// ------------------------------------------------- depreciation runs (BS-asset-1 rules 6 and 8)
// ------------------------------------------------- depreciation runs (BS-asset-1 statements 14 and 28)
/// A run is the books' record of what they carry for an asset
/// (Ledger::accumulated_posted): recorded live, replayed from the journal,
@@ -1,4 +1,4 @@
//! An invoice's or bill's lines in the journal (BS-statement-5 item 8,
//! An invoice's or bill's lines in the journal (BS-statement-5 statement 6,
//! BS-format-1): a line naming its project carries `class_id` (journal feature
//! `document_line_projects`), and the entry's revenue or expense line for
//! that project is tagged by `entry.line_class_set` right after its
@@ -9,7 +9,7 @@
//! ```text
//! GOAL: a document's projects are journaled once, replay exactly, and
//! never reach books whose owner hasn't consented to the format.
//! SOURCE: BS-statement-5 item 8, BS-format-1, BS-entry-4; plan/served.md
//! SOURCE: BS-statement-5 statement 6, BS-format-1, BS-entry-4; plan/served.md
//! D-39 (the owner's upgrade).
//! ```
+1 -1
View File
@@ -2636,7 +2636,7 @@ fn every_figure_of(l: &ledger_core::Ledger) -> (usize, usize) {
tally(reports::general_ledger(l, start, end).map(|_| ()));
tally(reports::members_equity(l, start, end, &members).map(|_| ()));
// The statement of cash flows foots on every book, or is refused
// for a reason: never an engine error (BS-statement-3 rule 9).
// for a reason: never an engine error (BS-statement-3 statement 14).
let cf = reports::cash_flow(
l,
&reports::CashFlowParams {