diff options
author | Joris | 2015-09-06 23:49:10 +0200 |
---|---|---|
committer | Joris | 2015-09-06 23:49:10 +0200 |
commit | bb7e0a46882bca0b5cb36c09f531a83759d95cb4 (patch) | |
tree | 2ce39ffc86f6ec6b18fe3ce1662c3c567bc30c1e /src/server/MonthlyPaymentJob.hs | |
parent | 53afb9c96904ab226ccee754419569da16c59871 (diff) | |
download | budget-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.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 |