refactor(ui): consolidate money formatting into one shared helper (MAPPS-197) #175

Merged
vas2000-work merged 2 commits from fix/MAPPS-197-money-format into main 2026-06-16 01:24:43 +02:00
Owner

What

Consolidate currency formatting into one shared helper. Projects, billing, and contracts each had their own money formatter, so the same amount rendered three different ways:

  • projects fmt_money (f64): $60000 (no separators, no cents)
  • billing money (raw server string): $60000.00 (no separators)
  • contracts format_money (Decimal): $60,000.00 (correct)

Change

  • New crate::utils::money module is the single source of truth: format_money(Decimal) / format_money_opt(Option<Decimal>) (the grouped-thousands, two-decimal logic promoted from contracts), plus format_money_f64(Option<f64>) and format_money_str(&str) adapters for the projects (f64) and billing (server-string) call sites.
  • Projects, billing, and contracts now all route through it. The redundant fmt_money (projects) and money (billing) helpers are removed; contracts imports the shared functions (call sites unchanged).
  • All currency now renders as $60,000.00 consistently.

Testing (rust-builder container, matches CI)

  • cargo test --lib: 3 new utils::money tests pass (grouping, negatives/zero, the opt/f64/str adapters).
  • cargo clippy --all-targets -- -D warnings: clean.
  • cargo check --target wasm32-unknown-unknown: clean.
  • cargo fmt --all --check: clean.
## What Consolidate currency formatting into one shared helper. Projects, billing, and contracts each had their own money formatter, so the same amount rendered three different ways: - projects `fmt_money` (f64): `$60000` (no separators, no cents) - billing `money` (raw server string): `$60000.00` (no separators) - contracts `format_money` (Decimal): `$60,000.00` (correct) ## Change - New `crate::utils::money` module is the single source of truth: `format_money(Decimal)` / `format_money_opt(Option<Decimal>)` (the grouped-thousands, two-decimal logic promoted from contracts), plus `format_money_f64(Option<f64>)` and `format_money_str(&str)` adapters for the projects (f64) and billing (server-string) call sites. - Projects, billing, and contracts now all route through it. The redundant `fmt_money` (projects) and `money` (billing) helpers are removed; contracts imports the shared functions (call sites unchanged). - All currency now renders as `$60,000.00` consistently. ## Testing (rust-builder container, matches CI) - `cargo test --lib`: 3 new `utils::money` tests pass (grouping, negatives/zero, the opt/f64/str adapters). - `cargo clippy --all-targets -- -D warnings`: clean. - `cargo check --target wasm32-unknown-unknown`: clean. - `cargo fmt --all --check`: clean.
refactor(ui): consolidate money formatting into one shared helper (MAPPS-197)
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 57s
30052997d5
Projects (fmt_money: f64, no separators or cents), billing (money: raw server string, no separators), and contracts (format_money: grouped thousands + 2 decimals) each formatted currency differently, so the same amount rendered three ways ($60000 / $60000.00 / $60,000.00). Move the grouped-thousands, two-decimal formatter into crate::utils::money as the single source of truth (format_money, format_money_opt, plus format_money_f64 and format_money_str adapters for the f64 and server-string call sites) and route projects, billing, and contracts through it. Removes the redundant fmt_money (projects) and money (billing) helpers. Adds unit tests.

#MAPPS-197

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Merge branch 'main' into fix/MAPPS-197-money-format
All checks were successful
Create release / Create release from merged PR (pull_request) Has been skipped
Check / clippy + fmt + tests (pull_request) Successful in 1m1s
d4045e56ee
vas2000-work deleted branch fix/MAPPS-197-money-format 2026-06-16 01:24:43 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!175
No description provided.