diff options
Diffstat (limited to 'src/client/elm/Model/Payment.elm')
-rw-r--r-- | src/client/elm/Model/Payment.elm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/client/elm/Model/Payment.elm b/src/client/elm/Model/Payment.elm index 31aba1d..80579e2 100644 --- a/src/client/elm/Model/Payment.elm +++ b/src/client/elm/Model/Payment.elm @@ -7,6 +7,7 @@ module Model.Payment , paymentIdDecoder , deletePayment , PaymentFrequency(..) + , totalPayments ) where import Date exposing (..) @@ -49,3 +50,10 @@ paymentIdDecoder = Json.int deletePayment : PaymentId -> Payments -> Payments deletePayment paymentId = List.filter (((/=) paymentId) << .id) + +totalPayments : (Payment -> Bool) -> UserId -> Payments -> Int +totalPayments paymentFilter userId payments = + payments + |> List.filter (\payment -> paymentFilter payment && payment.userId == userId) + |> List.map .cost + |> List.sum |