merge: every reversal is dated on or after its original (D-73; branch t3/reversal-dating-d73, bb5008ed; reviewed)

claims/ledger.md conflicted with the reduced B-9 section: the D-73 pick,
Enforced and Checked lines sit above its product rules; the check's
place corrected (after the schedule double-post check, not ahead of it)
and the citation completed (BS-ledger-16, the Lean model since L-G1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-11-08 17:14:13 -07:00
commit e080f761a0
14 files changed
+279 -69

No files matched your search

+20 -17
View File
@@ -2236,12 +2236,15 @@ impl Ledger {
/// - NEVER recognize one month of a schedule twice
/// BECAUSE a reversed month is due again and may have been run
/// again (P3 depreciation review R3).
/// 6. IF the entry carries a document's lines (an invoice's or a
/// bill's own entry, a payment, or a reversal of one) and `date`
/// is before the entry's own date:
/// - SHOULD refuse (DocumentReversalBeforeOriginal)
/// BECAUSE a correction comes after what it corrects (B-9; plan
/// P4b.3, "Dating rules").
/// 6. IF `date` is before the entry's own date (any kind of entry:
/// plain, document, payment, schedule run):
/// - SHOULD refuse (ReversalBeforeOriginal)
/// - NEVER refuse the same day
/// - NEVER refuse on replay
/// BECAUSE a correction comes after what it corrects (B-9; owner
/// decision D-73, 2026-11-08; plan P4b.3, "Dating rules"). Books
/// written before D-73 may hold an earlier-dated reversal and
/// reopen as they were (B-28).
/// 7. IF reversing it would leave a document it carries owing less
/// than nothing or more than its total at some date (a void
/// under a payment that stands; re-instating a payment beside
@@ -2285,13 +2288,21 @@ impl Ledger {
)));
}
if !crate::parties::is_replaying() {
if date < original.date() {
return Err(LedgerError::ReversalBeforeOriginal {
entry,
original: original.date(),
date,
});
}
self.check_document_reversal(original, date)?;
}
Ok(())
}
/// [`Self::check_reversal`] SCENARIOS 6 and 7: a reversal of an entry
/// carrying documents' lines.
/// [`Self::check_reversal`] SCENARIO 7: a reversal of an entry
/// carrying documents' lines (the date floor, SCENARIO 6, is checked
/// before this runs).
fn check_document_reversal(
&self,
original: &JournalEntry,
@@ -2308,16 +2319,8 @@ impl Ledger {
}
}
}
let Some(&(first, _)) = moves.first() else {
if moves.is_empty() {
return Ok(());
};
if date < original.date() {
return Err(LedgerError::DocumentReversalBeforeOriginal {
entry: original.id(),
document: first.to_string(),
original: original.date(),
date,
});
}
for (doc, by) in moves {
self.check_item_bounds(doc, &[(date, by)])?;