aboutsummaryrefslogtreecommitdiff
path: root/src/client/Model/Payer.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Model/Payer.elm')
-rw-r--r--src/client/Model/Payer.elm11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/client/Model/Payer.elm b/src/client/Model/Payer.elm
index af475bb..9fd1bb5 100644
--- a/src/client/Model/Payer.elm
+++ b/src/client/Model/Payer.elm
@@ -46,7 +46,7 @@ updatePayers payers userId creation amountDiff =
case mbPayer of
Just payer ->
let postIncome =
- incomeDefinedForAll (Dict.toList << mapValues .incomes <| payers)
+ payersIncomeDefinedForAll payers
|> Maybe.map (\date -> creation > date)
|> Maybe.withDefault False
in if postIncome
@@ -65,13 +65,12 @@ type alias ExceedingPayer =
getOrderedExceedingPayers : Time -> Payers -> List ExceedingPayer
getOrderedExceedingPayers currentTime payers =
- let mbIncomeDefinedForAll = incomeDefinedForAll (Dict.toList << mapValues .incomes <| payers)
- exceedingPayersOnPreIncome =
+ let exceedingPayersOnPreIncome =
payers
|> mapValues .preIncomePaymentSum
|> Dict.toList
|> exceedingPayersFromAmounts
- in case mbIncomeDefinedForAll of
+ in case payersIncomeDefinedForAll payers of
Just since ->
let postPaymentPayers =
payers
@@ -92,6 +91,10 @@ getOrderedExceedingPayers currentTime payers =
Nothing ->
exceedingPayersOnPreIncome
+payersIncomeDefinedForAll : Payers -> Maybe Time
+payersIncomeDefinedForAll payers =
+ incomeDefinedForAll (List.map (.incomes << snd) << Dict.toList <| payers)
+
exceedingPayersFromAmounts : List (UserId, Int) -> List ExceedingPayer
exceedingPayersFromAmounts userAmounts =
let mbMinAmount = List.minimum << List.map snd <| userAmounts