Skip to content

Add Excel report generation API (#67, 1/2) - #212

Merged
NotThaDev merged 6 commits into
mainfrom
feature/67-report-api
Nov 17, 2026
Merged

NotThaDev merged 6 commits into
mainfrom
feature/67-report-api

Conversation

@NotThaDev

@NotThaDev NotThaDev commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Part 1 of 2 for #67. Targets main.

What

  • Report entity stores the generated .xlsx (bytea) with period, label, size; migration AddReports (FK to user, cascade, index (UserId, CreatedAt)).
  • ReportPeriodRange: previous complete calendar month / quarter / year and the period before it (UTC, end exclusive).
  • ReportCalculator (pure): KPIs (income, expenses, net, savings rate, saved, invested, avg daily expense, largest expense, opening/closing balance, count) for the total and per pocket, trend buckets (daily for a month, monthly otherwise) with a Transfers column that reconciles each closing balance and a comment naming the other pocket of each move, categories with share and Δ vs previous, top expenses and top descriptions.
  • ReportWorkbook (EPPlus 8.7.2): Summary, Trend, Expenses by category, Income by category, Top spending, one Pocket - <name> sheet per pocket, Transactions (Excel table with totals). Native charts; skipped when there is no data.
  • /api/reports: GET list (no bytes), POST {period} (201, max 50 per user), GET {id}/download, DELETE {id}.
  • Docs: backend/docs/Reports.md, README links, backend skill.

Why

  • The file is stored, so a download always returns the same snapshot even if transactions change later.
  • Income/expense rules reuse Analytics.IsIncome/IsExpense (now internal) so report numbers match the Analytics page.
  • EPPlus is the only option here with native charts and a short API; it runs under the non-commercial personal license set in code.

Tested

  • dotnet format --verify-no-changes, Release build, dotnet test: 153/153.
  • Real Postgres (isolated DB): migration applied; API on a separate port; generated LastMonth/LastQuarter/LastYear reports (8 sheets, 9–10 charts each), invalid period → 400, download headers, delete → 204 then 404, other user's/nonexistent id → 404.
  • Ownership tests: another user cannot list, download or delete a report.

Out of scope

  • UI (part 2).
  • Scheduled reports + notification (follow-up issue), custom ranges, FX conversion.

🤖 Generated with Claude Code

@NotThaDev
NotThaDev force-pushed the feature/67-report-api branch from 29d1b9d to 3eabf5f Compare November 17, 2026 10:15
@NotThaDev
NotThaDev merged commit 9235fcf into main Nov 17, 2026
9 checks passed
@NotThaDev
NotThaDev deleted the feature/67-report-api branch November 17, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant