diff options
author | Joris | 2016-11-13 00:49:32 +0100 |
---|---|---|
committer | Joris | 2016-11-13 00:49:32 +0100 |
commit | 86a96decdb8892b10c5314eb916ef15a64204450 (patch) | |
tree | 6f41742d0466f77948680964188144fbff036902 /src/server/MonthlyPaymentJob.hs | |
parent | bf6a0a0b32a7efb88f75c2e89b84d6907aeb10bc (diff) |
Send weekly activity at start of week about previous week
Diffstat (limited to 'src/server/MonthlyPaymentJob.hs')
-rw-r--r-- | src/server/MonthlyPaymentJob.hs | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/server/MonthlyPaymentJob.hs b/src/server/MonthlyPaymentJob.hs deleted file mode 100644 index c4022c9..0000000 --- a/src/server/MonthlyPaymentJob.hs +++ /dev/null @@ -1,33 +0,0 @@ -module MonthlyPaymentJob - ( monthlyPaymentJobListener - ) where - -import Control.Monad.IO.Class (liftIO) - -import Data.Time.Clock - -import Database.Persist (entityVal, insert) - -import Job (jobListener) - -import Model.Database -import qualified Model.Payment as Payment -import Model.JobKind -import Model.Frequency - -import Utils.Time (belongToCurrentMonth, timeToDay) - -monthlyPaymentJobListener :: IO () -monthlyPaymentJobListener = - let lastExecutionTooOld = fmap not . belongToCurrentMonth - runJob () = monthlyPaymentJob - msDelay = 1000000 * 60 * 60 - in jobListener MonthlyPaymentJob lastExecutionTooOld runJob msDelay - -monthlyPaymentJob :: Persist () -monthlyPaymentJob = do - monthlyPayments <- map entityVal <$> Payment.listMonthly - now <- liftIO $ getCurrentTime - actualDay <- liftIO $ timeToDay now - let punctualPayments = map (\p -> p { paymentFrequency = Punctual, paymentDate = actualDay, paymentCreatedAt = now }) monthlyPayments - sequence_ $ map insert punctualPayments |