>>>>> Gabriel Kerneis <[email protected]> writes:

>>     2012-03-10 * KFC
>>         Liabilities:Credit            $100.00
>>         * Assets:Checking

> Is this a spurious * on the first line?

Ah, yes, thank you for catching that.  Craig, can you incorporate that fix?

>> 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?

The transaction will result in a balancing error.

>> 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.

Oops, it should be {$50.00}, you are right.  The @ goes to {} just as @@ goes
to {{}}.

>> 2012-04-10 My Broker Assets:Brokerage:Cash $750.00 Assets:Brokerage -10
>> AAPL {$50.00} @ $75.00
> 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 {{ }})?

Yes.  Without the pricing annotation, Ledger doesn't know there is a
difference between what you paid in the past, and what you are paying now.  It
is this difference which it accumulates in either Equity:Capital Gains or
Equity:Capital Losses (those strings soon to be made configurable).

>> 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).

Sorry, in this case it should be $500.00.  Guess it got too late for me. :)

When this document gets converted into Texinfo format by Craig, we'll add
markers to turn all these examples into regression tests, to prove that each
example does what I think it should.

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

No.  The only way to find a discrepancy is to add --lot-dates to a balance
report and look and see what results.  There is no case in Ledger where it
ensures that transactions balance against *other* transactions.  You can
balance the postings within a transaction, or you can balance an amount
against a current account total, but you can say that transaction B should
match the details of some earlier transaction A.

>> # Lot value expressions

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

Don't blame you. :) That feature is more to provide infrastructure.  It gets
used behind the scenes by -H and a few other features now.  Plus, it's an
access point into the valuation logic for those who have the need.  I'm
guessing 99% of people won't use it, but I'm glad it's there because Ledger
itself now uses it!

John

Reply via email to