← ClaudeAtlas

value-objects-money-and-unitslisted

Enforces a pure-Dart value-object core that stores every quantity canonically — money as integer minor units keyed to each currency's real ISO-4217 exponent (never *100), physical amounts as SI whole units, timestamps as UTC — and converts only at the presentation edge; forbids double/num money, cross-currency arithmetic, and defaulting an unknown currency to two decimals; routes every division of money through one largest-remainder allocate() primitive so parts always sum to the whole to the exact minor unit; derives totals instead of storing them, links entities by stable id, and injects a Clock instead of DateTime.now. Use when defining or changing Money, Currency, or a unit value object; parsing or formatting an amount; splitting, prorating, discounting, tax/tip, or distributing money; adding a currency or FX rate; converting quantities; or fixing float-money, hardcoded-100, cross-currency, off-by-a-cent, or stored-total-drift bugs.
zakariaf/CatchLaw · ★ 0 · API & Backend · score 55
Install: claude install-skill zakariaf/CatchLaw
# Value objects: money & units Store every quantity **once, in one canonical form, and convert only when shown or exported**. Money is integer minor units plus a currency; physical quantities are whole SI base units; time is UTC. This is what lets a user flip any display preference (currency symbol, unit system, locale) without corrupting one stored row, and lets "sum of parts == whole" be structural, not hoped-for. This core is **pure Dart** — no `flutter/*`, no `intl`, no `dart:io`, no plugins. Formatting and digit normalization happen upstream/downstream, not here. These value objects live in `lib/core/`, the sanctioned pure-foundation layer (see `project-structure-and-packages`) — never a `utils/`/`common/`/`shared/` grab-bag. Read the reference for the task at hand: - `references/allocate-and-splitting.md` — the largest-remainder `allocate()` primitive, its invariants, the two-rounding-sites trap, edge policies, verified test vectors, and the subtotal→tax→tip split pipeline. - `references/canonical-storage.md` — the ISO-4217 exponent rule, the SI unit tables, `decimal`-based parsing, the cents-accumulator for keypad input, rounding discipline, and the Clock-injected dated-rate / staleness engine. - `references/domain-model.md` — value-type modelling: relationships as id links, derive-don't-store, one currency per aggregate, immutable state with value equality. Run `scripts/check-money-violations.sh` and `scripts/verify-core.sh` before a PR. ## Non-negoti