Skip to content
isaacrowntreePublic

About

Personal finance ETL + dashboard for Australian bank statements and ATO tax returns

Topics

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Ledger

A personal finance tool that ingests bank statements from multiple Australian banks, categorises transactions, and generates ATO-ready tax reports — all from your terminal and a local web dashboard.

Tests License Python

What it does

  • Multi-source ingestion — parse statements from ING, CBA, Bankwest, HSBC, PayPal, Coles Mastercard, Amex and Airbnb (PDF + CSV)
  • Auto-categorisation — each merchant is filed once and every later visit follows; new merchants borrow the category of the most similar ones you have filed (local embeddings in a sqlite-vec index, no cloud). Uncategorized rows get one-click suggestions, and Claude can file a backlog through ledger categorise --export/--import; a "Merchants to check" page settles the ones that need a person
  • Source-of-truth dedup — prevents double-counting when transactions appear on both a bank account and a credit card
  • Business splits — automatically allocate percentages of expenses to businesses for tax reporting
  • ATO tax return view — structured output matching Australian individual tax return sections (salary, rental, business schedule, deductions)
  • Financial year view — outgoing/incoming/rental/work-trip sub-tabs replacing the manual Excel spreadsheet
  • Overview — where you stand: cash against card debt, what a partner owes you, and net worth at full value and at your ownership share. Balances are the last statement's balance carried forward by later exports
  • Shared expenses — split household costs with a partner and track what each side owes
  • Recurring schedules — config-driven repayment/subscription schedules with their own page
  • Depreciation register — business assets and their per-FY decline in value
  • Capital gains — CommSec contract notes parsed into a CGT schedule
  • Lodgement archive — previously lodged returns kept alongside the computed ones
  • Reconciliation — statement balances checked against the ledger to catch silent gaps
  • Tags — orthogonal to categories; sub-classify transactions for reporting (e.g. flight, biz-hosting, rental-income)
  • Local-first — SQLite database, no cloud dependency, your data stays on your machine

Quick start

# Clone and set up
git clone https://github.com/isaacrowntree/ledger.git
cd ledger
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[vectors]"        # or plain -e . : n-gram + NumPy fallback
# optional: pip install -e ".[llm]" for `ledger categorise --llm`

# Copy and customise config
cp config/accounts.yaml.example config/accounts.yaml
cp config/categories.yaml.example config/categories.yaml
cp config/tax.yaml.example config/tax.yaml
# Optional: recurring schedules, depreciation register, lodged-return archive
cp config/schedules.yaml.example config/schedules.yaml
cp config/depreciation.yaml.example config/depreciation.yaml
cp config/ato_returns.yaml.example config/ato_returns.yaml
# Edit these files with your accounts, merchant rules, and tax details

# Initialise database
ledger init

# Place statement files in staging/<source>/ and ingest
mkdir -p staging/ing staging/paypal
# Drop your PDF/CSV statements into the appropriate folders
ledger ingest

# Build the dashboard once, then start it
(cd frontend && npm install && npm run build)
python -m api
# Open http://127.0.0.1:5050

Supported formats

Source Format Parser
ING Australia PDF statements etl/parsers/ing_pdf.py
ING Australia CSV export etl/parsers/ing_csv.py
PayPal CSV activity download etl/parsers/paypal_csv.py
CBA transaction account PDF statements etl/parsers/cba_pdf.py
CBA credit card PDF statements etl/parsers/cba_cc_pdf.py
Bankwest credit card PDF eStatements etl/parsers/bankwest_pdf.py
Bankwest home loan / offset PDF statements etl/parsers/bankwest_account_pdf.py
Bankwest CSV export etl/parsers/bankwest_csv.py
HSBC credit card PDF statements etl/parsers/hsbc_pdf.py
HSBC everyday account PDF statements etl/parsers/hsbc_account_pdf.py
HSBC CSV export (TransHist) etl/parsers/hsbc_csv.py
Coles Mastercard PDF statements etl/parsers/coles_pdf.py
Coles Mastercard CSV export etl/parsers/coles_csv.py
CommSec PDF contract notes (CGT) etl/parsers/commsec_pdf.py
Amex CSV download etl/parsers/amex_csv.py
Airbnb CSV payout report etl/parsers/airbnb_csv.py

Adding a new bank: implement BaseParser in etl/parsers/, add to PARSERS in etl/cli.py.

Column-based PDF statements

CBA, Bankwest and HSBC's everyday accounts print debits and credits in separate columns as bare positive numbers, so flattening a page to text loses the only thing that tells a $10 fee from a $10 deposit. Those parsers use etl/parsers/pdf_layout.py, which keeps each word's horizontal position and recovers the column from its right edge -- the columns are right-aligned, so right edges stay put while left edges drift with the width of the number. The column anchors are read from each statement's own header row, since a bank changes its labels and their positions between layouts.

Statements are assigned to an account by staging directory, not filename, since CBA names every download Statement<date>.pdf and the Bankwest home loan and offset share a layout:

mkdir -p staging/cba staging/cba-cc staging/bankwest-loan staging/bankwest-offset

Configuration

All config lives in config/ (gitignored — copy from .example files).

accounts.yaml

Define your bank accounts, their types, and source-of-truth relationships:

accounts:
  - name: "My Everyday Account"
    source_type: ing
    account_type: checking
    file_prefix: my_everyday    # matches statement filenames

  - name: "My Credit Card"
    source_type: bankwest
    account_type: credit
    source_of_truth: true       # this account has the real transaction detail
    payment_patterns:           # patterns on OTHER accounts that are payments to this card
      - "MY CREDIT CARD"

categories.yaml

Categories, source rules, seed merchants, and tag rules:

categories:
  - name: Groceries
    budget_monthly: 600

rules:                       # only `type: source` rules
  - type: source
    source_type: airbnb
    category: Airbnb Income

merchants:                   # "description as on a statement": Category
  WOOLWORTHS: Groceries
  UBER EATS: Eating Out

tag_rules:
  - tag: flight
    pattern: "JETSTAR|QANTAS|VIRGIN AUSTRALIA"

tax.yaml

ATO-specific config — businesses, rental properties, depreciation, WFH:

businesses:
  - name: "My Business"
    abn: "00000000000"
    split_rules:
      - category: Utilities
        tag: internet
        business_pct: 50

rental_properties:
  - name: "MY PROPERTY"
    ownership_pct: 50
    rental_weeks: { 2025: 20 }

CLI commands

ledger init                      # Initialise database and load config
ledger ingest                    # Ingest all sources from staging/
ledger ingest --source ing       # Ingest only ING statements
ledger ingest --dry-run          # Preview without writing to DB
ledger split --backfill --fy 2025  # Compute business splits
ledger tax --fy 2025             # Print ATO tax summary
ledger cgt --fy 2025             # Capital gains from CommSec contract notes
ledger shared --backfill         # Apply shared-expense rules to existing rows
ledger reconcile                 # Check balances against statement closing balances
ledger reconcile --since 2026-01-01 --account Bankwest
ledger ingest --force            # Ingest even if a statement fails validation
ledger dedup                     # Find and resolve cross-account duplicates
ledger tag --pattern "UBER" --tag transport   # Bulk tag/recategorise by description
ledger categorise --setup        # First run: label merchants from existing categories, show next steps
ledger categorise --seed         # Label every merchant from the categories already in the ledger
ledger categorise --rerun --dry-run   # Recategorise unconfirmed rows (drop --dry-run to write)
ledger categorise --evaluate 2025-07-01   # Score the categoriser on rows from a date
ledger categorise --stats        # Labelled merchants by origin
ledger categorise --export pending.json   # Pending rows + similar merchants, for Claude
ledger categorise --import answers.json   # File Claude's answers
ledger categorise --llm --dry-run   # File pending rows with the Claude API (needs the llm extra)
ledger receipts                 # Match purchases to email receipts (himalaya) and keep the items
ledger reimbursements           # Link repayments from people to what they repaid

Ingest-time validation

Parsers describe statements; the engine decides what enters the ledger. Before anything is written, a statement is checked against its own printed balances, and one that does not add up is refused rather than partially ingested:

  ! balance_mismatch: rows sum to -1,234.56 but opening 1,000.00 -> closing 2,204.58 implies -1,204.58 (-29.98)
  REFUSED -- statement does not account for its own printed balances; nothing was ingested.

That is almost always a parser bug -- fix the parser rather than reaching for --force. See docs/adding-a-bank for the contract a parser must satisfy.

Stitching overlapping statements

A bank's PDF and CSV exports describe the same transaction with different text, and often a different date basis (transaction vs posting date), so the two formats cannot dedup against each other. Ingest one format per period and clip at the boundary:

ledger ingest --source bankwest                        # statements through 04 Aug
ledger ingest --source bankwest-csv --from 2026-08-05  # CSV covers only the tail

Windowed imports are left in staging/ rather than archived, since the file still holds transactions outside the window.

Reconciliation

ledger reconcile verifies the ledger against the balances printed on statements, which is what catches a silent gap that dedup cannot:

  • Anchor check — between two consecutive statements, the transactions in between must account for exactly the change in printed closing balance. A shortfall means missing transactions; an excess means double-counting. Works even for sources that print no per-record balance.
  • Running-balance chain check — where a source prints a balance per line (ING, the Bankwest CSV), each row's balance must equal the previous plus the amount. This localises a break to the exact transaction. A row stored with an inverted sign shows up as a drift of exactly twice its amount.

Transactions are attributed to statements by file, not by date — banks post with a lag, so a row dated before a statement's end can appear on the next one.

API endpoints

The Flask API serves data to the dashboard at http://127.0.0.1:5050.

Endpoint Description
GET /api/transactions All transactions with filters
GET /api/summary/period Income, spending and categories for a date range — the one definition every page's totals use
GET /api/summary/monthly Monthly income vs expenses
GET /api/summary/category Spending by category
GET /api/spreadsheet/outgoing?fy=2025 FY expenses with business splits
GET /api/spreadsheet/incoming?fy=2025 FY income by category
GET /api/spreadsheet/rental?fy=2025 Rental property schedule
GET /api/ato/return?fy=2025 Structured ATO return data
GET /api/accounts/summary Account balances and net worth
GET /api/shared-expenses Household expenses split with a partner
GET /api/schedules Recurring schedules (repayments, subscriptions)
GET /api/depreciation Depreciation register by financial year
GET /api/ato/lodged Previously lodged returns from ato_returns.yaml
GET /api/holdings Investment holdings and their events
GET /api/work-trips Work trips backing the travel deduction
PATCH /api/transactions/<id> Update category, notes or reviewed; labels the merchant unless learn: false
GET /api/merchants/review Merchants flagged for a person's decision
POST /api/merchants/<id>/decide File a flagged merchant and refile its unconfirmed rows
PATCH /api/transactions/<id>/split Override business split %

Architecture

config/              # Your personal config (gitignored)
  accounts.yaml      # Bank accounts and source-of-truth rules
  categories.yaml    # Categories, source rules, seed merchants, tag rules
  tax.yaml           # ATO tax config (businesses, rental, deductions)
  schedules.yaml     # Recurring schedules (repayments, subscriptions)
  depreciation.yaml  # Business asset register (decline in value)
  ato_returns.yaml   # Previously lodged returns

etl/                 # Extract-Transform-Load pipeline
  parsers/           # One parser per bank format (PDF/CSV)
  contract.py        # What a parser must hand back (ParsedStatement)
  engine.py          # Identity, idempotency and validation of statements
  categorizer.py     # Source rule → merchant label → nearest merchants
  merchant.py        # Normalised merchant key (strips receipt numbers, dates, suburbs)
  merchant_store.py  # Merchant labels and the sqlite-vec similarity index
  embedding.py       # Local embeddings (bge-small, or bge-base, via fastembed; n-gram fallback)
  categorise_cmd.py  # `ledger categorise`: setup, seed, rerun, evaluate, export/import
  llm_file.py        # `ledger categorise --llm`: Claude files pending rows by bucket
  vector_index.py    # sqlite-vec index, or NumPy brute force when it can't load
  receipts.py        # `ledger receipts`: email receipts via himalaya
  mailtext.py        # Plain text from HTML emails
  tagger.py          # Multi-tag assignment
  splitter.py        # Business expense split engine
  normalizer.py      # Dedup, source-of-truth, insert pipeline
  reconcile.py       # Balance checks against statement figures
  cgt.py             # Capital gains from CommSec contract notes
  cli.py             # CLI entry point

api/                 # Flask REST API
  server.py          # All endpoints

frontend/            # React dashboard (Vite, TanStack Router/Query/Table), client-side only
  src/router.tsx     # Four areas: Overview, Money, Tax, Analysis
  src/views/         # One component per page
  src/components/    # Shared UI and hand-built SVG charts
  src/lib/           # TanStack Query hooks and formatting
  src/api.ts         # API client and types

docs/                # Astro documentation site

data/                # SQLite database (gitignored)
staging/             # Drop statement files here (gitignored)
tests/               # Tests with generic fixtures
scripts/             # Utility scripts (reingest, etc.)

Development

# Run tests
python -m pytest tests/ -v

# Frontend dev server (hot reload, proxies /api to 127.0.0.1:5050)
cd frontend && npm run dev

# Type-check the frontend
cd frontend && npm run typecheck

# API server (auto-reload)
python -m api

How it works

  1. Ingest: Drop bank statement PDFs/CSVs into staging/<source>/. Run ledger ingest.
  2. Parse: Source-specific parsers extract date, description, amount, and balance from each format.
  3. Normalise: Dedup hashing prevents re-importing. Source-of-truth system marks ING payments to credit cards as transfers.
  4. Categorise: Source rules first, then the merchant's own label, then the nearest labelled merchants when they agree. Changing a category in the UI labels the merchant for next time.
  5. Tag: Multiple tags assigned per transaction for sub-classification.
  6. Split: Business split engine allocates percentages based on category + tag rules.
  7. View: Dashboard shows spending, income, budgets, trends, and ATO-ready tax reports.

Author

Created by Isaac Rowntree.

About

Personal finance ETL + dashboard for Australian bank statements and ATO tax returns

Topics

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages