aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/elm/LoggedIn/Stat/View.elm15
-rw-r--r--src/client/elm/LoggedIn/View/Date.elm4
-rw-r--r--src/client/elm/Model/Payment.elm3
3 files changed, 15 insertions, 7 deletions
diff --git a/src/client/elm/LoggedIn/Stat/View.elm b/src/client/elm/LoggedIn/Stat/View.elm
index a289002..f4bc56c 100644
--- a/src/client/elm/LoggedIn/Stat/View.elm
+++ b/src/client/elm/LoggedIn/Stat/View.elm
@@ -2,6 +2,8 @@ module LoggedIn.Stat.View
( view
) where
+import Date exposing (Month)
+
import Html exposing (..)
import Html.Attributes exposing (..)
@@ -12,6 +14,7 @@ import Model.Conf exposing (Conf)
import Model.Translations exposing (getMessage)
import LoggedIn.View.Format as Format
+import LoggedIn.View.Date as Date
import View.Plural exposing (plural)
@@ -46,18 +49,18 @@ monthsDetail loggedData =
[]
( Payment.punctual loggedData.payments
|> Payment.groupAndSortByMonth
- |> List.map (monthDetail loggedData.conf)
+ |> List.map (monthDetail loggedData)
)
-monthDetail : Conf -> ((Int, Int), Payments) -> Html
-monthDetail conf ((year, month), payments) =
+monthDetail : LoggedData -> ((Month, Int), Payments) -> Html
+monthDetail loggedData ((month, year), payments) =
li
[]
- [ text (toString month)
- , text "/"
+ [ text (Date.renderMonth loggedData.translations month)
+ , text " "
, text (toString year)
, text " − "
- , text (paymentsSum conf payments)
+ , text (paymentsSum loggedData.conf payments)
]
paymentsSum : Conf -> Payments -> String
diff --git a/src/client/elm/LoggedIn/View/Date.elm b/src/client/elm/LoggedIn/View/Date.elm
index f9528d4..c9d44ab 100644
--- a/src/client/elm/LoggedIn/View/Date.elm
+++ b/src/client/elm/LoggedIn/View/Date.elm
@@ -1,6 +1,7 @@
module LoggedIn.View.Date
( renderShortDate
, renderLongDate
+ , renderMonth
) where
import Date exposing (..)
@@ -27,6 +28,9 @@ renderLongDate date translations =
]
in getParamMessage params "LongDate" translations
+renderMonth : Translations -> Month -> String
+renderMonth translations month = getMessage (getMonthKey month) translations
+
getMonthKey : Month -> String
getMonthKey month =
case month of
diff --git a/src/client/elm/Model/Payment.elm b/src/client/elm/Model/Payment.elm
index 69315a9..013fc95 100644
--- a/src/client/elm/Model/Payment.elm
+++ b/src/client/elm/Model/Payment.elm
@@ -86,9 +86,10 @@ punctual = List.filter ((==) Punctual << .frequency)
monthly : UserId -> Payments -> Payments
monthly userId = List.filter (\p -> p.frequency == Monthly && p.userId == userId)
-groupAndSortByMonth : Payments -> List ((Int, Int), Payments)
+groupAndSortByMonth : Payments -> List ((Month, Int), Payments)
groupAndSortByMonth payments =
payments
|> List.groupBy (\payment -> (Date.year payment.creation, Date.monthToNum << Date.month <| payment.creation))
|> List.sortBy fst
+ |> List.map (\((year, month), payments) -> ((Date.numToMonth month, year), payments))
|> List.reverse