aboutsummaryrefslogtreecommitdiff
path: root/src/client/Update
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Update')
-rw-r--r--src/client/Update/Payment.elm12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/client/Update/Payment.elm b/src/client/Update/Payment.elm
index 67331d6..53dc08a 100644
--- a/src/client/Update/Payment.elm
+++ b/src/client/Update/Payment.elm
@@ -4,9 +4,11 @@ module Update.Payment
) where
import Date
+import Dict
import Model exposing (Model)
import Model.Payment exposing (..)
+import Model.Payers exposing (..)
import Model.View.PaymentView exposing (..)
import Model.View.Payment.Add exposing (..)
@@ -36,8 +38,16 @@ updatePayment model action paymentView =
in { paymentView
| payments <- addPayment paymentView.payments (id, payment)
, add <- initAddPayment
+ , payers <- updatePayers paymentView.payers payment.userName payment.cost
}
ToggleEdit id ->
{ paymentView | edition <- if paymentView.edition == Just id then Nothing else Just id }
Remove id ->
- { paymentView | payments <- removePayment paymentView.payments id }
+ case Dict.get id paymentView.payments of
+ Just payment ->
+ { paymentView
+ | payments <- removePayment paymentView.payments id
+ , payers <- updatePayers paymentView.payers payment.userName -payment.cost
+ }
+ Nothing ->
+ paymentView