diff options
author | Joris | 2017-04-02 17:51:12 +0200 |
---|---|---|
committer | Joris | 2017-04-02 21:07:08 +0200 |
commit | 5c110716cfda6e616a795edd12f2012b132dca9f (patch) | |
tree | 71c3d04780302edf0648bec1cd914757cdbb2883 /src/client/Model/Payment.elm | |
parent | 64ff4707fdcd81c27c6be9903c3c82bc543ef016 (diff) |
Add a chart on payments by month by categories
Diffstat (limited to 'src/client/Model/Payment.elm')
-rw-r--r-- | src/client/Model/Payment.elm | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/client/Model/Payment.elm b/src/client/Model/Payment.elm index 2412ab9..204f9f5 100644 --- a/src/client/Model/Payment.elm +++ b/src/client/Model/Payment.elm @@ -20,10 +20,11 @@ import Date.Extra.Core exposing (monthToInt, intToMonth) import Json.Decode as Decode exposing (Decoder) import Json.Decode.Extra as Decode import List +import List.Extra as List import Form.Validate as Validate exposing (Validation) -import Model.Frequency as Frequency exposing (Frequency(..)) import Model.Date exposing (dateDecoder) +import Model.Frequency as Frequency exposing (Frequency(..)) import Model.User exposing (UserId, userIdDecoder) import Utils.List as List import Utils.Search as Search @@ -63,8 +64,7 @@ paymentIdDecoder = Decode.int find : PaymentId -> Payments -> Maybe Payment find paymentId payments = payments - |> List.filter (\p -> p.id == paymentId) - |> List.head + |> List.find (\p -> p.id == paymentId) edit : Payment -> Payments -> Payments edit payment payments = payment :: delete payment.id payments @@ -94,7 +94,6 @@ groupAndSortByMonth payments = |> List.groupBy (\payment -> (Date.year payment.date, monthToInt << Date.month <| payment.date)) |> List.sortBy Tuple.first |> List.map (\((year, month), payments) -> ((intToMonth month, year), payments)) - |> List.reverse search : String -> Frequency -> Payments -> Payments search name frequency payments = |