Skip to content

Commit 09d442d

Browse files
committed
add compact formatter
1 parent 8411dbc commit 09d442d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/algora/shared/money_utils.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ defmodule Algora.MoneyUtils do
33
def fmt_precise(money), do: Money.to_string(money, no_fraction_if_integer: false)
44
def fmt_precise!(money), do: Money.to_string!(money, no_fraction_if_integer: false)
55

6+
def fmt_compact(money) do
7+
# TODO: handle other currencies
8+
"$" <> Algora.Util.format_number_compact(money.amount)
9+
end
10+
611
@spec split_evenly(Money.t(), non_neg_integer()) :: [Money.t()]
712
def split_evenly(_money, 0), do: []
813

0 commit comments

Comments
 (0)