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:
1 parent
609e4e6b26
commit
e41cc3a161
78 files changed
+298
-302
No files matched your search
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user