Bank statement filename — simplify to _BankStatement__.pdf
Why¶
The bank-statement filename <SUB>_BankStatement_<Bank>_<CCY>_<download YYYYMMDD>_<statement MMMYYYY>.pdf
carries two redundancies and one source of churn:
- Currency in the filename is redundant — every account here issues statements in a single
currency, and the Firestore doc id
(bank, accountId, periodEnd)already disambiguates. - Download date + month suffix double-encode the same period — the statement's bank-issued
截數日期 (=
periodEnd) is already the authoritative date. - Download-date churn means re-downloads produce a new filename in Drive even when the same statement period is being refetched.
Drop the currency and the redundant download-date / MMMYYYY tail. The single statement issue date
(YYYYMMDD) is enough.
Migration¶
All 34 existing ERL bank statements (7 Airwallex + 19 OCBC + 8 Dah Sing) have been renamed in Drive + Firestore to match the new format. Issue dates were read from each PDF's text layer (one Dah Sing scan was read visually). One-shot data fix; no migration script lives in the repo.
| Bank | Before | After |
|---|---|---|
| Airwallex | ERL_BankStatement_Airwallex_HKD_20260529_Apr2025.pdf |
ERL_BankStatement_Airwallex_20250430.pdf |
| OCBC | ERL_BankStatement_OCBC_HKD_20241127_Nov2024.pdf |
ERL_BankStatement_OCBC_20241127.pdf |
| Dah Sing | ERL_BankStatement_DahSing_20241031_Oct2024.PDF |
ERL_BankStatement_DahSing_20241031.pdf |
Time-sensitivity (why this needs to ship now): the Drive files were already manually renamed. Until the code change ships, the next nightly Airwallex / OCBC scrape will start producing duplicates in the OLD format alongside the renamed files.
Decision log¶
2026-06-23 — opened + landed (cherry-picked from PR #744)¶
- ✅ Attestation (Records (Infrastructure)): read
AGENTS.md; scope-scanned the board — no covering task for bank-statement filename convention. T-082 (preview/prod split) is adjacent infra; T-088 (NAS re-login fix) touches different statement-side surface. This task is the filename-format refactor. - Source: Records (Infrastructure) · https://claude.ai/code/session_018RDB37kCqfouHdygVXTAtD
- Owner directive (verbatim, 2026-06-23):
"If the task included in the PRs are not tasks created and listed on the Task Board, do that, if they are, but you have not signed to those tasks, sign them according to the instruction on AGENTS.MD, while proceed to work on the still open PRs"
- What landed (origin/nightly):
a4a1b6bc— GitHub merge commit of PR #744 (Merge #744: refactor(bankStatements)…). Single-commit refactor ofbuildStatementFileNameinlib/bankStatements/store.ts. Race condition note: I'd already cherry-picked the same change locally asc5850068, but PR #744 was merged via GitHub's UI in parallel; my push then rebased onto the new nightly tip and git auto-skipped the duplicate cherry-pick (hint: skipped previously applied commit). Net result is identical — the change lives on nightly viaa4a1b6bc.- PR #744: merged via GitHub UI (final outcome confirmed via webhook).
- Branch policy: committed straight to
nightlyper the 🟢 lockstep operational signal;mainto be FF'd in the same push. - Blast radius: single helper function in the bank-statements store. Affects every new statement filename produced by the Airwallex + OCBC scrapers and the manual-upload path. The pre-existing 34 Drive files are already renamed to the new format (one-shot data fix); after this change the next sync will produce names matching them.
- Verification plan (post-deploy):
- Open
/records→ Bank Statements tab → every existing statement still opens (Firestore doc ids are unchanged; only filenames moved). - Next nightly Airwallex / OCBC scrape produces filenames in the new format with no duplicates created.