Hi John,

thanks for the explanations, great piece of documentation.  A few remarks and
questions.

On Sat, Mar 10, 2012 at 01:51:37AM -0600, John Wiegley wrote:
> You can mark individual postings as cleared or pending, in case one "side" of
> the transaction has cleared, but the other hasn't yet:
> 
>     2012-03-10 * KFC
>         Liabilities:Credit            $100.00
>         * Assets:Checking

Is this a spurious * on the first line?

> If you want, you can state that virtual postings *should* balance against
> one or more other virtual postings by using brackets (which look "harder")
> rather than parentheses:

What happens if it doesn't balance?

> It is a general convention within Ledger that the "top" postings in a
> transaction contain the target accounts, while the final posting contains the
> source account.  Whenever a commodity is exchanged like this, the commodity
> moved to the target account is considered "secondary", while the commodity
> used for purchasing and tracked in the cost is "primary".

Great, this part is totally new to me.  Much clearer now.

> For example, consider the stock sale given above:
> 
>     2012-03-10 My Broker
>         Assets:Brokerage             10 AAPL @ $50.00
>         Assets:Brokerage:Cash
> 
> The commodity transferred into Assets:Brokerage is not actually 10 AAPL, but
> rather 10 AAPL {$5.00}.  The figure in braces after the amount is called the
> "lot price".  It's Ledger's way of remembering that this commodity was
> transferred through an exchange, and that $5.00 was the price of that
> exchange.

Is it {$50.00} or {$5.00}? You lost me there.

> Instead, if you reference that same hidden price annotation, Ledger will
> figure out that the price of the shares you're selling, and the cost you're
> selling them at, don't balance:
> 
>     2012-04-10 My Broker
>         Assets:Brokerage:Cash       $750.00
>         Assets:Brokerage            -10 AAPL {$50.00} @ $75.00


> This transaction will fail because the $250.00 price difference between the
> price you bought those shares at, and the cost you're selling them for, does
> not match.  The lot price also identifies which shares you purchased on that
> prior date.

So what is the exact rule when both sides of an @ don't match? Here we have a
$250 difference, and this difference is added to the balance of the transaction
if and only if I use the lot-price annotation { } (or the shorthand {{ }})?

> Plus, it comes with dangers.  This works fine:
> 
>     2012-04-10 My Broker
>         Assets:Brokerage            10 AAPL @ $50.00
>         Assets:Brokerage:Cash       $750.00

I don't understand how this can balance.  Should it be $500.00 instead? (I
believe it's not a typo since you reuse the example several times below).

> In addition to lot prices, you can specify lot dates and reveal them with
> --lot-dates.  Other than that, however, they have no special meaning to
> Ledger.  They are specified after the amount in square brackets (the same way
> that dates are parsed in value expressions):
> 
>     2012-04-10 My Broker
>         Assets:Brokerage:Cash       $375.00
>         Assets:Brokerage            -5 AAPL {$50.00} [2012-04-10] @@ $375.00
>         Income:Capital Gains       $-125.00

Does ledger check that the dates match (ie can I use the lot date as some kind
of inventory tracking)?

> # Lot value expressions

I skipped that part, I feel I need to understand the rest before diving into it.

Best,
-- 
Gabriel

Reply via email to