Money.from_integer
You're seeing just the function
from_integer
, go back to Money module for more information.
Specs
Convert an integer representation of money into a Money
struct.
This is the inverse operation of Money.to_integer_exp/1
. Note
that the ISO definition of currency digits (subunit) is always
used. This is, in some cases like the Colombian Peso (COP)
different to the CLDR definition.
Options
integer
is an integer representation of a mooney item including any decimal digits. ie. 20000 would interpreted to mean $200.00currency
is the currency code for theinteger
. The assumed decimal places is derived from the currency code.options
is a keyword list of options passed toMoney.new/3
Returns
A
t:Money
struct or{:error, {Cldr.UnknownCurrencyError, message}}
Examples
iex> Money.from_integer(20000, :USD)
#Money<:USD, 200.00>
iex> Money.from_integer(200, :JPY)
#Money<:JPY, 200>
iex> Money.from_integer(20012, :USD)
#Money<:USD, 200.12>
iex> Money.from_integer(20012, :COP)
#Money<:COP, 200.12>