I would like to use the -X flag to display balances in an alternative currency with Ledger 3.2.1-20200518. The conversion functionality works just fine, but the format directive isn’t working for me.
Everything in my
journal is in USD, but I would like to be able to show my balances in
AUD. To do this, I simply added the following line to my price
16:22:00 AUD $0.75244225
Based on information
in the manual I should be able to use the format commodity directive to handle the formatting for a given commodity, so I’ve set
mine up as follows:
note Aussie Dollars
When I run ledger, the balances are properly calculated and displayed in AUD, but the formatting is not honored.
register.ldg --price-db price_db.txt -V --strict –explicit bal Bank
The output looks looks like this:
What am I missing?
I’ve searched and searched, and I can’t find a resolution to this issue. In fact, I’m not even sure, at this point, that the format commodity directive is actually implemented in the software to function as outlined in the manual.
That said, I did
come up with a usable workaround. It’s kludgy, but it produces the
This can be
implemented in a number of different ways, but I did it by creating a
currency.ldg journal file and including it before my transaction
journals. In that file, I created dummy entries for each currency
that I want to use in my reporting:
* Australian Dollar
Assets:Currency 1,000.00 AUD @ $1,000.00
2020/01/01 * Australian Dollar
Assets:Currency -1,000.00 AUD @ $1,000.00
The two entries
cancel each other out while simultaneously telling Ledger how to
format the AUR commodity.
The next step, as
outlined in my first post, is to update the price database:
2021/10/30 16:22:00 AUD $0.75244225
that’s complete, I can run my report again:
-f register.ldg --price-db price_db.txt -V --strict –explicit bal
Bank -X AUD
time I get the desired output:
50,000 AUD Acct1
20,000 AUD Acct2
30,000 AUD Acct3
There may very well
be a cleaner way to do this, but this approach does seem to
effectively work around my initial problem. If you have thoughts on a
better way to do this, feel free to share your ideas.