Recurring: broke finds repeating charges and pay itself, for every account
Recurring charges only came from Plaid's detection, so imported statements, bank feeds and hand-added accounts had none (Coming up stayed empty), and a Plaid bill dropped off Coming up once its predicted date passed. - findRecurring (pure, tested): groups by cleaned merchant name and direction, finds a weekly, 2-weekly, monthly, quarterly or yearly rhythm (3 hits, 2 for yearly, most gaps on the rhythm). Bills may vary 40% (electricity); everyday spending (groceries, dining, gas) counts only at the same amount. Transfers skipped. Next date keeps the day of the month. Stopped ones are ended. - saveFoundRecurring runs after every sync and after a statement import. Plaid's own stream wins for the same merchant. Updates keep the category you picked and anything you hid. Plaid streams with a past next date roll forward. Tested: the sample CSV alone finds Geico, Planet Fitness, Spotify, Netflix, Verizon, rent, PG&E and Comcast, and Home's Coming up fills in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3a4b6a0371
commit
1cf12f4619
6 files changed
+218
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { saveFoundRecurring } from "@/lib/recurring-save";
|
||||
import { NextResponse } from "next/server";
|
||||
import { plaidError } from "@/lib/plaid";
|
||||
import { ITEM_COLS, syncItem } from "@/lib/sync";
|
||||
@@ -34,5 +35,7 @@ export async function POST() {
|
||||
results.push({ id: item.id, added: 0, modified: 0, removed: 0, error: err.code });
|
||||
}
|
||||
}
|
||||
// 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 });
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { saveFoundRecurring } from "@/lib/recurring-save";
|
||||
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 });
|
||||
return NextResponse.json(await saveFoundRecurring(user.id));
|
||||
}
|
||||
Reference in new issue
Block a user