Money.cross_rate-exclamation-mark
You're seeing just the function
cross_rate-exclamation-mark
, go back to Money module for more information.
Link to this function
cross_rate!(from, to_currency, rates \\ Money.ExchangeRates.latest_rates())
View SourceSpecs
cross_rate!( t() | currency_code(), currency_code(), Money.ExchangeRates.t() | {:ok, Money.ExchangeRates.t()} ) :: Decimal.t() | no_return()
Returns the effective cross-rate to convert from one currency to another.
Arguments
from
is anyMoney.t
struct returned byCldr.Currency.new/2
or a valid currency codeto_currency
is a valid currency code into which themoney
is convertedrates
is aMap
of currency rates where the map key is an upcased atom or string and the value is a Decimal conversion factor. The default is the latest available exchange rates returned fromMoney.ExchangeRates.latest_rates()
Examples
iex> Money.cross_rate!(Money.new(:USD, 100), :AUD, %{USD: Decimal.new(1), AUD: Decimal.new("0.7345")})
#Decimal<0.7345>
iex> Money.cross_rate!(:USD, :AUD, %{USD: Decimal.new(1), AUD: Decimal.new("0.7345")})
#Decimal<0.7345>
Money.cross_rate Money.new(:USD, 100), :ZZZ, %{USD: Decimal.new(1), AUD: Decimal.new("0.7345")}
** (Cldr.UnknownCurrencyError) Currency :ZZZ is not known