Custom format to remove the currency

52 views
Skip to first unread message

Jimi Damon

unread,
Oct 11, 2020, 3:08:52 PM10/11/20
to ledge...@googlegroups.com
Hi,

I am just looking for the correct command to remove the currency from a ledger custom format.

I have some other scripts that process the results and they I'd prefer to not have to pipe the output of ledger into something just to remove "$" from the report.

Is there a  way to get the %amount in a format without the currency attached to it ? 

echo -ne "2019/12/01 * Mortgage\n    Expenses:Mortgage      \$10000.00\n    Assets:Checking\n" | ledger -f - reg Expenses:Mortgage --format "%(roundto(amount, 2))\n"


I'd love to get 
10000.00

Instead of 
$10000.00




o1bigtenor

unread,
Oct 11, 2020, 4:17:38 PM10/11/20
to Ledger
Greetings

No answer(s) here but I'd be quite curious as to why you don't what
the currency symbol to be connected?

Regards

Jimi Damon

unread,
Oct 11, 2020, 5:11:39 PM10/11/20
to Ledger
I'm feeding it into other reporting /  tax software

Jasel17212

unread,
Oct 17, 2020, 8:48:31 AM10/17/20
to Ledger
The 'clear_commodity' function should do this for you.

echo -ne "2019/12/01 * Mortgage\n Expenses:Mortgage \$10000.00\n Assets:Checking\n" | ledger -f - reg Expenses:Mortgage --format "%(clear_commodity(roundto(amount, 2)))\n"

Jimi Damon

unread,
Oct 17, 2020, 7:21:27 PM10/17/20
to ledge...@googlegroups.com
Thanks for that...also you solved a problem for me with roundto.

Why is roundto() so sensitive to spaces in it's argument ? 

This works

roundto(amount, 2 )

but this doesn't ??

roundto(amount,2)



--

---
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 ledger-cli+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/6edc4ca9-e77b-4468-899c-bdb898077ec6n%40googlegroups.com.

John Wiegley

unread,
Oct 17, 2020, 7:42:32 PM10/17/20
to Jimi Damon, ledge...@googlegroups.com
>>>>> "JD" == Jimi Damon <jda...@gmail.com> writes:

JD> Thanks for that...also you solved a problem for me with roundto. Why is
JD> roundto() so sensitive to spaces in it's argument ?

JD> This works

JD> roundto(amount, 2 )

JD> but this doesn't ??

JD> roundto(amount,2)

Well, comma might be a European decimal separator, and "amount" might be the
name of a commodity, and you might be specifying 0,2 of that commodity very
lazily.

I agree this should be an error, and welcome a bug report, but that's what
Ledger is thinking in this case.

John
Reply all
Reply to author
Forward
0 new messages