error creating budget report with multiple commodities

675 views
Skip to first unread message

Łukasz Stelmach

unread,
Aug 17, 2010, 9:56:38 AM8/17/10
to ledge...@googlegroups.com
Hello.

I've used ledger 2.6.2 for a while now but the new `budget' report is so
appealing i think I'll switch to the development version. However, I get
a strange error when I run:

ledger -f /tmp/ledger.dat -p april budget

--8<---------------cut here---------------start------------->8---
While evaluating value expression:
ansify_if(justify(get_at(total_expr, 1) ? ((100% * scrub(get_at(total_expr, 0))) / -(scrub(get_at(total_expr, 1)))) : 0, 5, -1, true, false), ((color & get_at(total_expr, 1)) & (abs((quantity(scrub(get_at(total_expr, 0))) / quantity(scrub(get_at(total_expr, 1))))) >= 1)) ? magenta : null)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
While converting 50,00 PLN to an amount:
Error: Cannot convert a balance with multiple commodities to an amount
314,72 PLN 0 314,72 PLN 0 Checking
--8<---------------cut here---------------end--------------->8---

with the ledger.dat like this

--8<---------------cut here---------------start------------->8---
D 1000,00 PLN

~ Monthly since 2010/04/01
Expenses:Dining 150,00 PLN
Expenses 300,00 PLN
Savings 50,00 PLN
Income -500,00 PLN
Checking

2010/04/01 Income
Checking:PLN 500,00 PLN
Income:Salary

2010/04/04 ATM
Checking:PLN
Expenses:Cash 30,00 USD @ 2,8426 PLN

2010/04/04 Restaurant
Expenses:Dining 25,00 USD
Expenses:Cash

2010/04/14 Restaurant.PL
Checking:PLN
Expenses:Dining 50,00 PLN

2010/04/28 Savings
Checking:PLN
Savings:PLN 50,00 PLN

--8<---------------cut here---------------end--------------->8---

What does it all mean?

PS. BTW. Yet another error pops up if there is no newline after the last
posting

--8<---------------cut here---------------start------------->8---
While evaluating value expression:
ansify_if(justify(get_at(total_expr, 1) ? ((100% * scrub(get_at(total_expr, 0))) / -(scrub(get_at(total_expr, 1)))) : 0, 5, -1, true, false), ((color & get_at(total_expr, 1)) & (abs((quantity(scrub(get_at(total_expr, 0))) / quantity(scrub(get_at(total_expr, 1))))) >= 1)) ? magenta : null)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
While converting -50,00 PL to an amount:
Error: Cannot convert a balance with multiple commodities to an amount
--8<---------------cut here---------------end--------------->8---

--
Miłego dnia,
Łukasz Stelmach

John Wiegley

unread,
Aug 17, 2010, 4:59:24 PM8/17/10
to ledge...@googlegroups.com
On Aug 17, 2010, at 9:56 AM, Łukasz Stelmach wrote:

> While converting 50,00 PLN to an amount:
> Error: Cannot convert a balance with multiple commodities to an amount
> 314,72 PLN 0 314,72 PLN 0 Checking

Yeah, you can't budget with multiple commodities. You have to use -X to convert them all to a single reference commodity, like "-X USD".

John

Martin Michlmayr

unread,
Aug 17, 2010, 5:46:14 PM8/17/10
to ledge...@googlegroups.com
* John Wiegley <jo...@newartisans.com> [2010-08-17 16:59]:

> > While converting 50,00 PLN to an amount: Error: Cannot convert a
> > balance with multiple commodities to an amount 314,72 PLN
> > 0 314,72 PLN 0 Checking
>
> Yeah, you can't budget with multiple commodities. You have to use
> -X to convert them all to a single reference commodity, like "-X
> USD".

That doesn't work either. While -X EUR bal works in my case, -X EUR budget
gives
Error: Cannot find the value of a sequence

see http://newartisans.com/bugzilla/show_bug.cgi?id=378

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

John Wiegley

unread,
Aug 17, 2010, 7:36:24 PM8/17/10
to ledge...@googlegroups.com
On Aug 17, 2010, at 5:46 PM, Martin Michlmayr wrote:

> That doesn't work either. While -X EUR bal works in my case, -X EUR budget
> gives
> Error: Cannot find the value of a sequence

Ok, this is a bug.

John

Roman Root

unread,
Jun 19, 2017, 6:16:21 AM6/19/17
to Ledger, lukasz....@iem.pw.edu.pl
any fix for whis bug?


Lifepillar

unread,
Jun 19, 2017, 8:11:01 AM6/19/17
to ledge...@googlegroups.com
On 19/06/2017 12:16, Roman Root wrote:
> any fix for whis bug?

Using the following format, 'ledger -p april budget -f ledger.dat' does
not give me any error:

--budget-format %(justify(scrub(get_at(display_total, 0)), 20, -1, true,
color)) %(justify(get_at(display_total, 1) ?
-scrub(get_at(display_total, 1)) : 0.0, 20, 20 + 1 + 20, true, color))
%(justify(get_at(display_total, 1) ? (get_at(display_total, 0) ?
-(scrub(get_at(display_total, 1) + get_at(display_total, 0))) :
-(scrub(get_at(display_total, 1)))) : -(scrub(get_at(display_total,
0))), 20, 20 + 1 + 20 + 1 + 20, true, color))
%(ansify_if(justify((get_at(display_total, 1) ? (100% *
(get_at(display_total, 0) ? scrub(get_at(display_total, 0)) : 0.0)) /
-scrub(get_at(display_total, 1)) : "NA"), 5, -1, true, false), magenta
if (color and get_at(display_total, 1) and
(abs(quantity(scrub(get_at(display_total, 0))) /
quantity(scrub(get_at(display_total, 1)))) >= 1)))) %(!options.flat ?
depth_spacer : "")%-(ansify_if(partial_account(options.flat), blue if
color))\n%/%$1 %$2 %$3 %$4\n Actual Budgeted
Remaining Used\n%/%(prepend_width ? " " * int(prepend_width) :
"") ---------------- ---------------- ---------------- -----\n

You may copy and paste this into ~/.ledgerrc. Please keep in mind that
the text must be *in one line*.

If I add -X PLN, however, I get 'Error: Cannot negate an uninitialized
value'.

Enjoy,
Life.

Lifepillar

unread,
Jun 19, 2017, 8:19:11 AM6/19/17
to ledge...@googlegroups.com
On 19/06/2017 14:10, Lifepillar wrote:
> On 19/06/2017 12:16, Roman Root wrote:
>> any fix for whis bug?
>
> Using the following format, 'ledger -p april budget -f ledger.dat' does
> not give me any error:
>
> [snip]
>
> If I add -X PLN, however, I get 'Error: Cannot negate an uninitialized
> value'.

This works for me, however (using my format):

ledger -f ledger.dat -p '2010/04' budget -X PLN
ledger -f ledger.dat -p '2010/04' budget -X PLN Expenses

Note the value of -p. It might depend on my date format, which might be
different from yours.

Life.

matt.gr...@gmail.com

unread,
Oct 8, 2020, 4:44:40 AM10/8/20
to Ledger
This bug looks like it is still around (ledger 3.2.1). Is there an accounting reason that we can't budget with multiple commodities? Or is that just a bug that hasn't been fixed? Looking at Github, I see Bug #1957 seems to be this one. Except, using "-X $" doesn't solve the problem for me. I also note that the error here (mine too) is different from the bug's error listed. The bug has the error "Cannot convert a balance with multiple commodities into an amount", where m error is like listed in here "Cannot negate an uninitialized value".

Thanks,
Matt

Reply all
Reply to author
Forward
0 new messages