hledger-lib-1.12: Core data types, parsers and functionality for the hledger accounting tools

Safe HaskellNone
LanguageHaskell2010

Hledger.Data.TransactionModifier

Description

A TransactionModifier is a rule that modifies certain Transactions, typically adding automated postings to them.

Synopsis

Documentation

transactionModifierToFunction :: TransactionModifier -> Transaction -> Transaction Source #

Converts a TransactionModifier to a Transaction-transforming function, which applies the modification(s) specified by the TransactionModifier. Currently this means adding automated postings when certain other postings are present. The postings of the transformed transaction will reference it in the usual way (ie, txnTieKnot is called).

>>> putStr $ showTransaction $ transactionModifierToFunction (TransactionModifier "" ["pong" `post` usd 2]) nulltransaction{tpostings=["ping" `post` usd 1]}
0000/01/01
    ping           $1.00
    pong           $2.00

>>> putStr $ showTransaction $ transactionModifierToFunction (TransactionModifier "miss" ["pong" `post` usd 2]) nulltransaction{tpostings=["ping" `post` usd 1]}
0000/01/01
    ping           $1.00

>>> putStr $ showTransaction $ transactionModifierToFunction (TransactionModifier "ping" ["pong" `post` amount{amultiplier=True, aquantity=3}]) nulltransaction{tpostings=["ping" `post` usd 2]}
0000/01/01
    ping           $2.00
    pong           $6.00