diff options
author | Joris | 2016-01-02 22:19:40 +0100 |
---|---|---|
committer | Joris | 2016-01-02 22:19:40 +0100 |
commit | 25d15aacb940c2a19cae3b2e3d8d3ebd1972be02 (patch) | |
tree | 6a418a7a31b713a1d39bdb2da1f798ca07266fe1 /src/client/elm/Update | |
parent | 35493d8ec353f90a6ca67e2aedb702684e0abafa (diff) |
Merge AddPayment and AddMonthlyPayment
Diffstat (limited to 'src/client/elm/Update')
-rw-r--r-- | src/client/elm/Update/LoggedIn.elm | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/client/elm/Update/LoggedIn.elm b/src/client/elm/Update/LoggedIn.elm index 1553141..ca4690b 100644 --- a/src/client/elm/Update/LoggedIn.elm +++ b/src/client/elm/Update/LoggedIn.elm @@ -25,22 +25,23 @@ updateLoggedIn model action loggedInView = { loggedInView | add = updateAddPayment addPaymentAction loggedInView.add } UpdatePayments payments -> { loggedInView | payments = payments } - AddPayment paymentId name cost -> + AddPayment paymentId name cost frequency -> let newPayment = Payment paymentId (Date.fromTime model.currentTime) name cost loggedInView.account.me - in { loggedInView - | currentPage = 1 - , add = initAddPayment Punctual - , account = updateAccount (UpdatePayer loggedInView.account.me model.currentTime cost) loggedInView.account - , payments = newPayment :: loggedInView.payments - , paymentsCount = loggedInView.paymentsCount + 1 - } - AddMonthlyPayment id name cost -> - { loggedInView - | add = initAddPayment Monthly - , monthly = - let payment = Payment id (Date.fromTime model.currentTime) name cost loggedInView.account.me - in updateMonthly (Monthly.AddPayment payment) loggedInView.monthly - } + newAdd = initAddPayment frequency + in if frequency == Punctual + then + { loggedInView + | currentPage = 1 + , add = newAdd + , account = updateAccount (UpdatePayer loggedInView.account.me model.currentTime cost) loggedInView.account + , payments = newPayment :: loggedInView.payments + , paymentsCount = loggedInView.paymentsCount + 1 + } + else + { loggedInView + | add = newAdd + , monthly = updateMonthly (Monthly.AddPayment newPayment) loggedInView.monthly + } ToggleEdit id -> { loggedInView | paymentEdition = if loggedInView.paymentEdition == Just id then Nothing else Just id } DeletePayment payment -> |