This isn't a direct answer to your question, but this is how I do these kind of balance checks:
2017/01/01 * Opening Balance Assets:Checking $1000 Equity:Opening 2017/01/02 * Savings Assets:Savings $100 Assets:Checking 2017/01/03 * Reconcile [Assets:Checking] $0 = $900 [Assets:Savings] $0 = $100 2017/01/04 * Savings Assets:Savings $100 Assets:Checking 2017/01/05 * Reconcile [Assets:Checking] $0 = $800 [Assets:Savings] $0 = $200 This works well. I read these reconcile transactions as "If $0 is added to the account, the balance should be $800". If I instead change the last reconcile to "[Assets:Checking] $0 = $700" (that is, make it $100 off) I get this error: While parsing file "/home/mythmon/tmp/foo.ledger", line 18: While parsing posting: [Assets:Checking] $0 = $700 ^^^^ Error: Balance assertion off by $-100 (expected to see $800) This shows me both the value I said it should be ($700), the value Ledger says it should be ($800), and the difference ($-100). All of these end up being very useful at different times. I leave these in my ledger files. This gives me both a history of balances, and also a sort of test suite. If I change the organization of my files, change rules, or do other refactoring, these assertions give me confidence that I didn't break anything. -Michael Cooper On Thu, Oct 19, 2017 at 3:43 PM John Lee <j...@pobox.com> wrote: > An example that currently has me puzzled: the first assert below passes, > and the second fails. I'm interested both in learning why in this > particular case, and more important, learning how to use ledger to debug > problems like this in general. > > 2017-10-01 * Opening Balance > Assets:CurrentAccount $1000 > Equity:OpeningBalance > > 2017-10-02 * Savings > Assets:CurrentAccount:Savings $100 > Assets:CurrentAccount > > assert account("Assets:CurrentAccount").total == $1000 > > 2017-10-03 * Savings > Assets:CurrentAccount:Savings $100 > Assets:CurrentAccount > > assert account("Assets:CurrentAccount").total == $1000 > > > This surprises me because if I comment that last assert out and run > ledger b '^Assets:CurrentAccount$' I get $800, and ledger b > '^Assets:CurrentAccount:Savings$' prints $200 -- which adds to $1000, > and indeed ledger b '^Assets:CurrentAccount' prints $1000. Bug?? How > can I see what ledger *thinks* the total is when it evaluates the > assert? > > > On Thu, 19 Oct 2017, at 23:13, John Lee wrote: > > Sometimes the assert expressions I'm adding to my ledger file fail and I > > don't immediately know why. If I have something like this: > > > > assert account("Assets:CurrentAccount").total == $123.45 > > > > and I'm wrong about the total, then I'll just be told that I'm wrong, > > and not what the correct value is. What's the easiest way to get ledger > > to compute and print the correct value? > > > > Maybe there's a way to print out account values at a given point in a > > ledger file? In particular, maybe there's a way to print the values of > > value expressions as the ledger file is evaluated by a command like > > balance? > > > > I realize it's good to be able to see what the answer is before one > > writes it down, but sometimes it just saves time to have the computer > > work it out so you can see quickly what you did wrong. > > -- > > --- > 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. > For more options, visit https://groups.google.com/d/optout. > -- --- 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. For more options, visit https://groups.google.com/d/optout.