Unexpected balance verification

39 views
Skip to first unread message

Dave Webb

unread,
Feb 18, 2023, 2:53:11 PM2/18/23
to Ledger
Hi,
I found a transaction in my ledger for which I think balance verification should fail but ledger accepts it. I am using 3.3.0. Here is a simplified example of what I found

2016-08-19 OpeningBalances
  Assets:Cash  £ 3
  Equity:OpeningBalances

2016-09-25 X
  Expenses:Other  £ 2
  Assets:Cash  = £ 1

2016-09-26 X
  Expenses:Other  £ 1
  Assets:Cash   = £ 1       ; I would expect this to fail

I discovered this while playing with https://docs.rs/ledger-utils/latest/ledger_utils/

Not causing me a problem but thought it was worth mentioning
Regards Dave

Martin Michlmayr

unread,
Feb 18, 2023, 9:22:58 PM2/18/23
to 'Dave Webb' via Ledger, Daraul Harris
* 'Dave Webb' via Ledger <ledge...@googlegroups.com> [2023-02-18 11:53]:
> 2016-09-25 X
> Expenses:Other £ 2
> Assets:Cash = £ 1
>
> 2016-09-26 X
> Expenses:Other £ 1
> Assets:Cash = £ 1 ; I would expect this to fail

If I change the last transaction to:

2016-09-26 X
Expenses:Other £ 1
Assets:Cash = £ 1 ; I would expect this to fail
x

then I get:
with 3.2.1:
Error: Only one posting with null amount allowed per transaction
with 3.3.0:
2016-09-25 X Assets:Cash £ -2
x £ -1

so it seems the "Assets:Cash" posting is treated as not having an
amount.

BTW, if I rename "Assets:Cash" to another account it works fine.

So the problem is 2 balance assignments to the same account after
each other.

There are some open bug reports but I'm not sure this is covered
already.
--
Martin Michlmayr
https://www.cyrius.com/

Dave Webb

unread,
Feb 20, 2023, 2:11:01 PM2/20/23
to Ledger
Okay thankyou for your patience, just for the record, on a MacOS 12 machine I get the problem e.g., 
2016-08-19 OpeningBalances
  Assets:Cash  £ 3
  Equity:OpeningBalances

2016-09-25 X
  Expenses:Other  £ 2
  Assets:Cash

2016-09-26 X
  Expenses:Other  £ 1
  Assets:Cash   = £ 1  ; On a MacOS 12 machine, ledger is accepting anything
  ; between -0.5 and 1 here!

But on an up to date machine the transaction is rejected.

Dave Webb

unread,
Feb 20, 2023, 2:14:40 PM2/20/23
to Ledger
...so maybe no longer compatible environment (probably in the small print when I was installing homebrew stuff!)

John Wiegley

unread,
Feb 23, 2023, 2:03:20 PM2/23/23
to 'Dave Webb' via Ledger
>>>>> "'WvL" == 'Dave Webb' via Ledger <ledge...@googlegroups.com> writes:

'WvL> I found a transaction in my ledger for which I think balance
'WvL> verification should fail but ledger accepts it. I am using 3.3.0.
'WvL> Here is a simplified example of what I found

'WvL> 2016-08-19 OpeningBalances
'WvL>   Assets:Cash  £ 3
'WvL>   Equity:OpeningBalances

'WvL> 2016-09-25 X
'WvL>   Expenses:Other  £ 2
'WvL>   Assets:Cash  = £ 1

'WvL> 2016-09-26 X
'WvL>   Expenses:Other  £ 1
'WvL>   Assets:Cash   = £ 1       ; I would expect this to fail

Just to note, a balance assertion that has no associated amount will always
just adjust the balance to match.

Now, I edited this file to get rid of a lot of really strange whitespace, and
I changed the currency to $, just to rule out all strangeness. After I did
that, I got the output I expected to see:

Vulcan ~/dl $ ledger -f foo.dat reg
While parsing file "/Users/johnw/Downloads/foo.dat", line 11:
While balancing transaction from "/Users/johnw/Downloads/foo.dat", lines 9-11:
> 2022/09/26 X
> Expenses:Other $1
> Assets:Cash = $1
Unbalanced remainder is:
$1
Amount to balance against:
$1
Error: Transaction does not balance

John
Reply all
Reply to author
Forward
0 new messages