Skip to content

feat: add transactions export command#74

Open
johann-taberlet wants to merge 2 commits intoazerpas:mainfrom
johann-taberlet:feat/transactions
Open

feat: add transactions export command#74
johann-taberlet wants to merge 2 commits intoazerpas:mainfrom
johann-taberlet:feat/transactions

Conversation

@johann-taberlet
Copy link

Summary

Adds a new transactions subcommand to export account transactions over a date range, using BoursoBank's CSV export endpoint (/budget/exporter-mouvements).

# CSV output (default)
bourso transactions -a <account_id> -f "01/01/2026" -t "31/01/2026"

# JSON output
bourso transactions -a <account_id> -f "01/01/2026" -t "31/01/2026" -o json

Changes

  • bourso_api::account: Add Transaction struct with all fields from BoursoBank CSV export
  • bourso_api::client::transaction: Add get_transactions() method on BoursoWebClient
    • Hits the /budget/exporter-mouvements endpoint with date range and account filter
    • Handles the 302 redirect to api.boursobank.com for file download (since the client uses Policy::none())
    • Parses BoursoBank CSV format (semicolon-separated, French number format with comma decimals and space thousands separators)
    • Returns empty Vec gracefully when an HTML error page is returned
  • CLI: Add transactions subcommand with --account, --from, --to, --output args
  • New dependency: csv crate for robust CSV parsing

Test plan

  • cargo build --release compiles without errors
  • cargo test -p bourso_api — 11 tests pass (3 new: test_parse_amount, test_extract_transactions, test_extract_transactions_empty_html)
  • Manual test: successfully exported 8 transactions from a live BoursoBank account with CSV output
  • Manual test: JSON output (-o json) works correctly

Add a new `transactions` subcommand to export account transactions
over a date range using BoursoBank's CSV export endpoint.

- Add `Transaction` struct to `bourso_api::account`
- Add `get_transactions()` method on `BoursoWebClient`
- Handle redirect to `api.boursobank.com` for file download
- Parse BoursoBank CSV (semicolon-separated, French number format)
- Support CSV (default) and JSON output formats
- Add unit tests for CSV parsing and amount conversion
@azerpas
Copy link
Owner

azerpas commented Feb 11, 2026

Thank you very much for the contribution @johann-taberlet

A few things top of my head:

  • I feel like the command should be something like bourse-cli export transactions [...] so that we can have something similar for export orders or export transfers
  • -f is often used to used for --format args, which I feel could be a good replacement to the current --ouput/-o
  • same for -o/--ouput which often designate a file output. I feel like that would suit well an export to a json or csv file
  • to replace -f/--from I would use --start-date and --end-date to make it really explicit
  • With all these we'll have something like bourso export transactions -a <account_id> --start-date "01/01/2026" --end-date "31/01/2026" -f json -o /Users/johndoe/transactions.json. Wdyt?

- Move `transactions` under new `export` subcommand (`bourso export transactions`)
- Rename `--from`/`--to` to `--start-date`/`--end-date`
- Rename `--output` (format) to `--format`/`-f`
- Add `--output`/`-o` for file output path (defaults to stdout)
@johann-taberlet
Copy link
Author

Thanks for the feedback @azerpas! All changes implemented in the latest commit:

  • bourso export transactions — moved under a new export subcommand, ready for future export orders, export transfers, etc.
  • --start-date / --end-date — replaced --from/-f and --to/-t
  • --format / -f — replaced --output/-o for format selection (csv/json)
  • --output / -o — new optional arg for file output path (defaults to stdout)

Final usage:

bourso export transactions -a <account_id> --start-date "01/01/2026" --end-date "31/01/2026" -f json -o /path/to/transactions.json

All 11 tests still passing, build OK. Tested manually with both CSV (stdout) and JSON (stdout) output.

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.

2 participants