PTAX (ptax v0.2.0)

Agrega funções de listagem e conversão de moedas suportadas

Link to this section Summary

Functions

Converte um valor de uma moeda para outra

Semelhante a converter/2, mas gera um erro se o valor não puder ser convertido.

Link to this section Types

Link to this type

converter_opts()

Specs

converter_opts() :: [
  de: PTAX.Conversor.moeda(),
  para: PTAX.Conversor.moeda(),
  data: Date.t() | nil,
  operacao: PTAX.Conversor.operacao() | nil,
  tipo_boletim: PTAX.Cotacao.Boletim.t() | nil
]

Link to this section Functions

Link to this function

converter(valor, opts)

Specs

converter(
  valor :: PTAX.Conversor.valor(),
  opts :: converter_opts() | PTAX.Conversor.opts()
) :: {:ok, Decimal.t()} | {:error, PTAX.Error.t()}

Converte um valor de uma moeda para outra

Exemplo

iex> PTAX.converter(5, de: :USD, para: :BRL, data: ~D[2021-12-24], operacao: :compra, tipo_boletim: PTAX.Cotacao.Boletim.Fechamento)
{:ok, #Decimal<28.2705>}
Link to this function

converter!(valor, opts)

Specs

converter!(
  valor :: PTAX.Conversor.valor(),
  opts :: converter_opts() | PTAX.Conversor.opts()
) :: Decimal.t()

Semelhante a converter/2, mas gera um erro se o valor não puder ser convertido.

Exemplo

iex> PTAX.converter!(5, de: :USD, para: :BRL, data: ~D[2021-12-24], operacao: :compra, tipo_boletim: PTAX.Cotacao.Boletim.Fechamento)
#Decimal<28.2705>

Specs

moedas() :: [PTAX.Moeda.t()] | {:error, PTAX.Error.t()}

See PTAX.Moeda.list/0.