diff options
Diffstat (limited to 'src/server/MonthlyPaymentJob.hs')
-rw-r--r-- | src/server/MonthlyPaymentJob.hs | 11 |
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 |