Skip to content

Add CSV/JSON export for expenses and bills#590

Open
sofia-willow wants to merge 1 commit intorohitdash08:mainfrom
sofia-willow:feat/expense-export-589
Open

Add CSV/JSON export for expenses and bills#590
sofia-willow wants to merge 1 commit intorohitdash08:mainfrom
sofia-willow:feat/expense-export-589

Conversation

@sofia-willow
Copy link

Summary

Implements the CSV/JSON export feature mentioned in the README as a premium feature.

Closes #589

New Endpoints

Method Path Description
GET /expenses/export?format=csv Export expenses as CSV
GET /expenses/export?format=json Export expenses as JSON array
GET /bills/export?format=csv Export bills as CSV
GET /bills/export?format=json Export bills as JSON array

Query Parameters (expenses)

  • format: csv or json (default: csv)
  • from / to: Date range filter (ISO format)
  • category_id: Filter by category

CSV Format

date,amount,currency,category,type,notes
2026-03-15,42.50,USD,Food,EXPENSE,Lunch with team

Features

  • Proper Content-Disposition header for browser file download
  • Category names resolved (not just IDs)
  • Uses stdlib csv module — no new dependencies
  • Auth-protected (JWT required)
  • Reuses existing query filter logic

Tests (9 new, 31 total — all pass)

  • CSV/JSON export for both expenses and bills
  • Date range filtering
  • Empty export handling
  • Invalid format validation (400)
  • Auth protection (401)

Notes

This is a contribution to help move the export feature forward. Happy to adjust the implementation based on feedback (e.g., adding Excel support, pagination for large exports, etc.).

New endpoints:
- GET /expenses/export?format=csv|json — Export expenses with date/category filters
- GET /bills/export?format=csv|json — Export active bills

Features:
- CSV format with proper Content-Disposition header for file download
- JSON array format as alternative
- Date range filtering (from/to query params)
- Category filtering (category_id query param)
- Category names resolved in export (not just IDs)
- Auth-protected (JWT required)
- No new dependencies (uses stdlib csv module)

Tests (9 new, 31 total — all pass):
- Expense CSV export with content validation
- Expense JSON export
- Date range filtering
- Empty export (header only)
- Invalid format returns 400
- Auth required (401)
- Bill CSV export
- Bill JSON export
- Bill auth required

Test infrastructure:
- conftest.py updated with fakeredis mock (same fix as savings PR)

Closes rohitdash08#589
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.

Add CSV/JSON export for expenses and bills

1 participant