summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/CMakeLists.txt4
-rw-r--r--doc/DEVELOP.md81
-rw-r--r--doc/DEVELOP.md.new0
-rw-r--r--doc/LICENSE28
-rw-r--r--doc/LICENSE-utfcpp23
-rw-r--r--doc/LICENSE.rtfbin1719 -> 0 bytes
-rw-r--r--doc/NEWS24
-rw-r--r--doc/ledger-mode.texi121
-rw-r--r--doc/ledger.11154
-rw-r--r--doc/ledger3.texi1497
-rw-r--r--doc/version.texi.in8
11 files changed, 1943 insertions, 997 deletions
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 46c3f73f..e463c721 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -5,6 +5,10 @@
########################################################################
+configure_file(
+ ${PROJECT_SOURCE_DIR}/doc/version.texi.in
+ ${PROJECT_BINARY_DIR}/doc/version.texi)
+
if (USE_DOXYGEN)
find_package(Doxygen)
if (NOT DOXYGEN_FOUND)
diff --git a/doc/DEVELOP.md b/doc/DEVELOP.md
deleted file mode 100644
index ce897741..00000000
--- a/doc/DEVELOP.md
+++ /dev/null
@@ -1,81 +0,0 @@
-GLOSSARY
-----
-
-Developing the Ledger software uses a number different tools, not all of
-which will be familiar to all developers.
-
-[**Boost**](http://www.boost.org): a standard set of C++ libraries. Most
-Boost libraries consist of inline functions and templates in header files.
-
-[**Cheetah**](http://www.cheetahtemplate.org): a Python templating engine,
-used by *./python/server.py*.
-
-[**CMake**](http://www.cmake.org): A cross platform system for building
-from source code. It uses the *CMakeLists.txt* files.
-
-[**DOxygen**](http://doxygen.org): generates programming documentation from
-source code files. Primarily used on C++ sources, but works on all. Uses
-the *doc/Doxyfile.in* file.
-
-[**GCC**](http://gcc.gnu.org): Gnu Compiler Collection, which includes the
-*gcc* compiler and *gcov* coverage/profiler tool.
-
-[**GMP**](https://gmplib.org): Gnu Multiple Precision Arithmetic Library
-provides arbitrary precision math.
-
-[**Markdown**](https://daringfireball.net/projects/markdown/): A typesetter
-format that produces *html* files from *.md* files. Note that GitHub
-automatically renders *.md* files.
-
-[**sha1**](http://en.wikipedia.org/wiki/SHA-1): a marginally secure
-cryptographic hash function, used only for signing the license file.
-
-[**Texinfo**](http://www.gnu.org/software/texinfo/): Gnu documentation
-typesetter that produces *html* and *pdf* files from the *doc/\*.texi*
-files.
-
-[**Travis CI**](https://travis-ci.org): a hosted continuous integration
- service that builds and runs tests each commit posted to GitHub. Each
- build creates a [log](https://travis-ci.org/ledger/ledger), updates a
- [small graphic](https://travis-ci.org/ledger/ledger.png?branch=master) at
- the top left of the main project's
- [README.md](https://github.com/ledger/ledger/blob/master/README.md), and
- emails the author of the commit if any tests fail.
-
-[**utfcpp**](http://utfcpp.sourceforge.net): a library for handling utf-8
-in a variety of C++ versions.
-
-
-Orientation
----
-
-The source tree can be confusing to a new developer. Here is a selective
-orientation:
-
-**./acprep**: a custom thousand-line script to install dependencies, grab
- updates, and build. It also creates *\*.cmake*,
- *./CmakeFiles/* and other CMake temporary files. Use *./acprep --help*
- for more information.
-
-**./README.md**: user readme file in markdown format, also used as the project
- description on GitHub.
-
-**./contrib/**: contributed scripts of random quality and completion. They
- usually require editing to run.
-
-**./doc/**: documentation, licenses, and
- tools for generating documents such as the *pdf* manual.
-
-**./lib/**: a couple libraries used in development.
-
-**./lisp/**: the [Emacs](http://www.gnu.org/software/emacs/)
- [ledger-mode](http://ledger-cli.org/3.0/doc/ledger-mode.html) lisp code,
- under the [GPLv2](http://www.gnu.org/licenses/gpl-2.0.html) license.
-
-**./python/**: samples using the Python ledger module.
-
-**./src/**: the C++ header and source files in a flat directory.
-
-**./test/**: a testing harness with subdirectories full of tests
-
-**./tools/**: an accretion of tools, mostly small scripts, to aid development
diff --git a/doc/DEVELOP.md.new b/doc/DEVELOP.md.new
deleted file mode 100644
index e69de29b..00000000
--- a/doc/DEVELOP.md.new
+++ /dev/null
diff --git a/doc/LICENSE b/doc/LICENSE
deleted file mode 100644
index 92be3a1d..00000000
--- a/doc/LICENSE
+++ /dev/null
@@ -1,28 +0,0 @@
-Copyright (c) 2003-2015, 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.
diff --git a/doc/LICENSE-utfcpp b/doc/LICENSE-utfcpp
deleted file mode 100644
index 1751a003..00000000
--- a/doc/LICENSE-utfcpp
+++ /dev/null
@@ -1,23 +0,0 @@
-Copyright 2006 Nemanja Trifunovic
-
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/doc/LICENSE.rtf b/doc/LICENSE.rtf
deleted file mode 100644
index 471065fe..00000000
--- a/doc/LICENSE.rtf
+++ /dev/null
Binary files differ
diff --git a/doc/NEWS b/doc/NEWS
index 45596ddc..94c0946a 100644
--- a/doc/NEWS
+++ b/doc/NEWS
@@ -1,5 +1,29 @@
Ledger NEWS
+* 3.x.x
+
+- Added a --no-revalued option
+
+- Improved Embedded Python Support
+
+- Fixed parsing of transactions with single-character payees and comments
+
+- Fixed crash when using -M with empty result
+
+- Fixed sorting for option --auto-match
+
+- Fixed treatment of "year 2015" and "Y2014" directives
+
+- Fixed crash when using --trace 10 or above
+
+- Build fix for boost 1.56
+
+- Build fix for Cygwin
+
+- Fixed Util and Math tests on Mac OS X
+
+- Various documentation improvements
+
* 3.1
- Changed the definition of cost basis to preserve the original cost basis
diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi
index b76cb309..8ff284b1 100644
--- a/doc/ledger-mode.texi
+++ b/doc/ledger-mode.texi
@@ -194,8 +194,10 @@ outside world. This process is called reconciliation (@pxref{Basics of
Reconciliation}) and can be quite onerous. Ledger-mode attempts to make
it as painless as possible.
-In the @file{demo.ledger} buffer type @kbd{C-c C-r}. Emacs will prompt
-for an account to reconcile in the Minibuffer. Enter @samp{Checking}.
+In the @file{demo.ledger} buffer type @kbd{C-c C-r}. If cursor is on an
+account, Ledger-mode will propose this account, or in the Minibuffer,
+will prompt for an account to reconcile. Hit @kbd{RET} if you are happy
+with proposed account, or enter @samp{Checking} as example.
Emacs will then prompt for a target value. The target value is the
amount you want the cleared transactions in the buffer to total.
Normally this would be the ending value from your bank statement, or the
@@ -367,7 +369,7 @@ some additional meaning to the states:
No state. This is equivalent to sticking a check in the mail. It has
been obligated, but not been cashed by the recipient. It could also
apply to credit/debit card transactions that have not been cleared into
-your account balance. You bank may call these transactions ``pending'',
+your account balance. You bank may call these transactions @emph{pending},
but Ledger-mode uses a slightly different meaning.
@item Pending.
@@ -383,13 +385,15 @@ transaction.
@end itemize
-@kindex C-c C-e
@kindex C-c C-c
+@kindex C-c C-e
-Clearing complete transactions is done by typing @kbd{C-c C-e} with
-point in a transaction. This places an asterisk @samp{*} after the
-date. Clearing individual postings is done by typing @kbd{C-c C-c}
-while in a posting. This places an asterisk prior to the posting.
+Typing @kbd{C-c C-c}, depending where is the point, will clear the
+complete transaction, or an individual posting. This places an asterisk
+@samp{*} prior to the payee for the complete transaction, or prior to
+the account for an individual posting. When point is inside
+a transaction, specifically on an individual posting, you can still
+clear the complete transaction by typing @kbd{C-c C-e}.
@node Formatting Transactions, Deleting Transactions, Marking Transactions, The Ledger Buffer
@section Formatting Transactions
@@ -550,17 +554,25 @@ about. You can get this from a monthly statement, or from checking your
on-line transaction history. It also helps immensely to know the final
cleared balance you are aiming for.
-Use menu @samp{Reconcile Account} or @kbd{C-c C-r} and enter the account
-you wish to reconcile in the Minibuffer. Ledger-mode is not particular
-about what you enter for the account. You can leave it blank and
-@file{*Reconcile*} buffer will show you @emph{all} uncleared
-transactions. After you enter the account enter the target amount.
-Ledger expects you to enter an amount with a commodity. It assumes
-initially that you are using @samp{$} (USD) as your default commodity.
-If you are working in a different currency you can change the default in
-variable @option{ledger-reconcile-default-commodity} to whatever you
-need. If you work in multiple commodities simply enter the commoditized
-amount (for example @samp{340 VSDX}, for 340 shares of VSDX).
+Use menu @samp{Reconcile Account} or keyboard shortcut @kbd{C-c C-r} to
+start reconciliation.
+
+If cursor is on an account, Ledger-mode will propose this account, or in
+the Minibuffer, will prompt for an account to reconcile. Hit @kbd{RET}
+if you are happy with proposed account, or enter @samp{Checking} as
+example. Ledger-mode is not particular about what you enter for the
+account. You can leave it blank and @file{*Reconcile*} buffer will show
+you @emph{all} uncleared transactions.
+
+After you enter the account enter the target amount. It is helpful to
+enter an amount with a commodity. You can also leave it blank, you will
+be able to clear transactions but not benefit from balance calculations.
+It assumes initially that you are using @samp{$} (USD) as your default
+commodity. If you are working in a different currency you can change
+the default in variable @option{ledger-reconcile-default-commodity} to
+whatever you need. If you work in multiple commodities simply enter the
+commoditized amount (for example @samp{340 VSDX}, for 340 shares of
+VSDX).
Ledger-mode reconcile cannot currently reconcile accounts that have
multiple commodities, such as brokerage accounts. You may use
@@ -589,17 +601,23 @@ difference from your target is zero.
If you find errors during reconciliation. You can visit the transaction
under point in the @file{*Reconcile*} buffer by hitting the @kbd{RET}
key. This will take you to the transaction in the Ledger buffer. When
-you have finished editing the transaction saving the buffer will
+you have finished editing the transaction, saving the buffer will
automatically return you to the @file{*Reconcile*} buffer and you can
mark the transaction if appropriate.
@node Finalize Reconciliation, Adding and Deleting Transactions during Reconciliation, Edit Transactions During Reconciliation, The Reconcile Buffer
@section Finalize Reconciliation
@cindex reconciliation, finalizing
+@kindex C-c C-c
+@kindex q
Once you have marked all transactions as pending and the cleared balance
is correct. Finish the reconciliation by typing @kbd{C-c C-c}. This
-marks all pending transaction as cleared and saves the ledger buffer.
+marks all pending transactions as cleared and saves the ledger buffer.
+
+Type @kbd{q} to close out the reconciliation buffer. If variable
+@var{ledger-reconcile-finish-force-quit} is set, the reconciliation
+buffer will be killed automatically after @kbd{C-c C-c}.
@node Adding and Deleting Transactions during Reconciliation, Changing Reconciliation Account, Finalize Reconciliation, The Reconcile Buffer
@section Adding and Deleting Transactions during Reconciliation
@@ -621,7 +639,7 @@ Typing @kbd{d} will delete the transaction under point in the
You can conveniently switch the account being reconciled by typing
@kbd{g}, and entering a new account to reconcile. This simply restarts
-the reconcile process. Any transactions that were marked `pending' in
+the reconcile process. Any transactions that were marked @emph{pending} in
the ledger buffer are left in that state when the account is switched.
@node Changing Reconciliation Target, , Changing Reconciliation Account, The Reconcile Buffer
@@ -795,7 +813,7 @@ maintain the proper mathematical sense.
@chapter Scheduling Transactions
The Ledger program provides for automating transactions but these
-transaction aren't ``real'', they only exist inside a ledger session and
+transaction aren't @emph{real}, they only exist inside a ledger session and
are not reflected in the actual data file. Many transactions are very
repetitive, but may vary slightly in the date they occur on, or the
amount. Some transactions are weekly, monthly, quarterly or annually.
@@ -866,7 +884,7 @@ recurrence relation to be specified. The day names are two character
codes that default to Mo, Tu, We, Th, Fr, Sa, Su, for Monday, Tuesday,
Wednesday, Thursday, Friday, Saturday, Sunday respectively. You can
change the codes to something more convenient for your locale by
-customizing the ledger @var{ledger-schedule-week-days}. They must be two
+customizing the ledger @option{ledger-schedule-week-days}. They must be two
characters long.
@@ -929,29 +947,66 @@ If non-nil, highlight transaction under point using
@ftable @option
-@item ledger-reconcile-default-commodity
-The default commodity for use in target calculations in ledger
-reconcile. Defaults to @samp{$} (USD).
-
@item ledger-recon-buffer-name
Name to use for reconciliation buffer. Defaults to @file{*Reconcile*}.
@item ledger-narrow-on-reconcile
-If non-nil, limit transactions shown in main buffer to those matching
+If t, limit transactions shown in main buffer to those matching
the reconcile regex.
@item ledger-buffer-tracks-reconcile-buffer
-If non-nil, then when the cursor is moved to a new transaction in the
-@file{*Reconcile*} window.
+If t, then when the cursor is moved to a new transaction in the
+@file{*Reconcile*} buffer. Then that transaction will be shown in its
+source buffer.
@item ledger-reconcile-force-window-bottom
-If non-nil, make the @file{*Reconcile*} window appear along the bottom
+If t, make the @file{*Reconcile*} window appear along the bottom
of the register window and resize.
@item ledger-reconcile-toggle-to-pending
-If non-nil, then toggle between uncleared and pending @samp{!}. If
+If t, then toggle between uncleared and pending @samp{!}. If
false toggle between uncleared and cleared @samp{*}.
+@item ledger-reconcile-default-date-format
+Date format for the reconcile buffer. Defaults to
+@option{ledger-default-date-format}.
+
+@item ledger-reconcile-target-prompt-string
+Prompt for recon target. Defaults to "Target amount for reconciliation ".
+
+@item ledger-reconcile-buffer-header
+Header string for the reconcile buffer. If non-nil, the name of the
+account being reconciled will be substituted into the '%s'. If nil, no
+header will be displayed. Defaults to "Reconciling account %s\n\n".
+
+@item ledger-reconcile-buffer-line-format
+Format string for the ledger reconcile posting format. Available fields
+are date, status, code, payee, account, amount. The format for each
+field is %WIDTH(FIELD), WIDTH can be preceded by a minus sign which mean
+to left justify and pad the field. WIDTH is the minimum number of
+characters to display; if string is longer, it is not truncated unless
+@option{ledger-reconcile-buffer-payee-max-chars} or
+@option{ledger-reconcile-buffer-account-max-chars} is defined. Defaults to
+"%(date)s %-4(code)s %-50(payee)s %-30(account)s %15(amount)s\n"
+
+@item ledger-reconcile-buffer-payee-max-chars
+If positive, truncate payee name right side to max number of characters.
+
+@item ledger-reconcile-buffer-account-max-chars
+If positive, truncate account name left side to max number of characters.
+
+@item ledger-reconcile-sort-key
+Key for sorting reconcile buffer. Possible values are '(date)',
+'(amount)', '(payee)' or '(0)' for no sorting, i.e. using
+ledger file order. Defaults to '(0)'.
+
+@item ledger-reconcile-insert-effective-date nil
+If t, prompt for effective date when clearing transactions during
+reconciliation.
+
+@item ledger-reconcile-finish-force-quit nil
+If t, will force closing reconcile window after @kbd{C-c C-c}.
+
@end ftable
@node Ledger Report Customization Group, Ledger Faces Customization Group, Ledger Reconcile Customization Group, Customization Variables
diff --git a/doc/ledger.1 b/doc/ledger.1
index b4746eb9..0445c237 100644
--- a/doc/ledger.1
+++ b/doc/ledger.1
@@ -1,21 +1,23 @@
.Dd March 23, 2012
-.Dt ledger 1
+.Dt LEDGER 1
+.Os
.Sh NAME
.Nm ledger
.Nd Command-line, double-entry account reporting tool
.Sh SYNOPSIS
-ledger
+.Nm
.Op Ar command
.Op Ar options
.Op Ar arguments
.Sh DESCRIPTION
-Ledger is a command-line accounting tool based on the power and completeness
+.Nm
+is a command-line accounting tool based on the power and completeness
of double-entry accounting. It is only a reporting tool, which means it never
-modifies your data files, but it does offers a large selection of reports, and
-different ways to customize them to your liking.
-.Pp
+modifies your data files, but it does offer a large selection of reports, and
+different ways to customize them to your needs.
.Sh COMMANDS
-Ledger accepts several top-level commands, each of which generates a different
+.Nm
+accepts several top-level commands, each of which generates a different
kind of basic report. Most of them accept a
.Ar report-query
argument, in order to determine what should be reported. To understand the
@@ -26,48 +28,48 @@ see the section on
In its most basic form, simply specifying one or more strings produces a
report for all accounts containing those strings.
.Pp
-If no command is given, Ledger enters a
+If no command is given,
+.Nm
+enters a
.Tn REPL ,
-or command loop, allowing several commands to be executed against the same
+or command loop, allowing several commands to be executed on the same
dataset without reparsing.
.Pp
-The following is a complete list of reporting commands accepted by Ledger:
+The following is a complete list of accepted reporting commands:
.Bl -tag -width accounts
-.It Nm accounts Oo Ar report-query Oc
-Lists all accounts for postings matching the
+.It Ic accounts Oo Ar report-query Oc
+List all accounts for postings that match the
.Ar report-query .
.El
-.Pp
.Bl -tag -width balance
-.It Nm balance Oo Ar report-query Oc
-Produces a balance report showing totals for all matching accounts, and
-aggregate totals for parents of those accounts. Options most commonly used
+.It Ic balance Oo Ar report-query Oc
+Print a balance report showing totals for postings that match
+.Ar report-query ,
+and aggregate totals for parents of those accounts. Options most commonly used
with this command are:
-.Pp
.Bl -tag -compact -width "--collapse (-n)"
.It Fl \-basis Pq Fl B
Report in terms of cost basis, not amount or value. This is the only form of
report which is guaranteed to always balance to zero, when no
.Ar report-query
is specified.
-.It Fl \-collapse Pq Fl n
Only show totals for the top-most accounts.
.It Fl \-empty Pq Fl E
-Also show accounts whose total is zero.
+Show accounts whose total is zero.
.It Fl \-flat
Rather than display a hierarchical tree, flatten the report to show subtotals
for only accounts matching
.Ar report-query .
.It Fl \-no-total
-Suppress the summary total shown at the bottom of the report (when not zero).
+Suppress the summary total shown at the bottom of the report.
.El
.Pp
The synonyms
-.Nm bal
+.Ic bal
and
-.Nm b
+.Ic b
are also accepted.
-.It Nm budget Oo Ar report-query Oc
+.It Ic budget Oo Ar report-query Oc
A special balance report which includes three extra columns: the amount
budgeted during the reporting period, how spending differed from the budget,
and the percentage of budget spent (exceeds 100% if you go over budget).
@@ -76,24 +78,27 @@ Note that budgeting requires one or more
periodic transactions
.Dc
to be defined in your data file(s). See the manual for more information.
-.It Nm cleared Oo Ar report-query Oc
+.It Ic cleared Oo Ar report-query Oc
A special balance report which adds two extra columns: the cleared balance for
each account, and the date of the most recent cleared posting in that account.
For this accounting to be meaningful, the cleared flag must be set on at least
one posting. See the manual for more information.
-.It Nm commodities Oo Ar report-query Oc
-Lists all commodities for postings matching the
+.It Ic commodities Oo Ar report-query Oc
+List all commodities for postings matching the
.Ar report-query .
-.It Nm convert
-Reads data from a CSV (comma-separated values) file and generates Ledger
+.It Ic convert
+Reads data from a CSV (comma-separated values) file and generates
+.Nm
transactions.
-.It Nm csv Oo Ar report-query Oc
+.It Ic csv Oo Ar report-query Oc
Report of postings matching the
.Ar report-query
in CSV format (comma-separated values). Useful for exporting data to a
spreadsheet for further analysis or charting.
-.It Nm entry Oo Ar entry-template Oc
-Generate and display a new, properly formatted Ledger transaction by comparing
+.It Ic entry Oo Ar entry-template Oc
+Generate and display a new, properly formatted
+.Nm
+transaction by comparing
the
.Ar entry-template
to the transactions in your data file(s). For more information on draft
@@ -102,53 +107,63 @@ section
.Sx ENTRIES .
.Pp
The synonym
-.Nm xact
+.Ic xact
is also accepted.
-.It Nm emacs Oo Ar query Oc
-Outputs posting and transaction data in a format readily consumed by the Emacs
+.It Ic emacs Oo Ar query Oc
+Output posting and transaction data in a format readily consumed by the Emacs
editor, in a series of Lisp forms. This is used by the
-.Li ledger.el
-Emacs mode to process reporting data from Ledger.
-.It Nm equity Oo Ar report-query Oc
-Prints a series of transactions that balance current totals for
+.Pa ledger.el
+Emacs mode to process reporting data from
+.Nm .
+.It Ic equity Oo Ar report-query Oc
+Print a transaction with a series of postings that balance current totals for
accounts matching the
.Ar report-query
in a special account called
.Li Equity:Opening Balances .
The purpose of this report is to close the books for a prior year, while using
-these equity transactions to carry forward those balances.
-.It Nm org
-Produces a journal file suitable for use in the Emacs org mode.
-.It Nm payees Oo Ar report-query Oc
-Lists all payees for postings matching the
+these equity postings to carry forward those balances.
+.It Ic org
+Produce a journal file suitable for use in the Emacs org mode.
+.It Ic payees Oo Ar report-query Oc
+List all payees for postings matching the
.Ar report-query .
-.It Nm pricemap
-Produces a file which can be used to generate a graph with graphviz showing
-the relationship of commodities in the Ledger file.
-.It Nm prices Oo Ar report-query Oc
-Reports prices for all commodities in postings matching the
+.It Ic pricemap
+Produce a file which can be used to generate a graph with graphviz showing
+the relationship of commodities in the
+.Nm
+file.
+.It Ic prices Oo Ar report-query Oc
+Report prices for all commodities in postings matching the
.Ar report-query .
The prices are reported with the granularity of a single day.
-.It Nm pricedb Oo Ar report-query Oc
-Reports prices for all commodities in postings matching the
+.It Ic pricedb Oo Ar report-query Oc
+Report prices for all commodities in postings matching the
.Ar report-query .
Prices are reported down to the second, using the same format as the
-.Li ~/.pricedb
+.Pa ~/.pricedb
file.
-.It Nm print Oo Ar report-query Oc
-Prints out the full transactions of any matching postings using the same
+.It Ic print Oo Ar report-query Oc
+Print out the full transactions of any matching postings using the same
format as they would appear in a data file. This can be used to extract
-subsets from a Ledger file to transfer to other files.
-.It Nm push Oo Ar options Oc
+subsets from a
+.Nm
+file to transfer to other files.
+.It Ic push Oo Ar options Oc
In the
.Tn REPL ,
-this command pushes a set of command-line options, so that they will apply to
-all subsequent reports.
-.It Nm pop
+push a set of command-line
+.Ar options ,
+so that they will apply to all subsequent reports.
+.It Ic pop
In the
.Tn REPL ,
-pops any option settings that have been pushed.
-.It Nm register Oo Ar report-query Oc
+pop any option settings that have been
+.Sm off
+.Ic push
+ed.
+.Sm on
+.It Ic register Oo Ar report-query Oc
List all postings matching the
.Ar report-query .
This is one of the most common commands, and can be used to provide a variety
@@ -165,10 +180,10 @@ Render all values in the given
.Ar commodity ,
if a price conversion rate can be determined. Rates are always displayed
relative to the date of the posting they are calculated for. This means a
-.Nm register
+.Ic register
report is a historical value report. For current values, it may be preferable
to use the
-.Nm balance
+.Ic balance
report.
.It Fl \-gain Pq Fl G
Show any gains (or losses) in commodity values over time.
@@ -177,29 +192,29 @@ Only show the top
.Ar number
postings.
.It Fl \-historical Pq Fl H
+Value commodities at the time of their acquisition.
.It Fl \-invert
Invert the value of amounts shown.
.It Fl \-market Pq Fl V
Show current market values for all amounts. This is determined in a somewhat
magical fashion. It is probably more straightforward to use
-.Fl \-exchange Ar commodity Pq Fl X .
+.Fl \-exchange
+option.
.It Fl \-period Ar time-period Pq Fl p
Show postings only for the given
.Ar time-period .
.It Fl \-related Pq Fl r
Show postings that are related to those that would have been shown. It has
the effect of displaying the
-.Do
-other side
-.Dc
-of the values.
+.Qq other side
+of the postings.
.It Fl \-sort Ar value-expression Pq Fl S
Sort postings by evaluating the given
.Ar value-expression .
Note that a comma-separated list of expressions is allowed, in which case each
sorting term is used in order to determine the final ordering. For example,
to search by date and then amount, one would use:
-.Li -S 'date, amount' .
+.Dl ledger reg --sort 'date, amount'
.It Fl \-tail Ar number
Only show the last
.Ar number
@@ -217,42 +232,46 @@ Group postings by common payee names.
Group postings by day.
.It Fl \-weekly Pq Fl W
Group postings by week (starting on Sundays).
-.It Fl \-start-of-week Ar day-name
-Set the start of each grouped way to the given
-.Ar day-name .
+.It Fl \-start-of-week Ar day
+Set the start of each report grouped by week to the given
+.Ar day .
.It Fl \-monthly Pq Fl M
Group postings by month.
.It Fl \-quarterly
Group postings by fiscal quarter.
.It Fl \-yearly Pq Fl Y
Group postings by year.
-.It Fl \-dow
+.It Fl \-days-of-week
Group postings by the day of the week on which they took place.
.It Fl \-subtotal Pq Fl s
Group all postings together. This is very similar to the totals shown by the
-.Nm balance
+.Ic balance
report.
.El
.Pp
The synonyms
-.Nm reg
+.Ic reg
and
-.Nm r
+.Ic r
are also accepted.
-.It Nm server
+.It Ic server
This command requires that Python support be active. If so, it starts up an
-HTTP server listening for requests on port 9000. This provides an alternate
+.Tn HTTP
+server listening for requests on port 9000. This provides an alternate
interface to creating and viewing reports. Note that this is very much a
work-in-progress, and will not be fully functional until a later version.
-.It Nm select Oo Ar sql-query Oc
+.It Ic select Oo Ar sql-query Oc
List all postings matching the
.Ar sql-query .
-This command allows to generate SQL-like queries.
-.It Nm source
-Parses a journal file and checks it for errors. Ledger will return success
+This command allows to generate SQL-like queries, e.g.:
+.Dl Li ledger select date,amount from posts where account=~/Income/
+.It Ic source
+Parse a journal file and checks it for errors.
+.Nm
+will return success
if no errors are found.
-.It Nm stats Oo Ar report-query Oc
-Provides summary information about all the postings matching
+.It Ic stats Oo Ar report-query Oc
+Provide summary information about all the postings matching
.Ar report-query .
It provides information such as:
.Bl -bullet -offset indent -compact
@@ -269,43 +288,54 @@ Uncleared postings
.It
Days since last posting
.It
-More...
+Posts in the last 7 days
+.It
+Posts in the last 30 days
+.It
+Posts this month
.El
-.It Nm xml Oo Ar report-query Oc
-Outputs data relating to the current report in XML format. It includes all
+.It Ic xml Oo Ar report-query Oc
+Output data relating to the current report in
+.Tn XML
+format. It includes all
accounts and commodities involved in the report, plus the postings and the
transactions they are contained in. See the manual for more information.
.El
-.Pp
.Sh OPTIONS
-.Pp
.Bl -tag -width -indent
.It Fl \-abbrev-len Ar INT
Set the minimum length an account can be abbreviated to if it doesn't
fit inside the
-.Nm account-width .
+.Sy account-width .
If
.Ar INT
is zero, then the
-account name will be truncated on the right. If
+account name will be truncated on the right. If
.Ar INT
is greater
than
-.Nm account-width
+.Sy account-width
then the account will be truncated on the
left, with no shortening of the account names in order to fit into the
desired width.
-.It Fl \-account Ar STR
+.It Fl \-account Ar EXPR
Prepend
-.Ar STR
-to all accounts reported. That is, the option
-.Nm --account Personal
+.Ar EXPR
+to all accounts reported. That is, the option
+.Fl \-account Ar \*q'Personal'\*q
would tack
-.Nm Personal:
-to the beginning of every account reported in a balance report or register report.
+.Ar Personal:
+and
+.Fl \-account Ar \*qtag('VAT')\*q
+would tack the value of the VAT tag to the beginning of every account
+reported in a
+.Ic balance
+or
+.Ic register
+report.
.It Fl \-account-width Ar INT
Set the width of the account column in the
-.Nm register
+.Ic register
report
to
.Ar INT
@@ -316,8 +346,8 @@ transactions used.
.It Fl \-add-budget
Show only un-budgeted postings.
.It Fl \-amount Ar EXPR Pq Fl t
-Apply the given value expression to the posting amount. Using
-.Nm --amount Ar EXPR
+Apply the given value expression to the posting amount. Using
+.Fl \-amount Ar EXPR
you can apply an
arbitrary transformation to the postings.
.It Fl \-amount-data Pq Fl j
@@ -325,24 +355,36 @@ On a register report print only the dates and amount of postings.
Useful for graphing and spreadsheet applications.
.It Fl \-amount-width Ar INT
Set the width in characters of the amount column in the
-.Nm register
+.Ic register
report.
.It Fl \-anon
Anonymize registry output, mostly for sending in bug reports.
+.It Fl \-ansi
+Use color if the terminal supports it.
+Alias for
+.Fl \-color
.It Fl \-args-only
+Ignore init files and environment variables for the
+.Nm
+run.
.It Fl \-auto-match
+When generating a ledger transaction from a CSV file using the
+.Ic convert
+command, automatically match an account from the Ledger journal.
.It Fl \-aux-date
Show auxiliary dates for all calculations.
-Alias for
+Alias for
.Fl \-effective
.It Fl \-average Pq Fl A
Print average values over the number of transactions instead of
running totals.
.It Fl \-balance-format Ar FMT
Specify the format to use for the
-.Nm balance
+.Ic balance
report.
.It Fl \-base
+Reduce convertible commodities down the bottom of the conversion, e.g.
+display time in seconds.
.It Fl \-basis Pq Fl B
Report the cost basis on all posting.
Alias for
@@ -350,21 +392,21 @@ Alias for
.It Fl \-begin Ar DATE Pq Fl b
Specify the start
.Ar DATE
-of all calculations. Transactions before
+of all calculations. Transactions before
that date will be ignored.
.It Fl \-bold-if Ar EXPR
Print the entire line in bold if the given value expression is true.
.It Fl \-budget
-Only display budgeted items. In a register report this
-displays transaction in the budget, in a balance report this displays
-accounts in the budget.
+Only display budgeted items. In a
+.Ic register
+report this displays transaction in the budget, in a balance report this
+displays accounts in the budget.
.It Fl \-budget-format Ar FMT
Specify the format to use for the
-.Nm budget
+.Ic budget
report.
.It Fl \-by-payee Pq Fl P
Group postings in the register report by common payee names.
-.It Fl \-cache Ar FILE
.It Fl \-check-payees
Enable strict and pedantic checking for payees as well as accounts,
commodities and tags.
@@ -372,12 +414,10 @@ commodities and tags.
Display only cleared postings.
.It Fl \-cleared-format Ar FMT
Specify the format to use for the
-.Nm cleared
+.Ic cleared
report
.It Fl \-collapse Pq Fl n
-By default ledger prints all accounts in an account tree. With
-.Fl \-collapse
-it prints only the top level account specified.
+Print only the top level accounts.
.It Fl \-collapse-if-zero
Collapse the account display only if it has a zero balance.
.It Fl \-color
@@ -385,95 +425,136 @@ Use color if the terminal supports it.
Alias for
.Fl \-ansi
.It Fl \-columns Ar INT
-Specify the width of the
-.Nm register
-report in characters.
+Make the
+.Ic register
+report
+.Ar INT
+characters wide. By default
+.Nm
+will use all available columns in your terminal.
.It Fl \-cost
Report the cost basis on all posting.
Alias for
.Fl \-basis .
.It Fl \-count
-Direct ledger to report the number of items when appended to the
-.Nm commodities ,
-.Nm accounts
+Direct
+.Nm
+to report the number of items when appended to the
+.Ic commodities ,
+.Ic accounts
or
-.Nm payees
+.Ic payees
commands.
.It Fl \-csv-format Ar FMT
-Specify the format to use for the
-.Nm csv
+Format
+.Ic csv
report
+according to
+.Ar FMT .
.It Fl \-current Pq Fl c
Shorthand for
-.Nm --limit 'date <= today' .
+.Fl \-limit Ar "'date <= today'" .
.It Fl \-daily Pq Fl D
Shorthand for
-.Nm --period 'daily' .
+.Fl \-period Ar daily .
.It Fl \-date Ar EXPR
Transform the date of the transaction using
.Ar EXPR .
.It Fl \-date-format Ar DATEFMT Pq Fl y
-Specify the format ledger should use to print dates.
-.It Fl \-datetime-format Ar FMT
+Print dates using
+.Ar DATEFMT .
+Refer to
+.Xr strftime 3
+for details on the format string syntax.
+.It Fl \-datetime-format Ar DATETIMEFMT
+Print datetimes using
+.Ar DATETIMEFMT .
+Refer to
+.Xr strftime 3
+for details on the format string syntax.
.It Fl \-date-width Ar INT
Specify the width, in characters, of the date column in the
-.Nm register
+.Ic register
report.
.It Fl \-day-break
+Break up
+.Ic register
+report of timelog entries that span multiple days by day.
+.It Fl \-days-of-week
+Group transactions by the days of the week.
+Alias for
+.Fl \-dow .
.It Fl \-dc
Display register or balance in debit/credit format If you use
.Fl \-dc
-with either the register (reg) or balance (bal) commands,
-you will now get separate columns for debits and credits.
+with either the
+.Ic register
+or
+.Ic balance
+commands, you will now get separate columns for debits and credits.
.It Fl \-debug Ar STR
-If Ledger has been built with debug options this will provide extra
+If
+.Nm
+has been built with debug options this will provide extra
data during the run.
.It Fl \-decimal-comma
-Direct Ledger to parse journals using the European standard comma as
+Direct
+.Nm
+to parse journals using the European standard comma as
decimal separator, vice a period.
.It Fl \-depth Ar INT
Limit the depth of the account tree. In a balance report, for example,
-a
-.Fl \-depth 2
-statement will print balances only for account with
-two levels, i.e.
-.Nm Expenses:Entertainment
+.Fl \-depth Ar 2
+will print balances only for accounts with two levels, i.e.
+.Sy Expenses:Entertainment
but not
-.Nm Expenses:entertainment:Dining .
-This is a display predicate, which
-means it only affects display, not the total calculations.
-.It Fl \-deviation Pq Fl D
-Report each posting’s deviation from the average. It is only meaningful
-in the register and prices reports.
+.Sy Expenses:Entertainment:Dining .
+This is a display predicate, which means it only affects display,
+not the total calculations.
+.It Fl \-detail
+Related to
+.Ic convert
+command. Synonym to
+.Fl \-rich-data
+option.
+.It Fl \-deviation
+Report each posting's deviation from the average. It is only meaningful
+in the
+.Ic register No and Ic prices
+reports.
.It Fl \-display Ar EXPR Pq Fl d
Display lines that satisfy the expression
.Ar EXPR .
.It Fl \-display-amount Ar EXPR
Apply a transformation to the
-.Nm displayed
+.Em displayed
amount. This occurs after
calculations occur.
.It Fl \-display-total Ar EXPR
Apply a transformation to the
-.Nm displayed
+.Em displayed
total. This occurs after
calculations occur.
.It Fl \-dow
Group transactions by the days of the week.
Alias for
-.Fl \-days-of-week
+.Fl \-days-of-week .
.It Fl \-download
Cause quotes to be automagically downloaded, as needed, by running
a script named
-.Nm getquote
+.Em getquote
and expecting that script to return
-a value understood by ledger. A sample implementation of
-a
-.Nm getquote
+a value understood by
+.Nm .
+A sample implementation of a
+.Em getquote
script, implemented in Perl, is provided in the
distribution. Downloaded quote price are then appended to the price
database, usually specified using the environment variable
-.Nm LEDGER_PRICE_DB .
+.Ev LEDGER_PRICE_DB .
+.It Fl \-effective
+Show auxiliary dates for all calculations. Alias for
+.Fl \-aux-date .
.It Fl \-empty Pq Fl E
Include empty accounts in report.
.It Fl \-end Ar DATE Pq Fl e
@@ -483,34 +564,42 @@ for a transaction to be considered in the
report.
.It Fl \-equity
Related to the
-.Nm equity
+.Ic equity
command. Gives current account balances in the form of a register
report.
.It Fl \-exact
-.It Fl \-exchange Ar COMMODITY Oo , COMM, ... Oc Pq Fl X
+Report beginning and ending of periods by the date of the first and last
+posting occurring in that period.
+.It Fl \-exchange Ar COMMODITY Oo , Ar COMMODITY, ... Oc Pq Fl X
Display values in terms of the given
.Ar COMMODITY .
The latest available price is used.
.It Fl \-explicit
+Direct
+.Nm
+to require pre-declarations for entities (such as accounts,
+commodities and tags) rather than taking entities from cleared
+transactions as defined.
.It Fl \-file Ar FILE
-Read
-.Ar FILE
-as a ledger file.
+Read journal data from
+.Ar FILE .
.It Fl \-first Ar INT
Print the first
.Ar INT
-entries. Opposite of
-.Fl \-tail Ar INT .
-Alias for
+entries. Opposite of
+.Fl \-last Ar INT .
+Alias for
.Fl \-head .
.It Fl \-flat
-Force the full names of accounts to be used in the balance report. The
+Force the full names of accounts to be used in the balance report. The
balance report will not use an indented tree.
.It Fl \-force-color
-Output TTY color codes even if the TTY doesn't support them. Useful
+Output TTY color codes even if the TTY doesn't support them. Useful
for TTYs that don't advertise their capabilities correctly.
.It Fl \-force-pager
-Force Ledger to paginate its output.
+Force
+.Nm
+to paginate its output.
.It Fl \-forecast-while Ar EXPR
Continue forecasting while
.Ar VEXPR
@@ -533,15 +622,15 @@ transactions) in the report, in cases where you normally wouldn't want
them.
.It Fl \-group-by Ar EXPR
Group transaction together in the
-.Nm register
+.Ic register
report.
.Ar EXPR
can be anything, although most common would be
-.Nm payee
+.Ar payee
or
-.Nm commodity .
+.Ar commodity .
The
-.Nm tags()
+.Fn tag
function is also useful here.
.It Fl \-group-title-format Ar FMT
Set the format for the headers that separate reports section of
@@ -551,38 +640,48 @@ register report.
.It Fl \-head Ar INT
Print the first
.Ar INT
-entries. Opposite of
+entries. Opposite of
.Fl \-tail Ar INT .
Alias for
.Fl \-first
.It Fl \-help
-Print a summary of all the options, and what they are used for. This
-can be a handy way to remember which options do what. This help screen
-is also printed if ledger is run without a command.
+Print this man page.
.It Fl \-immediate
-Instruct ledger to evaluate calculations immediately rather than lazily.
-.It Fl \-init-file Ar FILE
-Causes
-.Nm FILE
-to be read by ledger before any other ledger file.
+Evaluate calculations immediately rather than lazily.
+.It Fl \-import Ar FILE
+Import
+.Ar FILE
+as Python module.
+.It Fl \-init-file Ar FILE Pq Fl i
+Read
+.Ar FILE
+before any other
+.Nm
+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, but put each option on its own line.
.It Fl \-inject Ar STR
-TODO
+Use
+.Ar STR
+amounts in calculations. In case you know
+what amount a transaction should be, but the actual transaction has the
+wrong value you can use metadata
+.Ar STR
+to specify the expected amount.
.It Fl \-input-date-format Ar DATEFMT
Specify the input date format for journal entries.
.It Fl \-invert
Change the sign of all reported values.
-.It Fl \-last Ar INT
+.It Fl \-last Ar INT .
Report only the last
.Ar INT
-entries. Only useful on a register
-report.
-Alias for
+entries. Opposite of
+.Fl \-first Ar INT .
+Only useful on a register report. Alias for
.Fl \-tail .
.It Fl \-leeway Ar INT Pq Fl Z
-Alias for
+Alias for
.Fl \-price-expr .
.It Fl \-limit Ar EXPR Pq Fl l
Limit postings in calculations.
@@ -598,30 +697,41 @@ purchased.
Report the date and price at which each commodity was purchased in
a balance report.
.It Fl \-lots-actual
+Preserve the uniqueness of commodities so they aren't merged during
+reporting without printing the lot annotations.
.It Fl \-market Pq Fl V
Use the latest market value for all commodities.
.It Fl \-master-account Ar STR
Prepend all account names with
.Ar STR
-.It Fl \-meta Ar EXPR
+.It Fl \-meta Ar STR
In the register report, prepend the transaction with the value of the given
-.Ar TAG .
+tag
+.Ar STR .
.It Fl \-meta-width Ar INT
Specify the width of the Meta column used for the
.Fl \-meta Ar TAG
options.
.It Fl \-monthly Pq Fl M
Shorthand for
-.Fl \-period 'monthly' .
+.Fl \-period Ar monthly .
.It Fl \-no-aliases
Aliases are completely ignored.
.It Fl \-no-color
Suppress any color TTY output.
+.It Fl \-no-pager
+Disables the pager on TTY output.
+.It Fl \-no-revalued
+Stop
+.Nm
+from showing
+<Revalued>
+postings.
.It Fl \-no-rounding
Don't output
-.Nm <Rounding>
+.Qq Li <Adjustment>
postings. Note that this will cause the
-running total to often not add up! It's main use is for
+running total to often not add up! Its main use is for
.Fl \-amount-data Pq Fl j
and
.Fl \-total-data Pq Fl J
@@ -631,24 +741,35 @@ Suppress the output of group titles.
.It Fl \-no-total
Suppress printing the final total line in a balance report.
.It Fl \-now Ar DATE
-Define the current date in case to you to do calculate in the past or
-future using
-.Fl \-current .
+Use
+.Ar DATE
+as the current date. This affects the output when using
+.Fl \-period ,
+.Fl \-begin ,
+.Fl \-end ,
+or
+.Fl \-current
+to decide which dates lie in the past or future.
.It Fl \-only Ar EXPR
This is a postings predicate that applies after certain transforms have
been executed, such as periodic gathering.
.It Fl \-options
-Display the options in effect for this Ledger invocation, along with
+Display the options in effect for this
+.Nm
+invocation, along with
their values and the source of those values.
.It Fl \-output Ar FILE Pq Fl o
-Redirect the output of ledger to the file defined in
+Redirect the output of
+.Nm
+to
.Ar FILE .
.It Fl \-pager Ar STR
-Specify the pager program to use as
-.Ar STR .
+Use
+.Ar STR
+as the pager program.
.It Fl \-payee
-Sets a value expression for formatting the payee. In the
-.Nm register
+Sets a value expression for formatting the payee. In the
+.Ic register
report this prevents the second entry from having
a date and payee for each transaction.
.It Fl \-payee-width Ar INT
@@ -659,13 +780,13 @@ report to
Accounts, tags or commodities not previously declared will cause errors.
.It Fl \-pending
Use only postings that are marked pending.
-.It Fl \-percent Pq Fl \b'%'
+.It Fl \-percent Pq Fl %
Calculate the percentage value of each account in a balance reports.
Only works for account that have a single commodity.
.It Fl \-period Ar PERIOD Pq Fl p
Define a period expression that sets the time period during which
-transactions are to be accounted. For a
-.Nm register
+transactions are to be accounted. For a
+.Ic register
report only
the transactions that satisfy the period expression with be displayed.
For a balance report only those transactions will be accounted in the
@@ -673,9 +794,10 @@ final balances.
.It Fl \-period-sort
Sort the posting within transactions using the given value expression.
.It Fl \-permissive
-.It Fl \-pivot Ar STR
+Quiet balance assertions.
+.It Fl \-pivot Ar TAG
Produce a balance pivot report
-.Nm around
+.Qq around
the given
.Ar TAG .
.It Fl \-plot-amount-format Ar FMT
@@ -684,7 +806,7 @@ Define the output format for an amount data plot.
Define the output format for a total data plot.
.It Fl \-prepend-format Ar FMT
Prepend
-.Ar STR
+.Ar FMT
to every line of the output.
.It Fl \-prepend-width Ar INT
Reserve
@@ -696,28 +818,32 @@ Use the price of the commodity purchase for performing calculations.
.It Fl \-price-exp Ar STR Pq Fl Z
Set the expected freshness of price quotes, in
.Ar INT
-minutes. That
+minutes. That
is, if the last known quote for any commodity is older than this value,
and if
.Fl \-download
is being used, then the Internet will be
-consulted again for a newer price. Otherwise, the old price is still
+consulted again for a newer price. Otherwise, the old price is still
considered to be fresh enough.
Alias for
-.Fl \-leeway Ar INT Pq Fl Z
+.Fl \-leeway .
.It Fl \-prices-format Ar FMT
+Set the format for the
+.Ic prices
+report.
.It Fl \-pricedb-format Ar FMT
+Set the format expected for the historical price file.
.It Fl \-primary-date
-Show primary dates for all calculations. Alias for
+Show primary dates for all calculations. Alias for
.Fl \-actual-dates
.It Fl \-quantity Pq Fl O
Report commodity totals (this is the default).
.It Fl \-quarterly
-Synonym for
-\Fl \-period 'quarterly' .
+Shorthand for
+.Fl \-period Ar quarterly .
.It Fl \-raw
In the
-.Nm print
+.Ic print
report, show transactions using the exact same syntax as
specified by the user in their data file. Don't do any massaging or
interpreting. Can be useful for minor cleanups, like just aligning
@@ -726,44 +852,70 @@ amounts.
Account using only real transactions ignoring virtual and automatic
transactions.
.It Fl \-recursive-aliases
-Causes ledger to try to expand aliases recursively, i.e. try to expand
+Causes
+.Nm
+to try to expand aliases recursively, i.e. try to expand
the result of an earlier expansion again, until no more expansions apply.
.It Fl \-register-format Ar FMT
Define the output format for the
-.Nm register
+.Ic register
report.
.It Fl \-related Pq Fl r
In a register report show the related account. This is the other
-.Nm side
+.Em side
of the transaction.
.It Fl \-related-all
Show all postings in a transaction, similar to
.Fl \-related
-but show
-.Nm both sides
-of each transaction.
+but show both sides of each transaction.
.It Fl \-revalued
+Report discrepancy in values for manual reports by inserting
+<Revalued>
+postings.
+This is implied when using
+the
+.Fl \-exchange Pq Fl X
+or
+.Fl \-market Pq Fl V
+option.
.It Fl \-revalued-only
-.It Fl \-revalued-total Ar EXPR
+Show only
+<Revalued>
+postings.
+.It Fl \-revalued-total
+Display the sum of the revalued postings as the running total, which serves
+to show unrealized capital in a gain/losses report.
.It Fl \-rich-data
+When generating a ledger transaction from a CSV file using the
+.Ic convert
+command, add CSV, Imported, and UUID meta-data.
.It Fl \-seed Ar INT
Set the random seed to
.Ar INT
for the
-.Nm generate
+.Ic generate
command. Used as part of development testing.
.It Fl \-script Ar FILE
-Execute a ledger script.
+Execute a
+.Nm
+script.
.It Fl \-sort Ar EXPR Pq Fl S
-Sort the register report based on the value expression given to sort.
-.It Fl \-sort-all
+Sort the register report based on the value expression
+.Ar EXPR .
+.\".It Fl \-sort-all Ar EXPR
.It Fl \-sort-xacts
Sort the posting within transactions using the given value expression.
.It Fl \-start-of-week Ar STR
-Tell ledger to use a particular day of the week to start its "weekly"
-summary.
-.Fl \-start-of-week=1
-specifies Monday as the start of the week.
+Use
+.Ar STR
+as the particular day of the week to start when using the
+.Fl \-weekly
+option.
+.Ar STR
+can be day names, their abbreviations like
+.Qq Mon ,
+or the weekday number
+starting at 0 for Sunday.
.It Fl \-strict
Accounts, tags or commodities not previously declared will cause warnings.
.It Fl \-subtotal Pq Fl s
@@ -771,9 +923,15 @@ Report register as a single subtotal.
.It Fl \-tail Ar INT
Report only the last
.Ar INT
-entries. Only useful on a register report. Alias for
+entries. Only useful on a register report. Alias for
.Fl \-last Ar INT
+.It Fl \-time-colon
+Display the value for commodities based on seconds as hours and minutes.
+Thus 8100s will be displayed as 2:15h instead of 2.25h.
.It Fl \-time-report
+Add two columns to the
+.Ic balance
+report to show the earliest checkin and checkout times for timelog entries.
.It Fl \-total Ar EXPR Pq Fl T
Define a value expression used to calculate the total in reports.
.It Fl \-total-data Pq Fl J
@@ -781,18 +939,22 @@ Show only dates and totals to format the output for plots.
.It Fl \-total-width Ar INT
Set the width of the total field in the register report.
.It Fl \-trace Ar INT
-Enable tracing. The
+Enable tracing. The
.Ar INT
specifies the level of trace desired.
-.It Fl \-truncate Ar CODE
+.It Fl \-truncate Ar STR
Indicates how truncation should happen when the contents of columns
-exceed their width. Valid arguments are
-.Nm leading , Nm middle ,
+exceed their width. Valid arguments for
+.Ar STR
+are
+.Ar leading ,
+.Ar middle ,
and
-.Nm trailing .
+.Ar trailing .
The default is smarter than any of these three,
as it considers sub-names within the account name (that style is
-called "abbreviate").
+called
+.Qq abbreviate ) .
.It Fl \-unbudgeted
Show only un-budgeted postings.
.It Fl \-uncleared Pq Fl U
@@ -802,76 +964,97 @@ Show generated unrealized gain and loss accounts in the balance
report.
.It Fl \-unrealized-gains
Allow the user to specify what account name should be used for
-unrealized gains. Defaults to
-.Nm "Equity:Unrealized Gains" .
+unrealized gains. Defaults to
+.Sy "Equity:Unrealized Gains" .
Often set in one's
-.Nm ~/.ledgerrc
+.Pa ~/.ledgerrc
file to change the default.
.It Fl \-unrealized-losses
Allow the user to specify what account name should be used for
-unrealized gains. Defaults to
-.Nm "Equity:Unrealized Losses" .
+unrealized losses. Defaults to
+.Sy "Equity:Unrealized Losses" .
Often set in one's
-.Nm ~/.ledgerrc
+.Pa ~/.ledgerrc
file to change the default.
.It Fl \-unround
Perform all calculations without rounding and display results to full
precision.
.It Fl \-values
-Shows the values used by each tag when used in combination with the
-.Nm tags
+Show the values used by each tag when used in combination with the
+.Ic tags
command.
.It Fl \-value-expr Ar EXPR
+Set a global value expression annotation.
.It Fl \-verbose
-Print detailed information on the execution of Ledger.
+Print detailed information on the execution of
+.Nm .
.It Fl \-verify
-Enable additional assertions during run-time. This causes a significant
+Enable additional assertions during run-time. This causes a significant
slowdown. When combined with
.Fl \-debug Ar CODE
-ledger will produce memory trace information.
+.Nm
+will produce memory trace information.
.It Fl \-verify-memory
+Verify that every constructed object is properly destructed. This is for
+debugging purposes only.
.It Fl \-version
Print version information and exit.
.It Fl \-weekly Pq Fl W
-Synonym for
-.Fl \-period 'weekly' .
+Shorthand for
+.Fl \-period Ar weekly .
.It Fl \-wide Pq Fl w
-Assume 132 columns instead of 80.
+Assume 132 columns instead of the TTY width.
.It Fl \-yearly Pq Fl Y
-Synonym for
-.Fl \-period 'yearly' .
+Shorthand for
+.Fl \-period Ar yearly .
.El
-.Pp
.Sh PRE-COMMANDS
Pre-commands are useful when you aren't sure how a command or option
-will work. The difference between a pre-command and a regular command
+will work. The difference between a pre-command and a regular command
is that pre-commands ignore the journal data file completely, nor is
the user's init file read.
-.Pp
.Bl -tag -width -indent
-.It Nm args / query
-Evaluate the given arguments and report how Ledger interprets it against
-the following model transaction.
-.It Nm eval
+.It Ic args No / Ic query
+Evaluate the given arguments and report how
+.Nm
+interprets it against the following model transaction:
+.Bd -literal -offset indent
+2004/05/27 Book Store
+ ; This note applies to all postings. :SecondTag:
+ Expenses:Books 20 BOOK @ $10
+ ; Metadata: Some Value
+ ; Typed:: $100 + $200
+ ; :ExampleTag:
+ ; Here follows a note describing the posting.
+ Liabilities:MasterCard $-200.00
+.Ed
+.It Ic eval
Evaluate the given value expression against the model transaction.
-.It Nm format
-Print details of how ledger uses the given formatting description and
+.It Ic format
+Print details of how
+.Nm
+uses the given formatting description and
apply it against a model transaction.
-.It Nm parse / expr
-Print details of how ledger uses the given value expression description
+.It Ic parse No / Ic expr
+Print details of how
+.Nm
+uses the given value expression description
and apply it against a model transaction.
-.It Nm generate
-Randomly generates syntactically valid Ledger data from a seed. Used
+.It Ic generate
+Randomly generates syntactically valid
+.Nm
+data from a seed. Used
by the GenerateTests harness for development testing.
-.It Nm period
-Evaluate the given period and report how Ledger interprets it.
-.It Nm script
-.It Nm template
+.It Ic period
+Evaluate the given period and report how
+.Nm
+interprets it.
+.\".It Ic script
+.It Ic template
Shows the insertion template that the
-.Nm xact sub-command generates.
-This is a debugging command.
+.Ic xact
+command generates. This is a debugging command.
.El
-.Pp
.Sh QUERIES
The syntax for reporting queries can get somewhat complex. It is a series of
query terms with an implicit OR operator between them. The following terms
@@ -883,43 +1066,56 @@ Thus, to report the current balance for all assets and liabilities, you would
use:
.Pp
.Dl ledger bal asset liab
-.It Nm payee Ar regex Pq \&@ Ns Ar regex
+.It Ic payee Ar regex Pq Ic \&@ Ns Ar regex
Query on the payee, rather than the account.
-.It Nm tag Ar regex Pq \&% Ns Ar regex
-.It Nm note Ar regex Pq \&= Ns Ar regex
+.It Ic tag Ar regex Pq Ic \&% Ns Ar regex
+.It Ic note Ar regex Pq Ic \&= Ns Ar regex
Query on anything found in an item's note.
-.It Nm code Ar regex Pq \&# Ns Ar regex
+.It Ic code Ar regex Pq Ic \&# Ns Ar regex
Query on the xact's optional code (which can be any string the user wishes).
-.It Ar term Nm and Ar term
+.It Ar term Cm and Ar term
Query terms are joined by an implicit OR operator. You can change this to AND
-by using that keyword. For example, to show food expenditures occurring at
+by using the
+.Cm and
+keyword. For example, to show food expenditures occurring at
Shakee's Pizza, you could say:
.Pp
-.Dl ledger reg food and @Shakee
-.It Ar term Nm or Ar term
+.Dl Li ledger reg food and @Shakee
+.It Ar term Cm or Ar term
When you wish to be more explicit, use the OR operator.
-.It Nm show
-.It Nm not Ar term
+.It Ic show
+.It Cm not Ar term
Reverse the logical meaning of the following term. This can be used with
parentheses to great effect:
.Pp
-.Dl ledger reg food and @Shakee and not dining
+.Dl Li ledger reg food and @Shakee and not dining
.It \&( Ar term No \&)
If you wish to mix OR and AND operators, it is often helpful to surround
logical units with parentheses. \fBNOTE\fR: Because of the way some shells
interpret parentheses, you should always escape them:
.Pp
-.Dl ledger bal \e\\\&( assets or liab \e\\\&) and not food
+.Dl Li ledger bal \e( assets or liab \e) and not food
.El
-.Pp
.Sh EXPRESSIONS
.Bl -tag -width "partial_account"
-.It Nm account
-.It Nm account_base
-.It Nm account_amount
-.It Nm actual
-.It Nm amount
-.It Nm amount_expr
+.It Fn abs value
+Return the absolute value of the given
+.Ar value .
+.It Sy account
+Return the posting's account.
+.It Sy account_base
+Return the base account, i.e. everything after the last account delimiter ':'.
+.\".It Sy account_amount
+.It Sy actual
+.\" Is there a difference between real and actual?
+Return true if the transaction is real, i.e not a automated or virtual
+transaction, false otherwise.
+.It Sy amount
+Return the amount of the posting.
+.It Sy amount_expr
+Return the calculated amount of the posting according to the
+.Fl \-amount
+option.
.It Fn ansify_if value color bool
Render the given
.Ar value
@@ -928,112 +1124,330 @@ as a string, applying the proper ANSI escape codes to display it in the given
if
.Ar bool
is true. It typically checks the value of the option
-.Nm Fl \-color ,
+.Fl \-color ,
for example:
-.Dl ansify_if(amount, "blue", options.color)
-.It Nm beg_line
-.It Nm beg_pos
-.It Nm calculated
-.It Nm cleared
-.It Nm code
-.It Nm comment
-.It Nm commodity
-.It Nm cost
-.It Nm count
-.It Nm date
-.It Nm depth
-.It Nm depth_spacer
-.It Nm display_amount
-.It Nm display_total
-.It Nm end_line
-.It Nm end_pos
-.It Nm filename
-.It Nm format_date
-.It Nm get_at
-.It Nm has_meta
-.It Nm has_tag
-.It Nm is_seq
-.It Nm join
-.It Nm market
-.It Nm meta
-.It Nm note
-.It Nm null
-.It Nm options
-.It Nm partial_account
-.It Nm payee
-.It Nm pending
-.It Nm post
-.It Nm print
-.It Nm quantity
-.It Nm quoted
-.It Nm real
-.It Nm rounded
-.It Nm scrub
-.It Nm status
-.It Nm strip
-.It Nm subcount
-.It Nm tag
-.It Nm today
-.It Nm total
-.It Nm total_expr
-.It Nm truncate
-.It Nm uncleared
-.It Nm virtual
-.It Nm xact
+.Dl Li ansify_if(amount, "blue", options.color)
+.It Sy beg_line
+Line number where entry for posting begins.
+.It Sy beg_pos
+Character position where entry for posting begins.
+.\".It Sy calculated
+.It Fn ceiling value
+Return the next integer of
+.Ar value
+toward +infinity.
+.It Sy cleared
+Return true if the posting was cleared, false otherwise.
+.It Sy code
+Return the transaction code, the string between the parenthesis after the date.
+.\".It Sy comment
+.It Fn commodity value
+Return the commodity of
+.Ar value
+or the posting amount when
+.Ar value
+was not specified.
+.\".It Sy cost
+.\".It Sy count
+.It Sy date
+Return the date of the posting.
+.\".It Sy depth
+.\".It Sy depth_spacer
+.\".It Sy display_amount
+.\".It Sy display_total
+.It Sy end_line
+Line number where entry for posting ends.
+.It Sy end_pos
+Character position where entry for posting ends.
+.It Fn floor value
+Return the next integer of
+.Ar value
+toward -infinity.
+.It Sy filename
+The name of the
+.Nm
+data file from whence the posting came.
+.It Fn format string
+Evaluate
+.Ar string
+as format just like the
+.Fl \-format
+option.
+.It Fn format_date date format
+Return the
+.Ar date
+as a string using
+.Ar format .
+Refer to
+.Xr strftime 3
+for format string details.
+.It Fn format_datetime datetime format
+Return the
+.Ar datetime
+as a string using
+.Ar format .
+Refer to
+.Xr strftime 3
+for format string details.
+.It Fn get_at seq index
+Return value at
+.Ar index
+from
+.Ar seq .
+Used internally to construct different reports.
+.It Fn has_meta
+Return true if the posting has metadata named
+.Ar tag ,
+false otherwise.
+.It Fn has_tag tag
+Return true if the posting has metadata named
+.Ar tag ,
+false otherwise.
+.It Fn is_seq value
+Return true if
+.Ar value
+is a sequence. Used internally.
+.It Fn join value
+Replace all newlines in
+.Ar value
+with
+.Li \en .
+.It Fn justify value first_width latter_width right_justify colorize
+Right or left justify the string representing
+.Ar value .
+The width of the field in the first line is given by
+.Ar first_width .
+For subsequent lines the width is given by
+.Ar latter_width .
+If
+.Ar latter_width
+is -1,
+.Ar first_width
+is used for all lines.
+If
+.Ar right_justify
+is true then the field is right justified within the width of the field. If it
+is false, then the field is left justified and padded to the full width of the
+field. If
+.Ar colorize
+is true, then ledger will honor color settings.
+.It Fn market value datetime
+Return the price of
+.Ar value
+at
+.Ar datetime .
+Note that
+.Ar datetime
+must be surrounded by brackets in order to be parsed correctly, e.g.
+.Bq 2012/03/23 .
+.It Fn meta
+Return the value of metadata named
+.Ar name .
+.It Sy note
+Return the note for the posting.
+.It Sy now
+Return the current datetime.
+.\".It Sy null
+.It Sy options
+A variable that allows access to the values of the given command-line options
+using the long option names, e.g. to see whether
+.Fl \-daily Pq Fl D
+was given use
+.Sy option.daily .
+.\" .It Sy partial_account
+.It Sy payee
+Return the payee of the posting.
+.It Fn percent value_a value_b
+Return the percentage of
+.Ar value_a
+in relation to
+.Ar value_b
+(used as 100%).
+.It Sy pending
+Return true if the posting is marked as pending, false otherwise.
+.It Fn percent value_a value_b
+Return the percentage of
+.Ar value_a
+in relation to
+.Ar value_b .
+.\".It Sy post
+.\" A variable scope
+.It Fn print value
+Print
+.Ar value
+to stdout.
+Used internally for debugging.
+.It Fn quantity value
+Return the quantity of
+.Ar value
+for values that have a per-unit cost.
+.It Fn quoted expression
+Surround
+.Ar expression
+with double-quotes.
+.It Sy real
+.\" Is there a difference between real and actual?
+Return true if the transaction is real, i.e not a automated or virtual
+transaction, false otherwise.
+.\".It Sy rounded
+.It Fn roundto value n
+Return
+.Ar value
+rounded to
+.Ar n
+digits. Does not affect formatting.
+.It Sy should_bold
+Return true if expression given to
+.Fl \-bold-if
+evaluates to true. Internal use only!
+.It Fn scrub value
+Clean
+.Ar value
+using various transformations such as round,
+stripping value annotations, and more.
+.\".It Sy status
+.It Fn strip value
+Strip value annotation from
+.Ar value .
+.\".It Sy subcount
+.It Fn tag name
+Return the value of tag named
+.Ar name .
+.It Fn to_amount value
+Convert
+.Ar value
+to an amount. Internal use only!
+.It Fn to_balance value
+Convert
+.Ar value
+to a balance. Internal use only!
+.It Fn to_boolean value
+Convert
+.Ar value
+to a boolean. Internal use only!
+.It Fn to_date value
+Convert
+.Ar value
+to a date. Internal use only!
+.It Fn to_datetime value
+Convert
+.Ar value
+to a datetime. Internal use only!
+.It Fn to_int value
+Return the integer value for
+.Ar value .
+.It Fn to_mask value
+Convert
+.Ar value
+to a mask. Internal use only!
+.It Fn to_sequence value
+Convert
+.Ar value
+to a sequence. Internal use only!
+.It Fn to_string value
+Convert
+.Ar value
+to a character string.
+.It Sy today
+Return today's date.
+.It Sy total
+Return the total of the posting.
+.It Sy total_expr
+Return the calculated total of the posting according to the
+.Fl \-total
+option.
+.It Fn trim value
+Trim leading and trailing whitespace from
+.Ar value .
+.It Fn truncated string, total_len, account_len
+Truncate
+.Ar string
+to
+.Ar total_len
+enusring that each account is at least
+.Ar account_len
+long.
+.\".It Sy uncleared
+.It Sy virtual
+Return true if the transaction is virtual, e.g automated, false otherwise.
+.\".It Sy xact
+.\" A variable scope
.El
-.Pp
-.Sh ENTRIES
-.Pp
-.Sh FORMATS
-.Pp
+.\".Sh ENTRIES
+.\".Sh FORMATS
.Sh DEBUG COMMANDS
-In addition to the regular reporting commands, Ledger also accepts several
+In addition to the regular reporting commands,
+.Nm
+also accepts several
debug commands:
.Bl -tag -width balance
-.It Nm args Oo Ar report-query Oc
-Accepts a
-.Ar report-query
-as its argument and displays it back to the user along with a complete
-analysis of how Ledger interpreted it. Useful if you want to understand how
-report queries are translated into value expressions.
-.It Nm eval Oo Ar value-expression Oc
-Evaluates the given
+.It Ic args Oo Ar report-query Oc
+Display complete analysis of how
+.Nm
+interpreted the given
+.Ar report-query .
+Useful if you want to understand how report queries are translated into value
+expressions.
+.It Ic eval Oo Ar value-expression Oc
+Evaluate the given
.Ar value-expression
and prints the result. For more on value expressions, see the section
.Sx EXPRESSIONS .
-.It Nm format Oo Ar format-string Oc
-Accepts a
+.It Ic format Oo Ar format-string Oc
+Display an analysis of how
.Ar format-string
-and displays an analysis of how it was parsed, and what it would look like
-applied to a sample transaction. For more on format strings, see the section
+was parsed, and what it would look like applied to a sample transaction. For
+more on format strings, see the section
.Sx FORMATS .
-.It Nm generate
-Generates 50 randomly composed yet valid Ledger transactions.
-.It Nm parse Oo Ar value-expression Oc
-Parses the given
+.It Ic generate
+Generate 50 randomly composed yet valid
+.Nm
+transactions.
+.It Ic parse Oo Ar value-expression Oc
+Parse the given
.Ar value-expression
and display an analysis of the expression tree and its evaluated value. For
more on value expressions, see the section
.Sx EXPRESSIONS .
-.It Nm python Oo Ar file Oc
-Invokes a Python interpreter to read the given
+.It Ic python Oo Ar file Oc
+Invoke a Python interpreter to read the given
.Ar file .
-What is special about this is that the ledger module is builtin, not read from
-disk, so it doesn't require Ledger to be installed anywhere, or the shared
+What is special about this is that the
+.Nm
+module is builtin, not read from
+disk, so it doesn't require
+.Nm
+to be installed anywhere, or the shared
library variants to be built.
-.It Nm reload
-Used only in the
-.Tn REPL ,
-it causes an immediate reloading of all data files for the current session.
-.It Nm template Oo Ar draft-template Oc
-Accepts a
+.It Ic reload
+Reload all data files for the current session immediately.
+Can only be used in the
+.Tn REPL .
+.It Ic template Oo Ar draft-template Oc
+Display information about how
.Ar draft-template
-and displays information about how it was parsed. See the section on
+was parsed. See the section on
.Sx DRAFTS .
.El
-.Pp
+.Sh ENVIRONMENT
+Every option to
+.Nm
+may be set using an environment variable if the option has a long name.
+For example setting the environment variable
+.Ev LEDGER_DATE_FORMAT="%d.%m.%Y'
+will have the same effect as specifying
+.Fl \-date-format Ar '%d.%m.%Y'
+on the command-line. Options on the command-line always take precedence over
+environment variable settings, however.
+.Sh FILES
+.Bl -tag -width -indent
+.It Pa ~/.ledgerrc
+Your personal
+.Nm
+initializations.
+.El
.Sh SEE ALSO
-.Xr beancount 1,
+.Xr beancount 1 ,
.Xr hledger 1
.Sh AUTHORS
.An "John Wiegley"
diff --git a/doc/ledger3.texi b/doc/ledger3.texi
index 4dc3f48f..c4266c20 100644
--- a/doc/ledger3.texi
+++ b/doc/ledger3.texi
@@ -1,6 +1,8 @@
\input texinfo @c -*-texinfo-*-
@setfilename ledger3.info
+@include version.texi
+@set FIXME:UNDOCUMENTED @sc{undocumented}! Please help by contributing documentation for this feature.
@settitle Ledger: Command-Line Accounting
@c Before release, run C-u C-c C-u C-a (texinfo-all-menus-update with
@@ -56,7 +58,7 @@
@c the documentation itself, in that case the journal example data
@c needs to be specially marked as well using @smallexample @c input:UUID,
@c again with the UUID being the UUID of the corresponding ledger example
-@c command. If multiple inputs with the same UUID are found they will be
+@c command. If multiple inputs with the same UUID are found they will be
@c concatenated together and given as one set of data to the example command.
@c
@c @smallexample @c input:35CB2A3
@@ -86,6 +88,19 @@
@c $ 36.84 Expenses:Food:Dining
@c @end smallexample
@c
+@c To pass additional input to ledger for certain commands, e.g. convert add
+@c with_file:filename to the example command and add a file:UUID to an example
+@c that holds the additional input, where UUID is the UUID of the command,
+@c e.g.:
+@c
+@c @smallexample @c file:download.csv
+@c 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,,
+@c @end smallexample
+@c
+@c @smallexample @c command:94FD2B6,with_file:download.csv
+@c $ ledger -f sample.dat convert download.csv
+@c @end smallexample
+@c
@c Additionally DocTests.py will pass --args-only and --columns 80 to ledger
@c to ignore any default arguments from the environment or .ledgerrc.
@c
@@ -146,7 +161,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@titlepage
@title Ledger: Command-Line Accounting
-@subtitle For Version 3.1 of Ledger
+@subtitle For Version @value{VERSION} of Ledger
@author John Wiegley
@page
@vskip 0pt plus 1filll
@@ -160,7 +175,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@node Top, Introduction to Ledger, (dir), (dir)
@top Overview
-Ledger is a command line accounting tool that provides double-entry
+Ledger is a command-line accounting tool that provides double-entry
accounting based on a text journal. It provides no bells or whistles,
and returns the user to the days before user interfaces were even a
twinkling in their father's CRT.
@@ -175,7 +190,7 @@ twinkling in their father's CRT.
* Transactions::
* Building Reports::
* Reporting Commands::
-* Command-line Syntax::
+* Command-Line Syntax::
* Budgeting and Forecasting::
* Time Keeping::
* Value Expressions::
@@ -286,7 +301,7 @@ Here is a good place for an aside on the use of the word ``account''.
Most private people consider an account to be something that holds
money at an institution for them. Ledger uses a more general
definition of the word. An account is anywhere money can go. Other
-finance programs use ``categories'', Ledger uses accounts. So, for
+finance programs use ``categories'', Ledger uses accounts. So, for
example, if you buy some groceries at Trader Joe's, then more groceries
at Whole Food Market, you might assign the transactions like this
@@ -366,26 +381,33 @@ data, not for altering it.
@node Building the program, Getting help, Fat-free Accounting, Introduction to Ledger
@section Building the program
-Ledger is written in ANSI C++, and should compile on any platform. It
-depends on the GNU multiple precision arithmetic library (libgmp), and
-the Perl regular expression library (libpcre). It was developed using
-GNU make and gcc 3.3, on a PowerBook running OS/X.
-
-To build and install once you have these libraries on your system,
-enter these commands:
+Ledger is written in ANSI C++, and should compile on any unix platform.
+The easiest way to build and install ledger is to use the prepared
+acprep script, that does a lot of the footwork:
@smallexample
-$ ./configure && make install
+ # to install missing dependencies
+ ./acprep dependencies
+ # building ledger
+ ./acprep update
+ # to run the actual installation
+ make install
@end smallexample
+See the `help` subcommand to `acprep`, which explains some of its many
+options. You can run `make check` to confirm the result, and `make
+install` to install. If these intructions do not work for you can check the
+`INSTALL.md` in the source directory for more up do date build instructions.
+
@node Getting help, , Building the program, Introduction to Ledger
@section Getting help
@findex help
-Ledger has a complete online help system based on GNU Info. This
-manual can be searched directly from the command line using the
-following options: @code{ledger --help} brings up this entire manual in
-your TTY.
+Ledger has a complete online help system based on GNU Info. This manual
+can be searched directly from the command-line using @code{info ledger},
+which will bring up this entire manual in your TTY. Alternatively, the
+shorter man page can be accessed from the command-line either via
+@code{man ledger} or @code{ledger --help}
If you need help on how to use Ledger, or run into problems, you can
join the Ledger mailing list at
@@ -423,17 +445,17 @@ If you would rather start with your own journal right away please
* Balance Report::
* Register Report::
* Cleared Report::
-* Using the Windows Command Line::
+* Using the Windows Command-Line::
@end menu
-Please note that as a command line program, Ledger is controlled from
+Please note that as a command-line program, Ledger is controlled from
your shell. There are several different command shells that all
behave slightly differently with respect to some special characters.
In particular, the ``bash'' shell will interpret @samp{$} signs
differently than ledger and they must be escaped to reach the actual
program. Another example is ``zsh'', which will interpret @samp{^}
differently than ledger expects. In all cases that follow you should
-take that into account when entering the command line arguments as given.
+take that into account when entering the command-line arguments as given.
There are too many variations between shells to give concrete examples
for each.
@@ -595,7 +617,7 @@ $ ledger -f drewr3.dat register payee "Organic"
Assets:Checking $ -225.00 0
@end smallexample
-@node Cleared Report, Using the Windows Command Line, Register Report, Run a Few Reports
+@node Cleared Report, Using the Windows Command-Line, Register Report, Run a Few Reports
@subsection Cleared Report
@cindex cleared report
@findex cleared
@@ -630,7 +652,7 @@ $ ledger -f drewr3.dat cleared
$ -20.00 0 MasterCard
$ 200.00 0 Mortgage:Principal
$ -243.60 0 Tithe
----------------- ---------------- ---------
+---------------- ---------------- ---------
$ -243.60 0
@end smallexample
@@ -638,8 +660,8 @@ $ ledger -f drewr3.dat cleared
The first column shows the outstanding balance, the second column
shows the ``cleared'' balance.
-@node Using the Windows Command Line, , Cleared Report, Run a Few Reports
-@subsection Using the Windows Command Line
+@node Using the Windows Command-Line, , Cleared Report, Run a Few Reports
+@subsection Using the Windows Command-Line
@cindex windows cmd.exe
@cindex currency symbol display on windows
@@ -1075,10 +1097,10 @@ the left value's commodity. The result of this command might be:
@menu
* Commodity price histories::
-* Commodity equivalencies::
+* Commodity equivalences::
@end menu
-@node Commodity price histories, Commodity equivalencies, Commodities and Currencies, Commodities and Currencies
+@node Commodity price histories, Commodity equivalences, Commodities and Currencies, Commodities and Currencies
@subsection Commodity price histories
Whenever a commodity is purchased using a different commodity (such as
@@ -1100,13 +1122,13 @@ its various reports. It will always report balances in terms of the
commodity total, rather than the current value of those commodities.
To enable pricing reports, use one of the commodity reporting options.
-@node Commodity equivalencies, , Commodity price histories, Commodities and Currencies
-@subsection Commodity equivalencies
+@node Commodity equivalences, , Commodity price histories, Commodities and Currencies
+@subsection Commodity equivalences
Sometimes a commodity has several forms which are all equivalent. An
example of this is time. Whether tracked in terms of minutes, hours
or days, it should be possible to convert between the various forms.
-Doing this requires the use of commodity equivalencies.
+Doing this requires the use of commodity equivalences.
For example, you might have the following two postings, one which
transfers an hour of time into a @samp{Billable} account, and another
@@ -1134,10 +1156,12 @@ $ ledger --no-total balance Billable Project
-50.0m Project:XYZ
@end smallexample
+@findex C
+
This example works because ledger already knows how to handle seconds,
minutes and hours, as part of its time tracking support. Defining
-other equivalencies is simple. The following is an example that
-creates data equivalencies, helpful for tracking bytes, kilobytes,
+other equivalences is simple. The following is an example that
+creates data equivalences, helpful for tracking bytes, kilobytes,
megabytes, and more:
@smallexample @c input:validate
@@ -1152,7 +1176,7 @@ and a default precision, with a certain quantity of another commodity.
In the above example, kilobytes are reported with two decimal places
of precision and each kilobyte is equal to 1024 bytes.
-Equivalency chains can be as long as desired. Whenever a commodity
+Equivalence chains can be as long as desired. Whenever a commodity
would report as a decimal amount (less than @samp{1.00}), the next
smallest commodity is used. If a commodity could be reported in terms
of a higher commodity without resulting to a partial fraction, then
@@ -1375,7 +1399,7 @@ $ ledger --real --no-total bal
If more asset accounts are needed as the source of a posting, just
list them as you would normally, for example:
-@smallexample
+@smallexample @c input:validate
2004/03/25 Payment for books (paid from Checking)
Expenses:Books $100.00
Assets:Checking $-50.00
@@ -1522,7 +1546,7 @@ Accounts}).
@cindex posting format details
@strong{The format is very flexible and it isn't necessary that you
-indent and space out things exactly as shown. The only requirements
+indent and space out things exactly as shown. The only requirements
are that the start of the transaction (the date typically) is at the
beginning of the first line of the transaction, and the accounts are
indented by at least one space. If you omit the leading spaces in the
@@ -1543,7 +1567,7 @@ Ledger has a starting point.
At some convenient point in time you knew the balances and outstanding
obligation of every financial account you have. Those amounts form the
-basis of the opening entry for ledger. For example if you chose the
+basis of the opening entry for ledger. For example if you chose the
beginning of 2011 as the date to start tracking finances with ledger,
your opening balance entry could look like this:
@@ -1591,7 +1615,7 @@ Beneath these top level accounts you can have any level of detail you
desire. For example, if you want to keep specific track of how much
you spend on burgers and fries, you could have the following:
-@smallexample
+@smallexample @c input:validate
Expenses:Food:Hamburgers and Fries
@end smallexample
@@ -1652,7 +1676,7 @@ Dollars, Euros, Pounds, Francs, Shares etc. are all just ``commodities''.
Holdings in stocks, bonds, mutual funds and other financial
instruments can be labeled using whatever is convenient for you (stock
ticker symbols are suggested for publicly traded assets).@footnote{You
-can track @emph{anything}, even time or distance traveled. As long as
+can track @emph{anything}, even time or distance traveled. As long as
it cannot be created or destroyed inside your accounting system.}
For the rest of this manual, we will only use the word ``commodities''
@@ -1683,7 +1707,7 @@ business trip to Europe from the US:
@end smallexample
This says that $66.00 came out of checking and turned into 50
-Euros. The implied exchange rate was $1.32. Then 35.00 Euros were
+Euros. The implied exchange rate was $1.32. Then 35.00 Euros were
spent on Dinner in Munich.
Running a ledger balance report shows:
@@ -1740,7 +1764,7 @@ commodity name must be enclosed in double quotes @samp{"}:
Buying stock is a typical example that many will use that involves
multiple commodities in the same transaction. The type of the share
(AAPL for Apple Inc.) and the share purchase price in the currency
-unit you made the purchase in ($ for AAPL). Yes, the typical
+unit you made the purchase in ($ for AAPL). Yes, the typical
convention is as follows:
@smallexample @c input:validate
@@ -1834,8 +1858,8 @@ Assets:Checking because its amount is null.
@findex --exchange @var{COMMODITY}
Ledger allows you to have very detailed control over how your
-commodities are valued. You can fine tune the results given using the
-@option{--market} or @option{--exchange @var{COMMODITY}} options. There
+commodities are valued. You can fine tune the results given using the
+@option{--market} or @option{--exchange @var{COMMODITY}} options. There
are now several points of interception; you can specify the valuation
method:
@@ -1866,7 +1890,7 @@ The reference date the price should be relative.
@item target
A string identifying the ``target'' commodity, or the commodity the
-returned price should be in. This argument is null if @option{--market}
+returned price should be in. This argument is null if @option{--market}
was used instead of @option{--exchange @var{COMMODITY}}.
@end table
@@ -1875,16 +1899,16 @@ The valuation function should return an amount. If you've written
your function in Python, you can return something like
@samp{Amount("$100")}. If the function returns an explicit value,
that value is always used, regardless of the commodity, the date, or
-the desired target commodity. For example,
+the desired target commodity. For example,
-@smallexample
+@smallexample @c input:validate
define myfunc_seven(s, d, t) = 7 EUR
@end smallexample
In order to specify a fixed price, but still valuate that price into
the target commodity, use something like this:
-@smallexample
+@smallexample @c input:validate
define myfunc_five(s, d, t) = market(5 EUR, d, t)
@end smallexample
@@ -1892,14 +1916,14 @@ The @code{value} directive sets the valuation used for all commodities
used in the rest of the data stream. This is the fallback, if nothing
more specific is found.
-@smallexample
+@smallexample @c input:validate
value myfunc_seven
@end smallexample
You can set a specific valuation function on a per-commodity basis.
Instead of defining a function, you can also pass a lambda.
-@smallexample
+@smallexample @c input:validate
commodity $
value s, d, t -> 6 EUR
@end smallexample
@@ -1907,7 +1931,7 @@ commodity $
Each account can also provide a default valuation function for any
commodities transferred to that account.
-@smallexample
+@smallexample @c input:validate
account Expenses:Food5
value myfunc_five
@end smallexample
@@ -1915,7 +1939,7 @@ account Expenses:Food5
The metadata field @samp{Value}, if found, overrides the valuation
function on a transaction-wide or per-posting basis.
-@smallexample
+@smallexample @c input:validate
= @@XACT and Food
; Value:: 8 EUR
(Equity) $1
@@ -1998,10 +2022,9 @@ In order to combat inconsistency you can define allowable accounts and
payees. For simplicity, create a separate text file and define accounts
and payees like
-@smallexample
+@smallexample @c input:validate
account Expenses
account Expenses:Utilities
-...
@end smallexample
Using the @option{--strict} option will cause Ledger to complain if any
@@ -2017,7 +2040,7 @@ Warning: "FinanceData/Master.dat", line 15: Unknown account 'Allocation:Equities
If you have a large Ledger register already created use the
@command{accounts} command to get started:
-@smallexample
+@smallexample @c command:validate
$ ledger accounts >> Accounts.dat
@end smallexample
@@ -2081,6 +2104,7 @@ the syntax @code{[ACTUAL_DATE]} or @code{[=EFFECTIVE_DATE]} or
@item P
@findex --download
+@findex P
Specifies a historical price for a commodity. These are usually found
in a pricing history file (see the @option{--download (-Q)} option).
The syntax is:
@@ -2107,7 +2131,7 @@ postings, just as if it were a normal transaction.
@item ; # % | *
A line beginning with a semicolon, pound, percent, bar or asterisk
-indicates a comment, and is ignored. Comments will not be returned in
+indicates a comment, and is ignored. Comments will not be returned in
a ``print'' response.
@item indented ;
@@ -2205,7 +2229,7 @@ until an @samp{end apply account} directive was found.
Define an alias for an account name. If you have a deeply nested tree
of accounts, it may be convenient to define an alias, for example:
-@smallexample @c input:validate
+@smallexample @c input:94A99E8
alias Dining=Expenses:Entertainment:Dining
alias Checking=Assets:Credit Union:Joint Checking Account
@@ -2218,11 +2242,11 @@ The aliases are only in effect for transactions read in after the alias
is defined and are affected by @code{account} directives that precede
them.
-@smallexample @c command:validate
+@smallexample @c command:94A99E8
$ ledger bal --no-total ^Exp
@end smallexample
-@smallexample
+@smallexample @c output:94A99E8
$10.00 Expenses:Entertainment:Dining
@end smallexample
@@ -2230,7 +2254,7 @@ With the option @option{--recursive-aliases}, aliases can refer to other
aliases, the following example produces exactly the same transactions
and account names as the preceding one:
-@smallexample @c input:validate
+@smallexample @c input:83E1FB3
alias Entertainment=Expenses:Entertainment
alias Dining=Entertainment:Dining
alias Checking=Assets:Credit Union:Joint Checking Account
@@ -2240,11 +2264,11 @@ alias Checking=Assets:Credit Union:Joint Checking Account
Checking
@end smallexample
-@smallexample @c command:validate
+@smallexample @c command:83E1FB3
$ ledger balance --no-total --recursive-aliases ^Exp
@end smallexample
-@smallexample
+@smallexample @c output:83E1FB3
$10.00 Expenses:Entertainment:Dining
@end smallexample
@@ -2261,6 +2285,7 @@ assert <VALUE EXPRESSION BOOLEAN RESULT>
@end smallexample
@item bucket
+@anchor{bucket}
@c instance_t::default_account_directive
Defines the default account to use for balancing transactions.
Normally, each transaction has at least two postings, which must
@@ -2290,7 +2315,7 @@ bucket Assets:Checking
@findex register
Directs Ledger to replace any account matching a regex with the given
-account. For example:
+account. For example:
@smallexample @c input:validate
capture Expenses:Deductible:Medical Medical
@@ -2351,7 +2376,7 @@ The @code{default} sub-directive marks this as the ``default'' commodity.
@item define
@c instance_t::define_directive in textual.cc
-Allows you to define value expressions for future use. For example:
+Allows you to define value expressions for future use. For example:
@smallexample @c input:validate
define var_name=$100
@@ -2434,15 +2459,14 @@ payee KFC
The @code{alias} sub-directive provides a regex which, if it matches
a parsed payee, the declared payee name is substituted:
-@smallexample
+@smallexample @c input:validate
2012-02-27 KENTUCKY FRIED CHICKEN ; will be read as being 'KFC'
-...
@end smallexample
The @code{uuid} sub-directive specifies that a transaction with exactly
the uuid given should have the declared payee name substituted:
-@smallexample
+@smallexample @c input:validate
2014-05-13 UNHELPFUL PAYEE ; will be read as being 'KFC'
; UUID: 2a2e21d434356f886c84371eebac6e44f1337fda
@end smallexample
@@ -2503,7 +2527,7 @@ is the equivalent of:
@c TODO: the following paragraph seems to be false, the automated tests
@c fail, if anything appears after end apply tag.
-@c Note that anything following @code{end apply tag} is ignored. placing
+@c Note that anything following @code{end apply tag} is ignored. Placing
@c the name of the tag that is being closed is a simple way to keep
@c track.
@@ -2539,6 +2563,7 @@ This is a synonym for @code{comment} and must be closed by an
@code{end} tag.
@item year
+@anchor{year}
@c instance_t::year_directive in textual.cc
Denotes the year used for all subsequent transactions that give a date
without a year. The year should appear immediately after the
@@ -2554,24 +2579,28 @@ alone, for backwards compatibility with older Ledger versions.
@table @code
@item A
-See @code{bucket}.
+@findex A
+@xref{bucket}.
@item Y
-See @code{year}.
+@findex Y
+@xref{year}.
@item N SYMBOL
+@findex N
Indicates that pricing information is to be ignored for a given
symbol, nor will quotes ever be downloaded for that symbol. Useful
with a home currency, such as the dollar @samp{$}. It is recommended
that these pricing options be set in the price database file, which
defaults to @file{~/.pricedb}. The syntax for this command is:
-@smallexample
+@smallexample @c input:validate
N SYMBOL
@end smallexample
@item D AMOUNT
@findex xact
+@findex D
Specifies the default commodity to use, by specifying an amount in the
expected format. The @command{xact} command will use this commodity as
@@ -2586,6 +2615,7 @@ D $1,000.00
@end smallexample
@item C AMOUNT1 = AMOUNT2
+@findex C
Specifies a commodity conversion, where the first amount is given to
be equivalent to the second amount. The first amount should use the
decimal precision desired during reporting:
@@ -2595,6 +2625,12 @@ C 1.00 Kb = 1024 bytes
@end smallexample
@item I, i, O, o, b, h
+@findex I
+@findex i
+@findex O
+@findex o
+@findex b
+@findex h
These four relate to timeclock support, which permits Ledger to read
timelog files. See timeclock's documentation for more info on the
syntax of its timelog files.
@@ -2826,7 +2862,7 @@ default is uncleared. To mark a transaction cleared, put an asterisk
@end smallexample
@noindent
-To mark it pending, use a !:
+To mark it pending, use a @samp{!}:
@smallexample @c input:validate
2012-03-10 ! KFC
@@ -2970,17 +3006,17 @@ You can gang up multiple tags by sharing colons:
@findex payees
@findex --by-payee
-``Payee'' is a special metadata field. If set on a posting, it will be
+``Payee'' is a special metadata field. If set on a posting, it will be
used as the payee name for that posting. This affects the
@command{register} report, the @command{payees} report, and the
@option{--by-payee} option.
This is useful when for example you deposit 4 checks at a time to the
-bank. On the bank statement, there is just one amount @samp{$400}, but
+bank. On the bank statement, there is just one amount @samp{$400}, but
you can specify from whom each check came from, as shown by example
below:
-@smallexample @c input:validate
+@smallexample @c input:9B43E57
2010-06-17 Sample
Assets:Bank $400.00
Income:Check1 $-100.00 ; Payee: Person One
@@ -2989,14 +3025,20 @@ below:
Income:Check4 $-100.00 ; Payee: Person Four
@end smallexample
-When reporting this, it appears as:
+When reporting with
-@smallexample
-10-Jun-17 Sample Assets:Bank $400.00 $400.00
- Person One Income:Check1 $-100.00 $300.00
- Person Two Income:Check2 $-100.00 $200.00
- Person Three Income:Check3 $-100.00 $100.00
- Person Four Income:Check4 $-100.00 0
+@smallexample @c command:9B43E57
+$ ledger reg
+@end smallexample
+
+it appears as:
+
+@smallexample @c output:9B43E57
+10-Jun-17 Sample Assets:Bank $400.00 $400.00
+ Person One Income:Check1 $-100.00 $300.00
+ Person Two Income:Check2 $-100.00 $200.00
+ Person Three Income:Check3 $-100.00 $100.00
+ Person Four Income:Check4 $-100.00 0
@end smallexample
This shows that they are all in the same transaction (which is why the
@@ -3098,6 +3140,7 @@ the amount expression with parentheses:
@node Balance verification, Posting cost, Expression amounts, Transactions
@section Balance verification
+@findex --permissive
@menu
* Balance assertions::
@@ -3109,7 +3152,7 @@ the amount expression with parentheses:
If at the end of a posting's amount (and after the cost too, if there
is one) there is an equals sign, then Ledger will verify that the
total value for that account as of that posting matches the amount
-specified.
+specified. See @option{--permissive} option to relax the balance assertions checks.
There are two forms of this features: balance assertions, and balance
assignments.
@@ -3389,7 +3432,7 @@ but is not required to be used with them:
It should be noted that this is a convenience only for cases where you
buy and sell whole lots. The @{@{$500.00@}@} is @emph{not} an attribute
-of the commodity, whereas @{$5.00@} is. In fact, when you write
+of the commodity, whereas @{$50.00@} is. In fact, when you write
@{@{$500.00@}@}, Ledger just divides that value by 10 and sees
@{$50.00@}. So if you use the print command to look at this
transaction, you'll see the single braces form in the output. The
@@ -3397,10 +3440,10 @@ double braces price form is a shorthand only.
Plus, it comes with dangers. This works fine:
-@smallexample
+@smallexample @c input:validate
2012-04-10 My Broker
Assets:Brokerage 10 AAPL @@ $50.00
- Assets:Brokerage:Cash $750.00
+ Assets:Brokerage:Cash $-500.00
2012-04-10 My Broker
Assets:Brokerage:Cash $375.00
@@ -3463,7 +3506,7 @@ sensitive to this difference.
If you buy a stock last year, and ask for its value today, Ledger will
consult its price database to see what the most recent price for that
stock is. You can short-circuit this lookup by ``fixing'' the price
-at the time of a transaction. This is done using @{=AMOUNT@}:
+at the time of a transaction. This is done using @samp{@{=AMOUNT@}}:
@smallexample
2012-04-10 My Broker
@@ -3549,13 +3592,13 @@ If you use the functional form, you can either specify a function
name, or a lambda expression. Here's a function that yields the price
as $10 in whatever commodity is being requested:
-@smallexample
+@smallexample @c input:validate
define ten_dollars(s, date, t) = market($10, date, t)
@end smallexample
I can now use that in a lot value expression as follows:
-@smallexample
+@smallexample @c input:validate
2012-04-10 My Broker
Assets:Brokerage:Cash $375.00
Assets:Brokerage -5 AAPL @{$50.00@} ((ten_dollars)) @@@@ $375.00
@@ -3606,7 +3649,7 @@ after modifying them to suit your needs.
An automated transaction is a special kind of transaction which adds
its postings to other transactions any time one of that other
transactions' postings matches its predicate. The predicate uses the
-same query syntax as the Ledger command line.
+same query syntax as the Ledger command-line.
Consider this posting:
@@ -3811,7 +3854,7 @@ the generated posting.
@findex --effective
In the real world, transactions do not take place instantaneously.
-Purchases can take several days to post to a bank account. And you may
+Purchases can take several days to post to a bank account. And you may
pay ahead for something for which you want to distribute costs. With
Ledger you can control every aspect of the timing of a transaction.
@@ -3859,7 +3902,7 @@ $ ledger --effective --begin 2008/01/01 --end 2008/01/14 bal Income
@noindent
gives you your cash basis income in the same two weeks.
-Another use is distributing costs out in time. As an example, suppose
+Another use is distributing costs out in time. As an example, suppose
you just prepaid into a local vegetable co-op that sustains you
through the winter. It costs $225 to join the program, so you write
a check. You don't want your October grocery budget to be blown
@@ -3906,7 +3949,7 @@ $ ledger --effective register Groceries
A periodic transaction starts with a @samp{~} followed by a period
expression. Periodic transactions are used for budgeting and
forecasting only, they have no effect without the @option{--budget}
-option specified. For examples and details, @pxref{Budgeting and
+option specified. For examples and details, @pxref{Budgeting and
Forecasting}.
@node Concrete Example of Automated Transactions, , Periodic Transactions, Automated Transactions
@@ -4020,7 +4063,7 @@ may be excluded from reports by using @option{--real}.
The power of Ledger comes from the incredible flexibility in its
reporting commands, combined with formatting commands. Some options
control what is included in the calculations, and formatting controls
-how it is displayed. The combinations are infinite. This chapter will
+how it is displayed. The combinations are infinite. This chapter will
show you the basics of combining various options and commands. In the
next chapters you will find details about the specific commands and
options.
@@ -4158,7 +4201,7 @@ $ ledger bal Expenses and not (Expenses:Drinks or Expenses:Candy or Expenses:Gif
@subsection Controlling Formatting
These examples all use the default formatting for the balance
-report. Customizing the formatting can easily allowing to see only what
+report. Customizing the formatting can easily allowing to see only what
you want, or interface Ledger with other programs.
@node Typical queries, Advanced Reports, Balance Reports, Building Reports
@@ -4167,8 +4210,7 @@ you want, or interface Ledger with other programs.
A query such as the following shows all expenses since last
October, sorted by total:
-@c TODO: does not validate with @c command:validate, because "last oct" is split at the space
-@smallexample
+@smallexample @c command:validate
$ ledger -b "last oct" -S T bal ^expenses
@end smallexample
@@ -4260,11 +4302,11 @@ invested in equities, and partially invested in bonds and cash. Below
is the asset allocation for each of the instruments listed above:
@multitable @columnfractions .2 .2 .3 .3
-@item @tab Domestic @tab Global @tab
-@item Symbol @tab Equity @tab Equity @tab bonds/cash
-@item VIFSX @tab 100% @tab @tab
-@item VTHRX @tab 24.0% @tab 56.3% @tab 19.7%
-@item VSGBX @tab @tab @tab 100%
+@item @tab Domestic @tab Global @tab
+@item Symbol @tab Equity @tab Equity @tab bonds/cash
+@item VIFSX @tab 100% @tab @tab
+@item VTHRX @tab 24.0% @tab 56.3% @tab 19.7%
+@item VSGBX @tab @tab @tab 100%
@end multitable
These numbers are available from the prospectus of any publicly
@@ -4273,7 +4315,7 @@ and a single bond issue is 100% bonds.
We track purchases of specific investments using the symbol of that
investment as its commodity. How do we tell Ledger that a share of
-VTHRX is 24% Global equity etc.? Enter automatic transactions and
+VTHRX is 24% Domestic equity? Enter automatic transactions and
virtual accounts.
At the top of our ledger we enter automatic transactions that describe
@@ -4284,12 +4326,9 @@ actual balances.
For the three instruments listed above, those automatic transactions
would look like:
-@smallexample @c input:validate
-;
-; automatic calculations for asset allocation tracking
-;
+@smallexample @c input:582C8C2
= expr ( commodity == 'VIFSX' )
- (Allocation:Equities:Domestic) 1.000
+ (Allocation:Equities:Domestic) 1.000
= expr ( commodity == 'VTHRX' )
(Allocation:Equities:Global) 0.240
@@ -4298,6 +4337,18 @@ would look like:
= expr ( commodity == 'VBMFX')
(Allocation:Bonds/Cash) 1.000
+
+2015-01-01 Buy VIFSX
+ Assets:Broker 100 VIFSX
+ Assets:Cash $-10000
+
+2015-01-01 Buy VTHRX
+ Assets:Broker 10 VTHRX
+ Assets:Cash $-10000
+
+2015-01-01 Buy VBMFX
+ Assets:Broker 1 VBMFX
+ Assets:Cash $-10000
@end smallexample
How do these work? First the @samp{=} sign at the beginning of the
@@ -4316,23 +4367,21 @@ the various asset classes how do we get a report that tells us our
current allocation? Using the balance command and some tricky
formatting!
-@c TODO: does not @c command:validate due to multiple lines
-@smallexample
+@smallexample @c command:582C8C2
ledger bal Allocation --current --format "\
%-17((depth_spacer)+(partial_account))\
%10(percent(market(display_total), market(parent.total)))\
%16(market(display_total))\n%/"
@end smallexample
-@noindent
Which yields:
-@smallexample
-Allocation 100.00% $100000.00
- Bonds/Cash 38.94% $38940.00
- Equities 61.06% $61060.00
- Domestic 95.31% $58196.29
- Global 4.69% $2863.71
+@smallexample @c output:582C8C2
+ Allocation 100.00% $30000
+ Bonds/Cash 39.90% $11970
+ Equities 60.10% $18030
+ Domestic 86.69% $15630
+ Global 13.31% $2400
@end smallexample
Let's look at the Ledger invocation a bit closer. The command above is
@@ -4350,7 +4399,7 @@ third line is where we calculate and display the percentages. The
for the account in this line. The @code{parent.total} command gives
the total for the next level up in the tree. @code{percent} formats
their ratio as a percentage. The fourth line tells ledger to display
-the current market value of the line. The last two characters
+the current market value of the line. The last two characters
@samp{%/} tell Ledger what to do for the last line, in this case,
nothing.
@@ -4364,13 +4413,13 @@ nothing.
@findex --display @var{EXPR}
If you have the ``Gnuplot'' program installed, you can graph any of the
-above register reports. The script to do this is included in the ledger
-distribution, and is named @file{contrib/report}. Install @file{report}
+above register reports. The script to do this is included in the ledger
+distribution, and is named @file{contrib/report}. Install @file{report}
anywhere along your @env{PATH}, and then use @file{report} instead of
-@file{ledger} when doing a register report. The only thing to keep in
+@file{ledger} when doing a register report. The only thing to keep in
mind is that you must specify @option{--amount-data (-j)} or
@option{--total-data (-J)} to indicate whether ``Gnuplot'' should plot
-the amount, or the running total. For example, this command plots total
+the amount, or the running total. For example, this command plots total
monthly expenses made on your MasterCard.
@smallexample
@@ -4393,7 +4442,7 @@ report -J reg ^income ^expenses # cash flow report
report -J -l "Ua>=@{\$0.01@}" reg ^assets ^liab
-# net worth report starting last February. the use of a display
+# net worth report starting last February. the use of a display
# predicate (-d) is needed, otherwise the balance will start at
# zero, and thus the y-axis will not reflect the true balance
@@ -4409,7 +4458,7 @@ transactions @emph{displayed} to just those since last February, even
though those transactions from before will be computed as part of the
balance.
-@node Reporting Commands, Command-line Syntax, Building Reports, Top
+@node Reporting Commands, Command-Line Syntax, Building Reports, Top
@chapter Reporting Commands
@menu
@@ -4548,9 +4597,9 @@ Transaction Number,Date,Description,Memo,Amount Debit,Amount Credit,Balance,Chec
1113648,12/12/2011,"Withdrawal","Tuscan IT #00037657",-29.73,,00001908.37,,
@end smallexample
-Unfortunately, as it stands Ledger cannot read it, but you can. Ledger
+Unfortunately, as it stands Ledger cannot read it, but you can. Ledger
expects the first line to contain a description of the fields on each
-line of the file. The fields ledger can recognize contain these
+line of the file. The fields ledger can recognize contain these
case-insensitive strings @code{date}, @code{posted}, @code{code},
@code{payee} or @code{desc} or @code{description}, @code{amount},
@code{cost}, @code{total}, and @code{note}.
@@ -4577,7 +4626,7 @@ scripting.
If there are columns in the bank data you would like to keep in your
ledger data, besides the primary fields described above, you can name
them in the field descriptor list and Ledger will include them in the
-transaction as meta data if it doesn't recognize the field name. For
+transaction as meta data if it doesn't recognize the field name. For
example, if you want to capture the bank transaction number and it
occurs in the first column of the data use:
@@ -4589,24 +4638,69 @@ Ledger will include @samp{; transid: 767718} in the first transaction
from the file above.
@findex --invert
+@findex --auto-match
@findex --account @var{STR}
@findex --rich-data
-The @command{convert} command accepts three options. They are
-@option{--invert} which inverts the amount field,
-@option{--account @var{STR}} which you can use to specify the account to
-balance against, and @option{--rich-data} which stores
-additional metadata as tags. There is, for example,
-a UUID field. If an entry with the same UUID tag is already included in
-the normal ledger file (specified via @option{--file @var{FILE} (-f)} or
-via the environment variable @env{LEDGER_FILE}) this entry will not be
+The @command{convert} command accepts four options. They are
+@option{--invert} which inverts the amount field, @option{--auto-match}
+which automatically matches an account from the Ledger journal for every
+CSV line, @option{--account @var{STR}} which you can use to specify the
+account to balance against, and @option{--rich-data} which stores
+additional tag/value pairs.
+
+Using the two first lines of the above csv file,
+
+@smallexample @c file:01B0350
+,date,payee,note,amount,,,code,
+767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,,
+767406,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-1.03,,00001648.84,,
+@end smallexample
+
+and launching the below command,
+
+@smallexample @c command:01B0350,with_file:download.csv
+$ ledger convert download.csv --input-date-format "%m/%d/%Y" \
+ --invert --account Assets:MyBank --rich-data \
+ --file sample.dat --now=2012/01/13
+@end smallexample
+
+you will get the result:
+
+@smallexample @c output:01B0350
+2011/12/13 * Withdrawal ;ACE HARDWARE 16335 S HOUGHTON RD
+ ; CSV: 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,,
+ ; Imported: 2012/01/13
+ ; UUID: dfdc3c3d5c54c6967dd39d5b4e4fd1ea76e87233
+ Expenses:Unknown 8.8
+ Assets:MyBank
+
+2011/12/13 * Withdrawal ;ACE HARDWARE 16335 S HOUGHTON RD
+ ; CSV: 767406,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-1.03,,00001648.84,,
+ ; Imported: 2012/01/13
+ ; UUID: 63086448b1f29f7fd6efb11ea40660185a213f9d
+ Expenses:Unknown 1.03
+ Assets:MyBank
+@end smallexample
+
+The three added metadata are: @samp{CSV} as the original line from csv
+file, @samp{Imported} as the date when the csv file was imported into
+Ledger, and @samp{UUID} as a checksum of original csv line.
+
+If an entry with the same @samp{UUID} tag is already included in the
+normal ledger file (specified via @option{--file @var{FILE} (-f)} or via
+the environment variable @env{LEDGER_FILE}) this entry will not be
printed again.
+In the output above, the account is @samp{Expenses:Unknown} for CSV
+lines. You can use the @option{--auto-match} option to automatically
+match an account from your Ledger journal.
+
You can also use @command{convert} with @code{payee} and @code{account}
-directives. First, you can use the @code{payee} and @code{alias}
-directive to rewrite the @code{payee} field based on some rules. Then
+directives. First, you can use the @code{payee} and @code{alias}
+directive to rewrite the @code{payee} field based on some rules. Then
you can use the account and its @code{payee} directive to specify the
-account. I use it like this, for example:
+account. I use it like this, for example:
@smallexample @c input:validate
payee Aldi
@@ -4617,7 +4711,7 @@ account Aufwand:Einkauf:Lebensmittel
Note that it may be necessary for the output of @samp{ledger convert}
to be passed through @code{ledger print} a second time if you want to
-match on the new payee field. During the @code{ledger convert} run,
+match on the new payee field. During the @code{ledger convert} run,
only the original payee name as specified in the csv data seems to be
used.
@@ -4664,7 +4758,7 @@ a very naive but still useful application of the Babel system:
The following are some entries and I have requested that ledger be run
to generate a balance on the accounts. I could have asked for
a register or, in fact, anything at all the ledger can do through
-command line options.
+command-line options.
#+begin_src ledger :cmdline bal :results value
2010/01/01 * Starting balance
@@ -4703,7 +4797,7 @@ Using Babel, it is possible to record financial transactions
conveniently in an org file and subsequently generate the financial
reports required.
-As of Org mode 7.01, Ledger support is provided. Check the Babel
+As of Org mode 7.01, Ledger support is provided. Check the Babel
documentation on Worg for instructions on how to achieve this but
I currently do this directly as follows:
@@ -4715,7 +4809,7 @@ I currently do this directly as follows:
@end smallexample
Once Ledger support in Babel has been enabled, we can proceed to
-include Ledger entries within an org file. There are three ways (at
+include Ledger entries within an org file. There are three ways (at
least) in which these can be included:
@enumerate
@@ -4754,7 +4848,7 @@ The first two are described in more detail in this short tutorial.
The easiest, albeit possibly least useful, way in which to use Ledger
within an org file is to use a single source block to record all Ledger
-entries. The following is an example source block:
+entries. The following is an example source block:
@smallexample
#+name: allinone
@@ -4784,11 +4878,11 @@ entries. The following is an example source block:
@end smallexample
In this example, we have combined both expenses and income into one set
-of Ledger entries. We can now generate register and balance reports (as
+of Ledger entries. We can now generate register and balance reports (as
well as many other types of reports) using Babel to invoke Ledger with
-specific arguments. The arguments are passed to Ledger using the
-@code{:cmdline} header argument. In the code block above, there is no
-such argument so the system takes the default. For Ledger code blocks,
+specific arguments. The arguments are passed to Ledger using the
+@code{:cmdline} header argument. In the code block above, there is no
+such argument so the system takes the default. For Ledger code blocks,
the default @code{:cmdline} argument is @code{bal} and the result of
evaluating this code block (@kbd{C-c C-c}) would be:
@@ -4808,7 +4902,7 @@ evaluating this code block (@kbd{C-c C-c}) would be:
If, instead, you wished to generate a register of all the transactions,
you would change the @code{#+begin_src} line for the code block to
-include the required command line option:
+include the required command-line option:
@smallexample
#+begin_src ledger :cmdline reg
@@ -4818,16 +4912,16 @@ Evaluating the code block again would generate a different report.
Having to change the actual directive on the code block and re-evaluate
makes it difficult to have more than one view of your transactions and
-financial state. Eventually, Babel will support passing arguments to
+financial state. Eventually, Babel will support passing arguments to
@code{#+call} evaluations of code blocks but this support is missing
-currently. Instead, we can use the concepts of literary programming, as
+currently. Instead, we can use the concepts of literary programming, as
implemented by the @code{noweb} features of Babel, to help us.
@node Multiple Ledger source blocks with @code{noweb}, Income Entries, Embedded Ledger example with single source block, Org mode with Babel
@subsubsection Multiple Ledger source blocks with @code{noweb}
The @code{noweb} feature of Babel allows us to expand references to
-other code blocks within a code block. For Ledger, this can be used to
+other code blocks within a code block. For Ledger, this can be used to
group transactions according to type, say, and then bring various sets
of transactions together to generate reports.
@@ -4838,9 +4932,9 @@ these into expenses and income, as follows:
@subsubsection Income Entries
The first set of entries relates to income, either monthly pay or
-interest, all typically going into one of my bank accounts. Here, I have
+interest, all typically going into one of my bank accounts. Here, I have
placed several entries, but we could have had each entry in a separate
-@code{src} block. Note that all code blocks you wish to refer to later
+@code{src} block. Note that all code blocks you wish to refer to later
must have the @code{:noweb yes} header argument specified.
@smallexample
@@ -4868,7 +4962,7 @@ must have the @code{:noweb yes} header argument specified.
@subsubsection Expenses
The following entries relate to personal expenses, such as rent and
-food. Again, these have all been placed in a single @code{src} block but
+food. Again, these have all been placed in a single @code{src} block but
could have been done individually.
@smallexample
@@ -4888,8 +4982,8 @@ could have been done individually.
Given the ledger entries defined above in the income and expenses code
blocks, we can now refer to these using the noweb expansion directives,
-@code{<<name>>}. We can now define different code blocks to generate
-specific reports for those transactions. Below are two examples, one to
+@code{<<name>>}. We can now define different code blocks to generate
+specific reports for those transactions. Below are two examples, one to
generate a balance report and one to generate a register report of all
transactions.
@@ -4899,7 +4993,7 @@ transactions.
The overall balance of your account and expenditure with a breakdown
according to category is specified by passing the @code{:cmdline bal}
-argument to Ledger. This code block can now be evaluated (@kbd{C-c C-c})
+argument to Ledger. This code block can now be evaluated (@kbd{C-c C-c})
and the results generated by incorporating the transactions referred to
by the @code{<<income>>} and @code{<<expenses>>} lines.
@@ -4945,7 +5039,7 @@ to tell Ledger to exclude sub-accounts in the report.
@findex --monthly
You can also generate a monthly register (the @command{reg} command) by
-executing the following @code{src} block. This presents a summary of
+executing the following @code{src} block. This presents a summary of
transactions for each monthly period (the @option{--monthly (-M)}
argument) with a running total in the final column (which should be 0 at
the end if all the entries are correct).
@@ -4971,7 +5065,7 @@ the end if all the entries are correct).
@end smallexample
We could also generate a monthly report on our assets showing how these
-are increasing (or decreasing!). In this case, the final column will be
+are increasing (or decreasing!). In this case, the final column will be
the running total of the assets in our ledger.
@smallexample
@@ -4992,7 +5086,7 @@ the running total of the assets in our ledger.
@subsubsection Summary
This short tutorial shows how Ledger entries can be embedded in an org
-file and manipulated using Babel. However, only simple Ledger features
+file and manipulated using Babel. However, only simple Ledger features
have been illustrated; please refer to the Ledger documentation for
examples of more complex operations on a ledger.
@@ -5005,7 +5099,7 @@ ledger can generate a graph of the relationship between your various
commodities. The output file is in the ``dot'' format.
This is probably not very interesting, unless you have many different
-commodities valued in terms of each other. For example, multiple
+commodities valued in terms of each other. For example, multiple
currencies and multiple investments valued in those currencies.
@node The @command{xml} command, @command{prices} and @command{pricedb} commands, The @command{pricemap} command, Reports in other Formats
@@ -5200,7 +5294,7 @@ pricedb database files.
The @command{accounts} command reports all of the accounts in the
journal. Following the command with a regular expression will limit the
-output to accounts matching the regex. The output is sorted by name.
+output to accounts matching the regex. The output is sorted by name.
Using the @option{--count} option will tell you how many entries use
each account.
@@ -5210,11 +5304,13 @@ each account.
The @command{payees} command reports all of the unique payees in the
journal. Using the @option{--count} option will tell you how many
-entries use each payee. To filter the payees displayed you must use the
+entries use each payee. To filter the payees displayed you must use the
prefix @@:
-@smallexample
+@smallexample @c command:validate
$ ledger payees @@Nic
+@end smallexample
+@smallexample
Nicolas
Nicolas BOILABUS
Oudtshoorn Municipality
@@ -5294,7 +5390,7 @@ $ ledger xact 4/9 viva dining "DM 11.50"
@end smallexample
@command{draft} and @command{entry} are both synonyms of
-@command{xact}. @command{entry} is provided for backwards compatibility
+@command{xact}. @command{entry} is provided for backwards compatibility
with Ledger 2.X.
@node @command{stats}, @command{select}, @command{xact}, Reports about your Journals
@@ -5302,28 +5398,28 @@ with Ledger 2.X.
@findex stats
@findex stat
-FIX THIS ENTRY @c FIXME thdox
+@value{FIXME:UNDOCUMENTED}
@node @command{select}, , @command{stats}, Reports about your Journals
@subsection @command{select}
@findex select
-FIX THIS ENTRY @c FIXME thdox
+@value{FIXME:UNDOCUMENTED}
-@node Command-line Syntax, Budgeting and Forecasting, Reporting Commands, Top
-@chapter Command-line Syntax
+@node Command-Line Syntax, Budgeting and Forecasting, Reporting Commands, Top
+@chapter Command-Line Syntax
@menu
* Basic Usage::
-* Command Line Quick Reference::
+* Command-Line Quick Reference::
* Detailed Option Description::
* Period Expressions::
@end menu
-@node Basic Usage, Command Line Quick Reference, Command-line Syntax, Command-line Syntax
+@node Basic Usage, Command-Line Quick Reference, Command-Line Syntax, Command-Line Syntax
@section Basic Usage
-This chapter describes Ledger's features and options. You may wish to
+This chapter describes Ledger's features and options. You may wish to
survey this to get an overview before diving into the @ref{Ledger
Tutorial} and more detailed examples that follow.
@@ -5364,8 +5460,8 @@ There are many, many command options available with the @file{ledger}
program, and it takes a while to master them. However, none of them are
required to use the basic reporting commands.
-@node Command Line Quick Reference, Detailed Option Description, Basic Usage, Command-line Syntax
-@section Command Line Quick Reference
+@node Command-Line Quick Reference, Detailed Option Description, Basic Usage, Command-Line Syntax
+@section Command-Line Quick Reference
@menu
* Basic Reporting Commands::
@@ -5377,10 +5473,10 @@ required to use the basic reporting commands.
* Commodity Reporting::
@end menu
-@node Basic Reporting Commands, Basic Options, Command Line Quick Reference, Command Line Quick Reference
+@node Basic Reporting Commands, Basic Options, Command-Line Quick Reference, Command-Line Quick Reference
@subsection Basic Reporting Commands
-@ftable @code
+@ftable @command
@item balance
@itemx bal
@@ -5419,17 +5515,16 @@ Generate transactions based on previous postings.
@end ftable
-@node Basic Options, Report Filtering, Basic Reporting Commands, Command Line Quick Reference
+@node Basic Options, Report Filtering, Basic Reporting Commands, Command-Line Quick Reference
@subsection Basic Options
-@ftable @code
+@ftable @option
@item --help
@itemx -h
-Print summary of all options.
+Display the man page for @file{ledger}.
@item --version
-@itemx -v
Print version information and exit.
@item --file @var{FILE}
@@ -5444,16 +5539,19 @@ Redirect output to @file{FILE}.
@itemx -i @var{FILE}
Specify an options file.
+@item --import @var{FILE}
+Import @var{FILE} as Python module.
+
@item --account @var{STR}
@itemx -a @var{STR}
Specify default account @var{STR} for QIF file postings.
@end ftable
-@node Report Filtering, Error Checking and Calculation Options, Basic Options, Command Line Quick Reference
+@node Report Filtering, Error Checking and Calculation Options, Basic Options, Command-Line Quick Reference
@subsection Report Filtering
-@ftable @code
+@ftable @option
@item --current
@itemx -c
@@ -5506,7 +5604,8 @@ Show unbudgeted postings.
@item --unbudgeted
Show only unbudgeted postings.
-@item --forecast @var{VEXPR}
+@item --forecast-while @var{VEXPR}
+@itemx --forecast @var{VEXPR}
Project balances into the future.
@item --limit @var{EXPR}
@@ -5524,10 +5623,10 @@ Change the value expression used for ``totals'' column in
@end ftable
-@node Error Checking and Calculation Options, Output Customization, Report Filtering, Command Line Quick Reference
+@node Error Checking and Calculation Options, Output Customization, Report Filtering, Command-Line Quick Reference
@subsection Error Checking and Calculation Options
-@ftable @code
+@ftable @option
@item --strict
Accounts, tags or commodities not previously declared will cause
@@ -5538,7 +5637,7 @@ Accounts, tags or commodities not previously declared will cause errors.
@item --check-payees
Enable strict and pedantic checking for payees as well as accounts,
-commodities and tags. This only works in conjunction with
+commodities and tags. This only works in conjunction with
@option{--strict} or @option{--pedantic}.
@item --immediate
@@ -5546,10 +5645,10 @@ Instruct ledger to evaluate calculations immediately rather than lazily.
@end ftable
-@node Output Customization, Grouping Options, Error Checking and Calculation Options, Command Line Quick Reference
+@node Output Customization, Grouping Options, Error Checking and Calculation Options, Command-Line Quick Reference
@subsection Output Customization
-@ftable @code
+@ftable @option
@item --collapse
@itemx -n
@@ -5598,6 +5697,9 @@ Report the last @var{INT} postings.
@item --pager @var{FILE}
Direct output to @var{FILE} pager program.
+@item --no-pager
+Direct output to stdout, avoiding pager program.
+
@item --average
@itemx -A
Report the average posting value.
@@ -5650,10 +5752,10 @@ for filing bug reports.
@end ftable
-@node Grouping Options, Commodity Reporting, Output Customization, Command Line Quick Reference
+@node Grouping Options, Commodity Reporting, Output Customization, Command-Line Quick Reference
@subsection Grouping Options
-@ftable @code
+@ftable @option
@item --by-payee
@itemx -P
@@ -5687,15 +5789,16 @@ Group postings together, similar to the balance report.
@end ftable
-@node Commodity Reporting, , Grouping Options, Command Line Quick Reference
+@node Commodity Reporting, , Grouping Options, Command-Line Quick Reference
@subsection Commodity Reporting
-@ftable @code
+@ftable @option
@item --price-db @var{FILE}
Use @file{FILE} for retrieving stored commodity prices.
@item --price-exp @var{INT}
+@itemx --leeway @var{INT}
@itemx -Z @var{INT}
Set expected freshness of prices in @var{INT} minutes.
@@ -5703,8 +5806,9 @@ Set expected freshness of prices in @var{INT} minutes.
@itemx -Q
Download quotes using the script named @file{getquote}.
-@item --getquote @var{FILE}
-Sets the path to a user-defined script to download commodity prices.
+@c FIXME: The option doesn't exist currently.
+@c @item --getquote @var{FILE}
+@c Sets the path to a user-defined script to download commodity prices.
@item --quantity
@itemx -O
@@ -5724,7 +5828,7 @@ Report net gain or loss for commodities that have a price history.
@end ftable
-@node Detailed Option Description, Period Expressions, Command Line Quick Reference, Command-line Syntax
+@node Detailed Option Description, Period Expressions, Command-Line Quick Reference, Command-Line Syntax
@section Detailed Option Description
@menu
@@ -5748,7 +5852,7 @@ GUIs, which would make use of the different scopes by keeping an
instance of Ledger running in the background and running multiple
sessions with multiple reports per session.
-@ftable @code
+@ftable @option
@item --args-only
Ignore all environment and init-file settings and
@@ -5757,52 +5861,48 @@ or testing small journal files not associated with your main financial
database.
@item --debug @var{CODE}
-FIX THIS ENTRY @c FIXME thdox
+@value{FIXME:UNDOCUMENTED}
@item --help
@itemx -h
-Display the man page for ledger.
+Display the man page for @file{ledger}.
@item --init-file @var{FILE}
-Specify the location of the init file. The default is @file{~/.ledgerrc}.
+Specify the location of the init file. The default is @file{~/.ledgerrc}.
@item --options
Display the options in effect for this Ledger invocation, along with
their values and the source of those values, for example:
-@smallexample
-$ ledger --options bal --cleared -f ~/ledger/test/input/drewr3.dat
-===========================================================================
+@smallexample @c command:A9349E4,with_input:03ACB97
+$ ledger --options bal --cleared
+@end smallexample
+
+@smallexample @c output:A9349E4
+===============================================================================
[Global scope options]
+ --args-only --args-only
[Session scope options]
- --file = ~/ledger/test/input/drewr3.dat -f
- --price-db = ~/FinanceData/PriceDB $price-db
+ --file = A9349E4.dat --file
[Report scope options]
- --cleared --cleared
- --color ?normalize
- --date-format = %Y/%m/%d $date-format
- --limit = cleared --cleared
- --prepend-width = 0 ?normalize
- --meta-width = 0 ?normalize
- --date-width = 10 ?normalize
- --payee-width = 21 ?normalize
- --account-width = 21 ?normalize
- --amount-width = 12 ?normalize
- --total-width = 12 ?normalize
-===========================================================================
- $ 775.00 Assets:Checking
- $ -1,000.00 Equity:Opening Balances
- $ 225.00 Expenses:Food:Groceries
+ --cleared --cleared
+ --columns = 80 --columns
+ --limit = cleared --cleared
+===============================================================================
+ $15.00 Expenses
+ $12.45 Food
+ $2.55 Tips
+ $-15.00 Liabilities:MasterCard
--------------------
0
@end smallexample
@noindent
For the source column, a value starting with a @samp{-} or @samp{--}
-indicated the source was a command line argument. If the entry starts
-with a @samp{$}, the source was an environment variable. If the source
+indicated the source was a command-line argument. If the entry starts
+with a @samp{$}, the source was an environment variable. If the source
is @code{?normalize} the value was set internally by ledger, in
a function called @code{normalize_options}.
@@ -5810,20 +5910,22 @@ a function called @code{normalize_options}.
Execute a ledger script.
@item --trace @var{INT}
-FIX THIS ENTRY @c FIXME thdox
+Enable tracing. The @var{INT} specifies the level of trace desired.
@item --verbose
@itemx -v
-FIX THIS ENTRY @c FIXME thdox
+Print detailed information on the execution of Ledger.
@item --verify
-FIX THIS ENTRY @c FIXME thdox
+Enable additional assertions during run-time. This causes a significant
+slowdown. When combined with @option{--debug @var{CODE}} ledger will
+produce memory trace information.
@item --verify-memory
-FIX THIS ENTRY @c FIXME thdox
+@value{FIXME:UNDOCUMENTED}
@item --version
-FIX THIS ENTRY @c FIXME thdox
+Print version information and exit.
@end ftable
@@ -5837,16 +5939,25 @@ GUIs, which would make use of the different scopes by keeping an
instance of Ledger running in the background and running multiple
sessions with multiple reports per session.
-@ftable @code
-
-@item --cache @var{FIXME}
-FIX THIS ENTRY @c FIXME thdox
+@ftable @option
@item --check-payees
-FIX THIS ENTRY @c FIXME thdox
+Enable strict and pedantic checking for payees as well as accounts,
+commodities and tags. This only works in conjunction with
+@option{--strict} or @option{--pedantic}.
@item --day-break
-FIX THIS ENTRY @c FIXME thdox
+Break up @command{register} report of @ref{timelog} entries that span multiple
+days by day.
+@c see test/baseline/opt-day-break.dat
+@c @smallexample @c input:
+@c i 2015/
+@c @end smallexample
+@c @smallexample @c command:
+@c $ ledger reg --day-break
+@c @end smallexample
+@c @smallexample @c output:
+@c @end smallexample
@item --decimal-comma
Direct Ledger to parse journals using the European standard comma as
@@ -5854,24 +5965,29 @@ a decimal separator, not the usual period.
@item --download
@itemx -Q
-Direct Ledger to download prices using the script defined via the option
-@option{--getquote @var{FILE}}.
+Direct Ledger to download prices.
+@c using the script defined via the option
+@c @option{--getquote @var{FILE}}.
@item --explicit
-FIX THIS ENTRY @c FIXME thdox
+Direct Ledger to require pre-declarations for entities (such as accounts,
+commodities and tags) rather than taking entities from cleared
+transactions as defined. This option is useful in combination with
+@option{--strict} or @option{--pedantic}.
@item --file @var{FILE}
@itemx -f @var{FILE}
Specify the input @file{FILE} for this invocation.
-@item --getquote @var{FILE}
-@cindex getquote
-@cindex download prices
-Tell ledger where to find the user defined script to download prices
-information.
+@c FIXME: The option doesn't exist currently.
+@c @item --getquote @var{FILE}
+@c @cindex getquote
+@c @cindex download prices
+@c Tell ledger where to find the user defined script to download prices
+@c information.
@item --input-date-format @var{DATE_FORMAT}
-Specify the input date format for journal entries. For example,
+Specify the input date format for journal entries. For example,
@smallexample
$ ledger convert Export.csv --input-date-format "%m/%d/%Y"
@@ -5916,18 +6032,18 @@ Ledger does not expand any aliases if this option is specified.
Accounts, tags or commodities not previously declared will cause errors.
@item --permissive
-FIX THIS ENTRY @c FIXME thdox
+Quiet balance assertions.
@item --price-db @var{FILE}
Specify the location of the price entry data file.
@item --price-exp @var{INT}
-@itemx -Z @var{INT}
@itemx --leeway @var{INT}
-Set the expected freshness of price quotes, in @var{INT} minutes. That
+@itemx -Z @var{INT}
+Set the expected freshness of price quotes, in @var{INT} minutes. That
is, if the last known quote for any commodity is older than this value,
and if @option{--download} is being used, then the Internet will be
-consulted again for a newer price. Otherwise, the old price is still
+consulted again for a newer price. Otherwise, the old price is still
considered to be fresh enough.
@item --strict
@@ -5940,7 +6056,7 @@ a misspelled commodity or account) it will issue a warning giving you
the file and line number of the problem.
@item --recursive-aliases
-Normally, ledger only expands aliases once. With this option, ledger
+Normally, ledger only expands aliases once. With this option, ledger
tries to expand the result of alias expansion recursively, until no more
expansions apply.
@@ -5951,8 +6067,9 @@ based commodity as real hours and minutes.
For example 8100 seconds by default will be displayed as 2.25 whereas
with the @option{--time-colon} option they will be displayed as 2:15.
-@item --value-expr @var{FIXME}
-FIX THIS ENTRY @c FIXME thdox
+@item --value-expr @var{VEXPR}
+Set a global value expression annotation.
+@c needs example
@end ftable
@@ -5966,18 +6083,18 @@ GUIs, which would make use of the different scopes by keeping an
instance of Ledger running in the background and running multiple
sessions with multiple reports per session.
-@ftable @code
+@ftable @option
@item --abbrev-len @var{INT}
Set the minimum length an account can be abbreviated to if it doesn't
-fit inside the @code{account-width}. If @var{INT} is zero, then the
-account name will be truncated on the right. If @var{INT} is greater
+fit inside the @code{account-width}. If @var{INT} is zero, then the
+account name will be truncated on the right. If @var{INT} is greater
than @code{account-width} then the account will be truncated on the
left, with no shortening of the account names in order to fit into the
desired width.
@item --account @var{STR}
-Prepend @var{STR} to all accounts reported. That is, the option
+Prepend @var{STR} to all accounts reported. That is, the option
@samp{--account Personal} would tack @samp{Personal:} to the beginning
of every account reported in a balance report or register report.
@@ -5996,7 +6113,7 @@ Show only unbudgeted postings.
@item --amount @var{EXPR}
@itemx -t @var{EXPR}
Apply the given value expression to the posting amount (@pxref{Value
-Expressions}). Using @option{--amount @var{EXPR}} you can apply an
+Expressions}). Using @option{--amount @var{EXPR}} you can apply an
arbitrary transformation to the postings.
@item --amount-data
@@ -6012,7 +6129,9 @@ Set the width in characters of the amount column in the
Anonymize registry output, mostly for sending in bug reports.
@item --auto-match
-FIX THIS ENTRY @c FIXME thdox
+When generating a ledger transaction from a CSV file using the
+@command{convert} command, automatically match an account from the
+Ledger journal.
@item --aux-date
@itemx --effective
@@ -6025,7 +6144,7 @@ running totals.
@item --balance-format @var{FORMAT_STRING}
Specify the format to use for the @command{balance} report (@pxref{Format
-Strings}). The default is:
+Strings}). The default is:
@smallexample
"%(justify(scrub(display_total), 20, -1, true, color))"
@@ -6036,7 +6155,9 @@ Strings}). The default is:
@end smallexample
@item --base
-FIX THIS ENTRY @c ASK JOHN
+Reduce convertible commodities down the bottom of the conversion, e.g.
+display time in seconds. This also applies to custom commodity
+conversions (@pxref{Commodity equivalences}).
@item --basis
@itemx -B
@@ -6044,7 +6165,7 @@ FIX THIS ENTRY @c ASK JOHN
Report the cost basis on all posting.
@item --begin @var{DATE}
-Specify the start @var{DATE} of all calculations. Transactions before
+Specify the start @var{DATE} of all calculations. Transactions before
that date will be ignored.
@item --bold-if @var{VEXPR}
@@ -6060,7 +6181,7 @@ list all transactions since the beginning of December and print in
bold any posting greater than $100.
@item --budget
-Only display budgeted items. In a register report this
+Only display budgeted items. In a register report this
displays transactions in the budget, in a balance report this displays
accounts in the budget (@pxref{Budgeting and Forecasting}).
@@ -6086,9 +6207,9 @@ Consider only transactions that have been cleared for display and
calculation.
@item --cleared-format @var{FORMAT_STRING}
-FIX THIS ENTRY @c FIXME thdox: to keep?
+@c FIXME thdox: to keep?
Specify the format to use for the @command{cleared} report (@pxref{Format
-Strings}). The default is:
+Strings}). The default is:
@smallexample
"%(justify(scrub(get_at(total_expr, 0)), 16, 16 + prepend_width, "
@@ -6104,7 +6225,7 @@ Strings}). The default is:
@item --collapse
@itemx -n
-By default ledger prints all accounts in an account tree. With
+By default ledger prints all accounts in an account tree. With
@option{--collapse} it prints only the top level account specified.
@item --collapse-if-zero
@@ -6155,8 +6276,8 @@ Specify the format ledger should use to read and print dates
Specify the width, in characters, of the date column in the
@command{register} report.
-@item --datetime-format @var{FIXME}
-FIX THIS ENTRY @c ASK JOHN
+@item --datetime-format @var{DATETIME_FORMAT}
+Specify the format ledger should use to print datetimes.
@item --dc
Display register or balance in debit/credit format If you use
@@ -6221,11 +6342,11 @@ And with @option{--dc} it becomes this:
Limit the depth of the account tree. In a balance report, for example,
a @samp{--depth 2} statement will print balances only for accounts with
two levels, i.e. @samp{Expenses:Entertainment} but not
-@samp{Expenses:Entertainment:Dining}. This is a display predicate, which
+@samp{Expenses:Entertainment:Dining}. This is a display predicate, which
means it only affects display, not the total calculations.
@item --deviation
-Report each posting’s deviation from the average. It is only meaningful
+Report each posting’s deviation from the average. It is only meaningful
in the register and prices reports.
@item --display @var{EXPR}
@@ -6256,7 +6377,7 @@ Include empty accounts in the report and in average calculations.
@item --end @var{DATE}
Specify the end @var{DATE} for a transaction to be considered in the
-report. All transactions on or after this date are ignored.
+report. All transactions on or after this date are ignored.
@item --equity
Related to the @command{equity} command (@pxref{The @command{equity}
@@ -6264,28 +6385,29 @@ command}). Gives current account balances in the form of a register
report.
@item --exact
-FIX THIS ENTRY @c ASK JOHN
+Report beginning and ending of periods by the date of the first and last
+posting occurring in that period.
@item --exchange @var{COMMODITY}
@itemx -X @var{COMMODITY}
-Display values in terms of the given @var{COMMODITY}. The latest
+Display values in terms of the given @var{COMMODITY}. The latest
available price is used. The syntax
@option{-X @var{COMMODITY1}:@var{COMMODITY2}} displays values in @var{COMMODITY1}
in terms of @var{COMMODITY2} using the latest available price, but
will not automatically covert any other commodities to
@var{COMMODITY2}. Multiple @option{-X} arguments may be used on a
-single command line (as in
+single command-line (as in
@option{-X COMMODITY1:COMMODITY2 -X COMMODITY3:COMMODITY2}),
which is particularly useful for situations where many prices are
available for reporting in terms of @var{COMMODITY2}, but only a few
should be displayed that way.
@item --flat
-Force the full names of accounts to be used in the balance report. The
+Force the full names of accounts to be used in the balance report. The
balance report will not use an indented tree.
@item --force-color
-Output TTY color codes even if the TTY doesn't support them. Useful
+Output TTY color codes even if the TTY doesn't support them. Useful
for TTYs that don't advertise their capabilities correctly.
@item --force-pager
@@ -6315,15 +6437,17 @@ them.
@item --group-by @var{EXPR}
Group transactions together in the @command{register} report.
@var{EXPR} can be anything, although most common would be @code{payee}
-or @code{commodity}. The @code{tags()} function is also useful here.
+or @code{commodity}. The @code{tags()} function is also useful here.
@item --group-title-format @var{FORMAT_STRING}
Set the format for the headers that separates the report sections of
a grouped report. Only has an effect with a @option{--group-by
@var{EXPR}} register report.
-@smallexample
+@smallexample @c command:validate
$ ledger reg Expenses --group-by "payee" --group-title-format "------------------------ %-20(value) ---------------------\n"
+@end smallexample
+@smallexample
------------------------ 7-Eleven ---------------------
2011/08/13 7-Eleven Expenses:Auto:Misc $ 5.80 $ 5.80
@@ -6331,21 +6455,21 @@ $ ledger reg Expenses --group-by "payee" --group-title-format "-----------------
2011/06/02 AAA Dues Expenses:Auto:Misc $ 215.00 $ 215.00
------------------------ ABC Towing and Wrecking ---------------------
-2011/03/17 ABC Towing and Wrec.. Expenses:Auto:Hobbies $ 48.20 $ 48.20
+2011/03/17 ABC Towing and Wrec.. Expenses:Auto:Hobbies $ 48.20 $ 48.20
...
@end smallexample
@item --head @var{INT}
@itemx --first @var{INT}
-Print the first @var{INT} entries. Opposite of @option{--tail
+Print the first @var{INT} entries. Opposite of @option{--tail
@var{INT}}.
@item --historical
@itemx -H
-FIX THIS ENTRY @c FIXME thdox
+Value commodities at the time of their acquisition.
@item --immediate
-FIX THIS ENTRY @c FIXME thdox
+Evaluate calculations immediately rather than lazily.
@item --inject
Use @code{Expected} amounts in calculations. In case you know
@@ -6386,7 +6510,8 @@ Report the date and price at which each commodity was purchased in
a balance report.
@item --lots-actual
-FIX THIS ENTRY
+Preserve the uniqueness of commodities so they aren't merged during
+reporting without printing the lot annotations.
@item --market
@itemx -V
@@ -6410,8 +6535,15 @@ Aliases are completely ignored.
@item --no-color
Suppress any color TTY output.
+@item --no-pager
+Direct output to stdout, avoiding pager program.
+
+@item --no-revalued
+Stop Ledger from showing @code{<Revalued>} postings. This option is useful
+in combination with the @option{--exchange} or @option{--market} option.
+
@item --no-rounding
-Don't output @samp{<Rounding>} postings. Note that this will cause the
+Don't output @samp{<Adjustment>} postings. Note that this will cause the
running total to often not add up! Its main use is for
@option{--amount-data (-j)} and @option{--total-data (-J)} reports.
@@ -6433,10 +6565,10 @@ been executed, such as periodic gathering.
Redirect the output of ledger to the file defined in @file{FILE}.
@item --pager @var{FILE}
-Specify the pager program to use.
+Direct output to @var{FILE} pager program.
@item --payee @var{VEXPR}
-Sets a value expression for formatting the payee. In the
+Sets a value expression for formatting the payee. In the
@command{register} report this prevents the second entry from having
a date and payee for each transaction.
@@ -6454,20 +6586,22 @@ Only works for accounts that have a single commodity.
@item --period @var{PERIOD_EXPRESSION}
Define a period expression that sets the time period during which
-transactions are to be accounted. For a @command{register} report only
+transactions are to be accounted. For a @command{register} report only
the transactions that satisfy the period expression with be displayed.
For a @command{balance} report only those transactions will be accounted
in the final balances.
@item --pivot @var{TAG}
-Produce a balance pivot report @emph{around} the given @var{TAG}. For
+Produce a balance pivot report @emph{around} the given @var{TAG}. For
example, if you have multiple cars and track each fuel purchase in
@samp{Expenses:Auto:Fuel} and tag each fuel purchase with a tag
identifying which car the purchase was for @samp{; Car: Prius}, then the
command:
-@smallexample
+@smallexample @c command:validate
$ ledger bal Fuel --pivot "Car" --period "this year"
+@end smallexample
+@smallexample
$ 3491.26 Car
$ 1084.22 M3:Expenses:Auto:Fuel
$ 149.65 MG V11:Expenses:Auto:Fuel
@@ -6481,11 +6615,11 @@ $ ledger bal Fuel --pivot "Car" --period "this year"
@xref{Metadata values}.
@item --plot-amount-format @var{FORMAT_STRING}
-Define the output format for an amount data plot. @xref{Visualizing
+Define the output format for an amount data plot. @xref{Visualizing
with Gnuplot}.
@item --plot-total-format @var{FORMAT_STRING}
-Define the output format for a total data plot. @xref{Visualizing with
+Define the output format for a total data plot. @xref{Visualizing with
Gnuplot}.
@item --prepend-format @var{FORMAT_STRING}
@@ -6499,10 +6633,10 @@ Reserve @var{INT} spaces at the beginning of each line of the output.
Use the price of the commodity purchase for performing calculations.
@item --pricedb-format @var{FORMAT_STRING}
-FIX THIS ENTRY @c FIXME thdox
+Set the format expected for the historical price file.
@item --prices-format @var{FORMAT_STRING}
-FIX THIS ENTRY @c FIXME thdox
+Set the format for the @command{prices} report.
@item --primary-date
@itemx --actual-dates
@@ -6538,20 +6672,24 @@ Show all postings in a transaction, similar to @option{--related} but
show both @emph{sides} of each transaction.
@item --revalued
-FIX THIS ENTRY
+Report discrepancy in values for manual reports by inserting @code{<Revalued>}
+postings. This is implied when using the @option{--exchange} or
+@option{--market} option.
@item --revalued-only
-FIX THIS ENTRY
+Show only @code{<Revalued>} postings.
@item --revalued-total @var{FIXME}
-FIX THIS ENTRY
+Display the sum of the revalued postings as the running total, which serves
+to show unrealized capital in a gain/losses report.
@item --rich-data
@itemx --detail
-FIX THIS ENTRY @c FIXME thdox
+When generating a ledger transaction from a CSV file using the
+@command{convert} command, add CSV, Imported, and UUID metadata.
-@item --seed @var{FIXME}
-Set the random seed to @var{FIXME} for the @code{generate} command.
+@item --seed @var{INT}
+Set the random seed to @var{INT} for the @code{generate} command.
Used as part of development testing.
@item --sort @var{VEXPR}
@@ -6560,7 +6698,7 @@ Sort the @command{register} report based on the value expression given
to sort.
@item --sort-all @var{FIXME}
-FIX THIS ENTRY
+@value{FIXME:UNDOCUMENTED}
@item --sort-xacts @var{VEXPR}
@itemx --period-sort @var{VEXPR}
@@ -6568,20 +6706,21 @@ Sort the postings within transactions using the given value expression.
@item --start-of-week @var{INT}
Tell ledger to use a particular day of the week to start its ``weekly''
-summary. @samp{--start-of-week=1} specifies Monday as the start of the
+summary. @samp{--start-of-week=1} specifies Monday as the start of the
week.
@item --subtotal
@itemx -s
-FIX THIS ENTRY
+@value{FIXME:UNDOCUMENTED}
@item --tail @var{INT}
@itemx --last @var{INT}
-Report only the last @var{INT} entries. Only useful in
+Report only the last @var{INT} entries. Only useful in
a @command{register} report.
@item --time-report
-FIX THIS ENTRY @c FIXME thdox
+Add two columns to the balance report to show the earliest checkin and
+checkout times for timelog entries.
@item --total @var{VEXPR}
@itemx -T @var{VEXPR}
@@ -6596,8 +6735,8 @@ Set the width of the total field in the register report.
@item --truncate @var{CODE}
Indicates how truncation should happen when the contents of columns
-exceed their width. Valid arguments are @samp{leading}, @samp{middle},
-and @samp{trailing}. The default is smarter than any of these three,
+exceed their width. Valid arguments are @samp{leading}, @samp{middle},
+and @samp{trailing}. The default is smarter than any of these three,
as it considers sub-names within the account name (that style is
called ``abbreviate'').
@@ -6614,12 +6753,12 @@ report.
@item --unrealized-gains @var{STR}
Allow the user to specify what account name should be used for
-unrealized gains. Defaults to @samp{"Equity:Unrealized Gains"}.
+unrealized gains. Defaults to @samp{"Equity:Unrealized Gains"}.
Often set in one's @file{~/.ledgerrc} file to change the default.
@item --unrealized-losses @var{STR}
Allow the user to specify what account name should be used for
-unrealized gains. Defaults to @samp{"Equity:Unrealized Losses"}.
+unrealized losses. Defaults to @samp{"Equity:Unrealized Losses"}.
Often set in one's @file{~/.ledgerrc} file to change the default.
@item --unround
@@ -6651,12 +6790,11 @@ These are the most basic command options. Most likely, the user will
want to set them using environment variables (see @ref{Environment
variables}), instead of using actual command-line options:
-@ftable @code
+@ftable @option
@item --help
@itemx -h
-Print a summary of all the options, and what they are used for. This
-can be a handy way to remember which options do what.
+Display the man page for @file{ledger}.
@item --version
Print the current version of ledger and exits. This is useful for
@@ -6665,9 +6803,9 @@ are using.
@item --file @var{FILE}
@itemx -f @var{FILE}
-Read @file{FILE} as a ledger file. @var{FILE} can be @samp{-} which is
-a synonym for @samp{/dev/stdin}. This command may be used multiple
-times. Typically, the environment variable @env{LEDGER_FILE} is set,
+Read @file{FILE} as a ledger file. @var{FILE} can be @samp{-} which is
+a synonym for @samp{/dev/stdin}. This command may be used multiple
+times. Typically, the environment variable @env{LEDGER_FILE} is set,
rather than using this command-line option.
@item --output @var{FILE}
@@ -6683,7 +6821,7 @@ settings. To specify options in the init file, use the same syntax as
on the command-line, but put each option on its own line. Here is an
example init file:
-@smallexample
+@smallexample @c input:validate
--price-db ~/finance/.pricedb
--wide
; ~/.ledgerrc ends here
@@ -6705,7 +6843,7 @@ relate to.
These options change which postings affect the outcome of a
report, in ways other than just using regular expressions:
-@ftable @code
+@ftable @option
@item --current
@itemx -c
@@ -6870,7 +7008,7 @@ Set the value expression used for the ``totals'' column in the
These options affect only the output, but not which postings are
used to create it:
-@ftable @code
+@ftable @option
@item --collapse
@itemx -n
@@ -6922,7 +7060,7 @@ least, using the absolute value of the total. For more on how to use
value expressions, see @ref{Value Expressions}.
@item --pivot @var{TAG}
-Produce a pivot table around the @var{TAG} provided. This requires
+Produce a pivot table around the @var{TAG} provided. This requires
meta data using valued tags.
@item --wide
@@ -6931,18 +7069,22 @@ Cause the default @command{register} report to assume 132 columns
instead of 80.
@item --head @var{INT}
-Cause only the first @var{INT} transactions to be printed. This is
+Cause only the first @var{INT} transactions to be printed. This is
different from using the command-line utility @file{head}, which would
-limit to the first @var{INT} postings. @option{--tail @var{INT}} outputs
-only the last @var{INT} transactions. Both options may be used
-simultaneously. If a negative amount is given, it will invert the
+limit to the first @var{INT} postings. @option{--tail @var{INT}} outputs
+only the last @var{INT} transactions. Both options may be used
+simultaneously. If a negative amount is given, it will invert the
meaning of the flag (instead of the first five transactions being
printed, for example, it would print all but the first five).
@item --pager @var{FILE}
-Tell Ledger to pass its output to the given pager program; very useful
-when the output is especially long. This behavior can be made the
-default by setting the @env{LEDGER_PAGER} environment variable.
+Tell Ledger to pass its output to the given @var{FILE} pager program;
+very useful when the output is especially long. This behavior can be
+made the default by setting the @env{LEDGER_PAGER} environment variable.
+
+@item --no-pager
+Tell Ledger to @emph{not} pass its output to a pager program; useful
+when a pager is set by default.
@item --average
@itemx -A
@@ -6982,8 +7124,7 @@ register report, for example, but they will not be displayed. This is
useful for seeing last month's checking postings, against a running
balance which includes all posting values:
-@c TODO: does not @c command:validate due to space in "last month"
-@smallexample
+@smallexample @c command:validate
$ ledger -d "d>=[last month]" reg checking
@end smallexample
@@ -6991,8 +7132,7 @@ The output from this command is very different from the following,
whose running total includes only postings from the last month
onward:
-@c TODO: does not @c command:validate due to space in "last month"
-@smallexample
+@smallexample @c command:validate
$ ledger -p "last month" reg checking
@end smallexample
@@ -7035,7 +7175,7 @@ Define the output format for the @command{balance} report. The default
@end smallexample
@item --cleared-format @var{FORMAT_STRING}
-Define the format for the cleared report. The default is:
+Define the format for the cleared report. The default is:
@smallexample
"%(justify(scrub(get_at(display_total, 0)), 16, 16 + int(prepend_width),
@@ -7046,7 +7186,7 @@ Define the format for the cleared report. The default is:
%-(ansify_if(partial_account(options.flat), blue if color))\n%/
%$1 %$2 %$3\n%/
%(prepend_width ? \" \" * int(prepend_width) : \"\")
- ---------------- ---------------- ---------\n"
+ ---------------- ---------------- ---------\n"
@end smallexample
@item --register-format @var{FORMAT_STRING}
@@ -7103,7 +7243,7 @@ Set the format for @command{csv} reports. The default is:
@item --plot-amount-format @var{FORMAT_STRING}
Set the format for amount plots, using the @option{--amount-data (-j)}
-option. The default is:
+option. The default is:
@smallexample
"%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(display_amount)))\n"
@@ -7118,14 +7258,14 @@ option. The default is:
@end smallexample
@item --pricedb-format @var{FORMAT_STRING}
-Set the format expected for the historical price file. The default is:
+Set the format expected for the historical price file. The default is:
@smallexample
"P %(datetime) %(display_account) %(scrub(display_amount))\n"
@end smallexample
@item --prices-format @var{FORMAT_STRING}
-Set the format for the @command{prices} report. The default is:
+Set the format for the @command{prices} report. The default is:
@smallexample
"%(date) %-8(display_account) %(justify(scrub(display_amount), 12,
@@ -7139,7 +7279,7 @@ Set the format for the @command{prices} report. The default is:
These options affect how commodity values are displayed:
-@ftable @code
+@ftable @option
@item --price-db @var{FILE}
Set the file that is used for recording downloaded commodity prices.
@@ -7148,7 +7288,7 @@ settings can be placed in this file manually, to prevent downloading
quotes for a specific commodity, for example. This is done by adding a
line like the following:
-@smallexample
+@smallexample @c input:validate
; Don't download quotes for the dollar, or timelog values
N $
N h
@@ -7163,11 +7303,12 @@ The format of the file can be changed by telling ledger to use the
@option{--pricedb-format @var{FORMAT_STRING}} you define.
@item --price-exp @var{INT}
+@itemx --leeway @var{INT}
@itemx -Z @var{INT}
-Set the expected freshness of price quotes, in @var{INT} minutes. That
+Set the expected freshness of price quotes, in @var{INT} minutes. That
is, if the last known quote for any commodity is older than this value,
and if @option{--download} is being used, then the Internet will be
-consulted again for a newer price. Otherwise, the old price is still
+consulted again for a newer price. Otherwise, the old price is still
considered to be fresh enough.
@item --download
@@ -7189,7 +7330,7 @@ expressions, and the @option{--amount @var{EXPR} (-t)} and
several ``default'' reports, which will satisfy most users' basic
reporting needs:
-@ftable @code
+@ftable @option
@item --quantity
@itemx -O
@@ -7225,7 +7366,7 @@ etc.
When you specify @option{--market (-V)}, or @option{--exchange
@var{COMMODITY} (-X)}, you are requesting that some or all of the
commodities be valuated as of today (or whatever @option{--now
-@var{DATE}} is set to). But what does such a valuation mean? This
+@var{DATE}} is set to). But what does such a valuation mean? This
meaning is governed by the presence of a @var{VALUE} meta-data property,
whose content is an expression used to compute that value.
@@ -7265,7 +7406,7 @@ they cannot have a different future value:
@end smallexample
This says the future valuation is the same as the valuation at the time
-of posting. post.date equals the posting's date, while just 'date' is
+of posting. @code{post.date} equals the posting's date, while just 'date' is
the value of @option{--now @var{DATE}} (defaults to today).
Or how about valuating miles based on a reimbursement rate during a
@@ -7377,21 +7518,20 @@ BTC:USD}.
@node Environment variables, , Commodity reporting, Detailed Option Description
@subsection Environment variables
-Every option to ledger may be set using an environment variable. If
-an option has a long name such @option{--this-option}, setting the
-environment variable @env{LEDGER_THIS_OPTION} will have the same
-effect as specifying that option on the command-line. Options on the
-command-line always take precedence over environment variable
-settings, however.
+Every option to ledger may be set using an environment variable if the
+option has a long name. For example setting the environment variable
+@samp{@env{LEDGER_DATE_FORMAT}="%d.%m.%Y"} will have the same effect as specifying
+@samp{@option{--date-format} '%d.%m.%Y'} on the command-line. Options on the
+command-line always take precedence over environment variable settings, however.
Note that you may also permanently specify option values by placing
-option settings in the file @file{~/.ledgerrc}, for example:
+option settings in the file @file{~/.ledgerrc} one option per line, for example:
-@smallexample
+@smallexample @c input:validate
--pager /bin/cat
@end smallexample
-@node Period Expressions, , Detailed Option Description, Command-line Syntax
+@node Period Expressions, , Detailed Option Description, Command-Line Syntax
@section Period Expressions
@c TODO use @var below
@@ -7479,7 +7619,7 @@ last oct
weekly last august
@end smallexample
-@node Budgeting and Forecasting, Time Keeping, Command-line Syntax, Top
+@node Budgeting and Forecasting, Time Keeping, Command-Line Syntax, Top
@chapter Budgeting and Forecasting
@menu
@@ -7525,7 +7665,7 @@ These two periodic transactions give the usual monthly expenses, as well
as one typical yearly expense. For help on finding out what your
average monthly expenses are for any category, use a command like:
-@smallexample
+@smallexample @c command:validate
$ ledger -p "this year" --monthly --average balance ^expenses
@end smallexample
@@ -7566,7 +7706,7 @@ makes this easy to do, using the same periodic transactions as are used
for budgeting. An example forecast report can be generated with:
@smallexample @c command:validate
-$ ledger --forecast "T>@{\$-500.00@}" register ^assets ^liabilities
+$ ledger --file drewr3.dat --forecast "T>@{\$-500.00@}" register ^assets ^liabilities
@end smallexample
This report continues outputting postings until the running total
@@ -7584,6 +7724,7 @@ $ ledger --forecast "d<[2010]" bal ^assets ^liabilities
@chapter Time Keeping
@findex --day-break
+@anchor{timelog}
Ledger directly supports ``timelog'' entries, which have this form:
@smallexample @c input:validate
@@ -7657,7 +7798,7 @@ constrain which transactions are printed. For example, the following
command shows only transactions from the beginning of the current month,
while still calculating the running balance based on all transactions:
-@smallexample
+@smallexample @c command:validate
$ ledger -d "d>[this month]" register checking
@end smallexample
@@ -7666,7 +7807,7 @@ running total in terms of all transactions in the register. The
following, simpler command is similar, but totals only the displayed
postings:
-@smallexample
+@smallexample @c command:validate
$ ledger -b "this month" register checking
@end smallexample
@@ -7733,13 +7874,6 @@ considering children.
The cost of a posting; the cost of an account, without its
children.
-@item v
-The market value of a posting or an account, without its children.
-
-@item g
-The net gain (market value minus cost basis), for a posting or an
-account, without its children. It is the same as @samp{v-b}.
-
@item depth
The depth (``level'') of an account. If an account has one parent,
its depth is one.
@@ -7772,19 +7906,6 @@ and all its children.
The total count of postings affecting an account and all its
children.
-@item B
-The total cost of all postings seen so far; the total cost of an
-account and all its children.
-
-@item V
-The market value of all postings seen so far, or of an account and
-all its children.
-
-@item G
-The total net gain (market value minus cost basis), for a series of
-postings, or an account and its children. It is the same as
-@samp{V-B}.
-
@end table
@node Functions, Operators, Variables, Value Expressions
@@ -7803,10 +7924,6 @@ The absolute (unsigned) value of the argument.
@item S
Strips the commodity from the argument.
-@item A
-The arithmetic mean of the argument; @samp{Ax} is the same as
-@samp{x/n}.
-
@item P
The present market value of the argument. The syntax @samp{P(x,d)} is
supported, which yields the market value at time @samp{d}. If no date
@@ -7892,11 +8009,11 @@ Useful for specifying a date in plain terms. For example, you could say
@item expr comment =~ /REGEX/
A regular expression that matches against a posting's comment
-field. This searches only a posting's field, not the transaction's note
+field. This searches only a posting's field, not the transaction's note
or comment field. For example, @code{ledger reg "expr" "comment =~
/landline/"} will match:
-@smallexample
+@smallexample @c input:validate
2014/1/29 Phone bill
Assets:Checking $50.00
Expenses:Phone $-50.00 ; landline bill
@@ -7904,7 +8021,7 @@ or comment field. For example, @code{ledger reg "expr" "comment =~
but will not match:
-@smallexample
+@smallexample @c input:validate
2014/1/29 Phone bill ; landline bill
; landline bill
Assets:Checking $50.00
@@ -7917,30 +8034,28 @@ instead.
@item expr note =~ /REGEX/
A regular expression that matches against a transaction's note field.
This searches all comments in the transaction, including comments on
-individual postings. Thus, @samp{ledger reg "expr" "note =~ /landline/"}
+individual postings. Thus, @samp{ledger reg "expr" "note =~ /landline/"}
will match both all the three examples below:
-@smallexample
+@smallexample @c input:validate
2014/1/29 Phone bill
Assets:Checking $50.00
Expenses:Phone $-50.00 ; landline bill
@end smallexample
-@smallexample
+@smallexample @c input:validate
2014/1/29 Phone bill ; landline bill
Assets:Checking $50.00
Expenses:Phone $-50.00
@end smallexample
-@smallexample
+@smallexample @c input:validate
2014/1/29 Phone bill
; landline bill
Assets:Checking $50.00
Expenses:Phone $-50.00
@end smallexample
-
-
@item (EXPR)
A sub-expression is nested in parenthesis. This can be useful passing
more complicated arguments to functions, or for overriding the natural
@@ -7968,61 +8083,337 @@ expect (@pxref{Pre-Commands}).
@node Miscellaneous, , Complex expressions, Complex expressions
@subsection Miscellaneous
-@table @code
-@item abs--> U
-@item amount_expr
-@item ansify_if
-@item ceiling
-Return the next integer toward +infinity
-@item code
-Return the transaction code, the string between the parenthesis after
-the date.
-@item commodity
-@item date
-@item display_amount --> t
-@item display_total --> T
-@item floor
-Return the next integer toward -infinity
-@item format
-@item format_date
-@item format_datetime
-@item get_at
-@item is_seq
-@item join
-@item justify
-@item market --> P
-@item nail_down
-@item now --> d m
-@item options
-@item percent
-@item print
-@item quantity
-@item quoted
-@item round
-@item rounded
-@item roundto
-Return value rounded to n digits. Does not affect formatting.
-@item scrub
-@item should_bold
-@item strip --> S
-@item to_amount
-@item to_balance
-@item to_boolean
-@item to_date
-@item to_datetime
-@item to_int
-@item to_mask
-@item to_sequence
-@item to_spring
-@item today
-@item top_amount
-@item total_expr
-@item trim
-@item truncated
-@item unround
-@item unrounded
-@item value_date
-@end table
+The following Ledger journal data (saved as @file{expr.dat}) is used to explain the behaviour of the
+functions and variables below:
+@anchor{expr.dat}
+@smallexample @c input:3406FC1
+2015/01/16 * (C0D3) Payee
+ Assets:Cash ¤ -123,45
+ ; Payee: PiggyBank
+ Expenses:Office Supplies
+@end smallexample
+
+@defun abs value
+@defunx U value
+Return the absolute value of the given @var{value}, e.g. @var{amount}.
+@smallexample @c command:3406FC1
+$ ledger -f expr.dat --format "%(account) %(abs(amount))\n" reg assets
+@end smallexample
+@smallexample @c output:3406FC1
+Assets:Cash ¤ 123,45
+@end smallexample
+@end defun
+
+@defun amount_expr
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun ansify_if value color bool
+Render the given @var{expression} as a string, applying the proper ANSI escape
+codes to display it in the given @var{color} if @var{bool} is true. It
+typically checks the value of the option @option{--color}. Since ANSI escape
+codes include non-printable character sequences, such as escape @kbd{^[}
+the following example may not appear as the final result on the command-line.
+@smallexample @c command:4D836EE,with_input:3406FC1
+$ ledger -f expr.dat --format "%(ansify_if(account, blue, options.color))\n" reg
+@end smallexample
+@smallexample @c output:4D836EE
+Assets:Cash
+Expenses:Office Supplies
+@end smallexample
+@end defun
+
+@defun ceiling value
+Return the next integer of @var{value} toward @math{+}infinity.
+@smallexample @c command:FF9C18C,with_input:3406FC1
+$ ledger -f expr.dat --format "%(account) %(ceiling(amount))\n" reg
+@end smallexample
+@smallexample @c output:FF9C18C
+Assets:Cash ¤ -123,00
+Expenses:Office Supplies ¤ 124,00
+@end smallexample
+@end defun
+
+@defvar code
+Return the transaction code, the string between the parenthesis after the date.
+@smallexample @c command:46FCFD3,with_input:3406FC1
+$ ledger -f expr.dat --format "%(account) %(code)\n" reg assets
+@end smallexample
+@smallexample @c output:46FCFD3
+Assets:Cash C0D3
+@end smallexample
+@end defvar
+
+@defvar commodity
+Return the commodity of the posting amount.
+@end defvar
+@smallexample @c command:2CD27D7,with_input:3406FC1
+$ ledger -f expr.dat --format "%(account) %(commodity)\n" reg
+@end smallexample
+@smallexample @c output:2CD27D7
+Assets:Cash ¤
+Expenses:Office Supplies ¤
+@end smallexample
+
+@defvar date
+Return the date of the posting.
+@end defvar
+@smallexample @c command:67EBA45,with_input:3406FC1
+$ ledger -f expr.dat --format "%(date) %(account)\n" reg assets
+@end smallexample
+@smallexample @c output:67EBA45
+2015/01/16 Assets:Cash
+@end smallexample
+
+@defvar display_amount
+@defvarx t
+@value{FIXME:UNDOCUMENTED}
+@end defvar
+
+@c FIXME
+@defvar display_total
+@defvarx T
+@value{FIXME:UNDOCUMENTED}
+@end defvar
+
+@defun floor value
+Return the next integer of @var{value} toward @math{-}infinity.
+@smallexample @c command:4FDC7C5,with_input:3406FC1
+$ ledger -f expr.dat --format "%(account) %(floor(amount))\n" reg
+@end smallexample
+@smallexample @c output:4FDC7C5
+Assets:Cash ¤ -124,00
+Expenses:Office Supplies ¤ 123,00
+@end smallexample
+@end defun
+
+@defun format
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun format_date date format
+Return the @var{date} as a string using @var{format}. See strftime (3)
+for format string details.
+@smallexample @c command:9605B13,with_input:3406FC1
+$ ledger -f expr.dat --format "%(format_date(date, '%A, %B %d. %Y'))\n" reg assets
+@end smallexample
+@smallexample @c output:9605B13
+Friday, January 16. 2015
+@end smallexample
+@end defun
+
+@defun format_datetime
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun get_at
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun is_seq
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun join
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun justify value first_width latter_width right_justify colorize
+Right or left justify the string representing @var{value}. The width
+of the field in the first line is given by @var{first_width}. For
+subsequent lines the width is given by @var{latter_width}. If
+@var{latter_width=-1}, then @var{first_width} is used for all lines.
+If @var{right_justify=true} then the field is right justified within
+the width of the field. If it is @var{false}, then the field is left
+justified and padded to the full width of the field. If
+@var{colorize} is true, then ledger will honor color settings.
+@smallexample @c command:082FB27,with_input:3406FC1
+$ ledger -f expr.dat --format "»%(justify(account, 30, 30, true))«\n" reg
+@end smallexample
+@smallexample @c output:082FB27
+» Assets:Cash«
+» Expenses:Office Supplies«
+@end smallexample
+@end defun
+
+@defun market
+@defunx P
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun nail_down
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defvar now
+@defvarx d
+@defvarx m
+@value{FIXME:UNDOCUMENTED}
+@end defvar
+
+@defvar options
+A variable that allows access to the values of the given command-line options
+using the long option names, e.g. to see whether @option{--daily} or @option{-D}
+was given use @code{option.daily}.
+@smallexample @c command:C1FC7A7,with_input:3406FC1
+$ ledger -f expr.dat -X $ -D --format "%(options.daily) %(options.exchange)\n" reg assets
+@end smallexample
+@smallexample @c output:C1FC7A7
+true $
+@end smallexample
+@end defvar
+
+@defun percent value_a value_b
+Return the percentage of @var{value_a} in relation to @var{value_b} (used as 100%)
+@smallexample @c command:04959BF,with_input:3406FC1
+$ ledger -f expr.dat --format "%(percent(amount, 200))\n" reg
+@end smallexample
+@smallexample @c output:04959BF
+-61.73%
+61.73%
+@end smallexample
+@end defun
+
+@defun print
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun quantity
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun quoted expression
+Surround @var{expression} with double-quotes.
+@smallexample @c command:EAD8AA7,with_input:3406FC1
+$ ledger -f expr.dat --format "%(quoted(account)) %(quoted(amount))\n" reg
+@end smallexample
+@smallexample @c output:EAD8AA7
+"Assets:Cash" "¤ -123,45"
+"Expenses:Office Supplies" "¤ 123,45"
+@end smallexample
+@end defun
+
+@defun round
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun rounded
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun roundto value n
+Return @var{value} rounded to @var{n} digits. Does not affect formatting.
+@smallexample @c command:B4DFB9F,with_input:3406FC1
+$ ledger -f expr.dat --format "%(account) %(roundto(amount, 1))\n" reg
+@end smallexample
+@smallexample @c output:B4DFB9F
+Assets:Cash ¤ -123,40
+Expenses:Office Supplies ¤ 123,50
+@end smallexample
+@end defun
+
+@defun scrub
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun should_bold
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun strip
+@defunx S
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_amount
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_balance
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_boolean
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_date
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_datetime
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_int value
+@defunx int value
+Return the integer value for @var{value}.
+@smallexample @c command:0B0CBA1,with_input:3406FC1
+$ ledger -f expr.dat --format "%(1 + to_int('1'))\n%(2,5 + int(2,5))\n" reg assets
+@end smallexample
+@smallexample @c output:0B0CBA1
+2
+4.5
+@end smallexample
+@end defun
+
+@defun to_mask
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_sequence
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_string value
+@defunx str value
+Convert @var{value} to a character string.
+@end defun
+
+@defvar today
+Return today's date.
+@end defvar
+@smallexample @c command:F2FDF4B,with_input:3406FC1
+$ ledger -f expr.dat --now 2015/01/01 --format "%(today)\n" reg assets
+@end smallexample
+@smallexample @c output:F2FDF4B
+2015/01/01
+@end smallexample
+
+@defun top_amount
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun total_expr
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun trim value
+Trim leading and trailing whitespace from @var{value}.
+@smallexample @c command:377BBAB,with_input:3406FC1
+$ ledger -f expr.dat --format "»%(trim(' Trimmed '))«\n" reg assets
+@end smallexample
+@smallexample @c output:377BBAB
+»Trimmed«
+@end smallexample
+@end defun
+
+@defun truncated
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun unround
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun unrounded
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun value_date
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
@node Format Strings, Extending with Python, Value Expressions, Top
@chapter Format Strings
@@ -8050,13 +8441,13 @@ Return value rounded to n digits. Does not affect formatting.
Format strings may be used to change the output format of reports. They
are specified by passing a formatting string to the @option{--format
-@var{FORMAT_STRING} (-F)} option. Within that string, constructs are
+@var{FORMAT_STRING} (-F)} option. Within that string, constructs are
allowed which make it possible to display the various parts of an
account or posting in custom ways.
There are several additional flags that allow you to define formats
-for specific reports. These are useful to define in your configuration
-file and will allow you to run ledger reports from the command line
+for specific reports. These are useful to define in your configuration
+file and will allow you to run ledger reports from the command-line
without having to enter a new format for each command.
@itemize
@@ -8109,12 +8500,19 @@ or an expression enclosed in parentheses or brackets.
@findex --amount @var{EXPR}
@findex --total @var{VEXPR}
+For demonstration purposes the journal data from @ref{expr.dat} is used.
The allowable expressions are:
@table @code
@item %
Inserts a percent sign.
+@smallexample @c command:6F90EFC,with_input:3406FC1
+$ ledger -f expr.dat --format "%%\n" reg assets
+@end smallexample
+@smallexample @c output:6F90EFC
+%
+@end smallexample
@item t
Inserts the results of the value expression specified by
@@ -8132,6 +8530,12 @@ parentheses. To insert five times the total value of an account, for
example, one could say @samp{%12(5*O)}. Note: It's important to put the
five first in that expression, so that the commodity doesn't get
stripped from the total.
+@smallexample @c command:494256E,with_input:3406FC1
+$ ledger -f expr.dat --format "%12(5*O)\n" reg assets
+@end smallexample
+@smallexample @c output:494256E
+ ¤ -617,25
+@end smallexample
@item [DATEFMT]
Inserts the result of formatting a posting's date with a date
@@ -8141,20 +8545,52 @@ example: @samp{%[%Y/%m/%d %H:%M:%S]}.
@item S
Insert the path name of the file from which the transaction's data was
read. Only sensible in a @command{register} report.
+@c Note: Unable to test this properly since the output depends on
+@c where the ledger source tree resides in the filesystem.
+@smallexample
+$ ledger -f ~/journal.dat --format "%S\n" reg assets
+@end smallexample
+@smallexample
+/home/jwiegley/journal.dat
+@end smallexample
@item B
Inserts the beginning character position of that transaction within the
file.
+@smallexample @c command:2B669C9,with_input:3406FC1
+$ ledger -f expr.dat --format "%B\n" reg assets
+@end smallexample
+@smallexample @c output:2B669C9
+26
+@end smallexample
@item b
Inserts the beginning line of that transaction within the file.
+@smallexample @c command:F6E356F,with_input:3406FC1
+$ ledger -f expr.dat --format "%b\n" reg assets
+@end smallexample
+@smallexample @c output:F6E356F
+2
+@end smallexample
@item E
Inserts the ending character position of that transaction within the
file.
+@smallexample @c command:0E55246,with_input:3406FC1
+$ ledger -f expr.dat --format "%E\n" reg assets
+@end smallexample
+@smallexample @c output:0E55246
+90
+@end smallexample
@item e
Inserts the ending line of that transaction within the file.
+@smallexample @c command:A26F4C0,with_input:3406FC1
+$ ledger -f expr.dat --format "%e\n" reg assets
+@end smallexample
+@smallexample @c output:A26F4C0
+3
+@end smallexample
@item D
Returns the date according to the default format.
@@ -8173,9 +8609,23 @@ character if all of the member postings have the same state.
@item C
Inserts the transaction code. This is the value specified between
parentheses on the first line of the transaction.
+@smallexample @c command:C1CAAF3,with_input:3406FC1
+$ ledger -f expr.dat --format "%C\n" reg assets
+@end smallexample
+@c Note: The output needs a space character at the end
+@c for this test to pass
+@smallexample @c output:C1CAAF3
+(C0D3)
+@end smallexample
@item P
Inserts the payee related to a posting.
+@smallexample @c command:F41A9BB,with_input:3406FC1
+$ ledger -f expr.dat --format "%P\n" reg assets
+@end smallexample
+@smallexample @c output:F41A9BB
+PiggyBank
+@end smallexample
@c @item a
@c Inserts the optimal short name for an account. This is normally
@@ -8185,6 +8635,13 @@ Inserts the payee related to a posting.
@item A
Inserts the full name of an account.
+@smallexample @c command:29A70DD,with_input:3406FC1
+$ ledger -f expr.dat --format "%A\n" reg
+@end smallexample
+@smallexample @c output:29A70DD
+Assets:Cash
+Expenses:Office Supplies
+@end smallexample
@c @item W
@c This is the same as @code{%A}, except that it first displays the
@@ -8201,12 +8658,25 @@ Inserts the full name of an account.
@item N
Inserts the note associated with a posting, if one exists.
+@smallexample @c command:E6DC93A,with_input:3406FC1
+$ ledger -f expr.dat --format "%N\n" reg assets
+@end smallexample
+@smallexample @c output:E6DC93A
+ Payee: PiggyBank
+@end smallexample
@item /
The @samp{%/} construct is special. It separates a format string
between what is printed for the first posting of a transaction, and
what is printed for all subsequent postings. If not used, the
same format string is used for all postings.
+@smallexample @c command:E80897D,with_input:3406FC1
+$ ledger -f expr.dat --format "%P\n%/%A\n" reg
+@end smallexample
+@smallexample @c output:E80897D
+PiggyBank
+Expenses:Office Supplies
+@end smallexample
@end table
@@ -8244,7 +8714,7 @@ functions are described later):
@subsection Field Widths
The following codes return the width allocated for the specific fields.
-The defaults can be changed using the corresponding command line
+The defaults can be changed using the corresponding command-line
options:
@itemize
@@ -8314,7 +8784,7 @@ Return the current date and time. If the @option{--now @var{DATE}}
option is defined it will return that value.
@item today
-Return the current date. If the @option{--now @var{DATE}} option is
+Return the current date. If the @option{--now @var{DATE}} option is
defined it will return that value.
@item to_datetime
@@ -8492,10 +8962,10 @@ Surrounds the string representing value with ANSI codes to give it
@item justify(value, first_width, latter_width, right_justify, colorize)
Right or left justify the string representing @code{value}. The width
of the field in the first line is given by @code{first_width}. For
-subsequent lines the width is given by @code{latterwidth}. If
+subsequent lines the width is given by @code{latter_width}. If
@code{latter_width=-1}, then @code{first_width} is use for all lines.
If @code{right_justify=true} then the field is right justify within
-the width of the field. If it is @code{false}, then the field is left
+the width of the field. If it is @code{false}, then the field is left
justified and padded to the full width of the field. If
@code{colorize} is true, then ledger will honor color settings.
@@ -8521,7 +8991,7 @@ generated the posting.
@table @code
@item filename
-the name of ledger the data file from whence the posting came,
+the name of the ledger data file from whence the posting came,
abbreviated @samp{S}.
@item beg_pos
@@ -8537,7 +9007,7 @@ line number in @code{filename} where entry for posting begins,
abbreviated @samp{b}.
@item end_line
-line number in @code{filename} where posting's entry for posting ends,
+line number in @code{filename} where entry for posting ends,
abbreviated @samp{e}.
@end table
@@ -8781,7 +9251,8 @@ and receive them from functions.
Expressions can be onerous to type at the command-line, so there's
a shorthand for reporting called ``query expressions''. These add no
functionality of their own, but are purely translated from the input
-string (cash) down to the corresponding value expression @samp{(account
+string down to the corresponding value expression, for example the
+input string @samp{cash} is translated to @samp{(account
=~ /cash/)}. This is a convenience layer.
@item Format strings
@@ -9232,7 +9703,7 @@ This command simply echoes its argument back to the output.
Forces ledger to reload any journal files. This function exists to
support external programs controlling a running ledger process and does
-nothing for a command line user.
+nothing for a command-line user.
@node @command{source}, Debug Options, @command{reload}, Developer Commands
@subsection @command{source}
@@ -9249,14 +9720,14 @@ are found.
These options are primarily for Ledger developers, but may be of some
use to a user trying something new.
-@ftable @code
+@ftable @option
@item --args-only
Ignore init files and environment variables for the ledger run.
@item --debug @var{CODE}
If Ledger has been built with debug options this will provide extra
-data during the run. The following are the available @var{CODES} to
+data during the run. The following are the available @var{CODES} to
debug:
@multitable @columnfractions .32 .43 .27
@@ -9289,7 +9760,7 @@ debug:
@
@item --trace @var{INT}
-Enable tracing. The @var{INT} specifies the level of trace desired:
+Enable tracing. The @var{INT} specifies the level of trace desired:
@multitable @columnfractions .3 .7
@item @code{LOG_OFF} @tab 0
@@ -9308,15 +9779,17 @@ Enable tracing. The @var{INT} specifies the level of trace desired:
@
@item --verbose
+@itemx -v
Print detailed information on the execution of Ledger.
@item --verify
-Enable additional assertions during run-time. This causes a significant
+Enable additional assertions during run-time. This causes a significant
slowdown. When combined with @option{--debug @var{CODE}} ledger will
produce memory trace information.
@item --verify-memory
-FIX THIS ENTRY @c FIXME thdox
+Verify that every constructed object is properly destructed. This is for
+debugging purposes only.
@item --version
Print version information and exit.
@@ -9328,7 +9801,7 @@ Print version information and exit.
@cindex pre-commands
Pre-commands are useful when you aren't sure how a command or option
-will work. The difference between a pre-command and a regular command
+will work. The difference between a pre-command and a regular command
is that pre-commands ignore the journal data file completely, nor is
the user's init file read.
@@ -9353,8 +9826,10 @@ and apply it against a model transaction.
@item period @var{PERIOD_EXPRESSION}
Evaluate the given period and report how Ledger interprets it:
-@smallexample
-$ ledger period "this year"
+@smallexample @c command:51F6A2C
+$ ledger period "this year" --now 2011-01-01
+@end smallexample
+@smallexample @c output:51F6A2C
--- Period expression tokens ---
TOK_THIS: this
TOK_YEAR: year
@@ -9377,8 +9852,10 @@ END_REACHED: <EOF>
Evaluate the given arguments and report how Ledger interprets it against
the following model transaction:
-@smallexample
+@smallexample @c command:validate
$ ledger query "/Book/"
+@end smallexample
+@smallexample
--- Input arguments ---
("/Book/")
@@ -9414,7 +9891,7 @@ true
@end smallexample
@item script
-FIX THIS ENTRY @c FIXME thdox
+@value{FIXME:UNDOCUMENTED}
@item template
Shows the insertion template that the @command{xact} sub-command
@@ -9472,6 +9949,90 @@ for example, issue @code{ctest -V -R "5FB"}.
@node Writing Tests, , Running Tests, Testing Framework
@subsubsection Writing Tests
+To write a new test first decide to which broad category the test belongs:
+baseline or regression. Depending on the category tests are named differently
+baseline tests are prefixed with their type, e.g. @samp{cmd}
+(@pxref{Baseline Test Types} for valid types), whereas regressions are either
+named after the bug id, e.g. @samp{1234.test} or uuid @samp{91416D62.test}.
+In case several test files belong to the same bug number the files by appending
+@code{_X} where @samp{X} is the number of the test, e.g. @samp{1234_1.test},
+@samp{1234_2.test}.
+
+@anchor{Baseline Test Types}
+@multitable @columnfractions .3 .7
+@headitem Type @tab Use
+@item @code{cmd} @tab Ledger commands like @code{register} or @code{balance}
+@item @code{dir} @tab ?
+@item @code{feat} @tab ?
+@item @code{opt} @tab Ledger options such as @option{--period} or @option{--format}
+@end multitable
+
+A ledger test file contains three sections:
+
+@enumerate
+@item the journal data used for the test, this can be empty in certain
+scenarios
+@item the ledger command-line options used for the test
+@item the expected output
+@end enumerate
+
+Ledger has a special command directive for tests, everything between
+@code{test} and @code{end test} is treated like a comment, so every
+Ledger test is automatically a valid Ledger file.
+The test scripts take the remainder of the @code{test} line and use
+it as command-line arguments for ledger, the text enclosed in @code{test}
+and @code{end test} is expected output, for example:
+
+@smallexample @c input:validate
+; This is the journal data
+year 2014
+12/24 (C0d3) Santa Claus
+ Assets:Bank ¤ -150,00
+ Expenses:Presents
+
+; The following line specifies the ledger command-line options for this test and
+; everything between the next line and `end test` specifies the expected output
+test reg --payee=code
+14-Dec-24 C0d3 Assets:Bank ¤ -150,00 ¤ -150,00
+14-Dec-24 C0d3 Expenses:Presents ¤ 150,00 0
+end test
+@end smallexample
+
+When it is necessary to test for errors printed to @code{stderr} redirect
+the test output by adding @code{->} to the @code{test} line and match the
+expected error text in an @code{__ERROR__} section:
+
+@smallexample
+2014/01/01 * Acme Corporation
+ Assets:Bank:Checking ¤ 1.000,00
+ [Fund:Vacation] ¤ 300,00
+ [Fund:Studies] ¤ 600,00
+ Income:Salary ¤ -2.000,00
+
+test reg ->
+__ERROR__
+While parsing file "$FILE", line 5:
+While balancing transaction from "$FILE", lines 1-5:
+> 2014/01/01 * Acme Corporation
+> Assets:Bank:Checking ¤ 1.000,00
+> [Fund:Vacation] ¤ 300,00
+> [Fund:Studies] ¤ 600,00
+> Income:Salary ¤ -2.000,00
+Unbalanced remainder is:
+ ¤ -100,00
+Amount to balance against:
+ ¤ 1.900,00
+Error: Transaction does not balance
+end test
+@end smallexample
+
+A special @code{$FILE} variable can be used to match the journal filename
+used during the test.
+
+To add new tests to the test suite use the rebuild_cache option for the
+build tool you use, for example @code{make rebuild_cache}, now the
+new tests can be run as documented in @ref{Running Tests}.
+
@node Major Changes from version 2.6, Example Journal File, Ledger for Developers, Top
@chapter Major Changes from version 2.6
@@ -9489,10 +10050,10 @@ GnuCash file import.
The option @option{--performance (-g)}.
@item
-The balance report now defaults to showing all relevant accounts. This
-is the opposite of 2.x. That is, @command{bal} in 3.0 does what @samp{-s
-bal} did in 2.x. To see 2.6 behavior, use @option{--collapse (-n)}
-option in 3.0, like @samp{bal -n}. The @option{--subtotal (-s)} option
+The balance report now defaults to showing all relevant accounts. This
+is the opposite of 2.x. That is, @command{bal} in 3.0 does what @samp{-s
+bal} did in 2.x. To see 2.6 behavior, use @option{--collapse (-n)}
+option in 3.0, like @samp{bal -n}. The @option{--subtotal (-s)} option
no longer has any effect on balance reports.
@end itemize
@@ -9615,11 +10176,23 @@ to the main body of the documentation.
@node Invoking Ledger, Ledger Files, Cookbook, Cookbook
@subsection Invoking Ledger
-@smallexample
+
+@smallexample @c command:validate
$ ledger --group-by "tag('trip')" bal
-$ ledger reg --sort "tag('foo')" %foo
+@end smallexample
+@c FIXME: The following example fails to validate due to:
+@c While applying is_realzero to :
+@c Error: Cannot determine if an uninitialized value is really zero
+@c @smallexample @c command:validate
+@c $ ledger reg --sort "tag('foo')" %foo
+@c @end smallexample
+@smallexample @c command:validate
$ ledger cleared VWCU NFCU Tithe Misentry
+@end smallexample
+@smallexample @c command:validate
$ ledger register Joint --uncleared
+@end smallexample
+@smallexample @c command:validate
$ ledger register Checking --sort d -d 'd>[2011/04/01]' until 2011/05/25
@end smallexample
diff --git a/doc/version.texi.in b/doc/version.texi.in
new file mode 100644
index 00000000..c477db70
--- /dev/null
+++ b/doc/version.texi.in
@@ -0,0 +1,8 @@
+@set Ledger_VERSION_MAJOR @Ledger_VERSION_MAJOR@
+@set Ledger_VERSION_MINOR @Ledger_VERSION_MINOR@
+@set Ledger_VERSION_PATCH @Ledger_VERSION_PATCH@
+@set Ledger_VERSION_PRERELEASE @Ledger_VERSION_PRERELEASE@
+@set Ledger_VERSION_DATE @Ledger_VERSION_DATE@
+
+@set VERSION @value{Ledger_VERSION_MAJOR}.@value{Ledger_VERSION_MINOR}.@value{Ledger_VERSION_PATCH}@value{Ledger_VERSION_PRERELEASE}
+