Skip to content

feat: universal bank statement normalization layer (CSV, OFX/QFX, QIF)#947

Open
selenaalpha77-sketch wants to merge 3 commits intorohitdash08:mainfrom
selenaalpha77-sketch:feat/bank-statement-normalization
Open

feat: universal bank statement normalization layer (CSV, OFX/QFX, QIF)#947
selenaalpha77-sketch wants to merge 3 commits intorohitdash08:mainfrom
selenaalpha77-sketch:feat/bank-statement-normalization

Conversation

@selenaalpha77-sketch
Copy link
Copy Markdown

Closes #112

Summary

Adds a universal bank statement normalization layer that converts diverse statement formats into FinMind's canonical expense schema.

New Endpoint

POST /expenses/import/normalize — accepts a file upload and returns normalised transactions with format metadata and deduplication fingerprints.

Supported Formats

Format Extensions Notes
CSV .csv Auto-detects Chase, HDFC, Axis bank profiles
OFX/QFX .ofx, .qfx Open Financial Exchange (SGML and XML variants)
QIF .qif Quicken Interchange Format

Bank Profile Auto-detection

The CSV parser inspects column headers to identify well-known bank layouts:

  • Chase: Transaction Date, Post Date, Description, Category, Type, Amount
  • HDFC: Date, Narration, Value Dat, Debit Amount, Credit Amount (split debit/credit columns)
  • Axis: Tran Date, PARTICULARS, DR, CR, BAL (split debit/credit columns)
  • Generic: best-guess fallback for any other CSV layout

Response Shape

{
  "format_detected": "CSV",
  "bank_profile": "Chase",
  "total_transactions": 42,
  "transactions": [{"date": "...", "amount": 25.00, "description": "...", ...}],
  "duplicate_fingerprints": ["sha256hex", ...]
}

Fingerprints are deterministic SHA-256 hashes of date|amount|description — callers can use them to detect duplicates before committing.

Files Changed

  • New: packages/backend/app/services/bank_normalizer.py
  • Updated: packages/backend/app/routes/expenses.py — added /import/normalize endpoint
  • New: packages/backend/tests/test_bank_normalizer.py — 8 tests

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.

Universal bank statement normalization layer

1 participant