Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides utilities for applying automated transactions like
ModifierTransaction
and PeriodicTransaction
.
- runModifierTransaction :: Query -> ModifierTransaction -> Transaction -> Transaction
- runPeriodicTransaction :: PeriodicTransaction -> DateSpan -> [Transaction]
- mtvaluequery :: ModifierTransaction -> Day -> Query
- jdatespan :: Journal -> DateSpan
Transaction processors
runModifierTransaction :: Query -> ModifierTransaction -> Transaction -> Transaction Source #
Builds a Transaction
transformer based on ModifierTransaction
.
Query
parameter allows injection of additional restriction on posting
match. Don't forget to call txnTieKnot
.
>>>
runModifierTransaction Any (ModifierTransaction "" ["pong" `post` usd 2]) nulltransaction{tpostings=["ping" `post` usd 1]}
0000/01/01 ping $1.00 pong $2.00>>>
runModifierTransaction Any (ModifierTransaction "miss" ["pong" `post` usd 2]) nulltransaction{tpostings=["ping" `post` usd 1]}
0000/01/01 ping $1.00>>>
runModifierTransaction None (ModifierTransaction "" ["pong" `post` usd 2]) nulltransaction{tpostings=["ping" `post` usd 1]}
0000/01/01 ping $1.00>>>
runModifierTransaction Any (ModifierTransaction "ping" ["pong" `post` amount{amultiplier=True, aquantity=3}]) nulltransaction{tpostings=["ping" `post` usd 2]}
0000/01/01 ping $2.00 pong $6.00
runPeriodicTransaction :: PeriodicTransaction -> DateSpan -> [Transaction] Source #
Generate transactions from PeriodicTransaction
within a DateSpan
Note that new transactions require txnTieKnot
post-processing.
>>>
mapM_ (putStr . show) $ runPeriodicTransaction (PeriodicTransaction "monthly from 2017/1 to 2017/4" ["hi" `post` usd 1]) nulldatespan
2017/01/01 hi $1.00 2017/02/01 hi $1.00 2017/03/01 hi $1.00
Accessors
mtvaluequery :: ModifierTransaction -> Day -> Query Source #
Extract Query
equivalent of mtvalueexpr
from ModifierTransaction
>>>
mtvaluequery (ModifierTransaction "" []) undefined
Any>>>
mtvaluequery (ModifierTransaction "ping" []) undefined
Acct "ping">>>
mtvaluequery (ModifierTransaction "date:2016" []) undefined
Date (DateSpan 2016)>>>
mtvaluequery (ModifierTransaction "date:today" []) (read "2017-01-01")
Date (DateSpan 2017/01/01)
jdatespan :: Journal -> DateSpan Source #
DateSpan
of all dates mentioned in Journal
>>>
jdatespan nulljournal
DateSpan ->>>
jdatespan nulljournal{jtxns=[nulltransaction{tdate=read "2016-01-01"}] }
DateSpan 2016/01/01>>>
jdatespan nulljournal{jtxns=[nulltransaction{tdate=read "2016-01-01", tpostings=[nullposting{pdate=Just $ read "2016-02-01"}]}] }
DateSpan 2016/01/01-2016/02/01