Fix FinTS transaction deduplication

This commit is contained in:
Matthias
2026-06-23 12:37:41 +02:00
parent 993616c2f9
commit 6e687dc9b5
8 changed files with 451 additions and 2 deletions

View File

@@ -186,4 +186,76 @@ describe("transactions.list", () => {
expect(effectiveResult.page.map((tx) => tx._id)).toEqual([seeded.shiftedId]);
expect(bookingResult.page).toEqual([]);
});
test("orders effective month results by booking date instead of import creation time", async () => {
const t = convexTest(schema, modules);
const seeded = await t.run(async (ctx) => {
const userId = await ctx.db.insert("users", {
name: "Ordering User",
email: "ordering@example.com",
});
const accountId = await ctx.db.insert("accounts", {
userId,
name: "Girokonto",
type: "checking",
openingBalance: 0,
currency: "EUR",
isArchived: false,
});
const olderCreatedNewestBookingId = await ctx.db.insert("transactions", {
userId,
accountId,
bookingDate: "2026-06-23",
description: "Newest booking created first",
amount: -10,
isPending: false,
effectiveMonth: "2026-06",
});
const newerCreatedOldestBookingId = await ctx.db.insert("transactions", {
userId,
accountId,
bookingDate: "2026-06-15",
description: "Oldest booking created later",
amount: -20,
isPending: false,
effectiveMonth: "2026-06",
});
const middleBookingId = await ctx.db.insert("transactions", {
userId,
accountId,
bookingDate: "2026-06-22",
description: "Middle booking created last",
amount: -30,
isPending: false,
effectiveMonth: "2026-06",
});
return {
userId,
olderCreatedNewestBookingId,
newerCreatedOldestBookingId,
middleBookingId,
};
});
const asUser = t.withIdentity({
subject: `${seeded.userId}|test-session`,
tokenIdentifier: `test:${seeded.userId}`,
});
const result = await asUser.query(api.transactions.list, {
paginationOpts: { cursor: null, numItems: 20 },
from: "2026-06-01",
to: "2026-06-30",
basis: "effective",
});
expect(result.page.map((tx) => tx._id)).toEqual([
seeded.olderCreatedNewestBookingId,
seeded.middleBookingId,
seeded.newerCreatedOldestBookingId,
]);
});
});