Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 4, 18:00 UTC
dependabot/npm_and_yarn/frontend/vite-8.4.0
ADR-032 — R3: compare the engine's own output, and what the 1404 data actually says
- Status: accepted
- Date: 2026-12-04
- Scope: booklet 2.1 task R3
- Supersedes: the "statement_balance is pre-signed" assumption in ADR-013/018 and ADR-031 §5. Everything else in those ADRs stands.
Context
The golden comparison aggregated the source workbook separately, so it could
agree with the official figures while build_statements produced something else.
R3 requires comparing the engine's own persisted output. Doing that exposed three
real defects and one source-data limitation.
Decision 1 — statement_balance is debit-positive, not pre-signed
Measured: applying the section display sign to statement_balance reproduces the
official 1404 balance sheet 16/16; treating it as pre-signed flipped 7 notes.
The sign is now applied exactly once, to whichever figure the row provides.
BalanceRow.display(sign, basis) and build_statements share the rule.
Decision 2 — the statement basis belongs to the import, not the row
If a source supplies statement balances at all, that column is the statement figure and a row without one contributes nothing. The old per-row fallback to CLOSING leaked non-statement rows into the totals (BS fell to 6/16). Sources without the column keep using CLOSING, so nothing else changes.
Decision 3 — the source assigns notes per row
Account 718291 posts to both note 6 and note 9. An account-level mapping cannot
express that, so LedgerBalance.source_note preserves the row's own assignment
(migration 20261204_09). Precedence: an explicit mapping wins; the source note
only disambiguates an account mapped to several notes. That keeps the mapping
workflow authoritative while preventing double-counting.
Decision 4 — the income statement presents expenses negative
Official 1404 notes 6/7/20-3 are negative while the ledger is debit-positive, so IS Revenue and Expenses both take −1. The net result is therefore the sum of the signed IS lines, not revenue minus expenses; C-08's input was corrected.
Decision 5 — each official statement gets the parser its layout needs
official_parse.py reads BS/IS/CF as note lists and EQ as a components ×
movements matrix (opening / changes / closing / prior closing). The year column is
located from the header row, because the title «به تاریخ 29 اسفند 1404» also
contains the year and previously won the search, pointing at column 0. CF's
46268 is flagged account_code, not a note. EQ went from 0 parsed figures to 24.
Measured outcome (real 1404, 131,280 rows)
| Statement | Result |
|---|---|
| BS | 16/16 matched — acceptance met |
| IS | 1/6 exact (note 5); 6 and 7 within 1–2 million rial; 8/9 differ by a 1,111,554 reclassification; 20-3 absent from the source |
| CF | 0/6 — CF is still not rendered (RENDERED_STATEMENTS = BS, IS) |
| EQ | 24 official figures parsed; no built EQ statement yet |
IS 6/6 is not met and cannot be met from this source. Note 20-3 (tax expense
−4,697,329) has no corresponding row in source_1404.xlsx at all. Notes 8 and 9
together match exactly (−9,057,668); only their split differs, and the official's
own adjustment column records exactly ±1,111,554. Notes 6/7 differ by 1–2 million
rial because the official sums per-category rounded values.
Per booklet 2.1, this is reported as not met, not softened into a pass. No tolerance was invented and no figure was adjusted to force a match.
Consequences
docs/discrepancies.jsonis regenerated from the built output, with a cause and the exact official cell for every difference, plus account-level deltas.- C-13 can now be fed by
official_comparisons(report);POST /years/{id}/official-comparisonaccepts an official workbook, parses it in memory and changes no stored figure. - Remaining R3 work (IS 8/9 reclassification decision, CF/EQ rendering) is carried forward explicitly rather than claimed.