@davoodmehraban89 / Aram-2 Mirror · read-only
Fork 0

Mirrored from https://github.com/davoodmehraban89/Aram.git

Synced Dec 4, 14:15 UTC

source-data-cleanup
add-index-html-10623938925177053894 arena/094f314c-aram arena/2d4eda07-aram chatgpt-phase1b2-autopilot codex/adr-future-connectors-pi-v1 codex/aram-account-note-source-trace-20261031 codex/aram-actions-node24-maintenance-20261031 codex/aram-analyst-review-workbook-20261031 codex/aram-bs-candidate-statement-20261031 codex/aram-cash-flow-direct-candidate-20261031 codex/aram-clean-reference-year-integrity-20261030 codex/aram-cross-statement-controls-20261031 codex/aram-equity-changes-candidate-20261031 codex/aram-five-statement-cli-20261031 codex/aram-five-statement-integration-20261031 codex/aram-five-statement-orchestrator-20261031 codex/aram-gate3-coverage-target-guard-20261030 codex/aram-gate3-hidden-xlsx-guard-20261030 codex/aram-gate3-integration-validation-20261030 codex/aram-gate3-mapping-change-preview-20261030 codex/aram-gate3-stale-note-guard-20261030 codex/aram-income-statement-candidate-20261031 codex/aram-manifest-referential-integrity-20261031 codex/aram-mapping-source-parser-20261101 codex/aram-multidimensional-mapping-20261101 codex/aram-multistatement-mapping-20261031 codex/aram-pipeline-manifest-schema-20261031 codex/aram-readonly-mapping-coverage-20261031 codex/aram-reconciliation-review-gate-20261031 codex/aram-same-flush-fiscal-lock-20261030 codex/aram-synthetic-windows-demo-20261031 codex/aram-trial-balance-diagnostic-20261031 codex/aram-windows-background-detail-search-20261031 codex/aram-windows-detail-review-20261031 codex/aram-windows-five-statement-pilot-20261031 codex/aram-windows-statement-figures-20261031 codex/gate-2a-pilot-workbook codex/gate-2a-pilot-workbook-6864754244772568979 codex/gate3-authenticated-principal-boundary-20261030 codex/gate3-authored-draft-staging-20261030 codex/gate3-carry-forward-preview-20261023 codex/gate3-draft-staging-audit-20261030 codex/gate3-mapping-batch-freshness-20261030 codex/gate3-mapping-batch-review-20261030 codex/gate3-mapping-core codex/gate3-mapping-coverage-20261023 codex/gate3-mapping-excel-20261023 codex/gate3-note-mapping-review-20261023 codex/gate3-signed-year-scope-20261030 codex/gate3-unapproved-proposal-storage-20261030 codex/payvast-mapping-discovery-20261023 codex/phase-2a-backend-foundation codex/phase-2b-post-merge-record codex/phase-2b-source-registration codex/phase-2b-source-registration-12955190277775369594 codex/post-gate2a-control-reconciliation codex/post-pr18-acceptance-record codex/project-control-foundation codex/t1-repo-hygiene-20261023 codex/t2-ci-hardening-20261023 codex/t3-explicit-migrations-20261023 codex/t6a-readonly-diagnostics-20261023 codex/v1-01-safety-gate-hardening codex/v1-year-isolation-followup-20261023 codex/windows-native-pilot-shell-20261030 dependabot/github_actions/actions/checkout-7 dependabot/github_actions/actions/setup-node-6 dependabot/github_actions/actions/setup-python-7 dependabot/github_actions/actions/upload-artifact-7 dependabot/npm_and_yarn/frontend/eslint-plugin-react-hooks-7.1.1 dependabot/npm_and_yarn/frontend/globals-17.15.0 dependabot/npm_and_yarn/frontend/vite-8.4.0 dependabot/npm_and_yarn/frontend/vitest-5.1.2 dependabot/npm_and_yarn/frontend/vitest/coverage-v8-5.1.2 dependabot/pip/backend/mypy-gte-1.13-and-lt-3 dependabot/pip/backend/pytest-cov-gte-6.0-and-lt-8 dependabot/pip/backend/setuptools-gte-75-and-lt-85 docs/aram-master-control-plan-20261111 docs/aram-roadmap-dashboard-20261030 docs/financial-statement-reconciliation-1402-1404-20261110 feat/gate3-governed-mapping-20261101 feat/gate3-package9-1-security-20261103 feat/gate3-package9-isolated-20261103 fix/password-unicode-validation-20261111 governance/aram-5-1-3-controls-20261030 governance/role-based-operating-model jules-1168663913887856558-73b8a885 jules-gate-2b-mapping-workflow-foundation-4137724387867065330 phase-1b1-audit-report-7365389436990903239 phase-2a-backend-foundation-10237597358138521261 phase1b2-postmerge-metadata-fix refactor/drg-parent-year-id-15088443704684163304 source-data-cleanup
md 78 lines 3.92 KB
Rendered Raw
1 # ADR-032 — R3: compare the engine's own output, and what the 1404 data actually says
2
3 - Status: accepted
4 - Date: 2026-12-04
5 - Scope: booklet 2.1 task R3
6 - Supersedes: the "statement_balance is pre-signed" assumption in ADR-013/018 and
7 ADR-031 §5. Everything else in those ADRs stands.
8
9 ## Context
10
11 The golden comparison aggregated the **source workbook** separately, so it could
12 agree with the official figures while `build_statements` produced something else.
13 R3 requires comparing the engine's own persisted output. Doing that exposed three
14 real defects and one source-data limitation.
15
16 ## Decision 1 — `statement_balance` is debit-positive, not pre-signed
17
18 Measured: applying the section display sign to `statement_balance` reproduces the
19 official 1404 balance sheet **16/16**; treating it as pre-signed flipped 7 notes.
20 The sign is now applied exactly once, to whichever figure the row provides.
21 `BalanceRow.display(sign, basis)` and `build_statements` share the rule.
22
23 ## Decision 2 — the statement basis belongs to the import, not the row
24
25 If a source supplies statement balances at all, that column is the statement
26 figure and a row without one contributes **nothing**. The old per-row fallback to
27 CLOSING leaked non-statement rows into the totals (BS fell to 6/16). Sources
28 without the column keep using CLOSING, so nothing else changes.
29
30 ## Decision 3 — the source assigns notes per row
31
32 Account 718291 posts to both note 6 and note 9. An account-level mapping cannot
33 express that, so `LedgerBalance.source_note` preserves the row's own assignment
34 (migration `20261204_09`). Precedence: an explicit mapping wins; the source note
35 only disambiguates an account mapped to **several** notes. That keeps the mapping
36 workflow authoritative while preventing double-counting.
37
38 ## Decision 4 — the income statement presents expenses negative
39
40 Official 1404 notes 6/7/20-3 are negative while the ledger is debit-positive, so
41 IS Revenue and Expenses both take −1. The net result is therefore the **sum** of
42 the signed IS lines, not revenue minus expenses; C-08's input was corrected.
43
44 ## Decision 5 — each official statement gets the parser its layout needs
45
46 `official_parse.py` reads BS/IS/CF as note lists and EQ as a components ×
47 movements matrix (opening / changes / closing / prior closing). The year column is
48 located from the **header row**, because the title «به تاریخ 29 اسفند 1404» also
49 contains the year and previously won the search, pointing at column 0. CF's
50 `46268` is flagged `account_code`, not a note. EQ went from 0 parsed figures to 24.
51
52 ## Measured outcome (real 1404, 131,280 rows)
53
54 | Statement | Result |
55 | --- | --- |
56 | BS | **16/16 matched** — acceptance met |
57 | 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 |
58 | CF | 0/6 — CF is still not rendered (`RENDERED_STATEMENTS = BS, IS`) |
59 | EQ | 24 official figures parsed; no built EQ statement yet |
60
61 **IS 6/6 is not met and cannot be met from this source.** Note 20-3 (tax expense
62 −4,697,329) has no corresponding row in `source_1404.xlsx` at all. Notes 8 and 9
63 together match exactly (−9,057,668); only their split differs, and the official's
64 own adjustment column records exactly ±1,111,554. Notes 6/7 differ by 1–2 million
65 rial because the official sums per-category rounded values.
66
67 Per booklet 2.1, this is reported as **not met**, not softened into a pass. No
68 tolerance was invented and no figure was adjusted to force a match.
69
70 ## Consequences
71
72 - `docs/discrepancies.json` is regenerated from the built output, with a cause and
73 the exact official cell for every difference, plus account-level deltas.
74 - C-13 can now be fed by `official_comparisons(report)`;
75 `POST /years/{id}/official-comparison` accepts an official workbook, parses it in
76 memory and changes no stored figure.
77 - Remaining R3 work (IS 8/9 reclassification decision, CF/EQ rendering) is carried
78 forward explicitly rather than claimed.