Money.cross_rate
You're seeing just the function
cross_rate
, go back to Money module for more information.
Specs
cross_rate( t() | currency_code(), currency_code(), Money.ExchangeRates.t() | {:ok, Money.ExchangeRates.t()} ) :: {:ok, Decimal.t()} | {:error, {module(), String.t()}}
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
Money.cross_rate(Money.new(:USD, 100), :AUD, %{USD: Decimal.new(1), AUD: Decimal.new("0.7345")})
{:ok, #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