Hacker News new | comments | ask | show | jobs | submit login

I used ledger-cli, but as I constantly deal with several currencies, I can't rely on it. Unfortunately, none of the open source accounting system I know support multi-currency accounting well.



Ledger deals with multiple currencies quite well in my experience, especially using a custom prices.db file. What is the problem you are having?


After currency exchange transactions it doesn't balance.


It can be done, but it is tricky, especially if you have to report capital gains as FIFO. The documentation is in ledger is misleading/wrong (or was the last time I looked). I have been meaning to write a blog post on this topic for ages (a year???).

Warning: This may be wrong. I just grabbed it randomly out of a test file I was using to try this out and I don't have time to verify it. However, I think it will put you on the right track even if it is wrong (also not sure how to get it formatted correctly here). Anyway this is the kind of thing you have to do:

  2014/09/04 Exchange Currency
    ; Note that the next line generates 20 GBP, not 10 GBP as you might expect
    ; This is so that the excess is captured by the capital gains account at the bottom
    ; Also note that the @ 0.50 GBP is not actually used by ledger in this case
    ; You could put @ 5000 GBP and it would do the same thing.  The rate is
    ; determined by the lot price.
    Assets:CDN                   -20.00 CDN {1.00 GBP} @ 0.50 GBP
    ; It is unfortunate that you can't get ledger to calculate or assert the next value
    Assets:GBP                    10.00 GBP ; Proceeds without commission
    Expenses:Commissions           0.20 GBP
    Assets:GBP                    -0.20 GBP ; Balance the commission
    Income:Capital Gains
The main things you have to understand are that you need to specify the lot price in the transaction. Second, you must specify the price of the transaction. The P line is only used for calculating current value -- it will not set the price of the transaction correctly (if you don't specify it, I think it sets it to whatever the P line is set to when you run the report, which is clearly wrong). Also, you have to calculate either the total proceeds for the balancing account or the capital gains. Also, very unfortunately, with this scheme you can not use the @@ method of specifying the price. I do the math and calculate the result and let ledger calculate capital gains, because that seems the most reasonable thing to do. Some people feel very strongly that a human should calculate the capital gains by hand and enter that value. Either way should work.

Hopefully the above should unstick you. If you are using average method for capital gains, it is dramatically simpler, but I don't have an example handy.

Printing reports with the lot prices is incredibly useful as the lots should balance out to zero. If they do not, then you have an error somewhere (and boy does that suck). It's also very frustrating when doing FIFO or LIFO that you constantly need to run the report to show you how much you have left in each lot, and then go and figure out which lots are the next ones to use. I think this can be automated, but I haven't gotten around to doing it.


Thanks, I will try. Can you drop me an email, so I will share my results or other ideas I have about this later?


BTW, will it balance if I want report not in GBP or CND, but in some other currency I use?


Yes it will. The trick is that the currency you use for capital gains always has to be the same. Also, my colleague mentioned that you might be trying to do this without recording the capital gains. You have to have a capital gains account, or else it will not balance. You can report in any currency you want with the -X flag.

I'm busy for the moment, but I will send you email tomorrow with some better information. I'm GMT+9 so depending on where you are, probably while you are sleeping ;-) It will get me off my butt to write a blog post about it.


I deal with multiple currencies in Ledger as well. Feel free to email me or join their IRC channel for some help! :)


You profile doesn't specify your email :)

I'd be glad to get help here, but I think this is just an unsolved problem. Discussed it on google group. I think I understand it relatively well, and even wanted to fix it, therefore I doubt multiple currencies can be handled with the current version of ledger; but would be glad to find a workaround.


I don't have it installed now, so an example just out of my head: suppose I have 100 USD; I exchange 50 USD to EUR at 1.2 rate. Then I spend 20 EUR on food. Then I exchange remaining EUR to USD at 1.1 rate. Now, if we generate a balance report, do you say it will be balanced?


What do you mean 'it will be balanced'? In double entry accounting, every ledger entry needs to balance. You have three entries. Whether they balance depends on how you enter them. What is the specific problem in your example?


I mean that balance report had 0 total. More precisely, I want to convert everything to a single currency, and than have 0 balance. I.g. I want to check my net worth in USD, or my net worth in EUR. To see capital gains/losses.


If I'm understanding you correctly you expected to see a line item in your balance report stating your losses due to the change in the exchange rate between USD and EUR? Ledger definitely supports that, you just need to make sure to arrange your accounts and transactions accordingly to capture that information. See the "Currency Trading Accounts" method:

https://github.com/ledger/ledger/wiki/Currency-trading-accou...


After every entry, your total system balances to 0. Of course you have to enter all your entries, and not use the 'auto balancing' and unit conversion things that ledger recommends because they don't make sense. If you use ledger just as a, well, ledger, you can do what you want, of course after specifying exchange rates, just like you'd do in a real accounting system.


You don't understand. I mean I want to enter facts as they are, included real currencies used in transactions. But when I review balance, net worth I want them presented a single currency I choose.


No, you don't understand. What you're asking doesn't make sense, but I'll admit it's not obvious when you've never done 'real' double entry accounting. What you need to enter are the 'real facts', it's only at balance time that you can make a 'net worth' in one currency, depending on a given exchange rate.


What about front accounting? It's been a bit since I used it, but I think it handles multi currency somewhat decently.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: