blob: 8c11ccf28da8c87ba64c76456507293829d2736b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
module Job.MonthlyPayment
( monthlyPayment
) where
import Data.Time.Clock (UTCTime, getCurrentTime)
import Model.Frequency
import qualified Model.Payment as Payment
import Utils.Time (timeToDay)
import qualified Model.Query as Query
monthlyPayment :: Maybe UTCTime -> IO UTCTime
monthlyPayment _ = do
monthlyPayments <- Query.run Payment.listMonthly
now <- getCurrentTime
actualDay <- timeToDay now
let punctualPayments = map (\p -> p { Payment.frequency = Punctual, Payment.date = actualDay, Payment.createdAt = now }) monthlyPayments
_ <- Query.run (Payment.createMany punctualPayments)
return now
|