blob: 78260988b3fd0ecc1eafa0d11bbcc949c1db0960 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
module Update.Payment
( PaymentAction(..)
, updatePayment
) where
import Date
import Model exposing (Model)
import Model.Payment exposing (..)
import Model.View.PaymentView exposing (..)
import Model.View.Payment.Add exposing (..)
import Update.Payment.Add exposing (..)
type PaymentAction =
UpdateAdd AddPaymentAction
| UpdatePayments Payments
| AddPayment String String Int
updatePayment : Model -> PaymentAction -> PaymentView -> PaymentView
updatePayment model action paymentView =
case action of
UpdateAdd addPaymentAction ->
{ paymentView | add <- updateAddPayment addPaymentAction paymentView.add }
UpdatePayments payments ->
{ paymentView | payments <- payments }
AddPayment id name cost ->
let payment =
{ id = id
, creation = Date.fromTime model.currentTime
, name = name
, cost = cost
, userName = paymentView.userName
}
in { paymentView
| payments <- payment :: paymentView.payments
, add <- initAddPayment
}
|