The client had ~15 hand-rolled currency formatters (local `fmt`/`money`/ `fmtFull`/`fmtDollars`/…) plus a canonical `fmt` in lib/utils used at ~190 sites — same rules copy-pasted, with inconsistent handling of negatives, whole-dollar, cents vs dollars, and blank input. Add client/lib/money.js as the one implementation: - formatUSD(dollars) — "$1,234.56" (whole/dash options) - formatUSDWhole(dollars) — "$1,235" - formatCentsUSD(cents) — from integer cents; signed "+/-" and dash options Inputs are coerced so null/''/NaN never render as "$NaN", and -0 is normalized so it never shows as "-$0.00". lib/utils.fmt now delegates to formatUSD (byte-identical — the existing utils.test.js fmt suite is the regression guard), and the 15 local formatters delegate to money.js. No display currency formatting remains outside money.js; the /100 conversions left behind are calculations (form prefill), not display. Tests: client/lib/money.test.js (13). Full client suite 46 pass; build clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| AutoMatchReview.jsx | ||
| BankSyncSection.jsx | ||
| DownloadMyDataSection.jsx | ||
| ImportHistorySection.jsx | ||
| ImportMyDataSection.jsx | ||
| ImportSpreadsheetSection.jsx | ||
| ImportTransactionCsvSection.jsx | ||
| SeedDemoDataSection.jsx | ||
| TransactionMatchingSection.jsx | ||
| dataShared.jsx | ||