blob: 2d558fd399bc2e2fbcd09f60fb5016664b6d13ee (
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
|
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 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 name cost ->
let payment =
{ creation = Date.fromTime model.currentTime
, name = name
, cost = cost
, userName = paymentView.userName
}
in { paymentView
| payments <- payment :: paymentView.payments
, add <- initAddPayment
}
|