aboutsummaryrefslogtreecommitdiff
path: root/server/src/Controller/Payment.hs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/Controller/Payment.hs')
-rw-r--r--server/src/Controller/Payment.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/server/src/Controller/Payment.hs b/server/src/Controller/Payment.hs
index fb7fcb2..e82fd49 100644
--- a/server/src/Controller/Payment.hs
+++ b/server/src/Controller/Payment.hs
@@ -10,6 +10,7 @@ import qualified Network.HTTP.Types.Status as Status
import Web.Scotty
import Common.Model (CreatePayment (..),
+ CreatedPayment (..),
EditPayment (..), PaymentId,
User (..))
import qualified Model.Query as Query
@@ -30,8 +31,9 @@ create createPayment@(CreatePayment name cost date category frequency) =
case CreatePaymentValidation.validate createPayment of
Nothing ->
(liftIO . Query.run $ do
- PaymentCategoryPersistence.save name category
- PaymentPersistence.create (_user_id user) name cost date frequency
+ pc <- PaymentCategoryPersistence.save name category
+ p <- PaymentPersistence.create (_user_id user) name cost date frequency
+ return $ CreatedPayment p pc
) >>= json
Just validationError ->
do