blob: ba24cca62c2116fcb2014dbd620a2d23d8ea19ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
module Job.MonthlyPayment
( monthlyPayment
) where
import Data.Time.Clock (UTCTime, getCurrentTime)
import Common.Model (Frequency(..), Payment(..))
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
|