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

+6 -1
View File
@@ -133,7 +133,12 @@ pub(crate) fn refusal(e: &LedgerError) -> String {
LedgerError::DuplicateAccountCode(_) => "code_taken",
LedgerError::TaxCategoryRequired { .. } => "tax_category_required",
LedgerError::DepreciationPastDisposal(_) => "depreciation_past_disposal",
LedgerError::AssetEntryIrreversible(..) => "entry_irreversible",
// A reversal dated before its original (D-73) is the examples'
// "entry_irreversible" too: bookspec's depreciation example words
// the refusal that way, whichever engine check makes it.
LedgerError::AssetEntryIrreversible(..) | LedgerError::ReversalBeforeOriginal { .. } => {
"entry_irreversible"
}
LedgerError::AssetAlreadyDisposed(_) => "already_disposed",
LedgerError::InvalidDepreciationPeriod(_) => "invalid_depreciation_period",
LedgerError::InvalidSchedule(_) => "invalid_schedule",
+3 -1
View File
@@ -218,7 +218,9 @@ impl Model {
return false;
};
let reversed_already = self.posted.iter().any(|e| e.reversal_of == Some(entry));
if reversed_already || orig.closes || self.closed_on(date) {
// D-73 (bookspec BS-ledger-5): a correction is dated on or after
// what it corrects.
if reversed_already || orig.closes || self.closed_on(date) || date < orig.date {
return false;
}
let lines = orig
+10 -2
View File
@@ -960,11 +960,19 @@ fn a_reinstated_run_counts_and_is_live() {
}
/// A reversal dated before its run: between the two dates the books carry
/// −100.00, as the trial balance does (review R2).
/// −100.00, as the trial balance does (review R2). No command can write one
/// any more (D-73: a reversal is dated on or after its original, so
/// `reverse_entry` refuses it), but a journal an earlier version wrote holds
/// them and replays as it was (B-28): this test replays one.
#[test]
fn a_reversal_dated_before_its_run_matches_the_trial_balance() {
let (mut l, a, id, e) = one_run();
l.reverse_entry(e, date(2026, 1, 15), "early").unwrap();
assert!(matches!(
l.reverse_entry(e, date(2026, 1, 15), "early"),
Err(LedgerError::ReversalBeforeOriginal { .. })
));
l.replay_reverse_entry(e, date(2026, 1, 15), "early")
.unwrap();
let on = date(2026, 1, 20);
assert_eq!(l.accumulated_posted(id, on).unwrap(), d("-100.00"));
let tb = ledger_core::trial_balance_as_of(&l, on);
+2 -2
View File
@@ -510,11 +510,11 @@ fn reversal_before_original_refused_for_documents() {
.unwrap();
assert!(matches!(
b.l.reverse_entry(pay, d(2026, 1, 19), "early"),
Err(LedgerError::DocumentReversalBeforeOriginal { .. })
Err(LedgerError::ReversalBeforeOriginal { .. })
));
assert!(matches!(
b.l.void_document(DocRef::Invoice(inv), d(2026, 1, 9), "early"),
Err(LedgerError::DocumentReversalBeforeOriginal { .. })
Err(LedgerError::ReversalBeforeOriginal { .. })
));
// The same day is fine.
b.l.reverse_entry(pay, d(2026, 1, 20), "same day").unwrap();