docs(finance): specify net-debit trial-balance assumptions and nonapproval gates
davoodmehraban89 committed
Oct 31, 2026 at 06:51 UTC
75c56d06c26aab3a50aacdf7826fea770ff9d74c
1 file changed
+56
docs/TRIAL_BALANCE_DIAGNOSTIC.md
new
+56
@@ -0,0 +1,56 @@
1
+# ARAM — unsigned trial balance arithmetic diagnostic
2
+
3
+## Scope
4
+
5
+This is a **read-only, nonofficial, fail-closed** trial balance control for one explicit company and fiscal year in an authorized Pilot XLSX file. It does not claim that the source ledger is complete, authentic, approved or compliant with any accounting standard.
6
+
7
+**Important accounting assumption:** `opening` and `closing` are treated as **net-debit signed balances**; credit-net balances must be negative. `debit` and `credit` represent nonnegative period turnovers. If the real Peyvast/source ledger uses different sign or cumulative semantics, this diagnostic is **not valid** until an approved data normalization rule is implemented. Never infer sign from the account code or label.
8
+
9
+## Calculations
10
+
11
+For each account:
12
+
13
+```text
14
+net_debit_movement = debit - credit
15
+closing = opening + net_debit_movement
16
+```
17
+
18
+Across all accounts of the selected company and fiscal year:
19
+
20
+```text
21
+opening_net_total = sum(opening)
22
+debit_total = sum(debit)
23
+credit_total = sum(credit)
24
+closing_net_total = sum(closing)
25
+debit_credit_difference = debit_total - credit_total
26
+rollforward_difference = opening_net_total + sum(net_debit_movement) - closing_net_total
27
+```
28
+
29
+An opening or closing total different from zero is reported; unequal debit/credit period turnovers are reported; nonmatching per-account opening/turnover/closing fails the input gate. Totals use exact Decimal aggregation; all-zero accounts are valid arithmetic, but still do **not** prove completeness. Accounts with negative debit/credit turnovers are rejected under the documented convention.
30
+
31
+The result includes the source SHA-256, scoped account count, ordered account/source-row trace, errors and arithmetic totals. It always includes `source_ledger_completeness_verified=false`, `accounting_policies_verified=false`, `official_financial_statement=false`, `independently_reviewed=false`, `releasable=false`. The flag `balanced_for_analyst_review=true` certifies **neither** account completeness nor correctness of the underlying accounting postings.
32
+
33
+## Local CLI
34
+
35
+```bash
36
+cd backend
37
+python -m aram_backend.trial_balance_diagnostic_cli \
38
+ --file ./synthetic.xlsx \
39
+ --company-code 001 \
40
+ --fiscal-year 1404
41
+```
42
+
43
+Exit status `0`: balanced arithmetic for analyst review only. `3`: parsed but one or more accounting totals do not balance (the JSON includes each finding). `2`: invalid/untrusted input, read error, or bad scope; no JSON success output. Nothing is uploaded, stored, posted or exported; only JSON is written to stdout.
44
+
45
+The parser rejects oversized XLSX, excessive ZIP expansion, hidden/merged financial data, invalid headers, wrong company/year, duplicate accounts, negative turnovers, invalid decimal figures and changed/missing local files. Results are calculated entirely in memory; XLSX bytes are never mutated.
46
+
47
+## Gaps before any real financial release
48
+
49
+- Verify the actual net debit/credit sign convention in Peyvast and imported financial data.
50
+- Confirm **completeness** of source ledger; synthetic balanced totals can also be incomplete or fabricated.
51
+- Reconcile account movements, period postings, trial balance and approved Mapping rules into statement numbers and note disclosures.
52
+- Obtain company/year role identities, independent C1/C2/C3 reviews and a formal finance-owner approval.
53
+- Implement authenticated audit signoff, locked fiscal years, immutable snapshots, official XLSX/PDF export and the final Windows GUI.
54
+- Do not upload real financial source documents to the public GitHub repository.
55
+
56
+Run `cd backend && pytest -q tests/test_trial_balance_diagnostic.py tests/test_trial_balance_diagnostic_cli.py`, full Backend CI, migration round-trip and compilation. Exact-head CI evidence must be verified from GitHub. Upstream PR #60–#63 remain unmerged.