summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/NEWS45
-rw-r--r--doc/README4
-rw-r--r--doc/grammar.y22
-rw-r--r--doc/ledger.149
-rw-r--r--doc/ledger.texi45
-rw-r--r--doc/ledger3.texi322
6 files changed, 420 insertions, 67 deletions
diff --git a/doc/NEWS b/doc/NEWS
index d640f445..1d4826dc 100644
--- a/doc/NEWS
+++ b/doc/NEWS
@@ -1,4 +1,4 @@
- Ledger NEWS
+ Ledger NEWS
* 3.0
@@ -13,6 +13,23 @@ features, please see the manual.
To see 2.6 behavior, use "bal -n" in 3.0. The -s option no longer has any
effect on balance reports.
+* 2.6.3
+
+- Minor fixes to allow for compilation with gcc 4.4.
+
+* 2.6.2
+
+- Bug fix: Command-line options, such as -O, now override init-file options
+ such as -V.
+
+- Bug fix: "cat data | ledger -f -" now works.
+
+- Bug fix: --no-cache is now honored. Previously, it was writing out a cache
+ file named "<none>".
+
+- Bug fix: Using %.2X in a format string now outputs 2 spaces if the state is
+ cleared.
+
* 2.6.1
- Added the concept of "balance setting transactions":
@@ -291,7 +308,7 @@ features, please see the manual.
monthly costs report, for example, because it makes the
following command possible:
- ledger -M --only "a>100" reg ^Expenses:Food
+ ledger -M --only "a>100" reg ^Expenses:Food
This shows only *months* whose amount is greater than 100. If
--limit had been used, it would have been a monthly summary of
@@ -303,7 +320,7 @@ features, please see the manual.
This predicate does not constrain calculation, but only display.
Consider the same command as above:
- ledger -M --display "a>100" reg ^Expenses:Food
+ ledger -M --display "a>100" reg ^Expenses:Food
This displays only lines whose amount is greater than 100, *yet
the running total still includes amounts from all transactions*.
@@ -311,7 +328,7 @@ features, please see the manual.
the current month's checking register while still giving a
correct ending balance:
- ledger --display "d>[this month]" reg Checking
+ ledger --display "d>[this month]" reg Checking
Note that these predicates can be combined. Here is a report that
considers only food bills whose individual cost is greater than
@@ -320,8 +337,8 @@ features, please see the manual.
retain an accurate running total with respect to the entire ledger
file:
- ledger -M --limit "a>20" --only "a>200" \
- --display "year == yearof([last year])" reg ^Expenses:Food
+ ledger -M --limit "a>20" --only "a>200" \
+ --display "year == yearof([last year])" reg ^Expenses:Food
- Added new "--descend AMOUNT" and "--descend-if VALEXPR" reporting
options. For any reports that display valued transactions (i.e.,
@@ -398,12 +415,12 @@ features, please see the manual.
G gain_total
U(x) abs(x)
S(x) quant(x), quantity(x)
- comm(x), commodity(x)
- setcomm(x,y), set_commodity(x,y)
+ comm(x), commodity(x)
+ setcomm(x,y), set_commodity(x,y)
A(x) mean(x), avg(x), average(x)
P(x,y) val(x,y), value(x,y)
- min(x,y)
- max(x,y)
+ min(x,y)
+ max(x,y)
- There are new "parse" and "expr" commands, whose argument is a
single value expression. Ledger will simply print out the result of
@@ -554,10 +571,10 @@ features, please see the manual.
the following is now supported, which wasn't previously:
2004/06/21 Adjustment
- Retirement 100 FUNDA
- Retirement 200 FUNDB
- Retirement 300 FUNDC
- Equity:Adjustments
+ Retirement 100 FUNDA
+ Retirement 200 FUNDB
+ Retirement 300 FUNDC
+ Equity:Adjustments
- Fixed several bugs relating to QIF parsing, budgeting and
forecasting.
diff --git a/doc/README b/doc/README
index 8f83ef39..190436a2 100644
--- a/doc/README
+++ b/doc/README
@@ -1,7 +1,7 @@
- Welcome to Ledger
+ Welcome to Ledger
- the command-line accounting program
+ the command-line accounting program
Introduction
============
diff --git a/doc/grammar.y b/doc/grammar.y
index 018e7391..9a5f740b 100644
--- a/doc/grammar.y
+++ b/doc/grammar.y
@@ -53,7 +53,7 @@ journal_item:
whitespace:
EOL |
WHITESPACE EOL |
- ';' TEXT EOL | /* these next four are all ignored */
+ ';' TEXT EOL | /* these next four are all ignored */
'*' TEXT EOL |
;
@@ -70,23 +70,23 @@ word_directive:
"end" |
"alias" STRING '=' TEXT |
"def" TEXT |
- TEXT WHITESPACE TEXT /* looked up in session (aka maybe Python) */
+ TEXT WHITESPACE TEXT /* looked up in session (aka maybe Python) */
;
char_directive:
- 'i' date time TEXT | /* a timeclock.el "check in" */
+ 'i' date time TEXT | /* a timeclock.el "check in" */
'I' date time TEXT |
- 'o' date time TEXT | /* a timeclock.el "check out" */
+ 'o' date time TEXT | /* a timeclock.el "check out" */
'O' date time TEXT |
'h' TEXT EOL |
'b' TEXT EOL |
- 'D' amount | /* sets display parameters for a commodity */
- 'A' TEXT | /* sets the "default balancing account" */
- 'C' commodity '=' amount | /* specifies a commodity conversion */
+ 'D' amount | /* sets display parameters for a commodity */
+ 'A' TEXT | /* sets the "default balancing account" */
+ 'C' commodity '=' amount | /* specifies a commodity conversion */
'P' date time commodity amount | /* a pricing history xact */
- 'N' commodity | /* commodity's price is never downloaded */
- 'Y' INT4 | /* sets the default year for date parsing */
- '-' '-' STRING TEXT | /* specify command-line options in the file */
+ 'N' commodity | /* commodity's price is never downloaded */
+ 'Y' INT4 | /* sets the default year for date parsing */
+ '-' '-' STRING TEXT | /* specify command-line options in the file */
;
date: INT4 date_sep INT2 date_sep INT2 ;
@@ -210,7 +210,7 @@ values_opt:
price_opt: price | /* epsilon */ ;
price:
'@' amount_expr |
- '@@' amount_expr /* in this case, it's the whole price */
+ '@@' amount_expr /* in this case, it's the whole price */
;
account:
diff --git a/doc/ledger.1 b/doc/ledger.1
index 5a91ceb2..5a3bd6db 100644
--- a/doc/ledger.1
+++ b/doc/ledger.1
@@ -1,4 +1,4 @@
-.Dd February 2, 2010
+.Dd June 22, 2010
.Dt ledger 1
.Sh NAME
.Nm ledger
@@ -53,7 +53,7 @@ Also show accounts whose total is zero.
Rather than display a hierarchical tree, flatten the report to show subtotals
for only accounts matching
.Ar report-query .
-.It Fl \-no\-total
+.It Fl \-no-total
Suppress the summary total shown at the bottom of the report (when not zero).
.El
.Pp
@@ -263,6 +263,7 @@ transactions they are contained in. See the manual for more information.
.It Fl \-account Ar STR
.It Fl \-account-width Ar INT
.It Fl \-actual Pq Fl L
+.It Fl \-actual-dates
.It Fl \-add-budget
.It Fl \-amount Ar EXPR Pq Fl t
.It Fl \-amount-data Pq Fl j
@@ -274,9 +275,13 @@ transactions they are contained in. See the manual for more information.
.It Fl \-base
.It Fl \-basis Pq Fl B
.It Fl \-begin Ar DATE Pq Fl b
+.It Fl \-bold-if Ar EXPR
.It Fl \-budget
+.It Fl \-budget-format Ar FMT
.It Fl \-by-payee Pq Fl P
+.It Fl \-cache Ar FILE
.It Fl \-cleared Pq Fl C
+.It Fl \-cleared-format Ar FMT
.It Fl \-collapse Pq Fl n
.It Fl \-collapse-if-zero
.It Fl \-color
@@ -284,12 +289,16 @@ transactions they are contained in. See the manual for more information.
.It Fl \-cost
See
.Fl \-basis .
+.It Fl \-count
.It Fl \-csv-format Ar FMT
.It Fl \-current Pq Fl c
.It Fl \-daily
+.It Fl \-date Ar EXPR
.It Fl \-date-format Ar DATEFMT Pq Fl y
+.It Fl \-datetime-format Ar FMT
.It Fl \-date-width Ar INT
.It Fl \-debug Ar STR
+.It Fl \-decimal-comma
.It Fl \-depth Ar INT
.It Fl \-deviation Pq Fl D
.It Fl \-display Ar EXPR Pq Fl d
@@ -308,14 +317,27 @@ See
See
.Fl \-head .
.It Fl \-flat
+.It Fl \-force-color
+.It Fl \-force-pager
.It Fl \-forecast-while Ar EXPR
(Also
.Fl \-forecast
).
+.It Fl \-forecast-years Ar INT
.It Fl \-format Ar FMT Pq Fl F
+.It Fl \-full-help
.It Fl \-gain Pq Fl G
+.It Fl \-generated
+.It Fl \-group-by Ar EXPR
+.It Fl \-group-title-format Ar FMT
.It Fl \-head Ar INT
+.It Fl \-help
+.It Fl \-help-calc
+.It Fl \-help-comm
+.It Fl \-help-disp
+.It Fl \-import Ar STR
.It Fl \-init-file Ar FILE
+.It Fl \-inject Ar STR
.It Fl \-input-date-format Ar DATEFMT
.It Fl \-invert
.It Fl \-last Ar INT
@@ -329,26 +351,37 @@ See
.It Fl \-lots
.It Fl \-lots-actual
.It Fl \-market Pq Fl V
+.It Fl \-master-account Ar STR
+.It Fl \-meta Ar EXPR
+.It Fl \-meta-width Ar INT
.It Fl \-monthly Pq Fl M
+.It Fl \-no-color
+.It Fl \-no-rounding
+.It Fl \-no-titles
+.It Fl \-no-total
+.It Fl \-now Ar DATE
.It Fl \-only Ar EXPR
+.It Fl \-options
.It Fl \-output Ar FILE Pq Fl o
.It Fl \-pager Ar STR
+.It Fl \-payee
.It Fl \-payee-width Ar INT
.It Fl \-pending
-.It Fl \-percentage Pq Fl \%
+.It Fl \-percent Pq Fl \%
.It Fl \-period Ar PERIOD Pq Fl p
.It Fl \-period-sort
.It Fl \-pivot Ar STR
.It Fl \-plot-amount-format Ar FMT
.It Fl \-plot-total-format Ar FMT
+.It Fl \-prepend-format Ar FMT
+.It Fl \-prepend-width Ar INT
.It Fl \-price Pq Fl I
.It Fl \-price-db Ar FILE
.It Fl \-price-exp Ar STR
See
.Fl \-leeway .
.It Fl \-prices-format Ar FMT
-.It Fl \-pricesdb-format Ar FMT
-.It Fl \-print-format Ar FMT
+.It Fl \-pricedb-format Ar FMT
.It Fl \-quantity Pq Fl O
.It Fl \-quarterly
.It Fl \-raw
@@ -365,9 +398,6 @@ appeared in the original journal file.
.It Fl \-revalued-total Ar EXPR
.It Fl \-seed Ar INT
.It Fl \-script
-.It Fl \-set-account Ar EXPR
-.It Fl \-set-payee Ar EXPR
-.It Fl \-set-price Ar EXPR
.It Fl \-sort Ar EXPR Pq Fl S
.It Fl \-sort-all
.It Fl \-sort-xacts
@@ -382,6 +412,9 @@ appeared in the original journal file.
.It Fl \-truncate
.It Fl \-unbudgeted
.It Fl \-uncleared Pq Fl U
+.It Fl \-unrealized
+.It Fl \-unrealized-gains
+.It Fl \-unrealized-losses
.It Fl \-unround
.It Fl \-verbose
.It Fl \-verify
diff --git a/doc/ledger.texi b/doc/ledger.texi
index 0a0224dc..ac7bfc5f 100644
--- a/doc/ledger.texi
+++ b/doc/ledger.texi
@@ -35,7 +35,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@end copying
-@documentencoding utf-8
+@documentencoding UTF-8
@iftex
@finalout
@@ -122,27 +122,13 @@ general ledger you need to record a payment to Pacific Bell for your
monthly phone bill. The cost is $23.00, let's say, and you want to
pay it from your checking account. In the general ledger you need to
say where the money came from, in addition to where it's going to.
-The transaction might look like this:
+Such a transaction might look like this:
@smallexample
-9/29 BAL Pacific Bell $-200.00 $-200.00
- Equity:Opening Balances $200.00
-9/29 BAL Checking $100.00 $100.00
- Equity:Opening Balances $-100.00
-9/29 100 Pacific Bell $23.00 $223.00
- Checking $-23.00 $77.00
+9/29 Pacific Bell $23.00 $23.00
+ Checking $-23.00 0
@end smallexample
-The first line shows a payment to Pacific Bell for $23.00. Because
-there is no ``balance'' in a general ledger---it's always zero---we
-write in the total balance of all payments to ``Pacific Bell'', which
-now is $223.00 (previously the balance was $200.00). This is done by
-looking at the last transaction for ``Pacific Bell'' in the ledger, adding
-$23.00 to that amount, and writing the total in the balance column.
-And the money came from ``Checking''---a withdrawal of $23.00---which
-leaves the ending balance in ``Checking'' at $77.00. This is a very
-manual procedure; but that's where computers come in...
-
The posting must balance to $0: $23 went to Pacific Bell, $23 came
from Checking. There is nothing left over to be accounted for, since
the money has simply moved from one account to another. This is the
@@ -174,16 +160,8 @@ formatting as the ledger program wishes to see them:
@smallexample
2004/09/29 Pacific Bell
- Payable:Pacific Bell $-200.00
- Equity:Opening Balances
-
-2004/09/29 Checking
- Accounts:Checking $100.00
- Equity:Opening Balances
-
-2004/09/29 Pacific Bell
- Payable:Pacific Bell $23.00
- Accounts:Checking
+ Expenses:Pacific Bell $23.00
+ Assets:Checking
@end smallexample
The account balances and registers in this file, if saved as
@@ -503,8 +481,8 @@ and exits. This is useful for sending bug reports, to let the author
know which version of ledger you are using.
@option{--file FILE} (@option{-f FILE}) reads FILE as a ledger file.
-This command may be used multiple times. FILE may also be a list of
-file names separated by colons. Typically, the environment variable
+This command may be used multiple times.
+Typically, the environment variable
@env{LEDGER_FILE} is set, rather than using this command-line option.
@option{--output FILE} (@option{-o FILE}) redirects output from any
@@ -514,11 +492,12 @@ output.
@option{--init-file FILE} (@option{-i FILE}) causes FILE to be read by
ledger before any other ledger file. This file may not contain any
postings, but it may contain option settings. To specify options
-in the init file, use the same syntax as the command-line. Here's an
-example init file:
+in the init file, use the same syntax as the command-line, but put each
+option on it's own line. Here's an example init file:
@smallexample
--price-db ~/finance/.pricedb
+--cache /tmp/ledger-cache
; ~/.ledgerrc ends here
@end smallexample
@@ -829,6 +808,8 @@ option settings in the file @file{~/.ledgerrc}, for example:
@example
--cache /tmp/.mycache
+--pager /bin/cat
+
@end example
@node Period expressions, Format strings, Options, Quick Reference
diff --git a/doc/ledger3.texi b/doc/ledger3.texi
new file mode 100644
index 00000000..1f875764
--- /dev/null
+++ b/doc/ledger3.texi
@@ -0,0 +1,322 @@
+\input texinfo @c -*-texinfo-*-
+
+@setfilename ledger.info
+@settitle Ledger: Command-Line Accounting
+
+@dircategory User Applications
+@copying
+Copyright (c) 2003-2010, John Wiegley. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+- Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+- Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+- Neither the name of New Artisans LLC nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+@end copying
+
+@documentencoding UTF-8
+
+@iftex
+@finalout
+@end iftex
+
+@titlepage
+@title Ledger: Command-Line Accounting
+@author John Wiegley
+@end titlepage
+
+@direntry
+* Ledger: (ledger). Command-Line Accounting
+@end direntry
+
+@contents
+
+@ifnottex
+@node Top, , (dir), (dir)
+@top Overview
+
+@insertcopying
+@end ifnottex
+
+@ifnottex
+@section Copyright
+@insertcopying
+@end ifnottex
+
+@chapter Introduction
+
+@chapter Principles of accounting
+
+@chapter Keeping a journal
+
+@chapter Basic reporting commands
+
+@chapter Command-line syntax
+
+@chapter Journal data format
+
+This chapter offers a complete description of the journal data format,
+suitable for implementors in other languages to follow. For users,
+the chapter on keeping a journal is less extensive, but more typical
+of common usage (@pxref{Keeping a journal}).
+
+Data is collected in the form of @dfn{transactions} which occur in one
+or more @dfn{journal files}. Each transaction, in turn, is made up of
+one or more @dfn{postings}, which describe how @dfn{amounts} flow from
+one @dfn{account} to another. Here is an example of the simplest of
+journal files:
+
+@example
+2010/05/31 Just an example
+ Expenses:Some:Account $100.00
+ Income:Another:Account
+@end example
+
+In this example, there is a transaction date, a payee, or description
+of the transaction, and two postings. The postings show movement of
+one hundred dollars from an account within the Income hierarchy, to
+the specified expense account. The name and meaning of these accounts
+in arbitrary, with no preferences implied, although you will find it
+useful to follow standard accounting practice (@pxref{Principles of
+accounting}).
+
+Since an amount is missing from the second posting, it is assumed to
+be the inverse of the first. This guarantee the cardinal rule of
+double-entry accounting: the sum of every transaction must balance to
+zero, or it is in error. Whenever Ledger encounters a @dfn{null
+posting} in a transaction, it uses it to balance the remainder.
+
+It is also typical---though not enforced---to think of the first
+posting as the destination, and the final as the source. Thus, the
+amount of the first posting is typically positive. Consider:
+
+@example
+2010/05/31 An income transaction
+ Assets:Checking $1,000.00
+ Income:Salary
+
+2010/05/31 An expense transaction
+ Expenses:Dining $100.00
+ Assets:Checking
+@end example
+
+@section Specifying amounts
+
+The heart of a journal is the amounts it records, and this fact is
+reflected in the diversity of amount expressions allowed. All of them
+are covered here, though it must be said that sometimes, there are
+multiple ways to achieve a desired result.
+
+@subsection Integer amounts
+
+In the simplest form, bare decimal numbers are accepted:
+
+@example
+2010/05/31 An income transaction
+ Assets:Checking 1000.00
+ Income:Salary
+@end example
+
+Such amounts may only use an optional period for a decimal point.
+These are referred to as @dfn{integer amounts} or @dfn{uncommoditized
+amounts}. In most ways they are similar to @dfn{commoditized
+amounts}, but for one signficant difference: They always display in
+reports with @dfn{full precision}. More on this in a moment. For
+now, a word must be said about how Ledger stores numbers.
+
+Every number parsed by Ledger is stored internally as an
+infinite-precision rational value. Floating-point math is never used,
+as it cannot be trusted to maintain precision of values. So, in the
+case of @samp{1000.00} above, the internal value is @samp{100000/100}.
+
+While rational numbers are great at not losing precision, the question
+arises: How should they be displayed? A number like @samp{100000/100}
+is no problem, since it represents a clean decimal fraction. But what
+about when the number @samp{1/1} is divided by three? How should one
+print @samp{1/3}, an infinitely repeating decimal?
+
+Ledger gets around this problem by rendering rationals into decimal at
+the last possible moment, and only for display. As such, some
+rounding must, at times, occur. If this rounding would affect the
+calculation of a running total, special accommodation postings are
+generated to make you aware it has happened. In practice, it happens
+rarely, but even then it does not reflect adjustment of the
+@emph{internal amount}, only the displayed amount.
+
+What has still not been answered is how Ledger rounds values. Should
+@samp{1/3} be printed as @samp{0.33} or @samp{0.33333}? For
+commoditized amounts, the number of decimal places is decided by
+observing how each commodity is used; but in the case of integer
+amounts, an arbitrary factor must be chosen. Initially, this factor
+is six. Thus, @samp{1/3} is printed back as @samp{0.333333}.
+Further, this rounding factor becomes associated with each particular
+value, and is carried through mathematical operations. For example,
+if that particular number were multiplied by itself, the decimal
+precision of the result would be twelve. Addition and subtraction do
+not affect precision.
+
+Since each integer amount retains its own display precision, this is
+called @dfn{full precision}, as opposed to commoditized amounts, which
+always look to their commodity to know what precision they should
+round to, and so use @dfn{commodity precision}.
+
+@subsection Commoditized amounts
+
+A @dfn{commoditized amount} is an integer amount which has an
+associated commodity. This commodity can appear before or after the
+amount, and may or may not be separated from it by a space. Most
+characters are allowed in a commodity name, except for the following:
+
+@itemize
+@item Any kind of whitespace
+@item Numerical digits
+@item Punctuation: @samp{.,;:?!}
+@item Mathematical and logical operators: @samp{-+*/^&|=}
+@item Bracketing characters: @samp{<>[](){}}
+@item The at symbol: @samp{@@}
+@end itemize
+
+And yet, any of these may appear in a commodity name if it is
+surrounded by double quotes, for example:
+
+@example
+100 "EUN+133"
+@end example
+
+If a @dfn{quoted commodity} is found, it is displayed in quotes as
+well, to avoid any confusion as to which part is the amount, and which
+part is the commodity.
+
+Another feature of commoditized amounts is that they are reported back
+in the same form as parsed. If you specify dollar amounts using
+@samp{$100}, they will print the same; likewise with @samp{100 $} or
+@samp{$100.000}. You may even use decimal commas, such as
+@samp{$100,00}, or thousand-marks, as in @samp{$10,000.00}.
+
+These display characteristics become associated with the commodity,
+with the result being that all amounts of the same commodity are
+reported consistently. Where this is most noticeable is the
+@dfn{display precision}, which is determined by the most precise value
+seen for a given commodity. In most cases.
+
+Ledger makes a distinction by @dfn{observed amounts} and unobserved
+amounts. An observed amount is critiqued by Ledger to determine how
+amounts using that commodity should be displayed; unobserved amounts
+are significant in their value only---no matter how they are
+specified, it does not change how other amounts in that commodity will
+be displayed.
+
+An example of this is found in cost expressions, covered next.
+
+@section Posting costs
+
+You have seen how to specify either a commoditized or an integer
+amount for a posting. But what if the amount you paid for something
+was in one commodity, and the amount received was another? There are
+two main ways to express this:
+
+@example
+2010/05/31 Farmer's Market
+ Assets:My Larder 100 apples
+ Assets:Checking $20.00
+@end example
+
+In this example, you have paid twenty dollars for one hundred apples.
+The cost to you is twenty cents per apple, and Ledger calculates this
+implied cost for you. You can also make the cost explicit using a
+@dfn{cost amount}:
+
+@example
+2010/05/31 Farmer's Market
+ Assets:My Larder 100 apples @@ $0.200000
+ Assets:Checking
+@end example
+
+Here the @dfn{per-unit cost} is given explicitly in the form of a cost
+amount; and since cost amount are @emph{unobserved}, the use of six
+decimal places has no effect on how dollar amounts are displayed in
+the final report. You can also specify the @dfn{total cost}:
+
+@example
+2010/05/31 Farmer's Market
+ Assets:My Larder 100 apples @@@@ $20
+ Assets:Checking
+@end example
+
+These three forms have identical meaning. In most cases the first is
+preferred, but the second two are necessary when more than two
+postings are involved:
+
+@example
+2010/05/31 Farmer's Market
+ Assets:My Larder 100 apples @@ $0.200000
+ Assets:My Larder 100 pineapples @@ $0.33
+ Assets:My Larder 100 "crab apples" @@ $0.04
+ Assets:Checking
+@end example
+
+Here the implied cost is @samp{$57.00}, which is entered into the null
+posting automatically so that the transaction balances.
+
+@subsection Primary commodities
+
+In every transaction involving more than one commodity, there is
+always one which is the @dfn{primary commodity}. This commodity
+should be thought of as the exchange commodity, or the commodity used
+to buy and sells units of the other commodity. In the fruit examples
+above, dollars are the primary commodity. This is decided by Ledger
+on the placement of the commodity in the transaction:
+
+@example
+2010/05/31 Sample Transaction
+ Expenses 100 secondary
+ Assets 50 primary
+
+2010/05/31 Sample Transaction
+ Expenses 100 secondary @@ 0.5 primary
+ Assets
+
+2010/05/31 Sample Transaction
+ Expenses 100 secondary @@@@ 50 primary
+ Assets
+@end example
+
+The only case where knowledge of primary versus secondary comes into
+play is in reports that use the @option{-V} or @option{-B} options.
+With these, only primary commodities are shown.
+
+If a transaction uses only one commodity, this commodity is also
+considered a primary. In fact, when Ledger goes about ensures that
+all transactions balance to zero, it only ever asks this of primary
+commodities.
+
+@chapter Report queries
+
+@chapter Value expressions
+
+@chapter Format strings
+
+@chapter Extending with Python
+
+@bye