From 9ec84e3a20c767f6525639f58cd22715e302b88d Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 26 Jun 2016 12:31:24 +0200 Subject: Add an editable date field for punctual payment creation --- src/server/MonthlyPaymentJob.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/server/MonthlyPaymentJob.hs') 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 -- cgit v1.2.3