aboutsummaryrefslogtreecommitdiff
path: root/src/server/Controller
diff options
context:
space:
mode:
authorJoris2015-09-06 00:05:50 +0200
committerJoris2015-09-06 00:05:50 +0200
commit24633871359ec9fbd63fdfebf79a6351b2792f77 (patch)
treea87c8a964a3c5114da13e622c604cf99ab905a06 /src/server/Controller
parent8c328987901973cd0ffd2e03cae547717ebbbc67 (diff)
Can add monthly payments, not visible at the moment though, just the count is printed
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
)