Skip to content

feat: add monthly budget tracker to dashboard#18

Merged
sleipi merged 7 commits into
mainfrom
feat/budget
Jul 3, 2026
Merged

feat: add monthly budget tracker to dashboard#18
sleipi merged 7 commits into
mainfrom
feat/budget

Conversation

@sleipi

@sleipi sleipi commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a budget_settings SQLite table (single-row) to persist monthly budget amount, work-day bitmask, and period start day
  • calcBudgetStatus() prorates budget by elapsed work days and returns pace delta, remaining amount, and reset date
  • Budget status bar rendered below Overall$ stats bar: [Budget$] [▲/▼/● pace] $X left · Y% Resets Aug 1
  • GET /POST /api/budget endpoints to read/write settings
  • Gear button in dashboard header opens a <dialog> modal with amount input, work-day toggles (Mo–So), and period start field

Test plan

  • Open dashboard at http://localhost:3333
  • Confirm no budget bar visible before configuration
  • Click next to "took Xms" — modal opens
  • Set a budget (e.g. $100), toggle off weekends, save
  • Confirm [Budget$] row appears below Overall$ with correct pace label (ahead/on-track/over)
  • Verify 5s auto-refresh updates budget bar
  • Set an amount much lower than current month spend — confirm ▼ over badge in orange
  • Test invalid save: enter negative amount — confirm modal stays open

🤖 Generated with Claude Code

sleipi and others added 6 commits July 2, 2026 16:58
Adds BudgetSettings/BudgetRepo interface, SqliteBudgetRepo implementation,
migration v3 creating the budget_settings table, wires repo into
createSqliteRepos, and updates all test stubs to satisfy the Repos interface.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Renders a Budget$ row in the stats bar showing pace badge (ahead/over/on-track),
remaining amount+%, and reset date. Wired into both page and stats routes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Allow async handle() in RouteHandler interface (backward-compatible)
- Implement createBudgetRoute: GET 404/200, POST 200/400 with validation
- Wire budget route in dashboard/index.ts before stats route
- Update routes.test.ts to await handle() calls for TS compatibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Gear button in header opens a dialog with amount, work-day toggles
(Mo–So, German labels), and period-start-day input. openBudgetModal()
loads existing budget via GET /api/budget; saveBudget() POSTs and
calls refresh(). Tests assert gear-btn, budget-modal, and day-toggle
elements are present in rendered HTML.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
POST /api/budget now rejects amount < 0 or non-finite, workDays > 127,
and periodStartDay outside 1-28 with 400. saveBudget() checks res.ok
and catches network errors, showing inline error instead of silently
closing the modal on failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sleipi sleipi added the enhancement New feature or request label Jul 2, 2026
- Center modal with margin:auto on dialog element
- Replace gear icon with credit-card SVG + "Budget" label
- Period row: compact layout (one line) with dynamic hint below
  showing "ends last day of month" or "ends Nth of next month"
- Fix resetDate to use periodStartDay instead of hardcoded day 1
- Add test: periodStartDay=5 produces resetDate on day 5 of next month

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sleipi sleipi merged commit 4dc4174 into main Jul 3, 2026
6 checks passed
@sleipi sleipi deleted the feat/budget branch July 3, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant