Currency Minor Unit
A currency minor unit is the subdivision used to express amounts at a defined scale. For USD, one cent is one hundredth of a dollar: an integer 1234 with currency USD and scale 2 means 12.34 USD. An integer by itself does not identify a monetary amount.
Do not assume every currency or API field uses two decimal places. Read the provider’s contract for each operation: charge and payout representations can differ. Currency metadata and API representation are related but not interchangeable. Reject unsupported currency/scale combinations rather than silently dividing every value by 100.
For a source integer amount a with scale s, a rate r in target major units per source major unit, and target scale t, the unrounded target minor-unit amount is a × r × 10^(t − s). Thus 1234 EUR cents at 1.10 USD per EUR becomes 1357.4 USD cents before rounding. Record rate direction, date, source, and the rounding rule.
Use integers for minor units or suitable decimal arithmetic, with checked storage limits and enough calculation precision. Converting a binary float to Decimal does not recover the intended decimal input. Build decimal rates from source strings and specify whether rounding happens per movement or after aggregation.
See Integrating Payment, Commerce, and Finance Data for worked examples.
Reference: Stripe: supported currencies and representations.
Discover more from Insightful Data Lab
Subscribe to get the latest posts sent to your email.
