Transfers between own accounts no longer count as spending and income

Imported statements come in without a category, so money moved to savings counted
as spent on one side and earned on the other. After every import and sync, brokeless
now marks them as Transfers out / in: pairs (same amount out of one own account and
into another within 4 days) and savings accounts by name (Oranje Spaarrekening,
Doelspaar, Direct Sparen...). Only rows without a category or with Other change.
All history, so existing imports get fixed on the next sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MangaValkandClaude Opus 5.5 committed 2026-11-19 20:20:40 +01:00
1 parent 49ecfb975f
commit 2371a5674f
5 files changed
+88 -3

No files matched your search

+3 -1
View File
@@ -1,7 +1,7 @@
import { saveFoundRecurring } from "@/lib/recurring-save";
import { NextResponse } from "next/server";
import { plaidError } from "@/lib/plaid";
import { ITEM_COLS, syncItem } from "@/lib/sync";
import { fileOwnTransfers, ITEM_COLS, syncItem } from "@/lib/sync";
import { createAdminClient } from "@/utils/supabase/admin";
import { createClient } from "@/utils/supabase/server";
@@ -35,6 +35,8 @@ export async function POST() {
results.push({ id: item.id, added: 0, modified: 0, removed: 0, error: err.code });
}
}
// Transfers between own accounts nobody marked (imported statements): neither spending nor income.
await fileOwnTransfers(user.id).catch((e) => console.error("[broke] own transfers:", e instanceof Error ? e.message : e));
// broke's own recurring finder, over every account (Plaid's misses, feeds, imported statements).
await saveFoundRecurring(user.id).catch((e) => console.error("[broke] recurring:", e instanceof Error ? e.message : e));
return NextResponse.json({ ok: true, results });
+3
View File
@@ -1,10 +1,13 @@
import { NextResponse } from "next/server";
import { saveFoundRecurring } from "@/lib/recurring-save";
import { fileOwnTransfers } from "@/lib/sync";
import { createClient } from "@/utils/supabase/server";
// Finds charges and pay that repeat in the signed-in user's own transactions. Called after a statement import.
export async function POST() {
const { data: { user } } = await (await createClient()).auth.getUser();
if (!user) return NextResponse.json({ error: "Not signed in" }, { status: 401 });
// A statement just came in: mark transfers between own accounts first, so they aren't found as repeating charges.
await fileOwnTransfers(user.id).catch((e) => console.error("[broke] own transfers:", e instanceof Error ? e.message : e));
return NextResponse.json(await saveFoundRecurring(user.id));
}