aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model/Income.elm
diff options
context:
space:
mode:
authorJoris2016-04-07 23:58:23 +0200
committerJoris2016-04-07 23:58:23 +0200
commit6541fa5316816d6f97a87a370775cfe278e7eeb8 (patch)
tree733c7136776d652db2711fad2d8427d70136bccf /src/client/elm/Model/Income.elm
parentf101c20c9da59c8c644d3cb6fa0b1d08f63e40e4 (diff)
downloadbudget-6541fa5316816d6f97a87a370775cfe278e7eeb8.tar.gz
budget-6541fa5316816d6f97a87a370775cfe278e7eeb8.tar.bz2
budget-6541fa5316816d6f97a87a370775cfe278e7eeb8.zip
Add cumulative incomes by user
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)