So… I was looking to do a PR for this, and I realized this feature already
exists — just under a different syntax. You were right John. What's needed
here may be an update to the documentation; not a code change.

The correct way to use expressions in the auto_xact account specification —
*without* the patches you provided — is in the ledger below

= ^Income
    Liabilities:Tax:%(tag(/Tax/))  (10/110)
    $account                       (-10/110)

2024-07-04 * Sale
    ; Tax: General
    Assets    10 USD
    Income:Customer A

I used this example to show that complex expressions also works. With this
accounts yields

Assets
Income:Customer A
Liabilities:Tax:General

Thank you!


*Igbanam*


On Fri, Jul 5, 2024 at 7:07 PM John Wiegley <jwieg...@gmail.com> wrote:

> >>>>> Igbanam Ogbuluijah <xigba...@gmail.com> writes:
>
> > Good stuff! Thanks for the pointer, John.
> >
> > I'll sit with this over the weekend and come up with a proposal on what
> the
> > feature-extension should look like. If we agree on that, I'll throw up an
> > issue on Github and try to tinker through.
>
> OK, here’s the “right” code: it accepts $expr — where expr can be any
> identifier — and evaluates this expression in the context of the account of
> the posting being matched against. Thus, $account and $account_base will
> have
> the same meaning, but now derived from actual evaluation rather than
> hard-coding the implementation of those two identifiers.
>
> The true completion of this feature would be to also support “$(expr)”,
> where
> nested parentheses are handled correctly, so that you can say
> “$(foo(123))”.
>
> John
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/CAOmRJrer94_gtE6JjsNu3Bm7UwW%3DLRDGiYFZJuhLa941bvQYEw%40mail.gmail.com.

Reply via email to