ledger-dashboard icon indicating copy to clipboard operation
ledger-dashboard copied to clipboard

Support for accounts with multiple currencies

Open alexjj opened this issue 9 years ago • 8 comments

I realize this may be a long shot, as probably you made this for yourself and have no need for it, but it would be great if this supported multiple currencies/commodities for the same account.

Or perhaps an option to convert everything just to one currency to view it.

alexjj avatar Feb 07 '16 03:02 alexjj

Thanks, I was planning to make this more general indeed. Any idea how I could support multiple currencies / commodities?

Ikke avatar Feb 09 '16 20:02 Ikke

You asked for an example ledger, two transactions can demonstrate it:

commodity USD
commodity GBP

2015/12/05 * Party City
    Expenses:Gift                     7.01 USD
    Assets:US:Checking

2015/12/06 * Amazon.co.uk
    Expenses:Gift                    26.28 GBP
    Liabilities:UK:BoE

The issue is when one account (Expenses:Gift) has transactions in multiple commodities.

Depending on the query, particularly with the csv command (and custom formats), I have to limit my queries with -l "commodity=~/GBP/"

edit: personally I'd be happy having everything converted to one currency, so maybe a setting to do so, but again if you're making it general others might not want that.

alexjj avatar Feb 10 '16 05:02 alexjj

+1 currently out of the box I cannot use ledger-dashboard at all, as the minute I start it it blows up with Error: Cannot convert a balance with multiple commodities to an amount I had to create a trivial wrapper forcing -X GBP on ledger and pass that to ledger-dashboard which is fine for my use case.

adamgibbins avatar Feb 14 '16 14:02 adamgibbins

I'm working on a fix for this.

Ikke avatar Feb 15 '16 21:02 Ikke

Can you try the feature/multiple-currencies branch?

Ikke avatar Feb 15 '16 22:02 Ikke

I could only get it to work by enabling the limit_currency setting.

Although the headings: Accounts, Expenses previous month, and Expenses this month all showed no information.

Without the currency limit the error is as before. I'm not sure why the -X isn't working though.

sh.ErrorReturnCode_1
sh.ErrorReturnCode_1: 

  RAN: '/usr/bin/ledger --no-color --file=/home/alex/money/money.ledger csv  ^Income -X GBP'

  STDOUT:
"2015/10/31","","Interest","Income:Interest","GBP","-0.0065","*",""
"2015/11/30","","Interest","<Adjustment>","","0","",""


  STDERR:
While evaluating value expression:
  quoted(commodity(scrub(display_amount)))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
While converting 0.08 GBP
-0.12 USD to an amount:
While calling function 'commodity 0.08 GBP
-0.12 USD':
While calling function 'quoted <#EXPR commodity(scrub(display_amount))>':
While handling posting from "/home/alex/money/assets.us.checking.ledger", line 18:
>     
Error: Cannot convert a balance with multiple commodities to an amount

alexjj avatar Feb 16 '16 04:02 alexjj

-X is only working when you specify the conversion rate somewhere (pricedb, or inline). Something like this worked for me:

2015/12/05 * Party City
    Expenses:Gift                     7.01 USD @0.69GBP
    Assets:US:Checking

Ikke avatar Feb 16 '16 07:02 Ikke

-X? What are the command switches, I'll add them to the readme.

blessedbiped avatar Feb 29 '16 03:02 blessedbiped