Storing and Send
When storing and sending monetary amounts you need to ensure that you retain the precision and decimal digits of the amount.
The best way to do this is to store the amount is three components.
Minor units
Decimal Digits
The currencies ISO Code
A value of $AUD1.99 would be stored as:
Minor Units: 199
Decimal Digits: 2
ISO Code: AUD
Using this technique guarantees you will always get back the amount you stored or transmitted.
If you are only using a single currency the Fixed package provides tools to store the minor units and decimal digits.
The Money package allows you to convert a Money amount to from a json format.
Last updated
Was this helpful?