SoftBank.Cldr.Money.put_fraction
You're seeing just the function
put_fraction
, go back to SoftBank.Cldr.Money module for more information.
Set the fractional part of a Money
.
Arguments
money
is a%:'Elixir.Money'{}
structfraction
is an integer amount that will be set as the fraction of themoney
Notes
The fraction can only be set if it matches the number of
decimal digits for the currency associated with the money
.
Therefore, for a currency with 2 decimal digits, the
maximum for fraction
is 99
.
Examples
iex> SoftBank.Cldr.Money.put_fraction Money.new(:USD, "2.49"), 99
#Money<:USD, 2.99>
iex> SoftBank.Cldr.Money.put_fraction Money.new(:USD, "2.49"), 0
#Money<:USD, 2.0>
iex> SoftBank.Cldr.Money.put_fraction Money.new(:USD, "2.49"), 999
{:error,
{Money.InvalidAmountError, "Rounding up to 999 is invalid for currency :USD"}}