aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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