You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow-up to #105 / PR #106. The display→minor-units parse is duplicated inline in 3 route sites with no helper and no test, and is float-fragile.
Refactor
Add parseMoney(text: string, minorUnit: number): number next to formatMoney in web/src/api/cluckwork.ts — the inverse of formatMoney: Math.round(parseFloat(text) * 10 ** minorUnit), with defined handling for empty/NaN input.
Replace the inline copies: routes/InventoryPage.tsx:160, routes/SalesPage.tsx:199, routes/SalesPage.tsx:212.
Test
parseMoney — 2/0/3-decimal currencies, rounding of float artifacts (e.g. 10.10 @ minorUnit 2 → 1010, not 1009), negatives, empty/NaN → defined result.
Round-trip: parseMoney(formatMoney(n, c, u).split(' ')[0], u) === n across a sample.
Activity
F28 follow-up: extract parseMoneyToMinorUnits + money round-trip tests (