diff options
author | Joris | 2019-08-05 21:53:30 +0200 |
---|---|---|
committer | Joris | 2019-08-05 21:53:30 +0200 |
commit | bc81084933f8ec1bfe6c2834defd12243117fdd9 (patch) | |
tree | 116d5e8ccd5f234d7376f4f14c74657d7c7e4792 /server/src/Controller | |
parent | 2741f47ef7b87255203bc2f7f7b2b9140c70b8f0 (diff) |
Use updated payment categories from payment add in payment’s table
Diffstat (limited to 'server/src/Controller')
-rw-r--r-- | server/src/Controller/Payment.hs | 6 |
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 |