aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn
diff options
context:
space:
mode:
authorJoris2016-04-06 14:28:16 +0200
committerJoris2016-04-06 14:28:16 +0200
commitac8a7c6210e2f430a3015e8004ff0726ef24d63b (patch)
tree0df4ccbef7fca622a0ee4e89d35b9ce7d2d6eb09 /src/client/elm/LoggedIn
parentd889c728c6ef1462fdeb56891de8d4d1a3df70c6 (diff)
Add payments by month in stat
Diffstat (limited to 'src/client/elm/LoggedIn')
-rw-r--r--src/client/elm/LoggedIn/Stat/View.elm31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/client/elm/LoggedIn/Stat/View.elm b/src/client/elm/LoggedIn/Stat/View.elm
index 3fe9d1f..a289002 100644
--- a/src/client/elm/LoggedIn/Stat/View.elm
+++ b/src/client/elm/LoggedIn/Stat/View.elm
@@ -37,25 +37,32 @@ paymentsDetail loggedData payments =
]
, li
[]
- [ payments
- |> List.map .cost
- |> List.sum
- |> Format.price loggedData.conf
- |> text
- ]
+ [ text (paymentsSum loggedData.conf payments) ]
]
monthsDetail : LoggedData -> Html
monthsDetail loggedData =
ul
[]
- []
+ ( Payment.punctual loggedData.payments
+ |> Payment.groupAndSortByMonth
+ |> List.map (monthDetail loggedData.conf)
+ )
-monthDetail : String -> Int -> Html
-monthDetail month amount =
+monthDetail : Conf -> ((Int, Int), Payments) -> Html
+monthDetail conf ((year, month), payments) =
li
[]
- [ text month
- , text " "
- , text (toString amount)
+ [ text (toString month)
+ , text "/"
+ , text (toString year)
+ , text " − "
+ , text (paymentsSum conf payments)
]
+
+paymentsSum : Conf -> Payments -> String
+paymentsSum conf payments =
+ payments
+ |> List.map .cost
+ |> List.sum
+ |> Format.price conf