diff options
author | Joris | 2016-06-04 11:02:43 +0200 |
---|---|---|
committer | Joris | 2016-06-04 11:02:43 +0200 |
commit | 38896af4281d2e191cbde15836a23e4c0274fff6 (patch) | |
tree | 0d7df152cc84beaa79cc9fa055db1e7992c4ac91 /src/client/elm/LoggedIn | |
parent | 9dfa7a7e2c6fac564a456b11623c04d0b26fbce5 (diff) |
Add mean payment by month
Diffstat (limited to 'src/client/elm/LoggedIn')
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Paging.elm | 13 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Table.elm | 6 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Stat/View.elm | 34 |
3 files changed, 38 insertions, 15 deletions
diff --git a/src/client/elm/LoggedIn/Home/View/Paging.elm b/src/client/elm/LoggedIn/Home/View/Paging.elm index b8d7db9..9166d23 100644 --- a/src/client/elm/LoggedIn/Home/View/Paging.elm +++ b/src/client/elm/LoggedIn/Home/View/Paging.elm @@ -2,7 +2,7 @@ module LoggedIn.Home.View.Paging exposing ( paymentsPaging ) -import Color +import Color exposing (Color) import FontAwesome @@ -60,7 +60,7 @@ firstPage homeModel = ] , onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| 1) ] - [ FontAwesome.fast_backward Color.darkGrey 20 ] + [ FontAwesome.fast_backward grey 20 ] previousPage : HomeModel.Model -> Html Msg previousPage homeModel = @@ -71,7 +71,7 @@ previousPage homeModel = then (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| homeModel.currentPage - 1) else Msg.NoOp ] - [ FontAwesome.backward Color.darkGrey 20 ] + [ FontAwesome.backward grey 20 ] nextPage : HomeModel.Model -> Int -> Html Msg nextPage homeModel maxPage = @@ -82,7 +82,7 @@ nextPage homeModel maxPage = then (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| homeModel.currentPage + 1) else Msg.NoOp ] - [ FontAwesome.forward Color.darkGrey 20 ] + [ FontAwesome.forward grey 20 ] lastPage : HomeModel.Model -> Int -> Html Msg lastPage homeModel maxPage = @@ -90,7 +90,7 @@ lastPage homeModel maxPage = [ class "page" , onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| maxPage) ] - [ FontAwesome.fast_forward Color.darkGrey 20 ] + [ FontAwesome.fast_forward grey 20 ] paymentsPage : HomeModel.Model -> Int -> Html Msg paymentsPage homeModel page = @@ -106,3 +106,6 @@ paymentsPage homeModel page = else Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| page ] [ text (toString page) ] + +grey : Color +grey = Color.greyscale 0.35 diff --git a/src/client/elm/LoggedIn/Home/View/Table.elm b/src/client/elm/LoggedIn/Home/View/Table.elm index 7c8a800..a03faa2 100644 --- a/src/client/elm/LoggedIn/Home/View/Table.elm +++ b/src/client/elm/LoggedIn/Home/View/Table.elm @@ -37,10 +37,10 @@ headerLine : LoggedData -> Html Msg headerLine loggedData = div [ class "header" ] - [ div [ class "cell category" ] [ FontAwesome.shopping_cart Color.white 25 ] + [ div [ class "cell category" ] [ FontAwesome.shopping_cart Color.white 28 ] , div [ class "cell cost" ] [ text loggedData.conf.currency ] - , div [ class "cell user" ] [ FontAwesome.user Color.white 25 ] - , div [ class "cell date" ] [ FontAwesome.calendar Color.white 25 ] + , div [ class "cell user" ] [ FontAwesome.user Color.white 28 ] + , div [ class "cell date" ] [ FontAwesome.calendar Color.white 28 ] , div [ class "cell" ] [] ] diff --git a/src/client/elm/LoggedIn/Stat/View.elm b/src/client/elm/LoggedIn/Stat/View.elm index 77a32a0..bb1ec84 100644 --- a/src/client/elm/LoggedIn/Stat/View.elm +++ b/src/client/elm/LoggedIn/Stat/View.elm @@ -15,7 +15,7 @@ import Msg exposing (Msg) import Model.Payment as Payment exposing (Payments) import Model.Conf exposing (Conf) -import Model.Translations exposing (getMessage) +import Model.Translations exposing (getMessage, getParamMessage) import LoggedIn.View.Format as Format import LoggedIn.View.Date as Date @@ -24,6 +24,7 @@ import View.Plural exposing (plural) import LoggedIn.View.Format as Format import Utils.Tuple as Tuple +import Utils.List as List view : LoggedData -> Html Msg view loggedData = @@ -74,12 +75,31 @@ totalPayments loggedData = monthsDetail : LoggedData -> Html Msg monthsDetail loggedData = - ul - [] - ( Payment.punctual loggedData.payments - |> Payment.groupAndSortByMonth - |> List.map (monthDetail loggedData) - ) + let paymentsByMonth = + loggedData.payments + |> Payment.punctual + |> Payment.groupAndSortByMonth + monthPaymentMean = + paymentsByMonth + |> List.filter (\((month, year), _) -> + let currentDate = Date.fromTime loggedData.currentTime + in not (Date.month currentDate == month && Date.year currentDate == year) + ) + |> List.map (List.sum << List.map .cost << snd) + |> List.mean + in div + [] + [ div + [ class "mean" ] + [ text (getParamMessage [ Format.price loggedData.conf monthPaymentMean ] "Mean" loggedData.translations) + ] + , ul + [] + ( Payment.punctual loggedData.payments + |> Payment.groupAndSortByMonth + |> List.map (monthDetail loggedData) + ) + ] monthDetail : LoggedData -> ((Month, Int), Payments) -> Html Msg monthDetail loggedData ((month, year), payments) = |