aboutsummaryrefslogtreecommitdiff
path: root/src/server/MonthlyPaymentJob.hs
diff options
context:
space:
mode:
authorJoris2015-09-06 23:49:10 +0200
committerJoris2015-09-06 23:49:10 +0200
commitbb7e0a46882bca0b5cb36c09f531a83759d95cb4 (patch)
tree2ce39ffc86f6ec6b18fe3ce1662c3c567bc30c1e /src/server/MonthlyPaymentJob.hs
parent53afb9c96904ab226ccee754419569da16c59871 (diff)
downloadbudget-bb7e0a46882bca0b5cb36c09f531a83759d95cb4.tar.gz
budget-bb7e0a46882bca0b5cb36c09f531a83759d95cb4.tar.bz2
budget-bb7e0a46882bca0b5cb36c09f531a83759d95cb4.zip
Simplifying paymentJob
Diffstat (limited to 'src/server/MonthlyPaymentJob.hs')
-rw-r--r--src/server/MonthlyPaymentJob.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/server/MonthlyPaymentJob.hs b/src/server/MonthlyPaymentJob.hs
index a3be375..f9d89c0 100644
--- a/src/server/MonthlyPaymentJob.hs
+++ b/src/server/MonthlyPaymentJob.hs
@@ -8,11 +8,12 @@ import Data.Time.Calendar
import Control.Concurrent (threadDelay)
+import Database.Persist (entityVal, insert)
+
import Model.Database
-import Model.Payment (createPayment, getMonthlyPayments)
+import Model.Payment (getMonthlyPayments)
import Model.JobKind
import Model.Job
-import Model.Json.Payment as P
import Model.Frequency
monthlyPaymentJobListener :: IO ()
@@ -29,9 +30,9 @@ monthlyPaymentJobListener = do
monthlyJob :: Persist ()
monthlyJob = do
- monthlyPayments <- getMonthlyPayments
- _ <- sequence $ map (\p -> createPayment (P.userId p) (P.name p) (P.cost p) Punctual) monthlyPayments
- return ()
+ monthlyPayments <- map entityVal <$> getMonthlyPayments
+ let punctualPayments = map (\p -> p { paymentFrequency = Punctual }) monthlyPayments
+ sequence_ $ map insert punctualPayments
belongToCurrentMonth :: UTCTime -> IO Bool
belongToCurrentMonth time = do