diff options
author | Joris | 2016-04-04 01:27:36 +0200 |
---|---|---|
committer | Joris | 2016-04-04 01:27:36 +0200 |
commit | 8cd63a64abafe21378c35c2489d49f24c9ece3c9 (patch) | |
tree | 541145481d1492f3e388002d931cb3f8fec0acb2 /src/client/elm/LoggedIn/View/Price.elm | |
parent | 01e4ce0fa7c369996ec4ef3a033d16d6fa0eb715 (diff) | |
download | budget-8cd63a64abafe21378c35c2489d49f24c9ece3c9.tar.gz budget-8cd63a64abafe21378c35c2489d49f24c9ece3c9.tar.bz2 budget-8cd63a64abafe21378c35c2489d49f24c9ece3c9.zip |
Add income list CRUD in user page
Diffstat (limited to 'src/client/elm/LoggedIn/View/Price.elm')
-rw-r--r-- | src/client/elm/LoggedIn/View/Price.elm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/client/elm/LoggedIn/View/Price.elm b/src/client/elm/LoggedIn/View/Price.elm new file mode 100644 index 0000000..2bfed23 --- /dev/null +++ b/src/client/elm/LoggedIn/View/Price.elm @@ -0,0 +1,37 @@ +module LoggedIn.View.Price + ( price + ) where + +import String exposing (..) + +import Model.Conf exposing (Conf) + +price : Conf -> Int -> String +price conf amount = + ( formatInt amount + ++ " " + ++ conf.currency + ) + +formatInt : Int -> String +formatInt n = + abs n + |> toString + |> toList + |> List.reverse + |> group 3 + |> List.intersperse [' '] + |> List.concat + |> List.reverse + |> fromList + |> append (if n < 0 then "-" else "") + +group : Int -> List a -> List (List a) +group n xs = + if List.length xs <= n + then + [xs] + else + let take = List.take n xs + drop = List.drop n xs + in take :: (group n drop) |