4 ms·
> Store money including the smallest possible subdivisions. This is fine as long as everybody follows ISO4217. In my experience many 3rd party systems _mostly_
by Rafert 6y ago
> Store money including the smallest possible subdivisions.
This is fine as long as everybody follows ISO4217. In my experience many 3rd party systems _mostly_ do it and of course you get bitten by the edge cases.
For example, Stripe decided HUF doesn't have 2 decimals (I know that's how it's used in practice today but we're talking standards and system interoperability here), or that ISK subdivides into hundreds ("cents") in contrast to the ISO tables. Compare https://stripe.com/docs/currencies https://stripe.com/docs/currencies with http://currency-iso.org/en/home/tables/table-a1.html http://currency-iso.org/en/home/tables/table-a1.html. As Stripe notes for UGX, backing out of this is nearly impossible because of the subtle break in backwards compatibility. And who knows how other payment providers deviate in their own way.
For my own sanity and that of my coworkers (e.g. easier analysis for extracted tables in the data warehouse) I strongly prefer avoiding this headache and use decimal instead. You can do the appropriate rounding for a currency in your money object as for example https://www.martinfowler.com/eaaCatalog/money.html https://www.martinfowler.com/eaaCatalog/money.html does.