Commit Graph

40 Commits

Author SHA1 Message Date
948ac2afe6 Fix Huntington profile detection: remove optional Split/Tags columns
Huntington CSVs don't always include Split and Tags headers, causing
detection to fail and fall back to the manual mapper with wrong defaults.
Detect on Date, Description, Amount which are always present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 09:37:28 -04:00
705a23c520 Revert bank profiles to invertAmountSign: true
Huntington and Fidelity CSVs use positive for deposits (CREDIT) and
negative for withdrawals (DEBIT). The previous change to false was wrong.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 09:32:36 -04:00
a472749b21 Fix bank account sign convention: positive = DEBIT (withdrawal)
Huntington and Fidelity CSVs use positive amounts for withdrawals/
purchases and negative for deposits/credits. Change invertAmountSign
to false so the normalizer correctly maps them.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 22:38:13 -04:00
99e41aab78 Fix pagination resetting to page 1 on navigation
push() depended on searchParams, causing the search debounce effect to
re-fire on every page change and delete the page param. Store searchParams
in a ref so push() is stable and only the search value triggers it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 21:20:22 -04:00
038539c191 Remove dedupeHash and duplicate skipping from CSV upload
Drop dedupeHash field and unique constraint from Transaction model.
Remove skipDuplicates from createMany. All rows in every upload are
now inserted unconditionally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 21:02:54 -04:00
decfb19ec6 Add restart: unless-stopped to db and app services
Automatically restarts both containers on crash or server reboot,
unless manually stopped with docker compose down.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 20:56:33 -04:00
3c13ae3597 Fix budget SelectValue showing ID instead of name in edit dialog
Pass budget name as explicit children to SelectValue so the selected
label renders correctly. Also handle TRANSFER type display in the header.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 20:28:36 -04:00
6f1376cc53 Add TRANSFER transaction type with bulk action and auto-rules
- Add TRANSFER to TransactionType enum; excluded from cash flow queries
- Add TransferRule model: description patterns that auto-mark transactions
  as transfers on upload (takes priority over budget rules)
- Bulk action "Mark as transfer" in transaction table
- Transfer Rules button/dialog on transactions page for managing patterns
- Transfers shown with ⇄ prefix and muted color in transaction list

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 20:15:07 -04:00
34bf24b35d Fix Discover CC sign convention: negative CSV = charge (DEBIT)
Discover CC exports charges as negative amounts and payments/refunds
as positive. invertAmountSign: true maps negative -> DEBIT (charge)
and positive -> CREDIT (payment/refund), which is correct.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 16:57:19 -04:00
587ac19b18 Revert budget to net DEBIT-CREDIT formula, remove fix-cc-types endpoint
Budget formula correctly adds DEBIT (CC charges stored from positive CSV
values) and subtracts CREDIT (refunds from negative CSV values).
Remove the fix-cc-types endpoint which was flipping CC transaction types
and causing charges to appear as CREDIT.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 16:46:49 -04:00
00d4796008 Fix budget totals going negative
Budget formula now sums DEBIT transactions only, matching the intended
"current-month DEBIT total" behavior. Previously, CREDIT transactions
(CC payments) assigned to a budget would subtract and push totals negative.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 16:40:03 -04:00
5a795d7e93 Fix stale balances after transaction delete
- Bulk delete now recomputes currentBalanceCents and BalanceSnapshot
  records for every affected account+month after deletion
- Add POST /api/admin/recalculate-balances to fix currently stale
  accounts (zeros out balances and removes orphaned snapshots)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 16:30:24 -04:00
60dabb6264 Recompute account balance after bulk transaction delete
After deleting transactions, recalculate currentBalanceCents for each
affected account so the account card and net worth dashboard stay accurate.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 16:24:59 -04:00
da938c1fcf Fix account delete blocked by CsvUpload FK constraint
Add onDelete: Cascade to CsvUpload.accountId so deleting an account
cascades to its upload records. Also explicitly delete uploads before
the account in the API route so existing deployed DBs without the
constraint don't error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 16:18:25 -04:00
0cf4612106 Add INVESTMENT account type with manual portfolio value recording 2026-04-21 11:32:50 -04:00
0ea6a7c698 Fix account select showing cuid instead of name in transaction filters 2026-04-21 11:05:11 -04:00
62ca178308 Remove CC type flip — normalizer already produces correct DEBIT/CREDIT for Discover CC 2026-04-21 10:59:59 -04:00
a9c12b94e1 Budget spend: simple DEBIT+/CREDIT- net formula, consistent with type flip 2026-04-21 10:52:39 -04:00
1a984d1eac Fix budget sign logic: CC CREDIT=spend, CC DEBIT=refund (type-flip aware) 2026-04-21 10:46:05 -04:00
c2b9184f2c Changed budget allocation 2026-04-21 10:43:00 -04:00
8c0e4ad684 budget pulls all Cc transactions instead of just credits 2026-04-21 10:37:33 -04:00
2a63b9120e Budget query needs to look for credit for CCs 2026-04-21 10:25:49 -04:00
e6f5d5a33b reverted budget allocation for credit cards 2026-04-21 09:47:49 -04:00
7ccd64a7bb CC account value consistency 2026-04-21 08:25:16 -04:00
d67a80b413 account specific budget queries 2026-04-20 23:44:06 -04:00
91a33cdfec Month Year selection for Dashboard 2026-04-20 23:31:59 -04:00
d865b02752 wrapped setBudgetTarget to fall back to '__none__' when the value is null. 2026-04-20 23:20:17 -04:00
f4216815e8 added functionality for multi-edit of transactions 2026-04-20 23:17:56 -04:00
jerick
60fc836b73 feat: category import from CSV + budget auto-assign rules
Category:
- Add categoryColumn to NormalizerConfig and NormalizedRow
- Map 'Category' column for Discover CC profile
- Write category to Transaction on upload

Budget rules:
- Add BudgetRule model (userId, budgetId, pattern)
- API: GET/POST /api/budget-rules, DELETE /api/budget-rules/:id
- Apply rules during upload (first case-insensitive match wins)
- Budgets page fetches and passes rules per budget
- BudgetCard 'Rules' menu item opens BudgetRulesDialog for add/delete

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 22:56:41 -04:00
jerick
efe42ac366 fix: show account name in upload select after selection
Base UI Select.Value renders the raw value prop (cuid) rather than
the item label. Pass the looked-up account name as children to
override it. Falls back to placeholder when no account matches.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 22:30:58 -04:00
jerick
42f1d34ddd fix: move seed command to prisma.config.ts (Prisma 7 requirement)
Prisma 7 no longer reads the seed command from package.json.
It must be set in prisma.config.ts under migrations.seed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 17:01:18 -04:00
jerick
adb5d144a0 fix: allow unauthenticated access to /login to prevent redirect loop
Unauthenticated requests to /login were hitting the auth gate and
redirecting back to /login?callbackUrl=/login, causing a loop.
Let the login page render for unauthenticated users; only redirect
away from /login when the user is already logged in.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 16:49:01 -04:00
jerick
2e264014b6 fix: derive redirect and origin check from Host header
req.url resolves to the internal hostname in Docker standalone mode.
Read the Host header directly so redirects and CSRF origin checks use
whatever host the browser actually used (IP, hostname, or domain).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 16:44:11 -04:00
jerick
8b0fba5014 fix: use req.url as redirect base so host is preserved
req.nextUrl.origin resolves to localhost inside the container.
Using req.url preserves the Host header the browser sent, so
redirects work when accessing via IP or any external hostname.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 16:35:47 -04:00
jerick
874b022139 fix: bind app port to 0.0.0.0 so it's reachable from the network
127.0.0.1:3000 only accepted connections from localhost.
DB port intentionally stays on 127.0.0.1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 16:33:04 -04:00
jerick
d41ab0c4e8 fix: split auth config so middleware uses Edge-compatible module
NextAuth's Credentials provider pulls in Prisma -> pg -> Node.js crypto,
which crashes in the Edge runtime. Extract an auth.config.ts with only
JWT/session callbacks (no DB, no bcrypt) and use NextAuth(authConfig) in
middleware. auth.ts spreads the config and adds the Credentials provider.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 16:12:15 -04:00
jerick
0b4f9f5c0e fix: add setup service for db push/seed; update README
The production runner image has no node_modules, so prisma CLI and tsx
are unavailable. Add a Compose 'setup' profile service that uses the
builder stage (which has all dev tools) to run db push and db seed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 15:25:02 -04:00
55debd082b first build commit 2026-04-19 00:44:43 -04:00
bc271b7ce1 First build commit 2026-04-19 00:35:42 -04:00
jerick
832b093d4f first commit 2026-04-17 23:47:21 -04:00