Fix FinTS transaction deduplication
This commit is contained in:
65
convex/bank/fintsMap.test.ts
Normal file
65
convex/bank/fintsMap.test.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { mapFinTsTransaction } from "./fintsMap";
|
||||
|
||||
const salaryShift = {
|
||||
enabled: true,
|
||||
categoryNames: ["Gehalt & Besoldung"],
|
||||
dayThreshold: 25,
|
||||
};
|
||||
|
||||
function baseTransaction(overrides: Partial<Parameters<typeof mapFinTsTransaction>[0]> = {}) {
|
||||
return {
|
||||
valueDate: new Date(2026, 5, 22),
|
||||
entryDate: new Date(2026, 5, 22),
|
||||
amount: -12.34,
|
||||
transactionType: "NMSC",
|
||||
bankReference: "",
|
||||
customerReference: "",
|
||||
bookingText: "Kartenzahlung",
|
||||
purpose: "REWE SAGT DANKE",
|
||||
remoteName: "REWE",
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("mapFinTsTransaction", () => {
|
||||
test("does not expose MT940 placeholder references as external references", () => {
|
||||
const placeholders = [
|
||||
"NONREF",
|
||||
"NOTPROVIDED",
|
||||
"NOT PROVIDED",
|
||||
"N/A",
|
||||
"POS 13",
|
||||
"POS-42",
|
||||
"POS_1155",
|
||||
"-",
|
||||
"",
|
||||
];
|
||||
|
||||
for (const placeholder of placeholders) {
|
||||
const mapped = mapFinTsTransaction(
|
||||
baseTransaction({
|
||||
bankReference: placeholder,
|
||||
customerReference: placeholder,
|
||||
}),
|
||||
[],
|
||||
salaryShift,
|
||||
);
|
||||
|
||||
expect(mapped.externalRef).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
test("keeps real FinTS references for provider-level duplicate detection", () => {
|
||||
const mapped = mapFinTsTransaction(
|
||||
baseTransaction({
|
||||
bankReference: "5J2C21XL0470L56V/39761",
|
||||
customerReference: "NONREF",
|
||||
}),
|
||||
[],
|
||||
salaryShift,
|
||||
);
|
||||
|
||||
expect(mapped.externalRef).toBe("5J2C21XL0470L56V/39761");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user