aboutsummaryrefslogtreecommitdiff
path: root/src/server/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Controller')
-rw-r--r--src/server/Controller/Payment.hs17
1 files changed, 12 insertions, 5 deletions
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
)