aboutsummaryrefslogtreecommitdiff
path: root/src/client/Update
diff options
context:
space:
mode:
authorJoris2015-08-29 13:30:09 +0200
committerJoris2015-08-29 13:30:09 +0200
commit6b466f616035c2fc03359d182c074f096d6b7f17 (patch)
tree47708f2e96614d71059f98c757d6a3fe88c8b923 /src/client/Update
parentaa7f70d172be9ef322f9a0d19d1d9d9489f9fa75 (diff)
Showing exceeding payers
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