HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Modulehledger-lib-1.52.4GHC2021

Hledger.Data.PeriodicTransaction

A PeriodicTransaction is a rule describing recurring transactions.

  • 2 values
  • Packagehledger-lib-1.52.4
  • Exports2
  • LanguageGHC2021
  • LicenceGPL-3.0-or-later
  • SourcePeriodicTransaction.hs

Generate transactions from PeriodicTransaction within a DateSpan. This should be a closed span with both start and end dates specified; an open ended span will generate no transactions.

Note that new transactions require txnTieKnot post-processing. The new transactions will have three tags added: - a recur:PERIODICEXPR tag whose value is the generating periodic expression - a generated-transaction: tag - a hidden _generated-transaction: tag which does not appear in the comment.

Example2 expressions
import Data.Time (fromGregorian)_ptgen "monthly from 2017/1 to 2017/4"2017-01-01    ; generated-transaction: ~ monthly from 2017/1 to 2017/4    a           $1.002017-02-01    ; generated-transaction: ~ monthly from 2017/1 to 2017/4    a           $1.002017-03-01    ; generated-transaction: ~ monthly from 2017/1 to 2017/4    a           $1.00
Example1 expression
_ptgen "monthly from 2017/1 to 2017/5"2017-01-01    ; generated-transaction: ~ monthly from 2017/1 to 2017/5    a           $1.002017-02-01    ; generated-transaction: ~ monthly from 2017/1 to 2017/5    a           $1.002017-03-01    ; generated-transaction: ~ monthly from 2017/1 to 2017/5    a           $1.002017-04-01    ; generated-transaction: ~ monthly from 2017/1 to 2017/5    a           $1.00
Example1 expression
_ptgen "every 2nd day of month from 2017/02 to 2017/04"2017-02-02    ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04    a           $1.002017-03-02    ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04    a           $1.00
Example1 expression
_ptgen "every 30th day of month from 2017/1 to 2017/5"2017-01-30    ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5    a           $1.002017-02-28    ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5    a           $1.002017-03-30    ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5    a           $1.002017-04-30    ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5    a           $1.00
Example1 expression
_ptgen "every 2nd Thursday of month from 2017/1 to 2017/4"2017-01-12    ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4    a           $1.002017-02-09    ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4    a           $1.002017-03-09    ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4    a           $1.00
Example1 expression
_ptgen "every nov 29th from 2017 to 2019"2017-11-29    ; generated-transaction: ~ every nov 29th from 2017 to 2019    a           $1.002018-11-29    ; generated-transaction: ~ every nov 29th from 2017 to 2019    a           $1.00
Example1 expression
_ptgen "2017/1"2017-01-01    ; generated-transaction: ~ 2017/1    a           $1.00
Example1 expression
let reportperiod="daily from 2018/01/03" in let (i,s) = parsePeriodExpr' nulldate reportperiod in runPeriodicTransaction True (nullperiodictransaction{ptperiodexpr=reportperiod, ptspan=s, ptinterval=i, ptpostings=["a" `post` usd 1]}) (DateSpan (Just $ Flex $ fromGregorian 2018 01 01) (Just $ Flex $ fromGregorian 2018 01 03))[]
Example1 expression
_ptgenspan "every 3 months from 2019-05" (DateSpan (Just $ Flex $ fromGregorian 2020 01 01) (Just $ Flex $ fromGregorian 2020 02 01))
Example3 expressions
_ptgenspan "every 3 months from 2019-05" (DateSpan (Just $ Flex $ fromGregorian 2020 02 01) (Just $ Flex $ fromGregorian 2020 03 01))2020-02-01    ; generated-transaction: ~ every 3 months from 2019-05    a           $1.00_ptgenspan "every 3 days from 2018" (DateSpan (Just $ Flex $ fromGregorian 2018 01 01) (Just $ Flex $ fromGregorian 2018 01 05))2018-01-01    ; generated-transaction: ~ every 3 days from 2018    a           $1.002018-01-04    ; generated-transaction: ~ every 3 days from 2018    a           $1.00_ptgenspan "every 3 days from 2018" (DateSpan (Just $ Flex $ fromGregorian 2018 01 02) (Just $ Flex $ fromGregorian 2018 01 05))2018-01-04    ; generated-transaction: ~ every 3 days from 2018    a           $1.00

Orphan instances

1 instance