Automated transaction amounts "doubled"

34 views
Skip to first unread message

Robert Shanley

unread,
Nov 8, 2022, 8:51:14 PM11/8/22
to Ledger
journal.txt:

= expr payee == "Joe"
    SetAside            $100
    MoreMoney          -$100

2022/01/05 * Joe
    Stuff                                 $600.00
    Checking

ledger -f journal.txt balance :

            $-600.00  Checking
            $-200.00  MoreMoney
             $200.00  SetAside
             $600.00  Stuff

What am I doing wrong?
Thanks.  
--------------------
                   0

Martin Michlmayr

unread,
Nov 8, 2022, 10:47:15 PM11/8/22
to ledge...@googlegroups.com
* Robert Shanley <rjsha...@gmail.com> [2022-11-08 17:51]:
> = expr payee == "Joe"
> SetAside $100
> MoreMoney -$100
>
> 2022/01/05 * Joe
> Stuff $600.00
> Checking
>
> What am I doing wrong?

My guess is that it's evaluated for each posting, so once for Stuff
and once for Checking. Therefore $200

You could do something like:

= /Stuff/ and expr payee == "Joe"
SetAside $100
MoreMoney -$100

--
Martin Michlmayr
https://www.cyrius.com/

Robert Shanley

unread,
Nov 8, 2022, 11:04:32 PM11/8/22
to Ledger
Thanks, that seems to have worked.

John Wiegley

unread,
Nov 10, 2022, 12:30:20 PM11/10/22
to Robert Shanley, Ledger
>>>>> "RS" == Robert Shanley <rjsha...@gmail.com> writes:

RS> journal.txt:
RS> = expr payee == "Joe"
RS> SetAside $100
RS> MoreMoney -$100

RS> 2022/01/05 * Joe
RS> Stuff $600.00
RS> Checking

RS> ledger -f journal.txt balance :

RS> $-600.00 Checking
RS> $-200.00 MoreMoney
RS> $200.00 SetAside
RS> $600.00 Stuff

RS> What am I doing wrong?

Your automated transaction expression is matching each posting within your
transaction, since they both have a payee of Joe. Imagine your file had looked
like this:

2022/01/05 * Joe
Stuff $600.00

2022/01/05 * Joe
Checking

That's where the doubling is coming from.

John

Robert Shanley

unread,
Nov 10, 2022, 10:19:24 PM11/10/22
to Robert Shanley, Ledger
Thanks, John. That clarification really helps.
Reply all
Reply to author
Forward
0 new messages