-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Problem
Financial data from GnuCash SQLite databases often needs to be presented in a professional, readable format with proper currency symbols, thousands separators, and column alignment. Currently, raw SQL output is difficult to read and share.
Proposed Solution
Add a new package packages/format-financial/ with a Python script that formats financial data tables with:
Key Features
- Currency formatting: Automatic
$symbols and thousands separators ($1,234.56) - Perfect column alignment: Dynamic width calculation for clean tables
- Dual output modes: Both plain text (terminal-friendly) and markdown table formats
- Decimal precision: Uses Python's
Decimalclass to avoid floating-point errors - Testable design: I/O separated from formatting logic with comprehensive doctests
Usage Examples
# Plain text output (also valid markdown)
python3 format_financial.py database.sqlite view_name
# Pure markdown output
python3 format_financial.py database.sqlite view_name --markdownSample Output
| as_of_date | assets | liabilities | net_worth | retained_earnings | equity | eq |
| ---------: | ----------: | ----------: | ----------: | ----------------: | ----------: | ----: |
| 2024-12-31 | $796,380.82 | $0.00 | $796,380.82 | $25,222.54 | $771,158.28 | $0.00 |
| 2025-06-30 | $811,111.21 | $0.00 | $811,111.21 | $36,153.82 | $774,957.39 | $0.00 |
Technical Implementation
- Object capability discipline: SQLite connections and stdout injected for testability
- Comprehensive doctests: All formatting functions have embedded tests
- Clean separation: I/O code isolated in
_script_io()function - Robust error handling: Graceful fallbacks for edge cases
Benefits
- Professional financial reports suitable for sharing
- Works with any SQLite view/table containing financial data
- Eliminates manual formatting of GnuCash query results
- Reusable across different finquick workflows
- Well-tested and maintainable code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels