Undeclared commodity

148 views
Skip to first unread message

Keith Edmunds

unread,
Feb 3, 2021, 1:37:46 PM2/3/21
to hledger
Hi, new to this. When I run 'hledger check -s', I get:

hledger: 
strict mode: undeclared commodity "£"
in transaction at: "/home/kae/.hledger.journal" (lines 167-182)

The first two lines of the journal are:

; Default formatting
D £1,000.00

Lines 167-182, as reported by the 'check' command, contain opening balances:

2020-9-30 Opening balances
    assets:current accounts:yyyyy    nnnn.nn
    assets:current accounts:xxxxx    nnnn.nn
    [...]
    equity:opening balances

(The "yyy" and "nnn" are names and amounts respectively).

So, "£" only appears in line two. I don't understand why the check is reporting that £ is an undeclared commodity. Can someone help?



niels...@gmail.com

unread,
Feb 3, 2021, 6:18:53 PM2/3/21
to hledger
Here is a solution that worked for me. Instead of 

   D £1,000.00

try

   commodity £1,000.00

(At least it worked for me with the $ sign, so I am hoping that it will work similarly for you.)

Rob

Keith Edmunds

unread,
Feb 4, 2021, 3:27:09 AM2/4/21
to hledger
That changes the message to:

hledger: 
strict mode: undeclared commodity ""
in transaction at: "/home/kae/.hledger.journal" (lines 167-182)

So I tried both:

; Default formatting
D £1,000.00
commodity £1,000.00

...and that seems to have fixed it - thank you.

I'm not sure that what I've done reflects the documentation, nor why I need both "commodity" and "D".

niels...@gmail.com

unread,
Feb 4, 2021, 7:50:39 AM2/4/21
to hledger
Here is my best guess at what is happening. (Please feel free for anyone to chime in who actually knows!) In lines 167-182 you have a number without a pound sign. So without declaring the default commodity, the strict mode is complaining that you are using a commodity, albeit blank, that you didn't declare. However, when you use the "D" to say that numbers without explicit commodities are such-and-such a commodity, strict doesn't complain about your using a number without saying what the commodity was.

Again, the above is a guess. Corrections welcomed!

Rob 

Simon Michael

unread,
Feb 4, 2021, 12:03:02 PM2/4/21
to hledger
100% correct!

To declare commodities for -s or "hledger check commodities", hledger requires a commodity directive, not just a D directive. 

The no-symbol commodity is also a commodity. When you had a D directive, it was assigning a commodity symbol to those, so you no longer had any no-symbol amounts. 

If you really did want to use the no-symbol commodity, and make -s work, you could declare it also:


commodity 1000. A
commodity 1000.

1/1
   (a)  1 A
   (b)  1

$ hledger check commodities





-- 
You received this message because you are subscribed to the Google Groups "hledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hledger+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hledger/633e4a89-6eee-4d30-bb2e-bcbe78733a84n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages