aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Update
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Update')
-rw-r--r--src/client/elm/Update/LoggedIn.elm18
-rw-r--r--src/client/elm/Update/LoggedIn/AddPayment.elm1
-rw-r--r--src/client/elm/Update/LoggedIn/Monthly.elm4
3 files changed, 15 insertions, 8 deletions
diff --git a/src/client/elm/Update/LoggedIn.elm b/src/client/elm/Update/LoggedIn.elm
index ca4690b..704dd7f 100644
--- a/src/client/elm/Update/LoggedIn.elm
+++ b/src/client/elm/Update/LoggedIn.elm
@@ -44,12 +44,18 @@ updateLoggedIn model action loggedInView =
}
ToggleEdit id ->
{ loggedInView | paymentEdition = if loggedInView.paymentEdition == Just id then Nothing else Just id }
- DeletePayment payment ->
- { loggedInView
- | account = updateAccount (UpdatePayer payment.userId (Date.toTime payment.creation) -payment.cost) loggedInView.account
- , payments = deletePayment payment.id loggedInView.payments
- , paymentsCount = loggedInView.paymentsCount - 1
- }
+ DeletePayment payment frequency ->
+ case frequency of
+ Monthly ->
+ { loggedInView
+ | monthly = updateMonthly (Monthly.DeletePayment payment) loggedInView.monthly
+ }
+ Punctual ->
+ { loggedInView
+ | account = updateAccount (UpdatePayer payment.userId (Date.toTime payment.creation) -payment.cost) loggedInView.account
+ , payments = deletePayment payment.id loggedInView.payments
+ , paymentsCount = loggedInView.paymentsCount - 1
+ }
UpdatePage page ->
{ loggedInView
| currentPage = page
diff --git a/src/client/elm/Update/LoggedIn/AddPayment.elm b/src/client/elm/Update/LoggedIn/AddPayment.elm
index 62eda85..978980d 100644
--- a/src/client/elm/Update/LoggedIn/AddPayment.elm
+++ b/src/client/elm/Update/LoggedIn/AddPayment.elm
@@ -4,6 +4,7 @@ module Update.LoggedIn.AddPayment
import Model.Action.AddPaymentAction exposing (..)
import Model.View.LoggedIn.AddPayment exposing (..)
+import Model.Payment exposing (PaymentFrequency(..))
updateAddPayment : AddPaymentAction -> AddPayment -> AddPayment
updateAddPayment action addPayment =
diff --git a/src/client/elm/Update/LoggedIn/Monthly.elm b/src/client/elm/Update/LoggedIn/Monthly.elm
index 2505091..3741e1f 100644
--- a/src/client/elm/Update/LoggedIn/Monthly.elm
+++ b/src/client/elm/Update/LoggedIn/Monthly.elm
@@ -15,7 +15,7 @@ updateMonthly action monthly =
| payments = payment :: monthly.payments
, visibleDetail = True
}
- DeletePayment id ->
+ DeletePayment payment ->
{ monthly
- | payments = List.filter (\payment -> payment.id /= id) monthly.payments
+ | payments = List.filter (((/=) payment.id) << .id) monthly.payments
}