SaltDns. Registrar. Money
(Salt v1.0.0)
Money in the registrar module is always an integer in minor units (cents for
EUR and USD) next to an ISO 4217 currency code. A registrar answers with
decimals (11.17); they are read with Decimal and turned into minor units
here, once, at the adapter's edge. No float survives past it.
The number of decimals of a currency is 2 unless listed here: 0 for currencies such as JPY and KRW, 3 for BHD, KWD, OMR and similar.
Summary
Functions
A normalised currency code ("usd" to "USD"), or nil if it is not three
letters.
Decimals of a currency: 0, 2 or 3.
Builds %{minor: _, currency: _} from a registrar's price pair, a map with
the keys "price" and "currency".
Minor units as a Decimal in the currency's main unit (for sending to a registrar).
Turns a registrar's number into minor units. Accepts an integer, a
Decimal, a decimal string, or a float (read through its shortest text, so
11.17 is 1117 and not 1116). rounding (default :ceiling, so a cost is
never understated) applies when the number has more decimals than the
currency.
Types
Functions
A normalised currency code ("usd" to "USD"), or nil if it is not three
letters.
@spec exponent(String.t()) :: 0 | 2 | 3
Decimals of a currency: 0, 2 or 3.
Builds %{minor: _, currency: _} from a registrar's price pair, a map with
the keys "price" and "currency".
Minor units as a Decimal in the currency's main unit (for sending to a registrar).
Turns a registrar's number into minor units. Accepts an integer, a
Decimal, a decimal string, or a float (read through its shortest text, so
11.17 is 1117 and not 1116). rounding (default :ceiling, so a cost is
never understated) applies when the number has more decimals than the
currency.