On 30/12/2017 20:45, Ra Check wrote:
Why does this journal throws error? Is it a bug or my misunderstanding
of how budgeting works?
My take is that it is a bug in Ledger.
*journal.ldg* content:
|
~Yearly
Expenses:Car€1000.00
Assets
2017/01/01*Fail
Expenses:Food $40.00@€0.83
Assets
|
Output ofledger --file journal.ldg -X € budget
|
Whileevaluating value expression:
justify(scrub((get_at(display_total,1)+get_at(display_total,0))),12,((((12+1)+12)+1)+12),true,color)
Whileadding to €-1000.00:
Whilecalling function'scrub <#EXPR (get_at(display_total, {1}) +
get_at(display_total, {0}))>':
Whilecalling function'justify (<#EXPR scrub((get_at(display_total, {1})
+ get_at(display_total, {0})))>, <#EXPR {12}>, <#EXPR (((({12} + {1}) +
{12}) + {1}) + {12})>, 1, 1)':
Error:Cannotadd an uninitialized value to an amount
You may fix the error by using a custom format. I have posted mine on
this list long time ago, but here it is again:
--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
Don't get scared: just copy and paste it into your ~/.ledgerrc.
It *must* be on a single line. It is a bit more robust than the one
coded in Ledger, and with your example it produces an output like this:
€-33.20 €-1000.00 €-966.80 3% Assets
€1000.00 €1000.00 0 Expenses:Car
---------- ------------- ------------- -----
€-33.20 0 €33.20 NA
Actual Budgeted Remaining Used
Enjoy,
Life.
--
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.