Check balance of account and all its children

35 views
Skip to first unread message

J J

unread,
Apr 14, 2022, 6:05:55 PMApr 14
to Ledger

I am trying to declare an account and check it's balance and all of its childrens' balances. Doc says

The check and assert directives warn or raise an error (respectively) if the given value expression evaluates to false within the context of any posting.

The doc for value expressions says

O - The total of all postings seen so far, or the total of an account and all its children.

So I am trying to write:

account Budget
    check O >= 0

But I get no errors with this test:

4/14 test
    Budget:Travel    $-10000
    Equity:Opening Balance     $10000


What is the correct syntax to do this? I've tried other formats like:

check O >= 0
check "O >= 0"
check expr = "O >= 0"

But I can't seem to get any of them to work. The documentation claims that the variable O contains the total of an account and all its children.  Is this the correct implementation?

Martin Michlmayr

unread,
Apr 14, 2022, 6:37:21 PMApr 14
to ledge...@googlegroups.com, jwie...@gmail.com
* J J <je...@fastmail.net> [2022-04-14 15:05]:
> O - The total of all postings seen so far, or the total of an account and
> all its children.
>
> So I am trying to write:
> *account Budget*
> * check O >= 0 *

John, I looked at the source code and 'O' seems to exist, but I also
failed to make it work. Any insights from you would be welcome.

My first theory was that the problem is that the "Budget" account on
its own was never used, but adding a $1 transaction to that account
didn't help.

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

John Wiegley

unread,
May 7, 2022, 3:35:21 PMMay 7
to J J, Ledger
>>>>> "JJ" == J J <je...@fastmail.net> writes:

JJ> O - The total of all postings seen so far, or the total of an account and
JJ> all its children.

I would just use "total". The O syntax is from the old version of value
expressions. Does that work?

John
Reply all
Reply to author
Forward
0 new messages