caelum0x 5a22085eb9 fix(webhook-ingestion): correlate deposits by reference, not amount alone
handleTransactionCreated previously matched an incoming Airwallex
transaction to a deposit purely by (tenant, amount, not-yet-received,
oldest) — its own doc comment called this "intentionally conservative"
and flagged a real misattribution risk once a tenant has two
outstanding deposits of the same amount.

Carry the depositor-facing reference through RecordDeposit's
external_ref and Airwallex's payload.Reference, and prefer an exact
reference match before falling back to the amount heuristic. Add the
matching.go helpers (matchDepositByReference,
matchDepositByAmountHeuristic) the handler already called but never
shipped.
2026-10-23 18:09:21 +03:00
..