@davoodmehraban89 / Aram-1 / commits / 44f476c
Fork 0

test(control): bind equity detail fixture to TB account rows and cover source trace mismatch

davoodmehraban89 committed Oct 31, 2026 at 11:28 UTC 44f476c9ed1c9d104ff5820546c89c49d5db5cd5
1 file changed +17 -7
backend/tests/test_cross_statement_reconciliation.py
+17 -7
@@ -106,8 +106,8 @@ def equity(*, closing="100", profit="40", eligible=True):
106 profit_value = Decimal(profit)
107 rollforward = Decimal("60") + profit_value - closing_value
108 account = EquityAccountMovement(
109 - account_code="EQ1", account_name="Equity", source_excel_row=2,
110 - source_row=1, statement_section="Equity", note_number="E01",
109 + account_code="EQ1", account_name="Equity", source_excel_row=3,
110 + source_row=2, statement_section="Equity", note_number="E01",
111 subnote_code="", equity_component="RETAINED_EARNINGS",
112 movement_category="NET_PROFIT_LOSS", sign_multiplier=-1,
113 opening_balance="60", debit_turnover="0", credit_turnover=profit,
@@ -172,14 +172,15 @@ def cash(*, closing="50", net="10", eligible=True):
172 def trial(*, balanced=True):
173 accounts = (
174 TrialBalanceAccount("CASH1", "Cash", 2, 1, "40", "30", "20", "50", "10"),
175 - TrialBalanceAccount("REV", "Revenue", 3, 2, "0", "0", "30", "-30", "-30"),
176 - TrialBalanceAccount("EXP", "Expense", 4, 3, "0", "20", "0", "20", "20"),
177 - TrialBalanceAccount("OFFSET", "Offset", 5, 4, "-40", "0", "0", "-40", "0"),
175 + TrialBalanceAccount("EQ1", "Equity", 3, 2, "-60", "0", "40", "-100", "-40"),
176 + TrialBalanceAccount("REV", "Revenue", 4, 3, "0", "0", "30", "-30", "-30"),
177 + TrialBalanceAccount("EXP", "Expense", 5, 4, "0", "20", "0", "20", "20"),
178 + TrialBalanceAccount("OFFSET", "Offset", 6, 5, "20", "40", "0", "60", "40"),
179 )
180 return TrialBalanceDiagnostic(
181 company_code="001", fiscal_year=1404, source_sha256=SOURCE,
181 - account_count=4, opening_debit_net_total="0",
182 - debit_turnover_total="50", credit_turnover_total="50",
182 + account_count=5, opening_debit_net_total="0",
183 + debit_turnover_total="90", credit_turnover_total="90",
184 closing_debit_net_total="0", movement_difference="0",
185 opening_to_closing_difference="0", findings=(), accounts=accounts,
186 balanced_for_analyst_review=balanced,
@@ -480,3 +481,12 @@ def test_cash_scope_and_ledger_completeness_flags_cannot_be_smuggled_in():
481 reconcile(cash_flow=replace(
482 cash(), cash_account_scope_owner_approved=True,
483 ))
484 +
485 +
486 +def test_equity_account_movement_must_match_trial_balance_source_row():
487 + source = trial()
488 + rows = list(source.accounts)
489 + rows[1] = replace(rows[1], credit="39", closing="-99", debit_net_movement="-39")
490 + result = reconcile(trial_balance=replace(source, accounts=tuple(rows)))
491 + assert not result.equity_rollforward_valid
492 + assert "EQUITY_STATEMENT_ROLLFORWARD_INVALID" in result.findings