Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 3, 20:45 UTC
fix(control): recompute both sides of internal cash transfers from line trace
davoodmehraban89 committed
Oct 31, 2026 at 08:39 UTC
99cfe8ab28035e3f6f3529f848fb66e9fb8bef1c
1 file changed
+7
-3
backend/src/aram_backend/cross_statement_reconciliation.py
+7
-3
@@ -157,6 +157,7 @@ def _cash_flow_bridge(cash: DirectCashFlowCandidate) -> bool:
157
for activity in ("OPERATING", "INVESTING", "FINANCING")
158
}
159
line_ids: set[str] = set()
160
+ transfer_values: list[Decimal] = []
161
if (type(cash.transaction_count) is not int
162
or cash.transaction_count != len(cash.cash_flow_lines)):
163
return False
@@ -174,7 +175,9 @@ def _cash_flow_bridge(cash: DirectCashFlowCandidate) -> bool:
175
if line.activity in categories:
176
categories[line.activity]["inflows"].append(inflow)
177
categories[line.activity]["outflows"].append(outflow)
177
- elif line.activity != "CASH_TRANSFER":
178
+ elif line.activity == "CASH_TRANSFER":
179
+ transfer_values.append(_sum_exact([inflow, outflow]))
180
+ else:
181
return False
182
183
operating = _sum_exact([
@@ -190,6 +193,7 @@ def _cash_flow_bridge(cash: DirectCashFlowCandidate) -> bool:
193
-_sum_exact(categories["FINANCING"]["outflows"]),
194
])
195
net_change = _money(cash.net_change_in_cash)
196
+ transfer_total = _sum_exact(transfer_values)
197
rollforward = _sum_exact([
198
_money(cash.opening_cash_and_equivalents), net_change,
199
-_money(cash.closing_cash_and_equivalents),
@@ -205,8 +209,8 @@ def _cash_flow_bridge(cash: DirectCashFlowCandidate) -> bool:
209
and _sum_exact(categories["FINANCING"]["outflows"]) == _money(cash.financing_outflows)
210
and financing == _money(cash.financing_net_cash_flow)
211
and _sum_exact([operating, investing, financing, -net_change]) == 0
208
- and _money(cash.internal_transfer_inflows) == _money(cash.internal_transfer_outflows)
209
- and _money(cash.internal_transfer_inflows) >= 0
212
+ and _money(cash.internal_transfer_inflows) == transfer_total
213
+ and _money(cash.internal_transfer_outflows) == transfer_total
214
and rollforward == _money(cash.rollforward_difference) == 0
215
)
216