Always show at least 2 decimal places for USD values

pull/202/head
jimmay5469 7 years ago
parent 0d49aea1f0
commit 6281b74e6f
  1. 6
      apps/explorer_web/lib/explorer_web/views/currency_helpers.ex

@ -14,10 +14,10 @@ defmodule ExplorerWeb.CurrencyHelpers do
## Examples
iex> format_usd_value(%USD{value: Decimal.new(5)})
"$5 USD"
"$5.00 USD"
iex> format_usd_value(%USD{value: Decimal.new(5000)})
"$5,000 USD"
"$5,000.00 USD"
iex> format_usd_value(%USD{value: Decimal.new(0.000005)})
"$0.000005 USD"
@ -28,7 +28,7 @@ defmodule ExplorerWeb.CurrencyHelpers do
def format_usd_value(%USD{value: nil}), do: nil
def format_usd_value(%USD{value: value}) do
case Number.to_string(value, format: "#,##0.##################") do
case Number.to_string(value, format: "#,##0.00################") do
{:ok, formatted} -> "$#{formatted} " <> gettext("USD")
_ -> nil
end

Loading…
Cancel
Save