aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Stat/View.elm
diff options
context:
space:
mode:
authorJoris2016-04-08 09:46:34 +0200
committerJoris2016-04-08 09:46:34 +0200
commit06ccc38b65f0f4da2046ac97de447cd1ad061425 (patch)
treefa39341fd3b054603c6ca3ac4a7b01650dfb9a2e /src/client/elm/LoggedIn/Stat/View.elm
parent6541fa5316816d6f97a87a370775cfe278e7eeb8 (diff)
downloadbudget-06ccc38b65f0f4da2046ac97de447cd1ad061425.tar.gz
budget-06ccc38b65f0f4da2046ac97de447cd1ad061425.tar.bz2
budget-06ccc38b65f0f4da2046ac97de447cd1ad061425.zip
Add total payment partition
Diffstat (limited to 'src/client/elm/LoggedIn/Stat/View.elm')
-rw-r--r--src/client/elm/LoggedIn/Stat/View.elm37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/client/elm/LoggedIn/Stat/View.elm b/src/client/elm/LoggedIn/Stat/View.elm
index 6661a75..573d5bc 100644
--- a/src/client/elm/LoggedIn/Stat/View.elm
+++ b/src/client/elm/LoggedIn/Stat/View.elm
@@ -3,6 +3,8 @@ module LoggedIn.Stat.View
) where
import Date exposing (Month)
+import Dict
+import String
import Html exposing (..)
import Html.Attributes exposing (..)
@@ -17,6 +19,9 @@ import LoggedIn.View.Format as Format
import LoggedIn.View.Date as Date
import View.Plural exposing (plural)
+import LoggedIn.View.Format as Format
+
+import Utils.Tuple as Tuple
view : LoggedData -> Html
view loggedData =
@@ -40,22 +45,30 @@ paymentsDetail loggedData payments =
]
, li
[]
- [ text (paymentsSum loggedData.conf payments) ]
- , li
- []
- [ text "Par utilisateur:"
- , totalPayments loggedData
+ [ text (paymentsSum loggedData.conf payments)
+ , text " − "
+ , text <| totalPayments loggedData
]
]
-totalPayments : LoggedData -> Html
+totalPayments : LoggedData -> String
totalPayments loggedData =
- ul
- []
- [ li [] [ text "Jacques: 1 300€" ]
- , li [] [ text "Anne: 2 500 €" ]
- ]
-
+ String.join
+ ", "
+ ( loggedData.users
+ |> Dict.toList
+ |> List.map (Tuple.mapFst (\userId -> Payment.totalPayments (always True) userId loggedData.payments))
+ |> List.sortBy fst
+ |> List.map (\(sum, user) ->
+ String.concat
+ [ Format.price loggedData.conf sum
+ , " "
+ , getMessage "By" loggedData.translations
+ , " "
+ , user.name
+ ]
+ )
+ )
monthsDetail : LoggedData -> Html
monthsDetail loggedData =