From 24633871359ec9fbd63fdfebf79a6351b2792f77 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 6 Sep 2015 00:05:50 +0200 Subject: Can add monthly payments, not visible at the moment though, just the count is printed --- src/server/Controller/Payment.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/server/Controller/Payment.hs') diff --git a/src/server/Controller/Payment.hs b/src/server/Controller/Payment.hs index 0a40771..7944ecd 100644 --- a/src/server/Controller/Payment.hs +++ b/src/server/Controller/Payment.hs @@ -1,5 +1,6 @@ module Controller.Payment ( getPaymentsAction + , getMonthlyPaymentsAction , createPaymentAction , deletePaymentAction , getTotalPaymentsAction @@ -20,6 +21,7 @@ import qualified Secure import Model.Database import Model.Payment +import Model.Frequency import Model.Json.Message import Model.Json.Number import Model.Message @@ -28,14 +30,19 @@ import Model.Message.Key (Key(PaymentNotDeleted)) getPaymentsAction :: Int -> Int -> ActionM () getPaymentsAction page perPage = Secure.loggedAction (\_ -> do - payments <- liftIO $ runDb (getPayments page perPage) - json payments + (liftIO $ runDb (getPunctualPayments page perPage)) >>= json ) -createPaymentAction :: Text -> Int -> ActionM () -createPaymentAction name cost = +getMonthlyPaymentsAction :: ActionM () +getMonthlyPaymentsAction = Secure.loggedAction (\user -> do - _ <- liftIO . runDb $ createPayment (entityKey user) name cost + (liftIO $ runDb (getMonthlyPayments (entityKey user))) >>= json + ) + +createPaymentAction :: Text -> Int -> Frequency -> ActionM () +createPaymentAction name cost frequency = + Secure.loggedAction (\user -> do + _ <- liftIO . runDb $ createPayment (entityKey user) name cost frequency status ok200 ) -- cgit v1.2.3