aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Stat
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/LoggedIn/Stat')
-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