From 8c24464a4bd0a486cd0ddf846d3b5a323a7aaa9a Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 4 Oct 2015 20:48:32 +0200 Subject: Using incomes to compute a fair computation to designate the payer --- src/server/MonthlyPaymentJob.hs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/server/MonthlyPaymentJob.hs') diff --git a/src/server/MonthlyPaymentJob.hs b/src/server/MonthlyPaymentJob.hs index 1b331af..f5f6878 100644 --- a/src/server/MonthlyPaymentJob.hs +++ b/src/server/MonthlyPaymentJob.hs @@ -5,8 +5,6 @@ module MonthlyPaymentJob import Control.Monad.IO.Class (liftIO) import Data.Time.Clock -import Data.Time.LocalTime -import Data.Time.Calendar import Database.Persist (entityVal, insert) @@ -17,6 +15,8 @@ import Model.Payment (getMonthlyPayments) import Model.JobKind import Model.Frequency +import Utils.Time (belongToCurrentMonth) + monthlyPaymentJobListener :: IO () monthlyPaymentJobListener = let lastExecutionTooOld = fmap not . belongToCurrentMonth @@ -24,18 +24,6 @@ monthlyPaymentJobListener = msDelay = 1000000 * 60 * 60 in jobListener MonthlyPaymentJob lastExecutionTooOld runJob msDelay -belongToCurrentMonth :: UTCTime -> IO Bool -belongToCurrentMonth time = do - month <- getLocalMonth time - actualMonth <- getCurrentTime >>= getLocalMonth - return (month == actualMonth) - -getLocalMonth :: UTCTime -> IO Int -getLocalMonth time = do - timeZone <- getCurrentTimeZone - let (_, month, _) = toGregorian . localDay $ utcToLocalTime timeZone time - return month - monthlyPaymentJob :: Persist () monthlyPaymentJob = do monthlyPayments <- map entityVal <$> getMonthlyPayments -- cgit v1.2.3