bettersight-statement-extra.../backend
JasonFraser 53ff90a8f7 Generalize money-format detection into a standing fail-safe, gated by dominant currency marker
Replaces the one-off "CA$" regex fix with a general mechanism:
_parse_money()/_money_value() recognize any currency-wrapped amount
(a currency-code prefix, or any real Unicode currency symbol via
category "Sc") rather than needing a new _MONEY_RE branch hardcoded
every time an unseen format shows up. Letters alone (no symbol) still
correctly fail, so a reference code like "REF123.45" is never
misread as money.

This alone reintroduced a real phantom-transaction bug, caught before
shipping by re-testing the already-fixed Equals Money USD fixture:
its own currency-exchange footnotes print a converted foreign-currency
amount (e.g. "£964.58") that's genuinely money-shaped but isn't this
ledger's own currency - and because this bank's narrative continuation
lines span the full page width, that token's x-position coincidentally
fell inside the money column's zone, promoting the whole line into a
phantom 37th transaction with a broken balance chain.

Fixed with a dominant-marker gate: _dominant_money_marker() tallies
every money-shaped word's own currency marker on a page, and the
fallback only accepts whichever marker is most common - a real
statement's own amounts use the same marker dozens of times; a one-off
foreign marker marks itself as an annotation, not the ledger's money.

Verified: 19 direct assertions on _money_value (including the false-
positive guards), the regression reproduced then fixed against the
real USD fixture (37→36 transactions, balance checks restored), the
original CAD case re-verified via a reconstructed synthetic PDF (its
real file's PocketBase record was since deleted), and the full
HSBC/RBC fixture corpus byte-identical to baseline throughout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 18:23:56 -04:00
..
repositories Move Excel exports to R2; remove dead per-extraction workbook generation 2026-10-13 07:13:20 -04:00
routes Add layout-mapper backend contract: fingerprinting + forced-mapping extraction (L.2) 2026-10-14 08:09:34 -04:00
schemas Add layout-mapper backend contract: fingerprinting + forced-mapping extraction (L.2) 2026-10-14 08:09:34 -04:00
services Generalize money-format detection into a standing fail-safe, gated by dominant currency marker 2026-10-30 18:23:56 -04:00
app.py Move Excel exports to R2; remove dead per-extraction workbook generation 2026-10-13 07:13:20 -04:00
dependencies.py Move Excel exports to R2; remove dead per-extraction workbook generation 2026-10-13 07:13:20 -04:00
measure.py Fix edit-icon color, description autogrow, and add image zoom controls 2026-10-11 23:44:06 -04:00