This works fine in Beancount, but requires you to distinguish correctly
between assets to be held at some cost (the house) and price conversions
(the USD you receive). The Ledger balancing method does not distinguish
between these two types of postings as far as I know (please someone
correct me if I'm wrong). Here's the equivalent Beancount syntax, for
illustration:
2000-01-01 open Assets:House
2000-01-01 open Assets:Bank
2000-01-01 open Equity:Capital
2000-01-01 open Income:Gains
2014-01-01 * "Opening Balance"
Assets:Bank 500000 CAD
Equity:Capital
2014-02-01 * "Buy House A"
Assets:House 1 HOU {100000 CAD}
Assets:Bank
2014-02-01 * "Buy House B"
Assets:House 1 HOU {120000 CAD}
Assets:Bank
2014-05-01 * "Sell House A"
Assets:House -1 HOU {100000 CAD}
Assets:Bank 100000 USD @ 1.05 CAD
Income:Gains -5000 CAD
The fact that this works is driven by a balancing rule for each posting in
the sell transaction. This is how this is to be interpreted (and it is
simple and unambiguous):
The first posting (unit held at cost) balances at its cost: -1 x 100000 CAD
= -100000 CAD. This is the balance amount. 1 unit of "HOU {100000 CAD}" is
removed from the inventory of Assets:House. (Note that it would (correctly)
fail if the inventory did not contain such a unit at this point in time.)
The second posting is a conversion at price, which balances with 100000 USD
x 1.05 CAD/USD = 105000 CAD. This is the "balance amount", again, used for
balancing the postings. 100000 USD is deposited to Assets:Bank.
The final posting is just a regular posting in CAD, 5000 CAD are removed
from Income:Gains.
So -100000 CAD + 105000 CAD + -5000 CAD = 0 CAD
Here's the balances you should be getting:
bean-query /Users/blais/tmp/charlton.beancount bal
|-- Assets
| |-- Bank 280,000.00 CAD
| | 100,000.00 USD
| `-- House 120,000.00 CAD
|-- Equity
| `-- Capital -500,000.00 CAD
|-- Expenses
|-- Income
| `-- Gains -5,000.00 CAD
`-- Liabilities
(More comments below.)
On Sun, Sep 21, 2014 at 4:22 PM, Mike Charlton <[email protected]> wrote:
> Hello. I'm new to accounting, ledger and this mailing list :-) So far
> I'm finding it all fascinating! Thank you very much for such a great piece
> of software. Like many people, I tried out GnuCash and would have stuck
> with it except that a friend suggested that I try Ledger. I am now
> convinced that CLI accounting is the only sane way of doing it.
>
> Anyway, I ran into a problem that I think might be a bug/feature
> deficiency in Ledger. First I will describe something that works currently
> and then modify it to show my problem. I am using the example of buying
> and selling houses in Peter Slinger's tutorial on currency trading accounts.
>
> 01/01 Opening Balance
> Assets:CAD CAD 500000
> Capital
>
> 02/01 Buy House A
> Assets:HOU HOU 1 @ CAD 100000
> Assets:CAD
>
> 03/01 Buy House B
> Assets:HOU HOU 1 @ CAD 120000
> Assets:CAD
>
This is a bit of a secondary point, but an argument could be made here that
if your houses aren't identical in every way, you should choose a different
currency than HOU, e.g., HOU1, and HOU2, since their price will fluctuate
independently.
>
> As you can see, I start with $500,000 and buy one house for $100,000 and
> the other for $120,000. I can sell the house and realize the capital gains
> with:
>
> 05/01 Sell House A
> Assets:HOU -HOU 1
> Assets:CAD CAD 105000
> Income:Gains -CAD 5000
>
> I was impressed that Ledger even figures out the cost of the house and
> removes the correct lot price when I inspect the balance with
> --lot-prices! So far so good.
>
Actually, that's not really what you would want the system to do, because
that's ambiguous: which of the houses are you selling? The fact that Ledger
does not fail on this is not reassuring to me. What you would want in this
case is for the system to barf an error indicating that you need to
disambiguate which of the HOU units you're selling: the one at 100000 CAD
or the one at 120000 CAD?
In fact, you might as well put any amount in the gains postings and Ledger
will accept it; try putting 15000 instead:
05/01 Sell House A
Assets:HOU -HOU 1
Assets:CAD CAD 105000
Income:Gains -CAD 15000
Here are the balances I get
ledger -f /Users/blais/tmp/charlton.ledger bal --lot-prices --no-color
385000 CAD
-1 HOU {90000 CAD}
1 HOU {100000 CAD}
1 HOU {120000 CAD} Assets
385000 CAD Bank
-1 HOU {90000 CAD}
1 HOU {100000 CAD}
1 HOU {120000 CAD} House
-500000 CAD Equity:Capital
-15000 CAD Income:Gains
--------------------
-130000 CAD
-1 HOU {90000 CAD}
1 HOU {100000 CAD}
1 HOU {120000 CAD}
In the cases which aren't ambiguous, down the road, this will be allowed in
Beancount:
2014-05-01 * "Sell House A"
Assets:House -1 HOU {}
Assets:Bank 100000 USD @ 1.05 CAD
Income:Gains -5000 CAD
See this working doc for more detail:
http://furius.ca/beancount/doc/proposal-inventory
>
> But let's say that someone wants to buy my house for USD. Ideally I would
> like this to work
>
> 05/01 Sell House A
> Assets:HOU -HOU 1
> Assets:CAD USD 100000 @ CAD 1.05
> Income:Gains -CAD 5000
>
> Unfortunately, this does not balance. Even the following does not balance:
>
> 05/01 Sell House A
> Assets:HOU -HOU 1 {CAD 100000}
> Assets:CAD USD 100000 @ CAD 1.05
> Income:Gains -CAD 5000
>
> The only thing that appears to work is:
>
> 05/01 Sell House A
> Assets:HOU -HOU 1 {CAD 100000} @@ USD 100000
> Assets:CAD USD 100000 @ CAD 1.05
> Income:Gains -CAD 5000
>
> (at which point you can let Ledger calculate the Income:Gains).
>
> I'm guessing this is a bug. I often have to deal with multiple currencies
> and I have to buy one with the other. For example, my main currency is
> JPY, but I have CAD, GBP and EUR and will buy GBP with CAD or EUR with GBP,
> for example. As I am new to accounting, it's very possible I am
> misunderstanding how I should calculate capital gains. Does anyone one
> else do this?
>
> Mike
>
> --
>
> ---
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.