I found one way that I think should work:

= "Liabilities:Apple Card" and %cashback
    Assets:Apple Cash           (-tag("cashback"))
    Income:Credit Card Rewards   (tag("cashback"))

2023/06/06 McDonalds
    ; cashback:: 0.02
    Expenses:Food:Restaurants                           $23.98
    Liabilities:Apple Card
2023/06/07 Transfer
    Liabilities:Apple Card                              $23.98
    Assets:Some bank

Mainly found by searching bugs
<https://github.com/ledger/ledger/issues?q=is%3Aissue+is%3Aopen+%22%3D+expr%22>.
The manual would really benefit with some more realistic examples in
the Automated
Transactions
<https://ledger-cli.org/doc/ledger3.html#Automated-Transactions> section.

Thanks,

Viraj.


On Thu, Jun 8, 2023 at 4:55 PM Yuri Khan <[email protected]> wrote:

> On Thu, 8 Jun 2023 at 21:28, Viraj Alankar <[email protected]> wrote:
>
> > What would be right way to do apply the automatic transaction only when
> there is also an Expenses entry? I could not figure out the proper syntax.
> I tried something like:
> >
> > = expr "any(account =~ /^Liabilities:Apple Card/) and any(account =~
> /^Expenses/)"
> >
> > but this does not seem to work. I get some errors if I try removing the
> quotes, but I'm likely doing it wrong.
>
> You might instead apply cashback only where the amount is negative.
> But I’m struggling with complex condition syntax too, so maybe someone
> else will chime in.
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Ledger" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ledger-cli/tqXZGjJbZSo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ledger-cli/CAP_d_8VuMoRwog1834ZnuXzQayrf074sx7_hApctjxEc%2BgcrEw%40mail.gmail.com
> .
>

-- 

--- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/CAM502dPsEMoLEv5uDvJHLpGCjXtVY5_15hWxB7EgX1uS-_Q5VA%40mail.gmail.com.

Reply via email to