aboutsummaryrefslogtreecommitdiff
path: root/src/server/MonthlyPaymentJob.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/MonthlyPaymentJob.hs')
-rw-r--r--src/server/MonthlyPaymentJob.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/server/MonthlyPaymentJob.hs b/src/server/MonthlyPaymentJob.hs
index f5f6878..c4022c9 100644
--- a/src/server/MonthlyPaymentJob.hs
+++ b/src/server/MonthlyPaymentJob.hs
@@ -11,11 +11,11 @@ import Database.Persist (entityVal, insert)
import Job (jobListener)
import Model.Database
-import Model.Payment (getMonthlyPayments)
+import qualified Model.Payment as Payment
import Model.JobKind
import Model.Frequency
-import Utils.Time (belongToCurrentMonth)
+import Utils.Time (belongToCurrentMonth, timeToDay)
monthlyPaymentJobListener :: IO ()
monthlyPaymentJobListener =
@@ -26,7 +26,8 @@ monthlyPaymentJobListener =
monthlyPaymentJob :: Persist ()
monthlyPaymentJob = do
- monthlyPayments <- map entityVal <$> getMonthlyPayments
+ monthlyPayments <- map entityVal <$> Payment.listMonthly
now <- liftIO $ getCurrentTime
- let punctualPayments = map (\p -> p { paymentFrequency = Punctual, paymentCreation = now }) monthlyPayments
+ actualDay <- liftIO $ timeToDay now
+ let punctualPayments = map (\p -> p { paymentFrequency = Punctual, paymentDate = actualDay, paymentCreatedAt = now }) monthlyPayments
sequence_ $ map insert punctualPayments