currency_formatter v0.4.3 CurrencyFormatter
This module takes care of formatting a number to a currency. You can also request a map containing all the formatting settings for a currency.
Summary
Functions
Formats a number to currency
Returns a map containing the full list of currencies
Returns a List with tuples that can be used as options for select
Returns a List with tuples that can be used as options for select
Returns a map with formatting settings for a currency
Returns the disambiguous symbol of a currency
Functions
Formats a number to currency
examples
iex> CurrencyFormatter.format(123456)
"US$1,234.56"
iex> CurrencyFormatter.format(654321, :eur)
"€6.543,21"
iex> CurrencyFormatter.format(654321, "AUD")
"A$6,543.21"
Returns a map containing the full list of currencies
examples
iex> currencies = CurrencyFormatter.get_currencies()
iex> Enum.count(currencies)
172
iex> currencies["usd"]
%{"alternate_symbols" => ["US$"], "decimal_mark" => ".",
"disambiguate_symbol" => "US$", "html_entity" => "$", "iso_code" => "USD",
"iso_numeric" => "840", "name" => "United States Dollar", "priority" => 1,
"smallest_denomination" => 1, "subunit" => "Cent", "subunit_to_unit" => 100,
"symbol" => "$", "symbol_first" => true, "thousands_separator" => ","}
Returns a List with tuples that can be used as options for select
Examples
CurrencyFormatter.get_currencies_for_select()
["AED", "AFN", "ALL",...]
Returns a List with tuples that can be used as options for select
Examples
CurrencyFormatter.get_currencies_for_select(:names)
[{"AED", "United Arab Emirates Dirham"}, {"AFN", "Afghan Afghani"} , {"ALL", "Albanian Lek"}, ...]
CurrencyFormatter.get_currencies_for_select(:symbols)
[{"AUD", "$"}, {"CAD", "$"}, {"USD", "$"},...]
CurrencyFormatter.get_currencies_for_select(:disambiguate_symbols)
[{"AUD", "A$"}, {"CAD", "C$"}, {"USD", "$"}, ...]
Returns a map with formatting settings for a currency
examples
iex> CurrencyFormatter.instructions(:EUR)
%{"alternate_symbols" => [], "decimal_mark" => ",", "html_entity" => "€",
"iso_code" => "EUR", "iso_numeric" => "978", "name" => "Euro", "priority" => 2,
"smallest_denomination" => 1, "subunit" => "Cent", "subunit_to_unit" => 100,
"symbol" => "€", "symbol_first" => true, "thousands_separator" => "."}