fix(core): every reversal is dated on or after its original (D-73)
A correction comes after what it corrects (Pacioli ch. 31; B-9). Until now only document reversals and depreciation/schedule runs were held to it; a plain posted entry could be reversed with an earlier date, leaving the books carrying the opposite of an entry that doesn't exist yet at the reversal's date. The owner's decision D-73 (2026-11-08) makes it one rule for every kind of entry; bookspec BS-ledger-5 states it. - Ledger::check_reversal refuses date < original.date() with one error, ReversalBeforeOriginal (it replaces DocumentReversalBeforeOriginal, which was the document-only wording). Same-day reversals are allowed. - Not on replay (B-28): the check sits behind is_replaying(), so a journal an earlier version wrote, holding a reversal dated before its original, reopens with the same figures. - The store's own date check for depreciation runs and schedule months (InvalidSchedule / AssetEntryIrreversible wording) was the same rule for a narrower case; it is removed so there is one variant for all. Store::check_reverse_entry, books.reverse_entry (preview and post), and the document voids all reach the refusal through check_reversal; the only construction path for a reversal is reverse_entry_steps, which calls it first. Tests: store reversal_dates.rs (plain entry refused before it, nothing journaled, same day and later taken; a journal with an earlier-dated reversal written the old way opens with the same figures); ledger-cli spec_mcp (preview, unconfirmed and confirmed post all refuse alike). Existing tests changed: store assets.rs (three expectations move to the new variant); core spec_asset_basis.rs (it backdated a reversal on purpose to check the trial balance carries -100.00 between the dates; it now replays one, as an old journal would); model.rs (the model oracle's `reverse` requires the date, as the Lean/bookspec rule does); bookspec common.rs (the pinned depreciation example words this refusal "entry_irreversible"); spec_documents.rs (variant rename). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5fc16cad6
commit
bb5008edb5
14 files changed
+278
-69
No files matched your search
@@ -584,9 +584,9 @@ every tool over every book in ledger-store's `tests/fixtures/old-books`.
|
||||
and a reversal whose reversal would post a depreciation period or a
|
||||
schedule month a second time (naming the entry that posts it now), or
|
||||
re-instate a run a later run caught up (carrying the books past the
|
||||
schedule); and a reversal of a depreciation run or a schedule month's
|
||||
posting (or of a reversal in its chain) dated before that entry's own
|
||||
date (a correction comes after what it corrects, B-9).
|
||||
schedule); and a reversal of any entry dated before that entry's own
|
||||
date (a correction comes after what it corrects, B-9, D-73; the preview
|
||||
refuses the same way, and books written before D-73 open as they were).
|
||||
- `books.get_entry { entry_id }` → full entry with lines (each `{
|
||||
account_id, code, name, side, amount, class_id?, project? }`: a tagged
|
||||
line's project, its id and name), receipts, and
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ in CI that the floor never falls between commits.
|
||||
| Trial balance as of a date | Reports → Trial Balance (as of) | done | hand-verified fixture; golden-covered (`tests/golden_reports.rs`, the fixture company extended with a three-leg entry, a January close and a February entry; `golden/trial_balance_as_of.json`, `golden_trial_balance_as_of`; worksheet `plan/golden-worksheets/trial-balance-as-of.md`) |
|
||||
| Statement of changes in members' equity | Reports → Statement of Changes in Equity | done | hand-verified two-member fixture incl. rounding and a close; golden-covered (`golden/members_equity_two_member.json`, `statements.rs::golden_members_equity_two_member`; worksheet `plan/golden-worksheets/members_equity_two_member.md`) |
|
||||
| Tax line mapping + tax summary | Accounts → Tax line mapping; Tax reports | done | hand-verified fixture (50% meals, nondeductible, contra income); golden-covered (`golden/tax_summary_form_1065.json`, `tax.rs::golden_tax_summary_form_1065`; worksheet `plan/golden-worksheets/tax_summary_form_1065.md`) |
|
||||
| Reversing entries | Reverse transaction | done | linked via `reversal_of` |
|
||||
| Reversing entries | Reverse transaction | done | linked via `reversal_of`; dated on or after its original, every kind of entry (D-73) |
|
||||
| Canonical report snapshots (JSON) | — (our oracle format) | done | `reports::snapshot` |
|
||||
| Fixed-asset register + straight-line depreciation | Fixed Asset register | done | `assets.rs`; golden-covered schedule; idempotent runs; disposal with gain/loss; posted (the books') vs scheduled, in-service vs acquired dates, the §723, depreciable and §704(c) figures (P3) |
|
||||
| Cash flow statement (direct, with the reconciliation schedule and noncash disclosures) | Reports → Cash Flow | done | R-FUTURE-3; rules.md B-14 (P3 defect 1) |
|
||||
|
||||
@@ -114,6 +114,24 @@ an entry on the opposite side under the same account."
|
||||
`reversal_of`). **Checked:** Kani `reversal_mirrors`, `reversal_cancels`;
|
||||
Lean `accepted_reversal_iff`, `movement_with_reversal`.
|
||||
|
||||
**Pick (D-73, the owner, 2026-11-08):** every reversal is dated on or after
|
||||
the entry it reverses, for every kind of entry (it was enforced only for
|
||||
document reversals and for schedule and depreciation runs): a correction
|
||||
comes after what it corrects. The same day is allowed. New commands only:
|
||||
a journal an earlier version wrote may hold a reversal dated before its
|
||||
original, and it replays as it was (B-28).
|
||||
**Enforced:** `Ledger::check_reversal` (SCENARIO 6) refuses with
|
||||
`ReversalBeforeOriginal`, ahead of the document and schedule checks; the
|
||||
store's `check_reverse_entry` and so `books.reverse_entry` (preview and
|
||||
post alike) and every document void go through it, and replay is exempt
|
||||
(`crate::parties::is_replaying`). **Checked:** store
|
||||
`a_plain_entrys_reversal_is_not_dated_before_it`,
|
||||
`a_journal_with_an_earlier_dated_reversal_opens_as_it_was`; core
|
||||
`reversal_before_original_refused_for_documents`,
|
||||
`a_reversal_dated_before_its_run_matches_the_trial_balance` (replayed);
|
||||
the model oracle `the_ledger_matches_its_model` (its `reverse` requires
|
||||
the date, as BS-ledger-5 does).
|
||||
|
||||
## B-10 An entry is reversed at most once; a closing entry never
|
||||
|
||||
**bookspec:** `BS-ledger-6`
|
||||
|
||||
@@ -1446,6 +1446,7 @@ a bookspec example (`bookspec/examples/`, P13, D-34).
|
||||
| Every order of runs, reversals (any day, before an entry's own included), re-runs, re-instatements, disposals and closes on one asset keeps the books right: refusals journal nothing; at every month end before the disposal the expense is the accumulated depreciation and within the schedule; one run in effect per month; a disposal's month and the end at the schedule through its day, accumulated 0.00, the gain proceeds less book value; an active asset run month by month past its life takes exactly cost less salvage (P3 review round 2) | store `asset_orders.rs` `every_order_of_runs_reversals_disposals_and_closes_keeps_the_books_right` (exhaustive, three commands deep; four and five with `WB_ORDERS_DEPTH`, run clean 2026-10-21), `prop_any_sequence_keeps_the_books_right` (64 cases, up to 9 commands, any day) |
|
||||
| The viewer reads an asset as the store does, whatever the runs, reversals and disposals: what the books carry, each finished month's status against a run of it, what is unposted (P3 review round 2) | GUI `prop_the_viewer_reads_an_asset_as_the_store_does` (48 cases), `the_viewer_counts_a_run_reinstated_after_its_rerun_was_reversed` |
|
||||
| A run re-instated after its month was run again and that run reversed still counts: in the store, the disposal and the viewer (P3 review round 2; before, the projection's row named the reversed re-run) | store `a_run_reinstated_after_its_rerun_was_reversed_still_counts`; GUI `the_viewer_counts_a_run_reinstated_after_its_rerun_was_reversed` |
|
||||
| Every reversal is dated on or after its original, any kind of entry (D-73); a journal holding an earlier-dated one still opens with the same figures (B-28): store `reversal_dates.rs` `a_plain_entrys_reversal_is_not_dated_before_it`, `a_journal_with_an_earlier_dated_reversal_opens_as_it_was` |
|
||||
| A depreciation run's or schedule month's reversal can't be dated before the entry it reverses (P3 review round 2: a run of March reversed on Jan 31, then a disposal on Feb 15, ended February with a 1,000.00 debit in accumulated depreciation) | store `a_reversal_dated_before_the_entry_it_reverses_is_refused` |
|
||||
| A disposal waits only until what the runs carry at its month's end is what they carry now, so a late change undone after its month closed lets it through (P3 review round 2; round 1 refused it for ever) | store `a_disposal_is_taken_once_a_late_change_is_undone_after_its_month_closed` |
|
||||
| Depreciation still due when the disposal's month has a run is charged in the disposal entry, never as a second run of the month (P3 review round 2; no store test held it) | store `a_disposal_whose_month_has_run_charges_what_is_still_due_in_its_entry` |
|
||||
|
||||
Reference in new issue
Block a user