Arithmetic

25 views
Skip to first unread message

Dan Sladden

unread,
Feb 7, 2021, 2:16:09 PMFeb 7
to Ledger
Hi

Why does this do what I expect:

2020/01/01 Works
    Assets:Cash    (£10*(3 -1))
    Equity

but this (without the space before the minus sign) doesn't:

2020/01/01 Doesn't work
    Assets:Cash    (£10*(3-1))
    Equity

Thanks
Dan

Martin Michlmayr

unread,
Feb 7, 2021, 8:58:03 PMFeb 7
to ledge...@googlegroups.com
* Dan Sladden <dan.s...@gmail.com> [2021-02-07 05:03]:
> but this (without the space before the minus sign) doesn't:
>
> 2020/01/01 Doesn't work
> Assets:Cash (£10*(3-1))
> Equity

Sounds like a parsing issue. What's particularly bad is that the
transaction is silenty ignored.

Please file an issue at https://github.com/ledger/ledger/issues/

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

Richard Lawrence

unread,
Feb 8, 2021, 3:39:18 AMFeb 8
to Dan Sladden, Ledger
Whoa, strange. I think this is probably a bug. I can confirm that the
first transaction puts £20 in Assets:Cash, but the second does not,
on ledger 3.1.2. (I realize this version is a bit old; I'm on Debian
stable.)

Dan, what version are you running? Can anyone test on a more recent version?

It's also strange that ledger does not throw an error or complain or
anything about the second transaction. It's as if it's simply blind to
it.

--
Best,
Richard

Martin Michlmayr

unread,
Feb 8, 2021, 4:28:04 AMFeb 8
to ledge...@googlegroups.com, Dan Sladden
* Richard Lawrence <wyl...@gmail.com> [2021-02-08 09:39]:
> Dan, what version are you running? Can anyone test on a more recent version?

It's a confirmed bug.

> It's also strange that ledger does not throw an error or complain or
> anything about the second transaction. It's as if it's simply blind to
> it.

The subtraction is incorrectly calculated as 0, so there's no error,
but since the transaction is 0 it's not shown. You can add --empty
to see it.

https://github.com/ledger/ledger/issues/2001
which as it turns out was reported back in 2019:
https://github.com/ledger/ledger/issues/1809

If someone wants to submit a fix, that'd be great!
Reply all
Reply to author
Forward
0 new messages