aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model/Income.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Model/Income.elm')
-rw-r--r--src/client/elm/Model/Income.elm8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/client/elm/Model/Income.elm b/src/client/elm/Model/Income.elm
index f364a8b..ea990e2 100644
--- a/src/client/elm/Model/Income.elm
+++ b/src/client/elm/Model/Income.elm
@@ -5,6 +5,7 @@ module Model.Income
, incomesDecoder
, incomeIdDecoder
, incomeDefinedForAll
+ , userCumulativeIncomeSince
, cumulativeIncomesSince
) where
@@ -55,6 +56,13 @@ incomeDefinedForAll userIds incomes =
then head << reverse << List.sort << map .creation << catMaybes <| firstIncomes
else Nothing
+userCumulativeIncomeSince : Time -> Time -> Incomes -> UserId -> Int
+userCumulativeIncomeSince currentTime since incomes userId =
+ incomes
+ |> Dict.values
+ |> List.filter (\income -> income.userId == userId)
+ |> cumulativeIncomesSince currentTime since
+
cumulativeIncomesSince : Time -> Time -> (List Income) -> Int
cumulativeIncomesSince currentTime since incomes =
cumulativeIncome currentTime (getOrderedIncomesSince since incomes)