Always Showing Account in one currency

26 views
Skip to first unread message

Henry Mitchell

unread,
Dec 1, 2022, 12:39:24 AM12/1/22
to ledge...@googlegroups.com
Hi,

I may incur expenses in multiple currencies using cash in those countries. What I'd like is to just display the expenses in one currency (USD), but the cash balances to always display in whatever currencies they hold.

Here's what I have:
account Assets:Dollars
account Assets:Yen
account Expenses
commodity JPY
commodity USD

P 2022-01-01 00:00:00 USD 100 JPY

2022-01-02 US Merchant
  Assets:Dollars             -11.00 USD
  Expenses                    11.00 USD

2022-01-03 JP Merchant
  Assets:Yen                 -2000 JPY
  Expenses                    2000 JPY ; 20.00 USD

P 2022-02-01 00:00:00 USD 125 JPY

2022-02-02 US Merchant
  Assets:Dollars             -22.00 USD
  Expenses                    22.00 USD

2022-02-03 JP Merchant
  Assets:Yen                 -3750 JPY
  Expenses                    3750 JPY ; 30.00 USD

I can get the expenses in USD as expected:
$ ledger -f temp.ledger bal --init-file /dev/null -H -X USD
          -83.00 USD  Assets
          -33.00 USD    Dollars
          -50.00 USD    Yen
           83.00 USD  Expenses
--------------------
                   0

However, I can't seem to get the Assets:Yen account to display in JPY properly. I found this snippet from the docs:
Or, if it better suits your accounting, you can be less symbolic, which allows you to report most everything in EUR if you use ‘-X EUR’, except for certain accounts or postings which should always be valuated in another currency. For example:

= /^Assets:Brokerage:CAD$/
    ; Always report the value of commodities in this account in
    ; terms of present day dollars, despite what was asked for
    ; on the command-line VALUE:: market(amount, date, ‘$’)


Sounds exactly like what I wanted. However, adding this:
= /Assets:Yen/
    ; VALUE:: market(amount, date, 'JPY')

results in complete nonsense for the Assets:Yen account:
$ ledger -f temp.ledger bal --init-file /dev/null -H -X USD
       144467.00 USD  Assets
          -33.00 USD    Dollars
       144500.00 USD    Yen
           83.00 USD  Expenses
--------------------
       144550.00 USD

What am I doing wrong?

Reply all
Reply to author
Forward
0 new messages