reconcile queue: offer a foreign row's exact native twin regardless of provisional AUD
ci / lint-test (push) Successful in 1m4s

Wallet INR taps were priced at a provisional 0.0180 AUD/INR; CommBank charged
~0.0149, so every rupee twin sat ~20% outside the picker's +-5% band. The
auto-matcher pairs on the native figure but refuses ambiguity (INR 112 twice in
three days, INR 175 three times), which left those rows offered nothing at all.
This commit is contained in:
2026-10-11 00:35:50 +11:00
parent e956f39ffc
commit 069034951e
2 changed files with 28 additions and 1 deletions
@@ -66,4 +66,21 @@ describe("getPendingReconciliations", () => {
expect(offered).toContain(live);
expect(offered).not.toContain(dupe);
});
it("offers the exact native twin of a foreign row even when its provisional AUD is far off", async () => {
// Live shape, 2026-10-09: wallet INR 112 at a provisional A$2.01; CommBank
// charged A$1.68 -- 16% under, outside the +-5% band.
const manual = await insertTransaction(pool, ownerId, { description: "SWIGGY LIMITED", amount: 2.01, transaction_date: "2026-10-04" });
await pool.query(`UPDATE transactions SET foreign_currency_code = 'INR', foreign_currency_amount = 112 WHERE id = $1`, [manual]);
const twin = await statementLine(1.68, "2026-10-04", "Swiggy Limited Bengaluru");
const otherRupees = await statementLine(1.68, "2026-10-04", "Swiggy Limited Bengaluru");
await pool.query(`UPDATE transactions SET foreign_currency_code = 'INR', foreign_currency_amount = 112 WHERE id = $1`, [twin]);
await pool.query(`UPDATE transactions SET foreign_currency_code = 'INR', foreign_currency_amount = 113 WHERE id = $1`, [otherRupees]);
const [row] = (await getPendingReconciliations(ownerId)).filter((r) => r.id === manual);
const offered = row.matches.map((m) => m.id);
expect(offered).toContain(twin);
// A different native figure at the same AUD is not admitted by this path.
expect(offered).not.toContain(otherRupees);
});
});