aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn
diff options
context:
space:
mode:
authorJoris2016-04-04 23:59:23 +0200
committerJoris2016-04-04 23:59:23 +0200
commitd19b69eeeb0c24ee7e4a75b0da32eefba1d43928 (patch)
treed56e30026a9c490f3c77fc1c7d3e315a7dc0214b /src/client/elm/LoggedIn
parent8cd63a64abafe21378c35c2489d49f24c9ece3c9 (diff)
Begin cumulative income at first payment and not before
Diffstat (limited to 'src/client/elm/LoggedIn')
-rw-r--r--src/client/elm/LoggedIn/Home/Model/Payer.elm15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/client/elm/LoggedIn/Home/Model/Payer.elm b/src/client/elm/LoggedIn/Home/Model/Payer.elm
index aabe50a..be40ffa 100644
--- a/src/client/elm/LoggedIn/Home/Model/Payer.elm
+++ b/src/client/elm/LoggedIn/Home/Model/Payer.elm
@@ -40,9 +40,16 @@ getOrderedExceedingPayers currentTime users incomes payments =
|> mapValues .preIncomePaymentSum
|> Dict.toList
|> exceedingPayersFromAmounts
- in case incomeDefinedForAll (Dict.keys users) incomes of
- Just since ->
- let postPaymentPayers = mapValues (getPostPaymentPayer currentTime since) payers
+ firstPaymentTime =
+ payments
+ |> List.map (Date.toTime << .creation)
+ |> List.sort
+ |> List.head
+ incomesForAllTime = incomeDefinedForAll (Dict.keys users) incomes
+ in case (firstPaymentTime, incomesForAllTime) of
+ (Just paymentTime, Just incomeTime) ->
+ let since = max paymentTime incomeTime
+ postPaymentPayers = mapValues (getPostPaymentPayer currentTime since) payers
mbMaxRatio =
postPaymentPayers
|> Dict.toList
@@ -56,7 +63,7 @@ getOrderedExceedingPayers currentTime users incomes payments =
|> exceedingPayersFromAmounts
Nothing ->
exceedingPayersOnPreIncome
- Nothing ->
+ _ ->
exceedingPayersOnPreIncome
getPayers : Time -> Users -> Incomes -> Payments -> Payers