@davoodmehraban89 / Aram-1 / commits / 93f676f
Fork 0

docs(control): document detail-level validation and real-builder five-statement integration

davoodmehraban89 committed Oct 31, 2026 at 11:34 UTC 93f676f7ff0b26de64df71e594603a3741736a3d
1 file changed +22 -9
docs/CROSS_STATEMENT_RECONCILIATION.md
+22 -9
@@ -14,14 +14,15 @@ The five independent previews now need a single arithmetic gate before any combi
14
15 ## Exact controls
16
17 -1. **Common source:** company code, fiscal year and source XLSX SHA-256 must be identical across all five candidates.
18 -2. **Trial balance:** recomputes opening, debit, credit, closing and net movement totals from the complete account trace; requires the debit-net opening and closing totals and debit/credit movement difference to be zero.
19 -3. **Balance sheet:** recomputes assets − liabilities − equity = 0 and compares the reported difference.
20 -4. **Equity:** balance-sheet equity total must exactly equal the statement-of-changes-in-equity closing total.
21 -5. **Profit:** income-statement net result must exactly equal the equity movement explicitly classified as `NET_PROFIT_LOSS`.
22 -6. **Cash:** caller must select the exact BS asset note/subnote keys that represent cash and cash equivalents, with a separate evidence reference for each. Their presentation total must exactly equal direct cash-flow closing cash.
23 -7. **Internal bridges:** recomputes P&L and equity arithmetic, and re-aggregates operating/investing/financing cash inflows/outflows from the individual classified cash-flow lines. Internal transfers are recomputed from line trace and must net to zero. Cash opening + net change = closing.
24 -8. **Cash account trace:** every cash account in the direct cash-flow candidate must exist in the trial-balance trace; opening, debit turnover, credit turnover, closing and source-row lineage must match exactly. Transaction turnover differences and account roll-forward are recomputed, not trusted from summary fields. The cash account list and opening/closing totals must also reconcile.
17 +1. **Common provenance:** company, fiscal year and source XLSX SHA-256 must match across all five candidates. BS, IS and EQ must also share one exact note-reference snapshot. Candidate eligibility must be a real boolean; nonempty findings or forged completeness/approval flags cannot be smuggled through.
18 +2. **Balance sheet detail:** re-aggregates every BS presentation line by category from its source closing exposure and explicit sign multiplier. Recomputes assets − liabilities − equity = 0; duplicate note keys, negative presentation lines and summary/detail mismatches block.
19 +3. **Income statement detail:** re-aggregates revenue, cost, operating expense, other income/expense and tax from individual presentation lines. Recomputes gross profit, operating profit, profit before tax and net result; the summary cannot pass if the underlying line amounts or sign policies differ.
20 +4. **Equity detail:** re-aggregates account movements into note movements, component totals and movement categories. Recomputes opening + movement = closing at account, note, component and statement levels. Each EQ account's opening, debit, credit, closing, account name and source-row identity must match its exact trial-balance account.
21 +5. **Trial balance:** recomputes each account's own opening + debit − credit = closing before aggregating totals. It also recomputes opening, debit, credit, closing and net movement totals from the full account trace; offsetting row errors cannot cancel to a green global total.
22 +6. **Five-statement bridges:** BS equity must equal EQ closing; IS net result must equal the EQ movement explicitly classified as `NET_PROFIT_LOSS`. All comparisons use exact Decimal arithmetic and zero tolerance.
23 +7. **Cash note policy:** caller must explicitly select the BS asset note/subnote keys that represent cash and cash equivalents, with separate evidence references. Their presentation total must equal direct cash-flow closing cash. Selection evidence is traceability, not authenticated approval.
24 +8. **Cash-flow detail:** re-aggregates operating/investing/financing inflows and outflows from individual classified lines, recomputes internal transfers, and verifies opening + net change = closing.
25 +9. **Cash account trace:** each registered cash account must exist in the TB trace. Transaction debit/credit turnovers are recomputed from cash-flow lines, including both sides of internal transfers, then tied to source turnover, opening/closing balances and source-row identity in TB.
26
27 All comparisons use exact Decimal values and zero tolerance. A missing note selection, duplicate BS note line, mismatched source hash, wrong scope, blocked upstream candidate or arithmetic mismatch makes the result ineligible.
28
@@ -57,6 +58,18 @@ if not result.eligible_for_analyst_review:
58
59 The cash-note selection is an untrusted input. Its evidence reference is traceability, not authenticated approval. The caller must ensure that the selected BS notes include **all and only** cash and cash equivalents, including approved treatment of restricted cash and overdrafts.
60
61 +## End-to-end integration test
62 +
63 +`tests/test_five_statement_pipeline_integration.py` builds one synthetic Pilot XLSX and invokes the actual BS, IS, EQ, direct-CF and TB builders against the exact same workbook bytes. The synthetic ledger demonstrates:
64 +
65 +- BS: assets 100 = liabilities 10 + equity 90
66 +- IS: net result 20 = EQ net-profit movement 20
67 +- EQ: opening 70 + movement 20 = closing 90
68 +- CF: opening cash 40 + net change 10 = closing cash 50
69 +- TB: opening and closing debit-net totals zero; debit and credit turnover both 60
70 +
71 +A second test omits a cash transaction and verifies that the combined gate blocks. These are synthetic software tests, not evidence that a real ledger or bank transaction population is complete.
72 +
73 ## Interpretation and limits
74
75 `eligible_for_analyst_review=true` means the provided candidates, references and arithmetic tie out under their explicit user-supplied policies. It does **not** prove that the ledger, bank transactions, cash-account registry, mapping or note selection is complete or authentic.
@@ -65,4 +78,4 @@ The result permanently marks `source_ledger_completeness_verified=false`, `accou
78
79 No real accounting approval, statutory compliance, tax treatment, authenticated C1/C2/C3 review, database write, report export, GUI or installer is implemented by this gate. It is an engineering control only.
80
68 -Run `cd backend && pytest -q tests/test_cross_statement_reconciliation.py` and full Backend CI. Synthetic candidate objects are used in tests; never place real financial files or approvals in public GitHub.
81 +Run `cd backend && pytest -q tests/test_cross_statement_reconciliation.py tests/test_five_statement_pipeline_integration.py` and full Backend CI. Synthetic candidate objects are used in tests; never place real financial files or approvals in public GitHub.