Representing Money

Integer minor units + currency + scale, kept exact and auditable end to end

Representing Money Integer minor units + currency + scale, kept exact and auditable end to end 01 / Input 02 / Parse 03 / Value 04 / Store 05 / Report Display amount · "1,234.56 INR" text · 01 / Input · human input Display amount "1,234.56 INR" text human input Parse & validate · reject ambiguous · 02 / Parse · strict Parse & validate reject ambiguous strict Money value · minor_units 123456 / INR / scale 2 · 03 / Value · never a float Money value minor_units 123456 / INR / scale 2 never a float FX source · foreign amount + timestamped rate · 02 / Parse · convert FX source foreign amount + timestamped rate convert Convert · apply exact rate · 03 / Value · reproducible Convert apply exact rate reproducible Ledger store · integer minor units · 04 / Store · durable Ledger store integer minor units durable Reporting / display · format back to 2 dp · 05 / Report · read Reporting / display format back to 2 dp read raw text validated amount minor units format to 2 dp amount + rate converted Money store exact rate used Legend primary data policy / PII async batch data store

Money invariants

  • • Amounts are integer minor units, never a float
  • • An amount is meaningless without its currency
  • • Scale records how many minor units per unit (INR = 2)

FX is reproducible

  • • Store the converted Money and the exact rate you used
  • • Rate is timestamped and sourced so results replay exactly
  • • Never re-derive historical values from today's rate