aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/elm/LoggedIn/Income/View.elm2
-rw-r--r--src/client/elm/LoggedIn/Stat/View.elm37
-rw-r--r--src/client/elm/Model/Payer.elm13
-rw-r--r--src/server/Model/Message/Key.hs1
-rw-r--r--src/server/Model/Message/Translations.hs5
5 files changed, 38 insertions, 20 deletions
diff --git a/src/client/elm/LoggedIn/Income/View.elm b/src/client/elm/LoggedIn/Income/View.elm
index 9e77fde..0d6e02d 100644
--- a/src/client/elm/LoggedIn/Income/View.elm
+++ b/src/client/elm/LoggedIn/Income/View.elm
@@ -64,7 +64,7 @@ cumulativeIncomesView loggedData since =
li
[]
[ text userName
- , text ": "
+ , text " − "
, text <| Format.price loggedData.conf cumulativeIncome
]
)
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 =
diff --git a/src/client/elm/Model/Payer.elm b/src/client/elm/Model/Payer.elm
index a7ce5fa..72f13b1 100644
--- a/src/client/elm/Model/Payer.elm
+++ b/src/client/elm/Model/Payer.elm
@@ -4,7 +4,6 @@ module Model.Payer
, ExceedingPayer
, getOrderedExceedingPayers
, useIncomesFrom
- , getPostPaymentPayer
) where
import Json.Decode as Json exposing (..)
@@ -29,6 +28,12 @@ type alias Payer =
, incomes : List Income
}
+type alias PostPaymentPayer =
+ { preIncomePaymentSum : Int
+ , cumulativeIncome : Int
+ , ratio : Float
+ }
+
type alias ExceedingPayer =
{ userId : UserId
, amount : Int
@@ -118,12 +123,6 @@ exceedingPayersFromAmounts userAmounts =
)
|> List.filter (\payer -> payer.amount > 0)
-type alias PostPaymentPayer =
- { preIncomePaymentSum : Int
- , cumulativeIncome : Int
- , ratio : Float
- }
-
getPostPaymentPayer : Time -> Time -> Payer -> PostPaymentPayer
getPostPaymentPayer currentTime since payer =
let cumulativeIncome = cumulativeIncomesSince currentTime since payer.incomes
diff --git a/src/server/Model/Message/Key.hs b/src/server/Model/Message/Key.hs
index 43b8faa..6d48682 100644
--- a/src/server/Model/Message/Key.hs
+++ b/src/server/Model/Message/Key.hs
@@ -69,6 +69,7 @@ data Key =
| Statistics
| Overall
| ByMonths
+ | By
-- Income
diff --git a/src/server/Model/Message/Translations.hs b/src/server/Model/Message/Translations.hs
index d4e5454..e31d2df 100644
--- a/src/server/Model/Message/Translations.hs
+++ b/src/server/Model/Message/Translations.hs
@@ -262,6 +262,11 @@ m l ByMonths =
English -> "By months"
French -> "Par mois"
+m l By =
+ case l of
+ English -> "by"
+ French -> "par"
+
-- Income
m l CumulativeIncomesSince =