mirror of
https://github.com/Sea-Haven-Industries/payments-dashboard.git
synced 2026-10-02 08:33:24 +00:00
fix(boaRecon): add method=Check filter to matchElectronicReturn
Electronic returns only apply to checks, but the matcher was not filtering by method, so an electronic return could incorrectly match against a same-amount, bank-confirmed ACH record.
This commit is contained in:
parent
b0f72f2b8c
commit
828901fba8
2 changed files with 20 additions and 0 deletions
|
|
@ -236,6 +236,7 @@ export function matchCheckTransaction(classified, payments, refDateISO) {
|
|||
export function matchElectronicReturn(classified, payments, refDateISO) {
|
||||
const candidates = payments.filter(
|
||||
(p) =>
|
||||
p.method === "Check" &&
|
||||
(p.clear_status === "Cleared" || p.clear_status === "Returned") &&
|
||||
amountsEqual(p.amount_usd, classified.amount) &&
|
||||
issuedWithinDays(p, refDateISO, 120)
|
||||
|
|
|
|||
|
|
@ -271,6 +271,25 @@ test("electronic return: unique amount among bank-confirmed payments matches", (
|
|||
assert.equal(m.payment.check_number, "1001");
|
||||
});
|
||||
|
||||
test("electronic return: never matches ACH payments", () => {
|
||||
const achCleared = payment({
|
||||
method: "ACH",
|
||||
check_number: "21222000264",
|
||||
amount_usd: 3992.15,
|
||||
clear_status: "Cleared",
|
||||
pk: "payment#21222000264",
|
||||
});
|
||||
const checkCleared = payment({
|
||||
check_number: "1001",
|
||||
amount_usd: 3992.15,
|
||||
clear_status: "Cleared",
|
||||
});
|
||||
// Only the Check should be a candidate — ACH is excluded.
|
||||
const m = matchElectronicReturn({ amount: 3992.15 }, [achCleared, checkCleared], "2026-07-20");
|
||||
assert.equal(m.payment.check_number, "1001");
|
||||
assert.equal(m.matchedBy, "amount+cleared");
|
||||
});
|
||||
|
||||
test("electronic return: ambiguity is unmatched", () => {
|
||||
const payments = [
|
||||
payment({ check_number: "1001", amount_usd: 2500, clear_status: "Cleared" }),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue