aboutsummaryrefslogtreecommitdiff
path: root/src/client/View/Price.elm
diff options
context:
space:
mode:
authorJoris2015-09-12 23:57:16 +0200
committerJoris2015-09-12 23:57:16 +0200
commita48e79e2f7c1ab1ffb52b86ef9e900c75c5d023b (patch)
tree05a613aef2d338f10bcdd394e520450656ed8f1c /src/client/View/Price.elm
parentd87dbd1360c14df83552fd757438c23e5d7b9f9c (diff)
downloadbudget-a48e79e2f7c1ab1ffb52b86ef9e900c75c5d023b.tar.gz
budget-a48e79e2f7c1ab1ffb52b86ef9e900c75c5d023b.tar.bz2
budget-a48e79e2f7c1ab1ffb52b86ef9e900c75c5d023b.zip
Adding UI income read-only
Diffstat (limited to 'src/client/View/Price.elm')
-rw-r--r--src/client/View/Price.elm38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/client/View/Price.elm b/src/client/View/Price.elm
new file mode 100644
index 0000000..cb8abd2
--- /dev/null
+++ b/src/client/View/Price.elm
@@ -0,0 +1,38 @@
+module View.Price
+ ( price
+ ) where
+
+import String exposing (..)
+
+import Model exposing (Model)
+import Model.Translations exposing (getMessage)
+
+price : Model -> Int -> String
+price model amount =
+ ( formatInt amount
+ ++ " "
+ ++ getMessage "MoneySymbol" model.translations
+ )
+
+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)