test(control): verify internal cash transfers reconcile both cash accounts to TB
davoodmehraban89 committed
Oct 31, 2026 at 11:31 UTC
6a996a0d1759c3860f16091d17d306511df876e3
1 file changed
+51
backend/tests/test_cross_statement_reconciliation.py
+51
@@ -187,6 +187,49 @@ def trial(*, balanced=True):
187
)
188
189
190
+
191
+def cash_with_transfer():
192
+ base = cash()
193
+ cash_one = replace(
194
+ base.account_reconciliations[0],
195
+ source_credit_turnover="30", closing_balance="40",
196
+ transaction_credit_turnover="30",
197
+ )
198
+ cash_two = CashAccountReconciliation(
199
+ account_code="CASH2", account_name="Cash two", source_row=6,
200
+ opening_balance="0", source_debit_turnover="10",
201
+ source_credit_turnover="0", closing_balance="10",
202
+ transaction_debit_turnover="10", transaction_credit_turnover="0",
203
+ debit_difference="0", credit_difference="0",
204
+ rollforward_difference="0", policy_evidence_ref="CASH2-POLICY",
205
+ )
206
+ transfer = CashFlowLine(
207
+ "L3", "V3", "1404-01-03", "CASH1", "CASH2",
208
+ "CASH_TRANSFER", "0", "10", "SRC3", "CASH2-POLICY",
209
+ )
210
+ return replace(
211
+ base, cash_account_count=2, transaction_count=3,
212
+ internal_transfer_inflows="10", internal_transfer_outflows="10",
213
+ account_reconciliations=(cash_one, cash_two),
214
+ cash_flow_lines=base.cash_flow_lines + (transfer,),
215
+ )
216
+
217
+
218
+def trial_with_transfer():
219
+ base = trial()
220
+ rows = list(base.accounts)
221
+ rows[0] = replace(
222
+ rows[0], credit="30", closing="40", debit_net_movement="0",
223
+ )
224
+ rows.append(
225
+ TrialBalanceAccount("CASH2", "Cash two", 7, 6, "0", "10", "0", "10", "10")
226
+ )
227
+ return replace(
228
+ base, account_count=6, debit_turnover_total="100",
229
+ credit_turnover_total="100", accounts=tuple(rows),
230
+ )
231
+
232
+
233
def reconcile(**overrides):
234
inputs = {
235
"balance_sheet": bs(),
@@ -491,3 +534,11 @@ def test_equity_account_movement_must_match_trial_balance_source_row():
534
result = reconcile(trial_balance=replace(source, accounts=tuple(rows)))
535
assert not result.equity_rollforward_valid
536
assert "EQUITY_STATEMENT_ROLLFORWARD_INVALID" in result.findings
537
+
538
+
539
+def test_internal_cash_transfer_line_ties_both_cash_accounts_to_trial_balance():
540
+ result = reconcile(cash_flow=cash_with_transfer(), trial_balance=trial_with_transfer())
541
+ assert result.eligible_for_analyst_review, result.findings
542
+ assert result.cash_flow_bridge_valid
543
+ assert result.cash_accounts_match_trial_balance
544
+ assert result.cash_account_totals_valid