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 }