>>>>> Simon Michael (sm) <[email protected]> writes:

> With a similar need, I made
> http://hledger.org/MANUAL.html#account-aliases. Copied from ledger but
> improved I think . They wouldn't handle your more complex cases, but they
> are simple and can do a fair amount. They interact well with include.

I've thought about this request a lot, and I think many things can already be
accomplished today, using Python.

To summarize, an automated transaction predicate matches *postings*, and at
present let's you do two things with those postings natively:

 1. Add a new posting within the matched posting's transaction, with the
    amount (optionally) based on the matched posting's amount and account.

 2. Add or modify metadata for the matched posting.

Note that metadata will soon be able to override any standard field within a
posting or transaction.  In fact, you can already override the Payee *for the
matched posting*:

    = some query predicate
        ; Payee: Custom payee for the matched posting

Further, you can use the 'check' directive in an automated transaction, which
expects a value expression returning a bool.  If it returns true, nothing is
reported to the output *but that expression could still have side-effects*.
For example:

    python
        def change_amount(post):
            post.amount = Amount("$100.00")
            return True

    = some query predicate
        check change_amount(post)

I think the only other behavior we'd need a new directive for would be to
actually delete the matched posting from it's transaction:

    = some query predicate
        remove                      ; drops the posting in a safe way

So, this feature request is already 98% of the way there, if you're willing to
use the Python bridge to write your manipulation functions.


Lastly, Ledger's alias directive differs from hledger in the following ways:

 1. Ledger has no --alias option

 2. Ledger has no end aliases directive

John

Reply via email to