diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/CMakeLists.txt | 98 | ||||
-rw-r--r-- | doc/DEVELOP.md | 81 | ||||
-rw-r--r-- | doc/DEVELOP.md.new | 0 | ||||
-rw-r--r-- | doc/Doxyfile.in | 2 | ||||
-rw-r--r-- | doc/GLOSSARY.md | 151 | ||||
-rw-r--r-- | doc/INSTALL | 234 | ||||
-rw-r--r-- | doc/LICENSE | 2 | ||||
-rw-r--r-- | doc/LICENSE-sha1 | 13 | ||||
-rw-r--r-- | doc/LICENSE.rtf | bin | 1718 -> 1719 bytes | |||
-rw-r--r-- | doc/NEWS | 47 | ||||
-rw-r--r-- | doc/README | 64 | ||||
-rw-r--r-- | doc/ledger-mode.texi | 224 | ||||
-rw-r--r-- | doc/ledger.1 | 462 | ||||
-rw-r--r-- | doc/ledger3.texi | 1901 |
14 files changed, 2098 insertions, 1181 deletions
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 2777da68..46c3f73f 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -7,7 +7,7 @@ if (USE_DOXYGEN) find_package(Doxygen) - if(NOT DOXYGEN_FOUND) + if (NOT DOXYGEN_FOUND) message(FATAL_ERROR "Could not find doxygen. Reference documentation cannot be built.") endif() @@ -27,38 +27,55 @@ endif() ######################################################################## -if(NOT BUILD_DOCS) - add_custom_target(doc DEPENDS doc.doxygen) - return() +# BUILD_WEB_DOCS implies BUILD_DOCS +if (BUILD_WEB_DOCS) + set(BUILD_DOCS 1) endif() -set(info_files ledger3.texi ledger-mode.texi) +if (BUILD_DOCS) + find_program(MAKEINFO makeinfo) + find_program(TEXI2PDF texi2pdf) + find_program(TEX tex) + find_program(MAN2HTML man2html) + find_program(GROFF groff) + set(ledger_info_files ledger3.texi ledger-mode.texi) -find_program(MAKEINFO makeinfo) -find_program(TEXI2PDF texi2pdf) -find_program(MAN2HTML man2html) + if (NOT MAKEINFO) + message(WARNING "Could not find makeinfo. Info version of documentation cannot be built.") + endif() + + if (NOT TEXI2PDF OR NOT TEX) + message(WARNING "Could not find texi2pdf or tex. PDF version of documentation will not be built.") + endif() +endif() ######################################################################## -foreach(file ${info_files}) +foreach(file ${ledger_info_files}) get_filename_component(file_base ${file} NAME_WE) - if(BUILD_WEB_DOCS) - if(NOT MAKEINFO) - message(FATAL_ERROR "Could not find makeinfo. HTML version of documentation cannot be built.") - endif() + if (MAKEINFO) + add_custom_command(OUTPUT ${file_base}.info + COMMAND makeinfo --force --no-split -o ${file_base}.info ${CMAKE_CURRENT_SOURCE_DIR}/${file} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} + VERBATIM) + list(APPEND ledger_doc_files ${file_base}.info) + endif() + + if (BUILD_WEB_DOCS AND MAKEINFO) add_custom_command(OUTPUT ${file_base}.html COMMAND makeinfo --force --html --no-split -o ${file_base}.html ${CMAKE_CURRENT_SOURCE_DIR}/${file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} VERBATIM) list(APPEND ledger_doc_files ${file_base}.html) - endif(BUILD_WEB_DOCS) + endif() - if(NOT TEXI2PDF) - message(WARNING "Could not find texi2pdf. PDF version of documentation will not be built.") - else() + if (TEXI2PDF AND TEX) + if (BUILD_A4_PDF) + set(papersize --texinfo=@afourpaper) + endif() add_custom_command(OUTPUT ${file_base}.pdf - COMMAND texi2pdf -b -q -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file} + COMMAND texi2pdf ${papersize} -b -q -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} VERBATIM) list(APPEND ledger_doc_files ${file_base}.pdf) @@ -67,20 +84,26 @@ endforeach() ######################################################################## -if(BUILD_WEB_DOCS) +if (BUILD_WEB_DOCS) include(FindUnixCommands) - if(NOT BASH) + if (NOT BASH) message(FATAL_ERROR "Could not find bash. Unable to build documentation.") endif() - if(NOT MAN2HTML) - message(FATAL_ERROR "Could not find man2html. HTML version of man page cannot be built.") + if (MAN2HTML) + add_custom_command(OUTPUT ledger.1.html + COMMAND ${BASH} -c "man2html ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 | tail -n+3 > ledger.1.html" + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 + VERBATIM) + list(APPEND ledger_doc_files ledger.1.html) + elseif(GROFF) + add_custom_command(OUTPUT ledger.1.html + COMMAND ${BASH} -c "groff -mandoc -Thtml ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 > ledger.1.html" + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 + VERBATIM) + list(APPEND ledger_doc_files ledger.1.html) + else() + message(FATAL_ERROR "Could not find man2html or groff. HTML version of man page cannot be built.") endif() - - add_custom_command(OUTPUT ledger.1.html - COMMAND ${BASH} -c "man2html ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 | tail -n+3 > ledger.1.html" - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 - VERBATIM) - list(APPEND ledger_doc_files ledger.1.html) endif(BUILD_WEB_DOCS) ######################################################################## @@ -91,16 +114,21 @@ add_custom_target(doc DEPENDS ${ledger_doc_files} doc.doxygen) include(GNUInstallDirs) -if(CMAKE_INSTALL_MANDIR) +if (CMAKE_INSTALL_MANDIR) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) endif(CMAKE_INSTALL_MANDIR) -foreach(file ${info_files}) - get_filename_component(file_base ${file} NAME_WE) +foreach(file ${ledger_doc_files}) + get_filename_component(file_ext ${file} EXT) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file} - DESTINATION ${CMAKE_INSTALL_INFODIR} COMPONENT doc) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file_base}.pdf - DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc OPTIONAL) + if(file_ext STREQUAL ".info") + if(CMAKE_INSTALL_INFODIR) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file} + DESTINATION ${CMAKE_INSTALL_INFODIR} COMPONENT doc) + endif() + elseif(CMAKE_INSTALL_DOCDIR) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file} + DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc) + endif() endforeach() diff --git a/doc/DEVELOP.md b/doc/DEVELOP.md new file mode 100644 index 00000000..ce897741 --- /dev/null +++ b/doc/DEVELOP.md @@ -0,0 +1,81 @@ +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 new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/doc/DEVELOP.md.new diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index e340d84a..95373660 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -938,7 +938,7 @@ HTML_STYLESHEET = # user-defined cascading style sheet that is included after the standard # style sheets created by doxygen. Using this option one can overrule # certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more +# since it does not replace the standard style sheet and is therefore more # robust against future updates. Doxygen will copy the style sheet file to # the output directory. diff --git a/doc/GLOSSARY.md b/doc/GLOSSARY.md new file mode 100644 index 00000000..263a3cff --- /dev/null +++ b/doc/GLOSSARY.md @@ -0,0 +1,151 @@ +ACCOUNTING GLOSSARY +--- + + Accounting and bookkeeping represent an entire field of human effort and has + evolved its own specialized vocabulary. Accounting hopes to summarize and + add understanding to where the money is going. + +**Account**: A category for grouping together amounts from similar + transactions. Each account has a name, which is usually capitalized, and an + account type. Accounts are often organized into a hierarchy when it helps + understanding. For example, a coffee shop might have Coffee, Merchandise, + and Equipment as accounts but arranged under an Inventory account because + different decisions are made on the total inventory rather than just coffee. + A hierarchy can be part of the account name in Ledger, e.g., + "Assets:Inventory:Coffee". Note that the Ledger software usually creates + the list of accounts on the fly: accounts are created when transactions use + them. + +**Account Type**: Each account has a type of Asset, Liability, Equity, Income, + or Expense. Assets represent something owned, e.g., Cash or Inventory. + Liabilities represent sometime owed, e.g., a Loan or Mortgage. Equity, also + called capital, is everything owned minus everything owed (Assets - + Liabilities). It is the financial measure of how much you are ahead. + Income is money earned somewhere, which puts you more ahead. Expenses is + money spent somewhere, which puts you less ahead. The type of account + determines if a debit represents an increase or decrease in an account. For + example, Inventory is an asset so a transaction debiting Inventory would + increase its value. Assets and Expenses increase with debits and decrease + with credits; Liabilities, Equity, and Expenses increase with credits and + decrease with debits. + +**Journal**: A record of all the financial transactions of a person or firm. + This data of where money goes can be collated into reports. This used to be + done with a physical book, called a ledger, where each account was on one + page. Each debit or credit in the journal was transferred to the + appropriate account page and the pages were totaled to produce reports. + This process is now done with the Ledger software which creates reports from + the journal. A journal is sometimes called a register. + +**Posting**: A single debit or credit line of a transaction. A posting + comprises an account and the debit or credit amount. It also inherits the + shared description and date from the transaction. In the Ledger software, + a posting may also have metadata and an account state. + + +**Report**: A summary made from a journal of transactions. Each transaction + affects accounts and those effects are collated and totaled. The two most + common reports are the balance sheet, which shows what is owned and owed on + a specific date, and the cash flow statement, which shows how money was + earned and spent over a period. The cash flow statement is also called + a profit and loss statement or an income statement. + +**Transaction**: Our financial lives are recorded as a series of transactions. + Each transaction has a specific date, an equal total of debits and credits + affecting accounts, and some sort of description. For example, "On January + 1, pay $100 with check #243 from Checking to Utilities for my Verizon phone + bill" is a transaction. A credit of $100 decreases my Checking asset, while + a balancing debit of $100 increases my Utility expense. A transaction needs + at least two *postings*, meaning account debits or credits, but can be as + complicated as humans can make finances. + +LEDGER GLOSSARY +--- + +The Ledger software also has its own terms. + +**Automated Transaction**: a command directive that modifies subsequent + transactions that match an expression. An automated transaction can add + additional postings to a transaction, add metadata, or change transaction + amounts. Reports can be filter postings modified or generated by an + automated transaction. + [§ Automated Transactions](http://www.ledger-cli.org/3.0/doc/ledger3.html#Automated-Transactions); + [§ Concrete Example of Automated Transactions](http://www.ledger-cli.org/3.0/doc/ledger3.html#Concrete-Example-of-Automated-Transactions) + +**Command Directive**: a command in a journal file to change how subsequent + lines and transactions in a journal file are processed. Command directives + control processing, set default values for subsequent accounts and + transactions, or override parts of subsequent transactions. A directive + line begins with name of the directive and may have additional arguments or + additional indented lines. The single letters *AbCDhIiNOoY* are aliased to + other command directives, providing compatibility with the ancient past. + The characters **'='** and **'-'** are command directives for a automatic + transactions and periodic transactions, respectively. + [§ Command Directives](http://www.ledger-cli.org/3.0/doc/ledger3.html#Command-Directives) + +**Commodity**: any currency, stock, time or resource to be tracked + numerically. While many people only track money in Ledger, Ledger can track + different resources and manage rules to convert between them. The system is + flexible enough for the needs of very different users. Some track billable + time, converting minutes and hours into dollars. Others track multiple + currencies. Still others track the purchase and sale of stocks. Each + commodity is separate unless a conversion rule is given. + [§ Commodities and Currencies](http://www.ledger-cli.org/3.0/doc/ledger3.html#Commodities-and-Currencies); + [§ Currencies and Commodities](http://www.ledger-cli.org/3.0/doc/ledger3.html#Currency-and-Commodities); + [§ Accounts and Inventories](http://www.ledger-cli.org/3.0/doc/ledger3.html#Accounts-and-Inventories); + [§ Posting Cost](http://www.ledger-cli.org/3.0/doc/ledger3.html#Posting-cost) + *(and next ten sections)*; + [§ Commodity Reporting](http://www.ledger-cli.org/3.0/doc/ledger3.html#Commodity-Reporting) + +**Effective Date**: an optional, second date information item in for a posting + or transaction. Some use the effective date for when work is billed or when + a check has cleared. The `--effective-date` option causes the effective + date to override the transaction's initial date for that report. + [§ Effective Dates](http://www.ledger-cli.org/3.0/doc/ledger3.html#Effective-Dates); + +**Journal File**: the text input file for ledger, sometimes called a register + file. A journal file is a series of transactions, command directives, and + comments. Command directives start with the single word name of the + directive at the beginning of the line and include any following indented + lines. Transactions start with a date a the beginning of the line and + include any indented lines following. The journal file is expected to be + encoded as ASCII or UTF-8 text. + +**Periodic Transaction**: the estimate of a transaction that would occur + periodically, e.g., a monthly expense. These estimates are only used in + budgeting and forecasting reports using the `--budget`, `--forecast`, or + `--unbudgeted` options. + [§ Budgeting and Forecasting](http://www.ledger-cli.org/3.0/doc/ledger3.html#Budgeting-and-Forecasting) + +**Transaction Code**: an optional item in a transaction or posting often used + to record a check number or bank code. Certain custom reports can report + this code. + [§ Codes](http://www.ledger-cli.org/3.0/doc/ledger3.html#Codes); + [§ Format Expressions](http://www.ledger-cli.org/3.0/doc/ledger3.html#Format-Expressions) + +**Transaction Metadata**: a term for comments and tags annotating + a transaction. Comments indented with a transaction will be stored with + each posting of a transaction. Tags are words in comments followed by + colons. Tags can be used as filters in reports and certain tags, "Payee" or + "Value", may affect fields of the transaction. + [§ Metadata](http://www.ledger-cli.org/3.0/doc/ledger3.html#Metadata), + [§ Applying Metadata to every matched posting](http://www.ledger-cli.org/3.0/doc/ledger3.html#Applying-metadata-to-every-matched-posting), + [§ Applying Metadata to the generated posting](http://www.ledger-cli.org/3.0/doc/ledger3.html#Applying-metadata-to-the-generated-posting) + +**Transaction State**: a state of *cleared*, *pending*, or *uncleared* on each + posting. The state is usually set for an entire transaction at once with + a mark after the date. The marks are ***** (cleared), **!** (pending), + or no mark (uncleared). The interpretation of this state is up to the user, + but is typically used in bank reconciliations or differentiating time worked + versus billed. Ledger supports reports and filters based on state. + [§ Transaction State](http://www.ledger-cli.org/3.0/doc/ledger3.html#Transaction-state); + [§ Cleared Report]( http://www.ledger-cli.org/3.0/doc/ledger3.html#Cleared-Report) + +**Virtual Posting**: an annotation posting in a transaction, similar in form + as a regular posting but not required to balance debits and credits. It is + often used to support + [Fund Accounting](http://en.wikipedia.org/wiki/Fund_accounting) and various + reports will collate and summarize virtual postings. Virtual postings + should not be confused with virtual posting costs. + [§ Virtual Postings](http://www.ledger-cli.org/3.0/doc/ledger3.html#Virtual-postings) + [§ Working with Multiple Funds and Accounts](http://www.ledger-cli.org/3.0/doc/ledger3.html#Working-with-multiple-funds-and-accounts) diff --git a/doc/INSTALL b/doc/INSTALL deleted file mode 100644 index 5458714e..00000000 --- a/doc/INSTALL +++ /dev/null @@ -1,234 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006 Free Software Foundation, Inc. - -This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - -Briefly, the shell commands `./configure; make; make install' should -configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for -instructions specific to this package. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. - - Running `configure' might take a while. While running, it prints - some messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - -Some systems require unusual options for compilation or linking that the -`configure' script does not know about. Run `./configure --help' for -details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c99 CFLAGS=-g LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - -You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - With a non-GNU `make', it is safer to compile the package for one -architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before -reconfiguring for another architecture. - -Installation Names -================== - -By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - -Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - -There may be some features `configure' cannot figure out automatically, -but needs to determine by the type of machine the package will run on. -Usually, assuming the package is built to be run on the _same_ -architectures, `configure' can figure that out, but if it prints a -message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - -If you want to set default values for `configure' scripts to share, you -can create a site shell script called `config.site' that gives default -values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - -Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). - -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf bug. Until the bug is fixed you can use this workaround: - - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash - -`configure' Invocation -====================== - -`configure' recognizes the following options to control how it operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/doc/LICENSE b/doc/LICENSE index df1a0028..92be3a1d 100644 --- a/doc/LICENSE +++ b/doc/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2003-2009, John Wiegley. All rights reserved. +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 diff --git a/doc/LICENSE-sha1 b/doc/LICENSE-sha1 deleted file mode 100644 index 8d886177..00000000 --- a/doc/LICENSE-sha1 +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (C) 1998
-Paul E. Jones <paulej@arid.us>
-All Rights Reserved.
-
-This software is licensed as "freeware." Permission to distribute
-this software in source and binary forms is hereby granted without
-a fee. THIS SOFTWARE IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESSED
-OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-THE AUTHOR SHALL NOT BE HELD LIABLE FOR ANY DAMAGES RESULTING
-FROM THE USE OF THIS SOFTWARE, EITHER DIRECTLY OR INDIRECTLY, INCLUDING,
-BUT NOT LIMITED TO, LOSS OF DATA OR DATA BEING RENDERED INACCURATE.
-
diff --git a/doc/LICENSE.rtf b/doc/LICENSE.rtf Binary files differindex 8da96b65..471065fe 100644 --- a/doc/LICENSE.rtf +++ b/doc/LICENSE.rtf @@ -1,5 +1,48 @@ Ledger NEWS +* 3.1 + +- Changed the definition of cost basis to preserve the original cost basis + when a gain or loss is made (if you bought 1 AAA for $10 and then sold + it for $12, ledger would previously take $12 as the cost; the original + cost of $10 is preserved as the cost basis now, which addresses strange + behavior with -B after a capital gain or loss is made). + +- Incorrect automatic Equity:Capital Gains and Equity:Capital Loss entries + are no longer generated when a commodity is sold for loss or profit. + +- Support for virtual posting costs. + +- The option --permissive now quiets balance assertions + +- Removed SHA1 files due to license issues and use boost instead. + +- Added option --no-pager to disable the pager. + +- Added option --no-aliases to completely disable alias expansion + +- Added option --recursive-aliases to expand aliases recursively + +- Support payee "uuid" directive. + +- Bug fix: when a status flag (! or *) is explicitly specified for an + individual posting, it always has a priority over entire transaction + status. + +- Bug fix: don't lose commodity when cost is not separated by whitespace + +- Improved backwards compatibility with ledger 2.x + +- Build fix for GCC 4.9 + +- Build fix for boost 1.56 + +- Many improvements to ledger-mode, including fontification + +- More test cases and unit tests + +- Contrib: Added script to generate commodities from ISO 4217 + * 3.0 Due to the magnitude of changes in 3.0, only changes that affect compatibility @@ -296,7 +339,7 @@ features, please see the manual. This flag limits computation to *only transactions whose amount is greater than 100 of a given commodity*. It means that if you scan your dining expenses, for example, only individual bills - greater than $100 would be caculated by the report. + greater than $100 would be calculated by the report. --only "a>100" @@ -538,7 +581,7 @@ features, please see the manual. * 2.4.1 -- Corrected an issue that had inadvertantly disabled Gnucash support. +- Corrected an issue that had inadvertently disabled Gnucash support. * 2.4 diff --git a/doc/README b/doc/README deleted file mode 100644 index 190436a2..00000000 --- a/doc/README +++ /dev/null @@ -1,64 +0,0 @@ - - Welcome to Ledger - - the command-line accounting program - -Introduction -============ - -Ledger is an accounting program which is invoked from the command-line using a -textual ledger file. To start using Ledger, you will need to create such a -file containing your financial postings. A sample has been provided in the -file "sample.dat". See the documentation (ledger.pdf, or ledger.info) for -full documentation on creating a ledger file and using Ledger to generate -reports. - -Once you have such a file -- you might call it "ledger.dat" -- you can start -looking at balances and account registers using commands like the following: - - ledger -f ledger.dat balance assets:checking - ledger -f ledger.dat register expenses:food - -This assumes, of course, that like the sample file you use account names such -as "Assets:Checking" and "Expenses:Food". If you use other account names, you -will need to vary the reporting commands you use accordingly. - - -Building -======== - -To build Ledger, you will need a fairly modern C++ compiler (gcc 2.95 will not -work), and at least these two libraries installed: - - gmp GNU multi-precision library - pcre Perl regular expression library - -(On some GNU/Linux systems, the packages you need to install are called -"gmp-dev" and "pcre-dev"). - -Once you have determined where the headers and libraries for the above -packages are installed, run the script "configure", passing those paths. If -you installed everything under /usr/local, you can probably just type -"./configure". Otherwise, do this: - - ./configure CPPFLAGS=-I<INCLUDE-PATH> LDFLAGS=-L<LIBRARY-PATH> - -If you need to specify multiple include or library paths, then do this: - - ./configure CPPFLAGS="-I<PATH1> -I<PATH2>" LDFLAGS="-L<PATH1> -L<PATH2>" - -Once configure is done running, just type: - - make install - - -Mailing List and IRC -==================== - -If you need help on how to use Ledger, or run into problems, you can join the -Ledger mailing list at the following Web address: - - http://groups.google.com/group/ledger-cli - -You can also find help at the #ledger channel on the IRC server -irc.freenode.net. diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi index 8ab8e11d..b76cb309 100644 --- a/doc/ledger-mode.texi +++ b/doc/ledger-mode.texi @@ -89,6 +89,7 @@ reports and much more... * The Ledger Buffer:: * The Reconcile Buffer:: * The Report Buffer:: +* Scheduling Transactions:: * Customizing Ledger-mode:: * Generating Ledger Regression Tests:: * Embedding Example results in Ledger Documentation:: @@ -118,9 +119,9 @@ initialization file (@file{~/.emacs}, @file{~/.emacs.d/init.el}, or @file{~/.Aquamacs/Preferences.el}). @lisp +(autoload 'ledger-mode "ledger-mode" "A major mode for Ledger" t) (add-to-list 'load-path (expand-file-name "/path/to/ledger/source/lisp/")) -(load "ledger-mode") (add-to-list 'auto-mode-alist '("\\.ledger$" . ledger-mode)) @end lisp @@ -174,6 +175,13 @@ typing a close match to the payee. Ledger-mode will call @command{ledger xact} with the data you enter and place the transaction in the proper chronological place in the ledger. +If you need to add a lot of transactions that are not near your current +date you can set the current year and month so that using @samp{Add +Transaction} will prompt you with a more convenient month and year. To +set the month type @kbd{C-c RET} and enter the month you want. @kbd{C-c +C-y} will prompt you for the year. These settings only effect the +@samp{Add Transaction} command. + @node Reconciliation, Reports, Quick Add, Quick Demo @subsection Reconciliation @kindex C-c C-r @@ -217,10 +225,10 @@ Emacs will prompt for a report name. There are a few built-in reports, and you can add any report you need @xref{Adding and Editing Reports}. In the Minibuffer type @samp{account}. When prompted for an account -type @samp{checking}. In another buffer you will see a Ledger register -report. You can move around the buffer, with the point on a transaction, -type @kbd{C-c C-c}. Ledger-mode will take you directly to that -transaction in the @file{demo.ledger} buffer. +type @samp{checking}. In a buffer named @file{*Ledger Report*}, you +will see a Ledger register report. You can move around the buffer, with +the point on a transaction, type @kbd{RET}. Ledger-mode will take you +directly to that transaction in the @file{demo.ledger} buffer. Another built-in report is the balance report. In the @file{demo.ledger} buffer, type @kbd{C-c C-o C-r}. When prompted for @@ -230,13 +238,15 @@ will be shown. @node Narrowing, , Reports, Quick Demo @subsection Narrowing @kindex C-c C-f +@kindex C-c C-g A ledger file can get very large. It can be helpful to collapse the buffer to display only the transactions you are interested in. Ledger-mode copies the @command{occur} mode functionality. Typing @kbd{C-c C-f} and entering any regex in the Minibuffer will show only transactions that match the regex. The regex can be on any field, or -amount. +amount. Use @kbd{C-c C-g} after editing transactions to re-apply the +current regex. Cancel the narrowing by typing @kbd{C-c C-f} again. @node The Ledger Buffer, The Reconcile Buffer, Introduction to Ledger-mode, Top @chapter The Ledger Buffer @@ -246,17 +256,12 @@ amount. * Copying Transactions:: * Editing Amounts:: * Marking Transactions:: +* Formatting Transactions:: * Deleting Transactions:: * Sorting Transactions:: * Narrowing Transactions:: @end menu -@c TODO -@c Describe also: -@c - Align Region -@c - Set effective date C-c C-t -@c - Set Year C-c C-t -@c - Set Month C-c RET @node Adding Transactions, Copying Transactions, The Ledger Buffer, The Ledger Buffer @section Adding Transactions @@ -272,17 +277,35 @@ payees and accounts. Included files are not currently included in the completion scan. Repeatedly hitting @kbd{TAB} will cycle through the possible completions. -Ledger-mode can also help you keep your amounts in alignment. Setting +Ledger-mode can also help you keep your amounts aligned. Setting @option{ledger-post-auto-adjust-amounts} to true tells Ledger-mode to automatically place any amounts such that their last digit is aligned to the column specified by @option{ledger-post-amount-alignment-column}, which defaults to @samp{52}. @xref{Ledger Post Customization Group}. @menu +* Setting a Transactions Effective Date:: * Quick Balance Display:: @end menu -@node Quick Balance Display, , Adding Transactions, Adding Transactions +@node Setting a Transactions Effective Date, Quick Balance Display, Adding Transactions, Adding Transactions +@subsection Setting a Transactions Effective Date +@kindex C-c C-t +@cindex effective date + +Ledger provides for adding information to a transaction that add details +to the dates. For example, you can specify when the transaction was +entered, when the transaction was cleared, or when individual postings +were cleared. +Ledger-mode refers to these additional dates as @emph{effective} dates. +To set the effective date of a transaction, place the point in the first +line of a transaction and type @kbd{C-c C-t}. The effective date will +be added to the transaction. To set the effective date for an +individual posting, place point in the posting and type @kbd{C-c C-t} and +the effective date for that posting will be added at the end of the +posting. + +@node Quick Balance Display, , Setting a Transactions Effective Date, Adding Transactions @subsection Quick Balance Display @kindex C-c C-p @cindex balance @@ -326,7 +349,7 @@ but it cannot intercept the value being yanked form the @command{Calc} stack, so decimal-comma users will have to manually replace the period with a comma. -@node Marking Transactions, Deleting Transactions, Editing Amounts, The Ledger Buffer +@node Marking Transactions, Formatting Transactions, Editing Amounts, The Ledger Buffer @section Marking Transactions @cindex transaction, marking @cindex uncleared @@ -368,7 +391,20 @@ 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. -@node Deleting Transactions, Sorting Transactions, Marking Transactions, The Ledger Buffer +@node Formatting Transactions, Deleting Transactions, Marking Transactions, The Ledger Buffer +@section Formatting Transactions +@cindex transaction, formatting + +When editing a transaction, liberal use of the @kbd{TAB} key can keep +the transaction well formatted. If you want to have Ledger-mode cleanup +the formatting of a transaction you can use @samp{Align Transaction} or +@samp{Align Region} from the menu bar. + +The menu item @samp{Clean-up Buffer} sorts all transactions in the buffer +by date, removes extraneous empty lines and aligns every transaction. + + +@node Deleting Transactions, Sorting Transactions, Formatting Transactions, The Ledger Buffer @section Deleting Transactions @kindex C-c C-d @cindex transaction, deleting @@ -420,6 +456,7 @@ automatically delete old markers and put new new marker at point. @node Narrowing Transactions, , Sorting Transactions, The Ledger Buffer @section Narrowing Transactions @kindex C-c C-f +@kindex C-c C-g @cindex transaction, narrowing @cindex transaction, display filtering @@ -435,12 +472,11 @@ The regular expression can match on any part of the transaction. If you want to find all transactions whose amount ends in @samp{.37}, you can do that (I don't know why, but hey, whatever ever floats you aerostat). -Using @kbd{C-c C-f} or the @samp{Narrow to Regex} menu entry, enter -a regular expression in the Minibuffer. Ledger-mode will hide all other -transactions. For details of the regular expression syntax, see -@ref{(emacs)Regexps, Syntax of Regular Expressions} or -@ref{(elisp)Regular Expressions, Regular Expressions}. A few examples -using the @file{demo.ledger} are given here: +Using @kbd{C-c C-f} or the @samp{Narrow to Regex} menu entry, enter a +regular expression in the Minibuffer. Ledger-mode will hide all other +transactions. For details of the regular expression syntax, see your +Emacs documentation. A few examples using the @file{demo.ledger} are +given here: @table @samp @@ -466,6 +502,10 @@ Show only transactions with any line ending with @samp{harley}. To show back all transactions simply invoke @samp{Narrow to Regex} or @kbd{C-c C-f} again. +If you've edited some transactions after narrowing such that they would +no longer match the regular expression, you can refresh the narrowed +view using @kbd{C-c C-g}. + @node The Reconcile Buffer, The Report Buffer, The Ledger Buffer, Top @chapter The Reconcile Buffer @@ -592,7 +632,7 @@ the ledger buffer are left in that state when the account is switched. If for some reason during reconciliation your target amount changes, type @kbd{t} and enter the new target value. -@node The Report Buffer, Customizing Ledger-mode, The Reconcile Buffer, Top +@node The Report Buffer, Scheduling Transactions, The Reconcile Buffer, Top @chapter The Report Buffer @menu @@ -601,22 +641,18 @@ type @kbd{t} and enter the new target value. * Reversing Report Order:: @end menu -@c TODO Describe also: -@c - Goto Report C-c C-o C-g -@c - Re-run Report C-c C-o C-a -@c - Save Report C-c C-o C-s -@c - Kill Report C-c C-o C-k - @node Running Basic Reports, Adding and Editing Reports, The Report Buffer, The Report Buffer @section Running Reports @kindex C-c C-o C-r +@kindex C-c C-o C-g +@kindex C-c C-o C-a @cindex report, running The real power behind Ledger is in its amazing reporting capability. Ledger-mode provides easy facility to run reports directly from Emacs. It has four reports built-in and facilities for adding custom reports. -Typing @kbd{C-c C-o C-r} or using menu @samp{Ledger Run Report} prompt +Typing @kbd{C-c C-o C-r} or using menu @samp{Run Report} prompts for the name of a saved report. The built-in reports are: @table @var @@ -637,6 +673,18 @@ transactions involving that account. @end table +While viewing reports you can easily switch back and forth between the +ledger buffer and the @file{*Ledger Report*} buffer. In @file{*Ledger +Report*} buffer, typing @kbd{RET} will take you to that transaction in +the ledger buffer. While in the ledger buffer @kbd{C-c C-o C-g} returns +you to the @file{*Ledger Report*} buffer. + +By default Ledger-mode will refresh the report buffer when the ledger +buffer is saved. If you want to rerun the report at another time +@kbd{C-c C-o C-a}. This is useful if you have other programs altering +your ledger file outside of Emacs. + + @node Adding and Editing Reports, Reversing Report Order, Running Basic Reports, The Report Buffer @section Adding and Editing Reports @findex ledger-reports @@ -666,18 +714,21 @@ buffer you will have the option to give it a new name, or overwrite the old report. Deleting reports is accomplished by typing @kbd{C-c C-o C-e} or using -@samp{Edit Reports} menu in the ledger buffer, or typing @kbd{e} in the +@samp{Edit Report} menu in the ledger buffer, or typing @kbd{e} in the @file{*Ledger Report*} buffer. This takes you to the Emacs customization window for the Ledger Reports variables. Use the widgets to delete the report you want removed. +Typing @kbd{C-c C-o C-s} will prompt for a name and save the current +report. + @node Expansion Formats, Make Report Transactions Active, Adding and Editing Reports, Adding and Editing Reports @subsection Expansion Formats @cindex report, custom variable It is sometimes convenient to leave room to customize a report without saving the command line every time. For example running a register -report for a specific account, enter at runtime by the user. The +report for a specific account entered at runtime by the user. The built-in report @var{account} does exactly that, using a variable expansion to prompt the user for the account to use. There are four variables that can be expanded to run a report: @@ -693,9 +744,11 @@ Prompts for a payee. @item account Prompt for an account. -@c FIXME : is it 'value' or 'tag' for '@item value' just below? -@item value -Prompt for a tag value. +@item tagname +Prompt for a meta-data tag name. + +@item tagvalue +Prompt for a meta-data tag value. @end table @@ -738,7 +791,87 @@ recent transactions at the top, type @kbd{R} in the @file{*Ledger Report*} buffer and it will reverse the order of the transactions and maintain the proper mathematical sense. -@node Customizing Ledger-mode, Generating Ledger Regression Tests, The Report Buffer, Top +@node Scheduling Transactions, Customizing Ledger-mode, The Report Buffer, Top +@chapter Scheduling Transactions + +The Ledger program provides for automating transactions but these +transaction aren't ``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. +Ledger mode provides a way to schedule upcoming transaction with a +flexible scheduler that allows you to specify the transactions in a +separate ledger file and calculate the upcoming occurrences of those +transactions. You can then copy the transactions into your live data +file. + +@menu +* Specifying Upcoming Transactions:: +@end menu + +@node Specifying Upcoming Transactions, , Scheduling Transactions, Scheduling Transactions +@section Specifying Upcoming Transactions + +The format for specifying transactions is identical to Ledger's file +format with the exception of the date field. The data field is modified +by surrounding it with brackets and using wild cards and special +characters to specify when the transactions should appear. + +@menu +* Transactions that occur on specific dates:: +* Transactions that occur on specific days:: +@end menu + +@node Transactions that occur on specific dates, Transactions that occur on specific days, Specifying Upcoming Transactions, Specifying Upcoming Transactions +@subsection Transactions that occur on specific dates + +Many times you will enter repetitive transactions that occur on the same +day of the month each month. These can be specified using a wild card +in the year and month with a fixed date in the day. The following entry +specifies a transaction that occurs on the first and fifteenth of every +month in every year. +@example +[*/*/1,15] Paycheck + Income:Job $1000.00 + Assets:Checking +@end example + +Some transactions do not occur every month. Comma separated lists of +the months, or @samp{E} for even, or @samp{O} for odd number months can +also be specified. The following entry specifies a bi-monthly +exterminator bill that occurs in the even months: +@example +[*/E/01] Exterminator + Expenses:Home $100.00 + Assets:Checking +@end example + +@node Transactions that occur on specific days, , Transactions that occur on specific dates, Specifying Upcoming Transactions +@subsection Transactions that occur on specific days + +Some transactions occur every relative to the day of the week rather +than the date of the month. For example, many people are paid every two +weeks without regard to the day of the month. Other events may occur on +specific days regardless of the date. For example the following +transactions creates a transaction every other Thursday: + +@example +[2014/11/27+2Th] Paycheck + Income:Job $1000.00 + Assets:Checking +@end example + +It is necessary to specify a starting date in order for this type of +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 +characters long. + + + +@node Customizing Ledger-mode, Generating Ledger Regression Tests, Scheduling Transactions, Top @chapter Customizing Ledger-mode @menu @@ -809,11 +942,11 @@ the reconcile regex. @item ledger-buffer-tracks-reconcile-buffer If non-nil, then when the cursor is moved to a new transaction in the -reconcile window. +@file{*Reconcile*} window. @item ledger-reconcile-force-window-bottom -If non-nil, make the reconcile window appear along the bottom of the -register window and resize. +If non-nil, 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 @@ -881,13 +1014,15 @@ Default face for Ledger occur mode shown transactions. Face for Ledger comments. @item ledger-font-reconciler-uncleared-face -Default face for uncleared transactions in the reconcile window. +Default face for uncleared transactions in the @file{*Reconcile*} buffer. @item ledger-font-reconciler-cleared-face -Default face for cleared @samp{*} transactions in the reconcile window. +Default face for cleared @samp{*} transactions in the @file{*Reconcile*} +buffer. @item ledger-font-reconciler-pending-face -Default face for pending @samp{!} transactions in the reconcile window. +Default face for pending @samp{!} transactions in the @file{*Reconcile*} +buffer. @item ledger-font-report-clickable-face FIXME @@ -996,3 +1131,8 @@ Work in Progress. @printindex ky @bye + +@c Local Variables: +@c mode: texinfo +@c TeX-master: t +@c End: diff --git a/doc/ledger.1 b/doc/ledger.1 index 659d3fbb..b4746eb9 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -182,7 +182,7 @@ 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 Pq Fl X . +.Fl \-exchange Ar commodity Pq Fl X . .It Fl \-period Ar time-period Pq Fl p Show postings only for the given .Ar time-period . @@ -281,193 +281,595 @@ transactions they are contained in. See the manual for more information. .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 . +If +.Ar INT +is zero, then the +account name will be truncated on the right. If +.Ar INT +is greater +than +.Nm 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 +Prepend +.Ar STR +to all accounts reported. That is, the option +.Nm --account Personal +would tack +.Nm Personal: +to the beginning of every account reported in a balance report or register report. .It Fl \-account-width Ar INT +Set the width of the account column in the +.Nm register +report +to +.Ar INT +characters. .It Fl \-actual Pq Fl L +Report only real transactions, with no automated or virtual +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 +you can apply an +arbitrary transformation to the postings. .It Fl \-amount-data Pq Fl j +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 +report. .It Fl \-anon +Anonymize registry output, mostly for sending in bug reports. .It Fl \-args-only .It Fl \-auto-match .It Fl \-aux-date +Show auxiliary dates for all calculations. +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 +report. .It Fl \-base .It Fl \-basis Pq Fl B +Report the cost basis on all posting. +Alias for +.Fl \-cost .It Fl \-begin Ar DATE Pq Fl b +Specify the start +.Ar DATE +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. .It Fl \-budget-format Ar FMT +Specify the format to use for the +.Nm 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. .It Fl \-cleared Pq Fl C +Display only cleared postings. .It Fl \-cleared-format Ar FMT +Specify the format to use for the +.Nm 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. .It Fl \-collapse-if-zero +Collapse the account display only if it has a zero balance. .It Fl \-color +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. .It Fl \-cost -See +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 +or +.Nm payees +commands. .It Fl \-csv-format Ar FMT +Specify the format to use for the +.Nm csv +report .It Fl \-current Pq Fl c -.It Fl \-daily +Shorthand for +.Nm --limit 'date <= today' . +.It Fl \-daily Pq Fl D +Shorthand for +.Nm --period '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 .It Fl \-date-width Ar INT +Specify the width, in characters, of the date column in the +.Nm register +report. .It Fl \-day-break .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. .It Fl \-debug Ar STR +If Ledger 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 +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 +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. .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 +amount. This occurs after +calculations occur. .It Fl \-display-total Ar EXPR +Apply a transformation to the +.Nm displayed +total. This occurs after +calculations occur. .It Fl \-dow +Group transactions by the days of the week. +Alias for +.Fl \-days-of-week .It Fl \-download +Cause quotes to be automagically downloaded, as needed, by running +a script named +.Nm getquote +and expecting that script to return +a value understood by ledger. A sample implementation of +a +.Nm 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 . .It Fl \-empty Pq Fl E -.It Fl \-end Pq Fl e +Include empty accounts in report. +.It Fl \-end Ar DATE Pq Fl e +Specify the end +.Ar DATE +for a transaction to be considered in the +report. .It Fl \-equity +Related to the +.Nm equity +command. Gives current account balances in the form of a register +report. .It Fl \-exact -.It Fl \-exchange Ar COMM Oo , COMM, ... Oc Pq Fl X +.It Fl \-exchange Ar COMMODITY Oo , COMM, ... Oc Pq Fl X +Display values in terms of the given +.Ar COMMODITY . +The latest available price is used. .It Fl \-explicit .It Fl \-file Ar FILE +Read +.Ar FILE +as a ledger file. .It Fl \-first Ar INT -See +Print the first +.Ar INT +entries. Opposite of +.Fl \-tail Ar INT . +Alias for .Fl \-head . .It Fl \-flat +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 +for TTYs that don't advertise their capabilities correctly. .It Fl \-force-pager +Force Ledger to paginate its output. .It Fl \-forecast-while Ar EXPR -(Also -.Fl \-forecast -). +Continue forecasting while +.Ar VEXPR +is true. +Alias for +.Fl \-forecast . .It Fl \-forecast-years Ar INT +Forecast at most +.Ar INT +years into the future. .It Fl \-format Ar FMT Pq Fl F -.It Fl \-full-help +Use the given format string +.Ar FMT +to print output. .It Fl \-gain Pq Fl G +Report net gain or loss for commodities that have a price history. .It Fl \-generated +Include auto-generated postings (such as those from automated +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 +report. +.Ar EXPR +can be anything, although most common would be +.Nm payee +or +.Nm commodity . +The +.Nm tags() +function is also useful here. .It Fl \-group-title-format Ar FMT +Set the format for the headers that separate reports section of +a grouped report. Only has effect with a +.Fl \-group-by Ar EXPR +register report. .It Fl \-head Ar INT +Print the first +.Ar INT +entries. Opposite of +.Fl \-tail Ar INT . +Alias for +.Fl \-first .It Fl \-help -.It Fl \-help-calc -.It Fl \-help-comm -.It Fl \-help-disp +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. .It Fl \-immediate -.It Fl \-import Ar STR +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. +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 .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 -See +Report only the last +.Ar INT +entries. Only useful on a register +report. +Alias for .Fl \-tail . .It Fl \-leeway Ar INT Pq Fl Z +Alias for +.Fl \-price-expr . .It Fl \-limit Ar EXPR Pq Fl l +Limit postings in calculations. .It Fl \-lot-dates +Report the date on which each commodity in a balance report was +purchased. .It Fl \-lot-notes +Report the tag attached to each commodity in a balance report. .It Fl \-lot-prices +Report the price at which each commodity in a balance report was +purchased. .It Fl \-lots +Report the date and price at which each commodity was purchased in +a balance report. .It Fl \-lots-actual .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 +In the register report, prepend the transaction with the value of the given +.Ar TAG . .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' . +.It Fl \-no-aliases +Aliases are completely ignored. .It Fl \-no-color -.It Fl \-no-pager +Suppress any color TTY output. .It Fl \-no-rounding +Don't output +.Nm <Rounding> +postings. Note that this will cause the +running total to often not add up! It's main use is for +.Fl \-amount-data Pq Fl j +and +.Fl \-total-data Pq Fl J +reports. .It Fl \-no-titles +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 . .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 +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 +.Ar FILE . .It Fl \-pager Ar STR +Specify the pager program to use as +.Ar STR . .It Fl \-payee +Sets a value expression for formatting the payee. In the +.Nm register +report this prevents the second entry from having +a date and payee for each transaction. .It Fl \-payee-width Ar INT +Set the number of columns dedicated to the payee in the register +report to +.Ar INT . .It Fl \-pedantic +Accounts, tags or commodities not previously declared will cause errors. .It Fl \-pending -.It Fl \-percent Pq Fl \% +Use only postings that are marked pending. +.It Fl \-percent Pq Fl \b'%' +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 +report only +the transactions that satisfy the period expression with be displayed. +For a balance report only those transactions will be accounted in the +final balances. .It Fl \-period-sort +Sort the posting within transactions using the given value expression. .It Fl \-permissive .It Fl \-pivot Ar STR +Produce a balance pivot report +.Nm around +the given +.Ar TAG . .It Fl \-plot-amount-format Ar FMT +Define the output format for an amount data plot. .It Fl \-plot-total-format Ar FMT +Define the output format for a total data plot. .It Fl \-prepend-format Ar FMT +Prepend +.Ar STR +to every line of the output. .It Fl \-prepend-width Ar INT +Reserve +.Ar INT +spaces at the beginning of each line of the output. .It Fl \-price Pq Fl I +Use the price of the commodity purchase for performing calculations. .It Fl \-price-db Ar FILE -.It Fl \-price-exp Ar STR -See -.Fl \-leeway . +.It Fl \-price-exp Ar STR Pq Fl Z +Set the expected freshness of price quotes, in +.Ar INT +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 +considered to be fresh enough. +Alias for +.Fl \-leeway Ar INT Pq Fl Z .It Fl \-prices-format Ar FMT .It Fl \-pricedb-format Ar FMT .It Fl \-primary-date +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' . .It Fl \-raw -For use only with the +In the .Nm print -command, it causes Ledger to print out matching entries exactly as they -appeared in the original journal file. +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 +amounts. .It Fl \-real Pq Fl R +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 +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 +report. .It Fl \-related Pq Fl r +In a register report show the related account. This is the other +.Nm 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. .It Fl \-revalued .It Fl \-revalued-only .It Fl \-revalued-total Ar EXPR .It Fl \-rich-data .It Fl \-seed Ar INT -.It Fl \-script +Set the random seed to +.Ar INT +for the +.Nm generate +command. Used as part of development testing. +.It Fl \-script Ar FILE +Execute a ledger 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 .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. .It Fl \-strict +Accounts, tags or commodities not previously declared will cause warnings. .It Fl \-subtotal Pq Fl s +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 +.Fl \-last Ar INT .It Fl \-time-report -.It Fl \-total Ar EXPR +.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 +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 -.It Fl \-truncate +Enable tracing. The +.Ar INT +specifies the level of trace desired. +.It Fl \-truncate Ar CODE +Indicates how truncation should happen when the contents of columns +exceed their width. Valid arguments are +.Nm leading , Nm middle , +and +.Nm trailing . +The default is smarter than any of these three, +as it considers sub-names within the account name (that style is +called "abbreviate"). .It Fl \-unbudgeted +Show only un-budgeted postings. .It Fl \-uncleared Pq Fl U +Use only uncleared transactions in calculations and reports. .It Fl \-unrealized +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" . +Often set in one's +.Nm ~/.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" . +Often set in one's +.Nm ~/.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 +command. .It Fl \-value-expr Ar EXPR .It Fl \-verbose +Print detailed information on the execution of Ledger. .It Fl \-verify +Enable additional assertions during run-time. This causes a significant +slowdown. When combined with +.Fl \-debug Ar CODE +ledger will produce memory trace information. .It Fl \-verify-memory .It Fl \-version +Print version information and exit. .It Fl \-weekly Pq Fl W +Synonym for +.Fl \-period 'weekly' . .It Fl \-wide Pq Fl w +Assume 132 columns instead of 80. .It Fl \-yearly Pq Fl Y +Synonym for +.Fl \-period 'yearly' . .El .Pp -.Sh PRECOMMANDS +.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 +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 +.It Nm args / query +Evaluate the given arguments and report how Ledger interprets it against +the following model transaction. .It Nm eval +Evaluate the given value expression against the model transaction. .It Nm format -.It Nm parse +Print details of how ledger 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 +and apply it against a model transaction. +.It Nm generate +Randomly generates syntactically valid Ledger data from a seed. Used +by the GenerateTests harness for development testing. .It Nm period -.It Nm python +Evaluate the given period and report how Ledger interprets it. +.It Nm script .It Nm template +Shows the insertion template that the +.Nm xact sub-command generates. +This is a debugging command. .El .Pp .Sh QUERIES diff --git a/doc/ledger3.texi b/doc/ledger3.texi index e95640e8..4dc3f48f 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -14,15 +14,88 @@ @c | @var | | Ledger CLI option Variable (like -f FILE) | @c | | | Ledger file Syntax | @c | @samp | | Valued example or single char | -@c | @file | | File | +@c | @file | | File, Buffer | @c | @file | | Program (like ledger, report, acprep) | @c Restructuring manual ideas @c http://beyondgrep.com/documentation/ack-2.04-man.html +@c How to make documented ledger examples validate automatically. +@c +@c The test/DocTests.py script will be run along with the other tests +@c when using ctest or acprep check. +@c The script parses the texinfo file and looks for three kinds of +@c specially marked @smallexamples, then it will run the ledger +@c command from the example, and compare the results with the output +@c from the documentation. +@c +@c To specially mark a @smallexample append @c command:UUID, where +@c UUID is the first 7 digits from the commands sha1sum, e.g.: +@c +@c @smallexample @c command:CDE330A +@c $ ledger -f sample.dat reg expenses +@c @end smallexample +@c +@c Then DocTests.py will look for corresponding documented output, +@c which may appear anywhere in the file, and is marked with +@c @smallexample @c output:UUID where UUID is the UUID from the +@c corresponding ledger command example, e.g.: +@c +@c @smallexample @c output:CDE330A +@c 04-May-27 Book Store Expenses:Books $20.00 $20.00 +@c Expenses:Cards $40.00 $60.00 +@c Expenses:Docs $30.00 $90.0 +@c @end smallexample +@c +@c Now where does this data in sample.dat come from? +@c DocTests.py is a bit smart about ledger's file argument, since +@c it will check if the given filename exists in the test/input/ +@c directory. +@c +@c Sometimes the journal data for an example is specified within +@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 concatenated together and given as one set of data to the example command. +@c +@c @smallexample @c input:35CB2A3 +@c 2014/02/09 The Italian Place +@c Expenses:Food:Dining $ 36.84 +@c Assets:Cash +@c @end smallexample +@c +@c @smallexample @c command:35CB2A3 +@c $ ledger -f inline.dat accounts +@c @end smallexample +@c +@c @smallexample @c output:35CB2A3 +@c Assets:Cash +@c Expenses:Food:Dining +@c @end smallexample +@c +@c To use different example commands with the same input from the documentation +@c add with_input:UUID to the example command, where UUID is the UUID of the input, +@c e.g.: +@c +@c @smallexample @c command:94FD2B6,with_input:35CB2A3 +@c $ ledger -f inline.dat bal expenses +@c @end smallexample +@c +@c @smallexample @c output:94FD2B6 +@c $ 36.84 Expenses:Food:Dining +@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 +@c To manually run the tests in this file run: +@c $ ./test/DocTests.py -vv --ledger ./ledger --file ./doc/ledger3.texi + + @copying -Copyright @copyright{} 2003–2013, John Wiegley. All rights reserved. +Copyright @copyright{} 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 @@ -73,7 +146,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @titlepage @title Ledger: Command-Line Accounting -@subtitle For Version 3.0 of Ledger +@subtitle For Version 3.1 of Ledger @author John Wiegley @page @vskip 0pt plus 1filll @@ -166,9 +239,9 @@ accounting tools. The next step up from a checkbook journal, is a journal that keeps track of all your accounts, not just checking. In such a journal, you record not only who gets paid---in the case of a debit---but where the -money came from. In a checkbook journal, its assumed that all the +money came from. In a checkbook journal, it's assumed that all the money comes from your checking account. But in a general journal, you -write posting two-lines: the source account and target account. +write postings in two lines: the source account and target account. @emph{There must always be a debit from at least one account for every credit made to another account}. This is what is meant by ``double-entry'' accounting: the journal must always balance to zero, @@ -214,10 +287,10 @@ 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 -example, if you buy some groceries at Trader Joe's then more groceries -at Whole Foods Markets you might assign the transactions like this +example, if you buy some groceries at Trader Joe's, then more groceries +at Whole Food Market, you might assign the transactions like this -@smallexample +@smallexample @c input:validate 2011/03/15 Trader Joe's Expenses:Groceries $100.00 Assets:Checking @@ -245,7 +318,7 @@ And just for the sake of example---as a starting point for those who want to dive in head-first---here are the journal transactions from above, formatted as the Ledger program wishes to see them: -@smallexample +@smallexample @c input:48DDF26 2004/09/29 Pacific Bell Expenses:Pacific Bell $23.00 Assets:Checking @@ -254,12 +327,37 @@ above, formatted as the Ledger program wishes to see them: The account balances and registers in this file, if saved as @file{ledger.dat}, could be reported using: -@smallexample +@smallexample @c command:48DDF26 $ ledger -f ledger.dat balance +@end smallexample + +@smallexample @c output:48DDF26 + $-23.00 Assets:Checking + $23.00 Expenses:Pacific Bell +-------------------- + 0 +@end smallexample + +Or + +@smallexample @c command:8C7295F,with_input:48DDF26 $ ledger -f ledger.dat register checking +@end smallexample + +@smallexample @c output:8C7295F +04-Sep-29 Pacific Bell Assets:Checking $-23.00 $-23.00 +@end smallexample + +And even: + +@smallexample @c command:BB32EF2,with_input:48DDF26 $ ledger -f ledger.dat register Bell @end smallexample +@smallexample @c output:BB32EF2 +04-Sep-29 Pacific Bell Expenses:Pacific Bell $23.00 $23.00 +@end smallexample + An important difference between Ledger and other finance packages is that Ledger will never alter your input file. You can create and edit that file in any way you prefer, but Ledger is only for analyzing the @@ -286,14 +384,14 @@ $ ./configure && make install 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} bring up this entire manual in -your tty. +following options: @code{ledger --help} brings up this entire manual in +your TTY. If you need help on how to use Ledger, or run into problems, you can join the Ledger mailing list at @url{http://groups.google.com/group/ledger-cli}. -You can also find help at the @code{#ledger} channel on the IRC server +You can also find help in the @code{#ledger} channel on the IRC server @code{irc.freenode.net}. @node Ledger Tutorial, Principles of Accounting with Ledger, Introduction to Ledger, Top @@ -331,11 +429,11 @@ If you would rather start with your own journal right away please 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 +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{^} +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 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. @@ -346,13 +444,13 @@ for each. To find the balances of all of your accounts, run this command: -@smallexample +@smallexample @c command:1071890 $ ledger -f drewr3.dat balance @end smallexample Ledger will generate: -@smallexample +@smallexample @c output:1071890 $ -3,804.00 Assets $ 1,396.00 Checking $ 30.00 Business @@ -381,8 +479,11 @@ pare this down to show only the accounts you want. A more useful report is to show only your Assets and Liabilities: -@smallexample +@smallexample @c command:5BF4D8E $ ledger -f drewr3.dat balance Assets Liabilities +@end smallexample + +@smallexample @c output:5BF4D8E $ -3,804.00 Assets $ 1,396.00 Checking $ 30.00 Business @@ -402,16 +503,16 @@ $ ledger -f drewr3.dat balance Assets Liabilities To show all transactions and a running total: -@smallexample +@smallexample @c command:66E3A2C $ ledger -f drewr3.dat register @end smallexample @noindent Ledger will generate: -@smallexample +@smallexample @c output:66E3A2C 10-Dec-01 Checking balance Assets:Checking $ 1,000.00 $ 1,000.00 - Equity:Opening Balances $ -1,000.00 0 + Equit:Opening Balances $ -1,000.00 0 10-Dec-20 Organic Co-op Expense:Food:Groceries $ 37.50 $ 37.50 Expense:Food:Groceries $ 37.50 $ 75.00 Expense:Food:Groceries $ 37.50 $ 112.50 @@ -450,8 +551,11 @@ interested in seeing transactions for: @cindex accounts, limiting by @cindex limiting by accounts -@smallexample +@smallexample @c command:96B0EB3 $ ledger -f drewr3.dat register Groceries +@end smallexample + +@smallexample @c output:96B0EB3 10-Dec-20 Organic Co-op Expense:Food:Groceries $ 37.50 $ 37.50 Expense:Food:Groceries $ 37.50 $ 75.00 Expense:Food:Groceries $ 37.50 $ 112.50 @@ -465,8 +569,11 @@ $ ledger -f drewr3.dat register Groceries @noindent Which matches the balance reported for the @samp{Groceries} account: -@smallexample +@smallexample @c command:AECD64E $ ledger -f drewr3.dat balance Groceries +@end smallexample + +@smallexample @c output:AECD64E $ 334.00 Expenses:Food:Groceries @end smallexample @@ -474,8 +581,11 @@ $ ledger -f drewr3.dat balance Groceries If you would like to find transaction to only a certain payee use @samp{payee} or @samp{@@}: -@smallexample +@smallexample @c command:C6BC57E $ ledger -f drewr3.dat register payee "Organic" +@end smallexample + +@smallexample @c output:C6BC57E 10-Dec-20 Organic Co-op Expense:Food:Groceries $ 37.50 $ 37.50 Expense:Food:Groceries $ 37.50 $ 75.00 Expense:Food:Groceries $ 37.50 $ 112.50 @@ -497,8 +607,11 @@ a check to clear, but you should treat it as money spent. The @command{cleared} report will not format correctly for accounts that contain multiple commodities): -@smallexample +@smallexample @c command:B86F6A6 $ ledger -f drewr3.dat cleared +@end smallexample + +@smallexample @c output:B86F6A6 $ -3,804.00 $ 775.00 Assets $ 1,396.00 $ 775.00 10-Dec-20 Checking $ 30.00 0 Business @@ -517,8 +630,8 @@ $ ledger -f drewr3.dat cleared $ -20.00 0 MasterCard $ 200.00 0 Mortgage:Principal $ -243.60 0 Tithe ----------------- ---------------- --------- - $ -243.60 0 +---------------- ---------------- --------- + $ -243.60 0 @end smallexample @noindent @@ -531,7 +644,7 @@ shows the ``cleared'' balance. @cindex currency symbol display on windows Using ledger under the windows command shell has one significant -limitation. CMD.exe is limited to standard ASCII characters and as +limitation. CMD.EXE is limited to standard ASCII characters and as such cannot display any currency symbols other than dollar signs @samp{$}. @@ -555,9 +668,9 @@ such cannot display any currency symbols other than dollar signs Accounting is simply tracking your money. It can range from nothing, and just waiting for automatic overdraft protection to kick in, or -not, to a full blown double entry accounting system. Ledger +not, to a full-blown double-entry accounting system. Ledger accomplishes the latter. With ledger you can handle your personal -finances or your businesses. Double-entry accounting scales. +finances or your business's. Double-entry accounting scales. @node Stating where money goes, Assets and Liabilities, Accounting with Ledger, Principles of Accounting with Ledger @section Stating where money goes @@ -578,7 +691,7 @@ where the money comes from and where it goes to. For example, when you are paid a salary, you must add money to your bank account and also subtract it from an income account: -@smallexample +@smallexample @c input:validate 9/29 My Employer Assets:Checking $500.00 Income:Salary $-500.00 @@ -624,7 +737,7 @@ owe. ``Liabilities'' is just a more inclusive name for Debts. An Asset is typically increased by transferring money from an Income account, such as when you get paid. Here is a typical transaction: -@smallexample +@smallexample @c input:6B43DD4 2004/09/29 My Employer Assets:Checking $500.00 Income:Salary @@ -639,7 +752,7 @@ borrow money to buy something, or if you owe someone money. Here is an example of increasing a MasterCard liability by spending money with it: -@smallexample +@smallexample @c input:6B43DD4 2004/09/30 Restaurant Expenses:Dining $25.00 Liabilities:MasterCard @@ -653,10 +766,17 @@ offsets the value of your assets. The combined total of your Assets and Liabilities is your net worth. So to see your current net worth, use this command: -@smallexample +@smallexample @c command:6B43DD4 $ ledger balance ^assets ^liabilities @end smallexample +@smallexample @c output:6B43DD4 + $500.00 Assets:Checking + $-25.00 Liabilities:MasterCard +-------------------- + $475.00 +@end smallexample + In a similar vein, your Income accounts show up negative, because they transfer money @emph{from} an account in order to increase your assets. Your Expenses show up positive because that is where the @@ -665,17 +785,28 @@ flow. A positive cash flow means you are spending more than you make, since income is always a negative figure. To see your current cash flow, use this command: -@smallexample +@smallexample @c command:DB128F3,with_input:6B43DD4 $ ledger balance ^income ^expenses @end smallexample +@smallexample @c output:DB128F3 + $25.00 Expenses:Dining + $-500.00 Income:Salary +-------------------- + $-475.00 +@end smallexample + Another common question to ask of your expenses is: How much do I spend each month on X? Ledger provides a simple way of displaying monthly totals for any account. Here is an example that summarizes your monthly automobile expenses: -@smallexample -$ ledger -M register expenses:auto +@smallexample @c command:DB524E4 +$ ledger -M register -f drewr3.dat expenses:auto +@end smallexample + +@smallexample @c output:DB524E4 +11-Jan-01 - 11-Jan-31 Expenses:Auto $ 5,500.00 $ 5,500.00 @end smallexample This assumes, of course, that you use account names like @@ -699,7 +830,7 @@ This is fairly easy to do in ledger. When spending the money, spend it @emph{to} your Assets:Reimbursements, using a different account for each person or business that you spend money for. For example: -@smallexample +@smallexample @c input:validate 2004/09/29 Circuit City Assets:Reimbursements:Company XYZ $100.00 Liabilities:MasterCard @@ -710,7 +841,7 @@ expense was made on behalf of Company XYZ. Later, when Company XYZ pays the amount back, the money will transfer from that reimbursement account back to a regular asset account: -@smallexample +@smallexample @c input:validate 2004/09/29 Company XYZ Assets:Checking $100.00 Assets:Reimbursements:Company XYZ @@ -732,7 +863,7 @@ company accounts. But keeping them in one file involves the same kinds of postings, so those are what is shown here. First, the personal transaction, which shows the need for reimbursement: -@smallexample +@smallexample @c input:validate 2004/09/29 Circuit City Assets:Reimbursements:Company XYZ $100.00 Liabilities:MasterCard @@ -744,7 +875,7 @@ transaction should be immediately followed by an equivalent transaction, which shows the kind of expense, and also notes the fact that $100.00 is now payable to you: -@smallexample +@smallexample @c input:validate 2004/09/29 Circuit City Company XYZ:Expenses:Computer:Software $100.00 Company XYZ:Accounts Payable:Your Name @@ -757,7 +888,7 @@ paid back. These two transactions can also be merged, to make things a little clearer. Note that all amounts must be specified now: -@smallexample +@smallexample @c input:validate 2004/09/29 Circuit City Assets:Reimbursements:Company XYZ $100.00 Liabilities:MasterCard $-100.00 @@ -771,7 +902,7 @@ paying it to accounts payable, and then drawing it again from the reimbursement account, and paying it to your personal asset account. It's easier shown than said: -@smallexample +@smallexample @c input:validate 2004/10/15 Company XYZ Assets:Checking $100.00 Assets:Reimbursements:Company XYZ $-100.00 @@ -801,7 +932,7 @@ above. For example, for both the expense and the pay-back shown above, the following four transactions would be created. Two in your personal ledger file: -@smallexample +@smallexample @c input:990E0D1 2004/09/29 Circuit City Assets:Reimbursements:Company XYZ $100.00 Liabilities:MasterCard $-100.00 @@ -813,7 +944,7 @@ personal ledger file: And two in your company ledger file: -@smallexample +@smallexample @c input:990E0D1 apply account Company XYZ 2004/09/29 Circuit City @@ -836,6 +967,18 @@ was spent using your MasterCard on behalf of Company XYZ, and that Company XYZ spent the money on computer software and paid it back about two weeks later. +@smallexample @c command:990E0D1 +$ ledger balance --no-total +@end smallexample + +@smallexample @c output:990E0D1 + $100.00 Assets:Checking + 0 Company XYZ + $-100.00 Assets:Checking + $100.00 Expenses:Computer:Software + $-100.00 Liabilities:MasterCard +@end smallexample + @node Commodities and Currencies, Accounts and Inventories, Assets and Liabilities, Principles of Accounting with Ledger @section Commodities and Currencies @@ -886,7 +1029,7 @@ be any commodity, in which case the balance will be computed in terms of that commodity. The usual way to specify prices is with a price history file, which might look like this: -@smallexample +@smallexample @c input:validate P 2004/06/21 02:18:01 FEQTX $22.49 P 2004/06/21 02:18:01 BORL $6.20 P 2004/06/21 02:18:02 AAPL $32.91 @@ -944,7 +1087,7 @@ that commodity on that day. It is also possible, by recording price details in a ledger file, to specify other prices for commodities at any given time. Such price transactions might look like those below: -@smallexample +@smallexample @c input:validate P 2004/06/21 02:17:58 TWCUX $27.76 P 2004/06/21 02:17:59 AGTHX $25.41 P 2004/06/21 02:18:00 OPTFX $39.31 @@ -970,7 +1113,7 @@ transfers an hour of time into a @samp{Billable} account, and another which decreases the same account by ten minutes. The resulting report will indicate that fifty minutes remain: -@smallexample +@smallexample @c input:DF3FEBE 2005/10/01 Work done for company Billable:Client 1h Project:XYZ @@ -982,9 +1125,13 @@ will indicate that fifty minutes remain: Reporting the balance for this ledger file produces: -@smallexample - 50.0m Billable:Client - -50.0m Project:XYZ +@smallexample @c command:DF3FEBE +$ ledger --no-total balance Billable Project +@end smallexample + +@smallexample @c output:DF3FEBE + 50.0m Billable:Client + -50.0m Project:XYZ @end smallexample This example works because ledger already knows how to handle seconds, @@ -993,7 +1140,7 @@ other equivalencies is simple. The following is an example that creates data equivalencies, helpful for tracking bytes, kilobytes, megabytes, and more: -@smallexample +@smallexample @c input:validate C 1.00 Kb = 1024 b C 1.00 Mb = 1024 Kb C 1.00 Gb = 1024 Mb @@ -1021,7 +1168,7 @@ various items in EverQuest, and want to keep track of them using a ledger. Just add items of whatever quantity you wish into your EverQuest account: -@smallexample +@smallexample @c input:48F4E47 9/29 Get some stuff at the Inn Places:Black's Tavern -3 Apples Places:Black's Tavern -5 Steaks @@ -1034,13 +1181,13 @@ Tavern in order to add to your Inventory account. Note that you don't have to use @samp{Places:Black's Tavern} as the source account. You could use @samp{EverQuest:System} to represent the fact that you acquired them online. The only purpose for choosing one kind of -source account over another is for generate more informative reports -later on. The more you know, the better analysis you can perform. +source account over another is to generate more informative reports +later on. The more you know, the better the analysis you can perform. If you later sell some of these items to another player, the transaction would look like: -@smallexample +@smallexample @c input:48F4E47 10/2 Sturm Brightblade EverQuest:Inventory -2 Steaks EverQuest:Inventory 15 Gold @@ -1049,6 +1196,16 @@ transaction would look like: Now you've turned 2 steaks into 15 gold, courtesy of your customer, Sturm Brightblade. +@smallexample @c command:48F4E47 +$ ledger balance EverQuest +@end smallexample + +@smallexample @c output:48F4E47 + 3 Apples + 15 Gold + 3 Steaks EverQuest:Inventory +@end smallexample + @node Understanding Equity, Dealing with Petty Cash, Accounts and Inventories, Principles of Accounting with Ledger @section Understanding Equity @@ -1058,9 +1215,9 @@ account---because starting balances can't come out of nowhere. When you first start your ledger, you will likely already have money in some of your accounts. Let's say there's $100 in your checking account; then add a transaction to your ledger to reflect this amount. -Where will money come from? The answer: your equity. +Where will the money come from? The answer: your equity. -@smallexample +@smallexample @c input:validate 10/2 Opening Balance Assets:Checking $100.00 Equity:Opening Balances @@ -1100,7 +1257,7 @@ One solution is: don't bother. Move your spending to a debit card, but in general ignore cash. Once you withdraw it from the ATM, mark it as already spent to an @samp{Expenses:Cash} category: -@smallexample +@smallexample @c input:validate 2004/03/15 ATM Expenses:Cash $100.00 Assets:Checking @@ -1110,7 +1267,7 @@ If at some point you make a large cash expense that you want to track, just @emph{move} the amount of the expense from @samp{Expenses:Cash} into the target account: -@smallexample +@smallexample @c input:validate 2004/03/20 Somebody Expenses:Food $65.00 Expenses:Cash @@ -1144,7 +1301,7 @@ reserves resources for later: @item Community fund @end itemize -The problem with this kind of setup is that when you spend money, it +The problem with this kind of setup is that, when you spend money, it comes from two or more places at once: the account and the fund. And yet, the correlation of amounts between funds and accounts is rarely one-to-one. What if the school fund has @samp{$500.00}, but @@ -1161,7 +1318,7 @@ This situation can be handled one of two ways. The first is using virtual postings to represent the fact that money is moving to and from two kind of accounts at the same time: -@smallexample +@smallexample @c input:396F24E 2004/03/20 Contributions Assets:Checking $500.00 Income:Donations @@ -1177,7 +1334,7 @@ virtual postings balance to zero. Now money can be spent directly from a fund at the same time as money is drawn from a physical account: -@smallexample +@smallexample @c input:396F24E 2004/03/25 Payment for books (paid from Checking) Expenses:Books $100.00 Assets:Checking $-100.00 @@ -1189,16 +1346,30 @@ funds. In this case, you will likely want to mask out your @samp{Assets} account, because otherwise the balance won't make much sense: -@smallexample -$ ledger bal -^Assets +@smallexample @c command:396F24E +$ ledger --no-total bal not ^Assets +@end smallexample + +@smallexample @c output:396F24E + $100.00 Expenses:Books + $400.00 Funds + $200.00 Building + $200.00 School + $-500.00 Income:Donations @end smallexample @findex --real If the @option{--real} option is used, the report will be in terms of the real accounts: -@smallexample -$ ledger --real bal +@smallexample @c command:2F1CB75,with_input:396F24E +$ ledger --real --no-total bal +@end smallexample + +@smallexample @c output:2F1CB75 + $400.00 Assets:Checking + $100.00 Expenses:Books + $-500.00 Income:Donations @end smallexample If more asset accounts are needed as the source of a posting, just @@ -1218,39 +1389,52 @@ set of postings. Basically, we are associating a transaction with a fund by setting its code. Here are two transactions that deposit money into, and spend money from, the @samp{Funds:School} fund: -@smallexample +@smallexample @c input:AD068BA 2004/03/25 (Funds:School) Donations Assets:Checking $100.00 Income:Donations +2004/03/25 (Funds:Building) Donations + Assets:Checking $20.00 + Income:Donations + 2004/04/25 (Funds:School) Payment for books Expenses:Books $50.00 Assets:Checking @end smallexample Note how the accounts now relate only to the real accounts, and any -balance or registers reports will reflect this. That the transactions +balance or register reports will reflect this. That the transactions relate to a particular fund is kept only in the code. -@findex --code-as-payee +@findex --payee=code @findex --by-payee How does this become a fund report? By using the -@option{--code-as-payee} option, you can generate a register report +@option{--payee=code} option, you can generate a register report where the payee for each posting shows the code. Alone, this is not terribly interesting; but when combined with the @option{--by-payee (-P)} option, you will now see account subtotals for any postings related to a specific fund. So, to see the current monetary balances of all funds, the command would be: -@smallexample -$ ledger --code-as-payee -P reg ^Assets +@smallexample @c command:AD068BA +$ ledger --payee=code -P reg ^Assets +@end smallexample + +@smallexample @c output:AD068BA +04-Mar-25 Funds:Building Assets:Checking $20.00 $20.00 +04-Mar-25 Funds:School Assets:Checking $50.00 $70.00 @end smallexample -Or to see a particular funds expenses, the @samp{School} fund in this +Or to see a particular fund's expenses, the @samp{School} fund in this case: -@smallexample -$ ledger --code-as-payee -P reg ^Expenses @@School +@smallexample @c command:E30B2FC,with_input:AD068BA +$ ledger --payee=code -P reg ^Expenses and code School +@end smallexample + +@smallexample @c output:E30B2FC +04-Apr-25 Funds:School Expenses:Books $50.00 $50.00 @end smallexample Both approaches yield different kinds of flexibility, depending on how @@ -1307,9 +1491,9 @@ posting. @section The Most Basic Entry Here is the Pacific Bell example from above, given as a Ledger -posting, with the additional of a check number: +posting, with the addition of a check number: -@smallexample +@smallexample @c input:validate 9/29 (1023) Pacific Bell Expenses:Utilities:Phone $23.00 Assets:Checking $-23.00 @@ -1321,7 +1505,7 @@ work better with Ledger's scheme of things. In fact, since Ledger is smart about many things, you don't need to specify the balanced amount, if it is the same as the first line: -@smallexample +@smallexample @c input:validate 9/29 (1023) Pacific Bell Expenses:Utilities:Phone $23.00 Assets:Checking @@ -1363,7 +1547,7 @@ 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: -@smallexample +@smallexample @c input:validate 2011/01/01 * Opening Balance Assets:Joint Checking $800.14 Assets:Other Checking $63.44 @@ -1419,13 +1603,13 @@ Expenses:Food:Hamburgers and Fries Comments are generally started using a @samp{;}. However, in order to increase compatibility with other text manipulation programs and -methods four additional comment characters are valid if used at the +methods, four additional comment characters are valid if used at the beginning of a line: @samp{#}, @samp{|}, and @samp{*} and @samp{%}. Block comments can be made by use @code{comment} ... @code{end comment}. -@smallexample +@smallexample @c input:validate ; This is a single line comment, # and this, % and this, @@ -1440,7 +1624,7 @@ end comment There are several forms of comments within a transaction, for example: -@smallexample +@smallexample @c input:validate ; this is a global comment that is not applied to a specific transaction ; it can start with any of the five characters but is not included in the ; output from 'print' or 'output' @@ -1464,7 +1648,7 @@ start with @samp{;} and are preserved as part of the transaction. The @cindex commodity Ledger is agnostic when it comes to how you value your accounts. -Dollars, Euros, Pounds, Francs, Shares etc. are just ``commodities''. +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 @@ -1485,41 +1669,44 @@ reporting capabilities to convert all commodities to a single commodity for reporting purposes without ever changing the underlying entry. -For example, the following entries reflect transaction made for a +For example, the following entries reflect transactions made for a business trip to Europe from the US: -@smallexample +@smallexample @c input:82150D9 2011/09/23 Cash in Munich - Assets:Cash E50.00 + Assets:Cash €50.00 Assets:Checking $-66.00 2011/09/24 Dinner in Munich - Expenses:Business:Travel E35.00 + Expenses:Business:Travel €35.00 Assets:Cash @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 was +Euros. The implied exchange rate was $1.32. Then 35.00 Euros were spent on Dinner in Munich. Running a ledger balance report shows: -@smallexample +@smallexample @c command:82150D9 $ ledger -f example.dat bal +@end smallexample + +@smallexample @c output:82150D9 $-66.00 - E15.00 Assets - E15.00 Cash + €15.00 Assets + €15.00 Cash $-66.00 Checking - E35.00 Expenses:Business:Travel + €35.00 Expenses:Business:Travel -------------------- $-66.00 - E50.00 + €50.00 @end smallexample The top two lines show my current assets as $-66.00 in checking (in this very short example I didn't establish opening an opening balance -for the checking account) and E15.00. After spending on dinner I have -E15.00 in my wallet. The bottom line balances to zero, but is shown +for the checking account) and €15.00. After spending on dinner I have +€15.00 in my wallet. The bottom line balances to zero, but is shown in two lines since we haven't told ledger to convert commodities. @menu @@ -1533,10 +1720,10 @@ in two lines since we haven't told ledger to convert commodities. @subsection Naming Commodities Commodity names can have any character, including white-space. -However, if you include white-space or numeric characters the +However, if you include white-space or numeric characters, the commodity name must be enclosed in double quotes @samp{"}: -@smallexample +@smallexample @c input:validate 1999/06/09 ! Achat Actif:SG PEE STK 49.957 "Arcancia Équilibre 454" Actif:SG PEE STK $-234.90 @@ -1556,22 +1743,22 @@ multiple commodities in the same transaction. The type of the share unit you made the purchase in ($ for AAPL). Yes, the typical convention is as follows: -@smallexample +@smallexample @c input:validate 2004/05/01 Stock purchase Assets:Broker 50 AAPL @@ $30.00 Expenses:Broker:Commissions $19.95 - Assets:Broker $-1,500.00 + Assets:Broker $-1,519.95 @end smallexample -This assumes you have a brokerage account that is capable of managed +This assumes you have a brokerage account that is capable of managing both liquid and commodity assets. Now, on the day of the sale: -@smallexample +@smallexample @c input:validate 2005/08/01 Stock sale - Assets:Broker -50 APPL @{$30.00@} @@ $50.00 + Assets:Broker -50 AAPL @{$30.00@} @@ $50.00 Expenses:Broker:Commissions $19.95 Income:Capital Gains $-1,000.00 - Assets:Broker $2,500.00 + Assets:Broker $2,480.05 @end smallexample @noindent @@ -1588,7 +1775,7 @@ longest-held-first. @cindex fixing lot prices @cindex consumable commodity pricing -Commodities that you keep in order to sell them at a later time have +Commodities that you keep in order to sell at a later time have a variable value that fluctuates with the market prices. Commodities that you consume should not fluctuate in value, but stay at the lot price they were purchased at. As an extension of ``lot pricing'', you @@ -1602,7 +1789,7 @@ reported in terms of today's price. This is supported as follows: -@smallexample +@smallexample @c input:validate 2009/01/01 Shell Expenses:Gasoline 11 GAL @{=$2.299@} Assets:Checking @@ -1614,9 +1801,9 @@ price of gasoline. If you do not want price fixing, you can specify this same transaction in one of two ways, both equivalent (note the lack of the equal sign -from the transaction above): +compared to the transaction above): -@smallexample +@smallexample @c input:validate 2009/01/01 Shell Expenses:Gasoline 11 GAL @{$2.299@} Assets:Checking @@ -1629,7 +1816,7 @@ from the transaction above): There is no difference in meaning between these two forms. Why do both exist, you ask? To support things like this: -@smallexample +@smallexample @c input:validate 2009/01/01 Shell Expenses:Gasoline 11 GAL @{=$2.299@} @@ $2.30 Assets:Checking @@ -1649,12 +1836,12 @@ Assets:Checking because its amount is null. 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 -are now several points of interception, you can specify the valuation +are now several points of interception; you can specify the valuation method: @enumerate @item on a commodity itself, -@item on a posting, via metadata (affect is largely the same as #1), +@item on a posting, via metadata (effect is largely the same as #1), @item on an xact, which then applies to all postings in that xact, @item on any posting via an automated transaction, @item on a per-account basis, @@ -1670,7 +1857,7 @@ A valuation function receives three arguments: @table @code -@item source +@item source A string identifying the commodity whose price is being asked for (example: @samp{EUR}). @@ -1741,7 +1928,7 @@ function on a transaction-wide or per-posting basis. Lastly, you can specify the valuation function/value for any specific amount using the @samp{(( ))} commodity annotation. -@smallexample +@smallexample @c input:814A366 2012-03-02 KFC Expenses:Food2 $1 ((2 EUR)) Assets:Cash2 @@ -1777,20 +1964,24 @@ amount using the @samp{(( ))} commodity annotation. Assets:Cash9 @end smallexample -@smallexample -ledger reg -V food +@smallexample @c command:814A366 +$ ledger reg -V food +@end smallexample + +@smallexample @c output:814A366 12-Mar-02 KFC Expenses:Food2 2 EUR 2 EUR -12-Mar-03 KFC <Adjustment> -1 EUR 1 EUR - Expenses:Food3 3 EUR 4 EUR -12-Mar-04 KFC <Adjustment> -2 EUR 2 EUR - Expenses:Food4 4 EUR 6 EUR -12-Mar-05 KFC <Adjustment> -3 EUR 3 EUR - Expenses:Food5 5 EUR 8 EUR -12-Mar-06 KFC <Adjustment> -4 EUR 4 EUR - Expenses:Food6 6 EUR 10 EUR -12-Mar-07 KFC Expenses:Food7 7 EUR 17 EUR -12-Mar-08 XACT Expenses:Food8 8 EUR 25 EUR -12-Mar-09 POST (Expenses:Food9) 9 EUR 34 EUR +12-Mar-03 KFC Expenses:Food3 3 EUR 5 EUR +12-Mar-04 KFC Expenses:Food4 4 EUR 9 EUR +12-Mar-05 KFC Expenses:Food5 $1 $1 + 9 EUR +12-Mar-06 KFC Expenses:Food6 $1 $2 + 9 EUR +12-Mar-07 KFC Expenses:Food7 1 CAD $2 + 1 CAD + 9 EUR +12-Mar-08 XACT Expenses:Food8 $1 $3 + 1 CAD + 9 EUR @end smallexample @node Keeping it Consistent, Journal Format, Currency and Commodities, Keeping a Journal @@ -1804,8 +1995,8 @@ data, but also easy to enter accounts or payees inconsistently or with spelling errors. In order to combat inconsistency you can define allowable accounts and -or payees. For simplicity, create a separate text file and enter -define accounts a payees like +payees. For simplicity, create a separate text file and define accounts +and payees like @smallexample account Expenses @@ -1831,7 +2022,8 @@ $ ledger accounts >> Accounts.dat @end smallexample @noindent -You will have to edit this file to add the @code{account} directive. +You will have to edit this file to add the @code{account} directive in +front of every line. @node Journal Format, Converting from other formats, Keeping it Consistent, Keeping a Journal @section Journal Format @@ -1875,7 +2067,7 @@ payee, or a description of the posting. The format of each following posting is: @smallexample -ACCOUNT AMOUNT [; NOTE] + ACCOUNT AMOUNT [; NOTE] @end smallexample The @code{ACCOUNT} may be surrounded by parentheses if it is a virtual @@ -1902,24 +2094,24 @@ An automated transaction. A value expression must appear after the equal sign. After this initial line there should be a set of one or more postings, -just as if it were normal transaction. If the amounts of the postings -have no commodity, they will be applied as modifiers to whichever real +just as if it were a normal transaction. If the amounts of the postings +have no commodity, they will be applied as multipliers to whichever real posting is matched by the value expression (@pxref{Automated Transactions}). @item ~ -A period transaction. A period expression must appear after the tilde. +A periodic transaction. A period expression must appear after the tilde. After this initial line there should be a set of one or more -postings, just as if it were normal transaction. +postings, just as if it were a normal transaction. @item ; # % | * -A line beginning with a colon, pound, percent, bar or asterisk +A line beginning with a semicolon, pound, percent, bar or asterisk indicates a comment, and is ignored. Comments will not be returned in a ``print'' response. @item indented ; -If the semi colon is indented and occurs inside a transaction, it is +If the semicolon is indented and occurs inside a transaction, it is parsed as a persistent note for its preceding category. These notes or tags can be used to augment the reporting and filtering capabilities of Ledger. @@ -1938,13 +2130,13 @@ Command directives must occur at the beginning of a line. Use of @samp{!} and @samp{@@} is deprecated. @item account -Pre-declare valid account names. This only has effect if +Pre-declare valid account names. This only has an effect if @option{--strict} or @option{--pedantic} is used (see below). The @code{account} directive supports several optional sub-directives, if they immediately follow the account directive and if they begin with whitespace: -@smallexample +@smallexample @c input:validate account Expenses:Food note This account is all about the chicken! alias food @@ -1956,8 +2148,8 @@ account Expenses:Food @end smallexample The @code{note} sub-directive associates a textual note with the -account. This can be accessed later using the @code{note} valexpr -function in any account context. +account. This can be accessed later using the @code{note} value +expression function in any account context. The @code{alias} sub-directive, which can occur multiple times, allows the alias to be used in place of the full account name anywhere that @@ -1968,13 +2160,13 @@ provides regexes that identify the account if that payee is encountered and an account within its transaction ends in the name "Unknown". Example: -@smallexample +@smallexample @c input:validate 2012-02-27 KFC Expenses:Unknown $10.00 ; Read now as "Expenses:Food" Assets:Cash @end smallexample -The @code{check} and @code{assert} directives warn or error +The @code{check} and @code{assert} directives warn or raise an error (respectively) if the given value expression evaluates to false within the context of any posting. @@ -1988,16 +2180,16 @@ contain only a single posting. @item apply account @c instance_t::master_account_directive -Sets the root for all accounts following the directive. Ledger +Sets the root for all accounts following this directive. Ledger supports a hierarchical tree of accounts. It may be convenient to keep two ``root accounts''. For example you may be tracking your personal finances and your business finances. In order to keep them separate you could preface all personal accounts with @samp{personal:} -and all business account with @samp{business:}. You can easily split -out large groups of transaction without manually editing them using +and all business accounts with @samp{business:}. You can easily split +out large groups of transactions without manually editing them using the account directive. For example: -@smallexample +@smallexample @c input:validate apply account Personal 2011/11/15 Supermarket Expenses:Groceries $ 50.00 @@ -2006,14 +2198,14 @@ apply account Personal Would result in all postings going into @samp{Personal:Expenses:Groceries} and @samp{Personal:Assets:Checking} -until and @samp{end apply account} directive was found. +until an @samp{end apply account} directive was found. @item alias @c instance_t::alias_directive 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 +@smallexample @c input:validate alias Dining=Expenses:Entertainment:Dining alias Checking=Assets:Credit Union:Joint Checking Account @@ -2023,9 +2215,42 @@ alias Checking=Assets:Credit Union:Joint Checking Account @end smallexample The aliases are only in effect for transactions read in after the alias -is defined and are effected by @code{account} directives that precede +is defined and are affected by @code{account} directives that precede them. +@smallexample @c command:validate +$ ledger bal --no-total ^Exp +@end smallexample + +@smallexample + $10.00 Expenses:Entertainment:Dining +@end smallexample + +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 +alias Entertainment=Expenses:Entertainment +alias Dining=Entertainment:Dining +alias Checking=Assets:Credit Union:Joint Checking Account + +2011/11/30 ChopChop + Dining $10.00 + Checking +@end smallexample + +@smallexample @c command:validate +$ ledger balance --no-total --recursive-aliases ^Exp +@end smallexample + +@smallexample + $10.00 Expenses:Entertainment:Dining +@end smallexample + +The option @option{--no-aliases} completely disables alias expansion. +All accounts are read verbatim as they are in the ledger file. + @item assert @c instance_t::assert_directive An assertion can throw an error if a condition is not met during @@ -2040,13 +2265,14 @@ assert <VALUE EXPRESSION BOOLEAN RESULT> Defines the default account to use for balancing transactions. Normally, each transaction has at least two postings, which must balance to zero. Ledger allows you to leave one posting with no -amount and automatically calculate balance the transaction in the +amount and automatically balance the transaction in the posting. The @code{bucket} allows you to fill in all postings and automatically generate an additional posting to the bucket account -balancing the transaction. The following example set the -@samp{Assets:Checking} as the bucket: +balancing the transaction. If any transaction is unbalanced, it +will automatically be balanced against the @code{bucket} account. +The following example sets @samp{Assets:Checking} as the bucket: -@smallexample +@smallexample @c input:validate bucket Assets:Checking 2011/01/25 Tom's Used Cars Expenses:Auto $ 5,500.00 @@ -2066,7 +2292,7 @@ bucket Assets:Checking Directs Ledger to replace any account matching a regex with the given account. For example: -@smallexample +@smallexample @c input:validate capture Expenses:Deductible:Medical Medical @end smallexample @@ -2078,7 +2304,7 @@ Ledger will display the mapped payees in @command{print} and @item check @c instance_t::check_directive in textual.cc -A check can issue a warning if a condition is not met during Ledger's +A check issues a warning if a condition is not met during Ledger's run. @smallexample @@ -2090,19 +2316,19 @@ check <VALUE EXPRESSION BOOLEAN RESULT> Start a block comment, closed by @code{end comment}. @item commodity -Pre-declare commodity names. This only has effect if @option{--strict} -or @option{--pedantic} is used (see below). +Pre-declare commodity names. This only has an effect if +@option{--strict} or @option{--pedantic} is used (see below). -@smallexample +@smallexample @c input:validate commodity $ commodity CAD @end smallexample The @code{commodity} directive supports several optional -sub-directives, if they immediately follow the commodity directive and -if they begin with whitespace: +sub-directives, if they immediately follow the commodity directive +and---if they are on successive lines---begin with whitespace: -@smallexample +@smallexample @c input:validate commodity $ note American Dollars format $1,000.00 @@ -2113,21 +2339,21 @@ commodity $ The @code{note} sub-directive associates a textual note with the commodity. At present this has no value other than documentation. -The @code{format} directive gives you a way to tell Ledger how to -format this commodity. In future using this directive will disable +The @code{format} sub-directive gives you a way to tell Ledger how to +format this commodity. In the future, using this directive will disable Ledger's observation of other ways that commodity is used, and will provide the ``canonical'' representation. -The @code{nomarket} directive states that the commodity's price should -never be auto-downloaded. +The @code{nomarket} sub-directive states that the commodity's price +should never be auto-downloaded. -The @code{default} directive marks this as the ``default'' commodity. +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 expression for future use. For example: +Allows you to define value expressions for future use. For example: -@smallexample +@smallexample @c input:validate define var_name=$100 2011/12/01 Test @@ -2153,21 +2379,21 @@ use when entering many transactions with fixated prices. Thus, the following: -@smallexample +@smallexample @c input:validate fixed CAD $0.90 - 2012-04-10 Lunch in Canada - Assets:Wallet -15.50 CAD - Expenses:Food 15.50 CAD +2012-04-10 Lunch in Canada + Assets:Wallet -15.50 CAD + Expenses:Food 15.50 CAD - 2012-04-11 Second day Dinner in Canada - Assets:Wallet -25.75 CAD - Expenses:Food 25.75 CAD -endfixed +2012-04-11 Second day Dinner in Canada + Assets:Wallet -25.75 CAD + Expenses:Food 25.75 CAD +endfixed CAD @end smallexample is equivalent to this: -@smallexample +@smallexample @c input:validate 2012-04-10 Lunch in Canada Assets:Wallet -15.50 CAD @{=$0.90@} Expenses:Food 15.50 CAD @{=$0.90@} @@ -2190,20 +2416,22 @@ before using the @code{fixed} directive in production. Include the stated file as if it were part of the current file. @item payee -@c instance_t::payee_mapping_directive in textual.cc +@c instance_t::payee_alias_mapping_directive in textual.cc +@c instance_t::payee_uuid_mapping_directive in textual.cc @findex print @findex register -The @code{payee} directive supports one optional sub-directive, if it -immediately follows the payee directive and if it begins with -whitespace: +The @code{payee} directive supports two optional sub-directives, if they +immediately follow the payee directive and---if it is on a successive +line---begins with whitespace: -@smallexample +@smallexample @c input:validate payee KFC alias KENTUCKY FRIED CHICKEN + uuid 2a2e21d434356f886c84371eebac6e44f1337fda @end smallexample -The @code{alias} directive provides a regex which, if it matches +The @code{alias} sub-directive provides a regex which, if it matches a parsed payee, the declared payee name is substituted: @smallexample @@ -2211,6 +2439,14 @@ a parsed payee, the declared payee name is substituted: ... @end smallexample +The @code{uuid} sub-directive specifies that a transaction with exactly +the uuid given should have the declared payee name substituted: + +@smallexample +2014-05-13 UNHELPFUL PAYEE ; will be read as being 'KFC' + ; UUID: 2a2e21d434356f886c84371eebac6e44f1337fda +@end smallexample + Ledger will display the mapped payees in @command{print} and @command{register} reports. @@ -2219,7 +2455,7 @@ Ledger will display the mapped payees in @command{print} and Allows you to designate a block of transactions and assign the same tag to all. Tags can have values and may be nested. -@smallexample +@smallexample @c input:validate apply tag hastag apply tag nestedtag: true @@ -2232,67 +2468,70 @@ apply tag nestedtag: true Expenses:Books $20.00 Liabilities:MasterCard -end apply tag nestedtag +end apply tag 2011/12/01 Sale Assets:Checking:Business $ 30.00 Income:Sales -end apply tag hastag +end apply tag @end smallexample @noindent is the equivalent of: -@smallexample +@smallexample @c input:validate 2011/01/25 Tom's Used Cars - :hastag: - nestedtag: true + ; :hastag: + ; nestedtag: true Expenses:Auto $ 5,500.00 ; :nobudget: Assets:Checking 2011/01/27 Book Store - :hastag: - nestedtag: true + ; :hastag: + ; nestedtag: true Expenses:Books $20.00 Liabilities:MasterCard 2011/12/01 Sale - :hastag: + ; :hastag: Assets:Checking:Business $ 30.00 Income:Sales @end smallexample -Note that anything following @code{end apply tag} is ignored. placing -the name of the tag that is being closed is a simple way to keep -track. +@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 the name of the tag that is being closed is a simple way to keep +@c track. @item tag -Pre-declares tag names. This only has effect if @option{--strict} or +Pre-declares tag names. This only has an effect if @option{--strict} or @option{--pedantic} is used (see below). -@smallexample +@smallexample @c input:validate tag Receipt tag CSV @end smallexample The @code{tag} directive supports two optional sub-directives, if they -immediately follow the tag directive and if they begin with -whitespace: +immediately follow the tag directive and---if on a successive +line---begin with whitespace: -@smallexample +@smallexample @c input:validate tag Receipt check value =~ /pattern/ assert value != "foobar" @end smallexample -The @code{check} and @code{assert} directives warn or error +The @code{check} and @code{assert} sub-directives warn or error (respectively) if the given value expression evaluates to false within the context of any use of the related tag. In such a context, -``value'' is bound to the value of the tag (which may not be a string -if typed-metadata is used!). Such checks or assertions are not called -if no value is given. +``value'' is bound to the value of the tag (which may be something else +but a string if typed metadata is used!). Such checks or assertions are +not called if no value is given. @item test @c instance_t::comment_directive in textual.cc @@ -2342,7 +2581,7 @@ whichever is seen last is used as the default commodity. For example, to set US dollars as the default commodity, while also setting the thousands flag and decimal flag for that commodity, use: -@smallexample +@smallexample @c input:validate D $1,000.00 @end smallexample @@ -2351,13 +2590,13 @@ 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: -@smallexample +@smallexample @c input:validate C 1.00 Kb = 1024 bytes @end smallexample @item I, i, O, o, b, h These four relate to timeclock support, which permits Ledger to read -timelog files. See the timeclock's documentation for more info on the +timelog files. See timeclock's documentation for more info on the syntax of its timelog files. @end table @@ -2464,7 +2703,7 @@ doing it. * Total posting costs:: * Virtual posting costs:: * Commodity prices:: -* Prices vs. costs:: +* Prices versus costs:: * Fixated prices and costs:: * Lot dates:: * Lot notes:: @@ -2477,7 +2716,7 @@ doing it. The most basic form of transaction is: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 Assets:Cash $-20.00 @@ -2489,7 +2728,7 @@ posting specifies what action is taken related to that account. A transaction can have any number of postings: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 Assets:Cash $-10.00 @@ -2503,7 +2742,7 @@ The first thing you can do to make things easier is elide amounts. That is, if exactly one posting has no amount specified, Ledger will infer the inverse of the other postings' amounts: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 Assets:Cash $-10.00 @@ -2515,7 +2754,7 @@ If the other postings use multiple commodities, Ledger will copy the empty posting N times and fill in the negated values of the various commodities: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 Expenses:Tips $2.00 @@ -2527,7 +2766,7 @@ commodities: @noindent This transaction is identical to writing: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 Expenses:Tips $2.00 @@ -2545,7 +2784,7 @@ This transaction is identical to writing: You can associate a second date with a transaction by following the primary date with an equals sign: -@smallexample +@smallexample @c input:validate 2012-03-10=2012-03-08 KFC Expenses:Food $20.00 Assets:Cash $-20.00 @@ -2553,8 +2792,8 @@ primary date with an equals sign: What this auxiliary date means is entirely up to you. The only use Ledger has for it is that if you specify @option{--aux-date}, then all -reports and calculations (including pricing) will use the aux date as if -it were the primary date. +reports and calculations (including pricing) will use the auxiliary +date as if it were the primary date. @node Codes, Transaction state, Auxiliary dates, Transactions @section Codes @@ -2564,7 +2803,7 @@ only displayed by the print command. Checking accounts often use codes like DEP, XFER, etc., as well as check numbers. This is to give you a place to put those codes: -@smallexample +@smallexample @c input:validate 2012-03-10 (#100) KFC Expenses:Food $20.00 Assets:Checking @@ -2576,11 +2815,11 @@ you a place to put those codes: @findex --uncleared @findex --pending -A transaction can have a ``state'': cleared, pending, or uncleared. -The default is uncleared. To mark a transaction cleared, put a * -before the payee, and after date or code: +A transaction can have a ``state'': cleared, pending, or uncleared. The +default is uncleared. To mark a transaction cleared, put an asterisk +@samp{*} before the payee, after the date or code: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC Expenses:Food $20.00 Assets:Cash @@ -2589,14 +2828,14 @@ before the payee, and after date or code: @noindent To mark it pending, use a !: -@smallexample +@smallexample @c input:validate 2012-03-10 ! KFC Expenses:Food $20.00 Assets:Cash @end smallexample What these mean is entirely up to you. The @option{--cleared} option -will limits to reports to only cleared items, while @option{--uncleared} +limits reports to only cleared items, while @option{--uncleared} shows both uncleared and pending items, and @option{--pending} shows only pending items. @@ -2607,7 +2846,7 @@ a reconciliation. When you clear a transaction, that's really just shorthand for clearing all of its postings. That is: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC Expenses:Food $20.00 Assets:Cash @@ -2616,7 +2855,7 @@ clearing all of its postings. That is: @noindent Is the same as writing: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC * Expenses:Food $20.00 * Assets:Cash @@ -2626,7 +2865,7 @@ Is the same as writing: You can mark individual postings as cleared or pending, in case one ``side'' of the transaction has cleared, but the other hasn't yet: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Liabilities:Credit $100.00 * Assets:Checking @@ -2636,10 +2875,10 @@ You can mark individual postings as cleared or pending, in case one @section Transaction notes After the payee, and after at least one tab or two spaces (or a space -and a tab, which Ledger calls this a ``hard separator''), you may +and a tab, which Ledger calls a ``hard separator''), you may introduce a note about the transaction using the @samp{;} character: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC ; yum, chicken... Expenses:Food $20.00 Assets:Cash @@ -2649,7 +2888,7 @@ introduce a note about the transaction using the @samp{;} character: Notes can also appear on the next line, so long as that line begins with whitespace: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC ; yum, chicken... ; and more notes... Expenses:Food $20.00 @@ -2661,12 +2900,12 @@ with whitespace: Assets:Cash @end smallexample -A transaction note is shared by all its postings. This becomes +A transaction's note is shared by all its postings. This becomes significant when querying for metadata (see below). To specify that a note belongs only to one posting, place it after a hard separator after the amount, or on its own line preceded by whitespace: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC Expenses:Food $20.00 ; posting #1 note Assets:Cash @@ -2690,7 +2929,7 @@ typed metadata with postings and transactions (by which I mean all of a transaction's postings). This metadata can be queried, displayed, and used in calculations. -The are two forms of metadata: tags and tag/value pairs. +The are two forms of metadata: plain tags, and tag/value pairs. @menu * Metadata tags:: @@ -2702,9 +2941,9 @@ The are two forms of metadata: tags and tag/value pairs. @subsection Metadata tags To tag an item, put any word not containing whitespace between two -colons: +colons inside a comment: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC Expenses:Food $20.00 Assets:Cash @@ -2713,7 +2952,7 @@ colons: You can gang up multiple tags by sharing colons: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC Expenses:Food $20.00 Assets:Cash @@ -2736,11 +2975,12 @@ 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 you can specify from whom each check came from, as shown by example below: +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 +you can specify from whom each check came from, as shown by example +below: -@smallexample +@smallexample @c input:validate 2010-06-17 Sample Assets:Bank $400.00 Income:Check1 $-100.00 ; Payee: Person One @@ -2769,7 +3009,7 @@ To associate a value with a tag, use the syntax ``Key: Value'', where the value can be any string of characters. Whitespace is needed after the colon, and cannot appear in the Key: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC Expenses:Food $20.00 Assets:Cash @@ -2783,7 +3023,7 @@ If a metadata tag ends in ::, its value will be parsed as a value expression and stored internally as a value rather than as a string. For example, although I can specify a date textually like so: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC Expenses:Food $20.00 Assets:Cash @@ -2824,7 +3064,7 @@ reports using @option{--real}. To specify a virtual account, surround the account name with parentheses: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC Expenses:Food $20.00 Assets:Cash @@ -2835,7 +3075,7 @@ If you want, you can state that virtual postings @emph{should} balance against one or more other virtual postings by using brackets (which look ``harder'') rather than parentheses: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC Expenses:Food $20.00 Assets:Cash @@ -2850,7 +3090,7 @@ An amount is usually a numerical figure with an (optional) commodity, but it can also be any value expression. To indicate this, surround the amount expression with parentheses: -@smallexample +@smallexample @c input:validate 2012-03-10 * KFC Expenses:Food ($10.00 + $20.00) ; Ledger adds it up for you Assets:Cash @@ -2899,8 +3139,8 @@ A balance assignment has this form: Assets:Cash = $500.00 @end smallexample -This sets the amount of the second posting to whatever it would need -to be for the total in Assets:Cash to be $500.00 after the posting. +This sets the amount of the second posting to whatever it would need to +be for the total in @samp{Assets:Cash} to be $500.00 after the posting. If the resulting amount is not $-20.00 in this case, it is an error. @node Resetting a balance, Balancing transactions, Balance assignments, Balance verification @@ -2910,7 +3150,7 @@ Say your book-keeping has gotten a bit out of date, and your Ledger balance no longer matches your bank balance. You can create an adjustment transaction using balance assignments: -@smallexample +@smallexample @c input:validate 2012-03-10 Adjustment Assets:Cash = $500.00 Equity:Adjustments @@ -2920,7 +3160,7 @@ Since the second posting is also null, it's value will become the inverse of whatever amount is generated for the first posting. This is the only time in ledger when more than one posting's amount -may be empty---and then only because it's not true empty, it is +may be empty---and then only because it's not truly empty, it is indirectly provided by the balance assignment's value. @node Balancing transactions, , Resetting a balance, Balance verification @@ -2935,9 +3175,9 @@ As a consequence of all the above, consider the following transaction: @end smallexample What this says is: set the amount of the posting to whatever value is -needed so that Assets:Brokerage contains 10 AAPL. Then, because this -posting must balance, ensure that its value is zero. This can only be -true if Assets:Brokerage does indeed contain 10 AAPL at that point in +needed so that @samp{Assets:Brokerage} contains 10 AAPL. Then, because +this posting must balance, ensure that its value is zero. This can only +be true if Assets:Brokerage does indeed contain 10 AAPL at that point in the input file. A balanced virtual transaction is used simply to indicate to Ledger that @@ -2948,7 +3188,7 @@ anyway (unless you use a register report with @option{--empty}). @section Posting cost When you transfer a commodity from one account to another, sometimes -it get transformed during the transaction. This happens when you +it gets transformed during the transaction. This happens when you spend money on gas, for example, which transforms dollars into gallons of gasoline, or dollars into stocks in a company. @@ -2956,7 +3196,7 @@ In those cases, Ledger will remember the ``cost'' of that transaction for you, and can use it during reporting in various ways. Here's an example of a stock purchase: -@smallexample +@smallexample @c input:validate 2012-03-10 My Broker Assets:Brokerage 10 AAPL Assets:Brokerage:Cash $-500.00 @@ -2964,7 +3204,7 @@ example of a stock purchase: This is different from transferring 10 AAPL shares from one account to another, in this case you are @emph{exchanging} one commodity for -another. The resulting posting cost is $50.00 per share. +another. The resulting posting's cost is $50.00 per share. @node Explicit posting costs, Posting cost expressions, Posting cost, Transactions @section Explicit posting costs @@ -2972,16 +3212,16 @@ another. The resulting posting cost is $50.00 per share. You can make any posting's cost explicit using the @samp{@@} symbol after the amount or amount expression: -@smallexample +@smallexample @c input:validate 2012-03-10 My Broker Assets:Brokerage 10 AAPL @@ $50.00 Assets:Brokerage:Cash $-500.00 @end smallexample When you do this, since Ledger can now figure out the balancing amount -from the first posting's cost, you can elide the otheramount: +from the first posting's cost, you can elide the other amount: -@smallexample +@smallexample @c input:validate 2012-03-10 My Broker Assets:Brokerage 10 AAPL @@ $50.00 Assets:Brokerage:Cash @@ -3007,9 +3247,10 @@ Said another way, whenever Ledger sees a posting cost of the form "AMOUNT @@ AMOUNT", the commodity used in the second amount is marked ``primary''. -The only meaning a primary commodity has is that @option{--market (-V)} -flag will never convert a primary commodity into any other commodity. -@option{--exchange @var{COMMODITY} (-X)} still will, however. +The only meaning a primary commodity has is that the @option{--market +(-V)} flag will never convert a primary commodity into any other +commodity. @option{--exchange @var{COMMODITY} (-X)} still will, +however. @node Posting cost expressions, Total posting costs, Explicit posting costs, Transactions @section Posting cost expressions @@ -3017,7 +3258,7 @@ flag will never convert a primary commodity into any other commodity. Just as you can have amount expressions, you can have posting expressions: -@smallexample +@smallexample @c input:validate 2012-03-10 My Broker Assets:Brokerage 10 AAPL @@ ($500.00 / 10) Assets:Brokerage:Cash @@ -3025,7 +3266,7 @@ expressions: You can even have both: -@smallexample +@smallexample @c input:validate 2012-03-10 My Broker Assets:Brokerage (5 AAPL * 2) @@ ($500.00 / 10) Assets:Brokerage:Cash @@ -3038,7 +3279,7 @@ The cost figure following the @samp{@@} character specifies the @emph{per-unit} price for the commodity being transferred. If you'd like to specify the total cost instead, use @samp{@@@@}: -@smallexample +@smallexample @c input:validate 2012-03-10 My Broker Assets:Brokerage 10 AAPL @@@@ $500.00 Assets:Brokerage:Cash @@ -3046,7 +3287,7 @@ like to specify the total cost instead, use @samp{@@@@}: Ledger reads this as if you had written: -@smallexample +@smallexample @c input:validate 2012-03-10 My Broker Assets:Brokerage 10 AAPL @@ ($500.00 / 10) Assets:Brokerage:Cash @@ -3061,17 +3302,17 @@ Ledger's internal price history database. To prevent this from happening in the case of an exceptional transaction, surround the @samp{@@} or @samp{@@@@} with parentheses: -@smallexample +@smallexample @c input:validate 2012-03-10 My Brother Assets:Brokerage 1000 AAPL (@@) $1 Income:Gifts Received @end smallexample -@node Commodity prices, Prices vs. costs, Virtual posting costs, Transactions +@node Commodity prices, Prices versus costs, Virtual posting costs, Transactions @section Commodity prices @findex --lot-prices -When a transaction occurs that exchange one commodity for another, +When a transaction occurs that exchanges one commodity for another, Ledger records that commodity price not only within its internal price database, but also attached to the commodity itself. Usually this fact remains invisible to the user, unless you turn on @option{--lot-prices} @@ -3079,22 +3320,22 @@ to show these hidden price figures. For example, consider the stock sale given above: -@smallexample +@smallexample @c input:validate 2012-03-10 My Broker Assets:Brokerage 10 AAPL @@ $50.00 Assets:Brokerage:Cash @end smallexample -The commodity transferred into Assets:Brokerage is not actually 10 -AAPL, but rather 10 AAPL @{$5.00@}. The figure in braces after the +The commodity transferred into @samp{Assets:Brokerage} is not actually 10 +AAPL, but rather 10 AAPL @{$50.00@}. The figure in braces after the amount is called the ``lot price''. It's Ledger's way of remembering that this commodity was transferred through an exchange, and that -$5.00 was the price of that exchange. +$50.00 was the price of that exchange. This becomes significant if you later sell that commodity again. For example, you might write this: -@smallexample +@smallexample @c input:validate 2012-04-10 My Broker Assets:Brokerage:Cash Assets:Brokerage -10 AAPL @@ $75.00 @@ -3103,7 +3344,7 @@ example, you might write this: And that would be perfectly fine, but how do you track the capital gains on the sale? It could be done with a virtual posting: -@smallexample +@smallexample @c input:validate 2012-04-10 My Broker Assets:Brokerage:Cash Assets:Brokerage -10 AAPL @@ $75.00 @@ -3139,7 +3380,7 @@ As a shorthand, you can specify the total price instead of the per-share price in doubled braces. This goes well with total costs, but is not required to be used with them: -@smallexample +@smallexample @c input:validate 2012-04-10 My Broker Assets:Brokerage:Cash $750.00 Assets:Brokerage -10 AAPL @{@{$500.00@}@} @@@@ $750.00 @@ -3147,12 +3388,12 @@ but is not required to be used with them: @end smallexample 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 commodity, whereas @{$5.00@} is. In fact, when you write +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 @{@{$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 form in the output. The double -price form is a shorthand only. +transaction, you'll see the single braces form in the output. The +double braces price form is a shorthand only. Plus, it comes with dangers. This works fine: @@ -3191,12 +3432,12 @@ But this does not do what you might expect: Income:Capital Gains $-125.00 @end smallexample -And in cases where the amounts do not divide into whole figure and +And in cases where the amounts do not divide into whole figures and must be rounded, the capital gains figure could be off by a cent. Use with caution. -@node Prices vs. costs, Fixated prices and costs, Commodity prices, Transactions -@section Prices vs. costs +@node Prices versus costs, Fixated prices and costs, Commodity prices, Transactions +@section Prices versus costs Because lot pricing provides enough information to infer the cost, the following two transactions are equivalent: @@ -3216,7 +3457,7 @@ example in the print report. Functionally, however, there is no difference, and neither the register nor the balance report are sensitive to this difference. -@node Fixated prices and costs, Lot dates, Prices vs. costs, Transactions +@node Fixated prices and costs, Lot dates, Prices versus costs, Transactions @section Fixated prices and costs If you buy a stock last year, and ask for its value today, Ledger will @@ -3247,7 +3488,7 @@ fixated prices by way of the cost: @end smallexample This is the same as the previous transaction, with the same caveats -found in @ref{Prices vs. costs}. +found in @ref{Prices versus costs}. @node Lot dates, Lot notes, Fixated prices and costs, Transactions @section Lot dates @@ -3283,8 +3524,8 @@ indicate a virtual cost: Income:Capital Gains $-125.00 @end smallexample -You can any combination of lot prices, dates or notes, in any order. -They are all optional. +You can specify any combination of lot prices, dates or notes, in any +order. They are all optional. To show all lot information in a report, use @option{--lots}. @@ -3301,7 +3542,7 @@ However, you can override this valuation logic by providing a commodity valuation expression in doubled parentheses. This expression must result in one of two values: either an amount to always be used as the per-share price for that commodity; or -a function taking three argument which is called to determine that +a function taking three arguments, which is called to determine that price. If you use the functional form, you can either specify a function @@ -3356,8 +3597,8 @@ indicate what is being desired. @end itemize In most cases, it is simplest to either use explicit amounts in your -valuation expressions, or just pass the arguments down to market after -modifying them to suit your needs. +valuation expressions, or just pass the arguments down to @samp{market} +after modifying them to suit your needs. @node Automated Transactions, , Lot value expressions, Transactions @section Automated Transactions @@ -3369,7 +3610,7 @@ same query syntax as the Ledger command line. Consider this posting: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 Assets:Cash @@ -3377,7 +3618,7 @@ Consider this posting: If I write this automated transaction before it in the file: -@smallexample +@smallexample @c input:validate = expr true Foo $50.00 Bar $-50.00 @@ -3386,7 +3627,7 @@ If I write this automated transaction before it in the file: Then the first transaction will be modified during parsing as if I'd written this: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 Foo $50.00 @@ -3423,7 +3664,7 @@ As a special case, if an automated transaction's posting's amount (phew) has no commodity, it is taken as a multiplier upon the matching posting's cost. For example: -@smallexample +@smallexample @c input:validate = expr true Foo 50.00 Bar -50.00 @@ -3435,7 +3676,7 @@ posting's cost. For example: Then the latter transaction turns into this during parsing: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 Foo $1000.00 @@ -3453,7 +3694,7 @@ posting, that expression has access to all the details of the matched posting. For example, you can refer to that posting's amount using the ``amount'' value expression variable: -@smallexample +@smallexample @c input:validate = expr true (Foo) (amount * 2) ; same as just "2" in this case @@ -3464,7 +3705,7 @@ the ``amount'' value expression variable: This becomes: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 (Foo) $40.00 @@ -3475,11 +3716,12 @@ This becomes: @node Referring to the matching posting's account, Applying metadata to every matched posting, Accessing the matching posting's amount, Automated Transactions @subsection Referring to the matching posting's account -Sometimes want to refer to the account that matched in some way within -the automated transaction itself. This is done by using the string -$account, anywhere within the account part of the automated posting: +Sometimes you want to refer to the account that was matched +in some way within the automated transaction itself. This is +done by using the string @samp{$account}, anywhere within the +account part of the automated posting: -@smallexample +@smallexample @c input:validate = food (Budget:$account) 10 @@ -3490,7 +3732,7 @@ $account, anywhere within the account part of the automated posting: Becomes: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 (Budget:Expenses:Food) $200.00 @@ -3504,7 +3746,7 @@ If the automated transaction has a transaction note, that note is copied (along with any metadata) to every posting that matches the predicate: -@smallexample +@smallexample @c input:validate = food ; Foo: Bar (Budget:$account) 10 @@ -3516,7 +3758,7 @@ predicate: Becomes: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 ; Foo: Bar @@ -3530,7 +3772,7 @@ Becomes: If the automated transaction's posting has a note, that note is carried to the generated posting within the matched transaction: -@smallexample +@smallexample @c input:validate = food (Budget:$account) 10 ; Foo: Bar @@ -3542,7 +3784,7 @@ carried to the generated posting within the matched transaction: Becomes: -@smallexample +@smallexample @c input:validate 2012-03-10 KFC Expenses:Food $20.00 (Budget:Expenses:Food) $200.00 @@ -3568,7 +3810,7 @@ the generated posting. @cindex effective dates @findex --effective -In the real world transactions do not take place instantaneously. +In the real world, transactions do not take place instantaneously. 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. @@ -3578,7 +3820,7 @@ something like @cindex effective date of invoice -@smallexample +@smallexample @c input:validate 2008/01/01=2008/01/14 Client invoice ; estimated date you'll be paid Assets:Accounts Receivable $100.00 Income: Client name @@ -3586,7 +3828,7 @@ something like Then, when you receive the payment, you change it to -@smallexample +@smallexample @c input:validate 2008/01/01=2008/01/15 Client invoice ; actual date money received Assets:Accounts Receivable $100.00 Income: Client name @@ -3595,7 +3837,7 @@ Then, when you receive the payment, you change it to @noindent and add something like -@smallexample +@smallexample @c input:validate 2008/01/15 Client payment Assets:Checking $100.00 Assets:Accounts Receivable @@ -3603,14 +3845,14 @@ and add something like Now -@smallexample +@smallexample @c command:validate $ ledger --begin 2008/01/01 --end 2008/01/14 bal Income @end smallexample @noindent gives you your accrued income in the first two weeks of the year, and -@smallexample +@smallexample @c command:validate $ ledger --effective --begin 2008/01/01 --end 2008/01/14 bal Income @end smallexample @@ -3626,7 +3868,7 @@ the money to be evenly distributed over the next six months so that your monthly budgets gradually take a hit for the vegetables you'll pick up from the co-op, even though you've already paid for them. -@smallexample +@smallexample @c input:6453542 2008/10/16 * (2090) Bountiful Blessings Farm Expenses:Food:Groceries $ 37.50 ; [=2008/10/01] Expenses:Food:Groceries $ 37.50 ; [=2008/11/01] @@ -3637,22 +3879,24 @@ pick up from the co-op, even though you've already paid for them. Assets:Checking @end smallexample -This entry accomplishes this. Every month until you'll start with an +This entry accomplishes this. Every month you'll see an automatic $37.50 deficit like you should, while your checking account really knows that it debited $225 this month. -And using @option{--effective} option, initial date will be overridden -by effective dates. +And using the @option{--effective} option, the initial date will be +overridden by the effective dates. -@smallexample +@smallexample @c command:6453542 $ ledger --effective register Groceries +@end smallexample -08-Oct-01 Bountiful Blessi.. Expe:Food:Groceries $ 37.50 $ 37.50 -08-Nov-01 Bountiful Blessi.. Expe:Food:Groceries $ 37.50 $ 75.00 -08-Dec-01 Bountiful Blessi.. Expe:Food:Groceries $ 37.50 $ 112.50 -09-Jan-01 Bountiful Blessi.. Expe:Food:Groceries $ 37.50 $ 150.00 -09-Feb-01 Bountiful Blessi.. Expe:Food:Groceries $ 37.50 $ 187.50 -09-Mar-01 Bountiful Blessi.. Expe:Food:Groceries $ 37.50 $ 225.00 +@smallexample @c output:6453542 +08-Oct-01 Bountiful Blessings.. Expense:Food:Groceries $ 37.50 $ 37.50 +08-Nov-01 Bountiful Blessings.. Expense:Food:Groceries $ 37.50 $ 75.00 +08-Dec-01 Bountiful Blessings.. Expense:Food:Groceries $ 37.50 $ 112.50 +09-Jan-01 Bountiful Blessings.. Expense:Food:Groceries $ 37.50 $ 150.00 +09-Feb-01 Bountiful Blessings.. Expense:Food:Groceries $ 37.50 $ 187.50 +09-Mar-01 Bountiful Blessings.. Expense:Food:Groceries $ 37.50 $ 225.00 @end smallexample @node Periodic Transactions, Concrete Example of Automated Transactions, Effective Dates, Automated Transactions @@ -3676,9 +3920,9 @@ complex, but if you have further interest, please consult the Web. Ledger makes this otherwise difficult law very easy. Just set up an automated posting at the top of your ledger file: -@smallexample +@smallexample @c input:C371854 ; This automated transaction will compute Huqúqu'lláh based on this -; journal's postings. Any that match will affect the +; journal's postings. Any accounts that match will affect the ; Liabilities:Huququ'llah account by 19% of the value of that posting. = /^(?:Income:|Expenses:(?:Business|Rent$|Furnishings|Taxes|Insurance))/ @@ -3690,12 +3934,24 @@ ledger file. If any match the given value expression, 19% of the posting's value is applied to the @samp{Liabilities:Huququ'llah} account. So, if $1000 is earned from @samp{Income:Salary}, $190 is added to @samp{Liabilities:Huqúqu'lláh}; if $1000 is spent on Rent, -$190 is subtracted. The ultimate balance of Huqúqu'lláh reflects how +$190 is subtracted. + +@smallexample @c input:C371854 +2003/01/01 (99) Salary + Income:Salary -$1000 + Assets:Checking + +2003/01/01 (100) Rent + Expenses:Rent $500 + Assets:Checking +@end smallexample + +The ultimate balance of Huqúqu'lláh reflects how much is owed in order to fulfill one's obligation to Huqúqu'lláh. When ready to pay, just write a check to cover the amount shown in @samp{Liabilities:Huququ'llah}. That transaction would look like: -@smallexample +@smallexample @c input:validate 2003/01/01 (101) Baha'i Huqúqu'lláh Trust Liabilities:Huququ'llah $1,000.00 Assets:Checking @@ -3704,17 +3960,22 @@ When ready to pay, just write a check to cover the amount shown in That's it. To see how much Huqúq is currently owed based on your ledger transactions, use: -@smallexample +@smallexample @c command:C371854 $ ledger balance Liabilities:Huquq @end smallexample -This works fine, but omits one aspect of the law: that Huquq is only +@smallexample @c output:C371854 + $-95 Liabilities:Huququ'llah +@end smallexample + +This works fine, but omits one aspect of the law: that Huqúq is only due once the liability exceeds the value of 19 mithqáls of gold (which is roughly 2.22 ounces). So what we want is for the liability to appear in the balance report only when it exceeds the present day value of 2.22 ounces of gold. This can be accomplished using the command: +@c TODO: fix this, it doesn't work any longer @smallexample $ ledger -Q -t "/Liab.*Huquq/?(a/P@{2.22 AU@}<=@{-1.0@}&a):a" bal liab @end smallexample @@ -3724,6 +3985,7 @@ Huqúqu'lláh is reported only if its value exceeds that of 2.22 ounces of gold. If you wish the liability to be reflected in the parent subtotal either way, use this instead: +@c TODO: fix this, it doesn't work any longer @smallexample $ ledger -Q -T "/Liab.*Huquq/?(O/P@{2.22 AU@}<=@{-1.0@}&O):O" bal liab @end smallexample @@ -3732,7 +3994,7 @@ In some cases, you may wish to refer to the account of whichever posting matched your automated transaction's value expression. To do this, use the special account name @samp{$account}: -@smallexample +@smallexample @c input:validate = /^Some:Long:Account:Name/ [$account] -0.10 [Savings] 0.10 @@ -3777,14 +4039,14 @@ options. The balance report is the most commonly used report. The simplest invocation is: -@smallexample +@smallexample @c command:1D00D56 $ ledger balance -f drewr3.dat @end smallexample @noindent which will print the balances of every account in your journal. -@smallexample +@smallexample @c output:1D00D56 $ -3,804.00 Assets $ 1,396.00 Checking $ 30.00 Business @@ -3807,12 +4069,15 @@ which will print the balances of every account in your journal. $ -243.60 @end smallexample -Most times this is more than you want. Limiting the results to +Most times, this is more than you want. Limiting the results to specific accounts is as easy as entering the names of the accounts -after the command. +after the command: -@smallexample +@smallexample @c command:06B2AD4 $ ledger balance -f drewr3.dat Auto MasterCard +@end smallexample + +@smallexample @c output:06B2AD4 $ 5,500.00 Expenses:Auto $ -20.00 Liabilities:MasterCard -------------------- @@ -3820,14 +4085,17 @@ $ ledger balance -f drewr3.dat Auto MasterCard @end smallexample @noindent -note the implicit logical and between @samp{Auto} and +Note the implicit logical or between @samp{Auto} and @samp{Mastercard}. If you want the entire contents of a branch of your account tree, use the highest common name in the branch: -@smallexample +@smallexample @c command:B0468E1 $ ledger balance -f drewr3.dat Income +@end smallexample + +@smallexample @c output:B0468E1 $ -2,030.00 Income $ -2,000.00 Salary $ -30.00 Sales @@ -3835,18 +4103,28 @@ $ ledger balance -f drewr3.dat Income $ -2,030.00 @end smallexample -You can use general regular expressions in nearly anyplace Ledger +You can use general regular expressions in nearly any place Ledger needs a string: -@smallexample +@smallexample @c command:EAE389F $ ledger balance -f drewr3.dat ^Bo +@end smallexample +@smallexample @c output:EAE389F +@end smallexample + +This first example looks for any account starting with @samp{Bo}, of +which there are none. + +@smallexample @c command:E2AF6AD $ ledger balance -f drewr3.dat Bo +@end smallexample + +@smallexample @c output:E2AF6AD $ 20.00 Expenses:Books @end smallexample -The first example looks for any account starting with @samp{Bo}, of -which there are none. The second looks for any account with @samp{Bo}, -which is @samp{Expenses:Books}. +This second example looks for any account containing @samp{Bo}, which is +@samp{Expenses:Books}. @cindex limit by payees @findex --limit @var{EXPR} @@ -3854,9 +4132,12 @@ which is @samp{Expenses:Books}. If you want to know exactly how much you have spent in a particular account on a particular payee, the following are equivalent: -@smallexample +@smallexample @c command:validate $ ledger balance Auto:Fuel and Chevron -$ ledger balance --limit "(account=~/Fuel/) & (payee=~/Chev/)" +@end smallexample + +@smallexample @c command:validate +$ ledger balance --limit 'account=~/Fuel/' and 'payee=~/Chev/' @end smallexample @noindent @@ -3869,8 +4150,8 @@ possibilities. If you want to exclude specific accounts from the report, you can exclude multiple accounts with parentheses: -@smallexample -$ ledger bal Expenses and not \(Expenses:Drinks or Expenses:Candy or Expenses:Gifts\) +@smallexample @c command:validate +$ ledger bal Expenses and not (Expenses:Drinks or Expenses:Candy or Expenses:Gifts) @end smallexample @node Controlling Formatting, , Controlling the Accounts and Payees, Balance Reports @@ -3886,6 +4167,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 $ ledger -b "last oct" -S T bal ^expenses @end smallexample @@ -3909,7 +4191,7 @@ for all accounts that begin with @samp{expenses}. The following query makes it easy to see monthly expenses, with each month's expenses sorted by the amount: -@smallexample +@smallexample @c command:validate $ ledger -M --period-sort "(amount)" reg ^expenses @end smallexample @@ -3917,7 +4199,7 @@ Now, you might wonder where the money came from to pay for these things. To see that report, add @option{--related (-r)}, which shows the ``related account'' postings: -@smallexample +@smallexample @c command:validate $ ledger -M --period-sort "(amount)" -r reg ^expenses @end smallexample @@ -3927,8 +4209,8 @@ requires the use of a display predicate, since the postings calculated must match @samp{^expenses}, while the postings displayed must match @samp{mastercard}. The command would be: -@smallexample -$ ledger -M -r --display "account =~ /mastercard/" reg ^expenses +@smallexample @c command:validate +$ ledger -M -r --display 'account=~/mastercard/' reg ^expenses @end smallexample This query says: Report monthly subtotals; report the ``related @@ -3936,10 +4218,10 @@ account'' postings; display only related postings whose account matches @samp{mastercard}, and base the calculation on postings matching @samp{^expenses}. -This works just as well for report the overall total, too: +This works just as well for reporting the overall total, too: -@smallexample -$ ledger -s -r --display "account =~ /mastercard/" reg ^expenses +@smallexample @c command:validate +$ ledger -s -r --display "account=~/mastercard/" reg ^expenses @end smallexample The @option{--subtotal (-s)} option subtotals all postings, just as @@ -3965,11 +4247,11 @@ allocation in ledger is not difficult but does require some additional effort to describe how the various assets you own contribute to the asset classes you want to track. -In our simple example we assume you want to apportion you assets into +In our simple example we assume you want to apportion your assets into the general categories of domestic and international equities (stocks) -and a combined category of bonds and cash. For illustrative purposes +and a combined category of bonds and cash. For illustrative purposes, we will use several publicly available mutual funds from Vanguard. -the three funds we will track are the Vanguard 500 IDX FD Signal +The three funds we will track are the Vanguard 500 IDX FD Signal (VIFSX), the Vanguard Target Retirement 2030 (VTHRX), and the Vanguard Short Term Federal Fund (VSGBX). Each of these funds allocates assets to different categories of the investment universe and in different @@ -4002,7 +4284,7 @@ actual balances. For the three instruments listed above, those automatic transactions would look like: -@smallexample +@smallexample @c input:validate ; ; automatic calculations for asset allocation tracking ; @@ -4034,6 +4316,7 @@ 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 ledger bal Allocation --current --format "\ %-17((depth_spacer)+(partial_account))\ @@ -4063,7 +4346,7 @@ tree, using a special formatter. The magic is in the formatter. The second line simply tells Ledger to print the partial account name indented by its depth in the tree. The third line is where we calculate and display the percentages. The -@code{display_total} command give the values of the total calculated +@code{display_total} command gives the values of the total calculated 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 @@ -4080,7 +4363,7 @@ nothing. @findex --limit @var{EXPR} @findex --display @var{EXPR} -If you have ``Gnuplot'' program installed, you can graph any of the +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} anywhere along your @env{PATH}, and then use @file{report} instead of @@ -4119,11 +4402,12 @@ report -J -l "Ua>=@{\$0.01@}" -d "d>=[last feb]" reg ^assets ^liab The last report uses both a calculation predicate @option{--limit @var{EXPR} (-l)} and a display predicate @option{--display @var{EXPR} -(-d)}. The calculation predicates limits the report to postings whose -amount is greater than $1 (which can only happen if the posting amount -is in dollars). The display predicate limits the transactions -@emph{displayed} to just those since last February, even those -transactions from before then will be computed as part of the balance. +(-d)}. The calculation predicate limits the report to postings whose +amount is greater than or equal to $1 (which can only happen if the +posting amount is in dollars). The display predicate limits the +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 @chapter Reporting Commands @@ -4158,7 +4442,7 @@ separately. @subsection The @command{equity} command @findex equity -The @command{equity} command prints out accounts balances as if they +The @command{equity} command prints out account balances as if they were transactions. This makes it easy to establish the starting balances for an account, such as when @ref{Archiving Previous Years}. @@ -4168,11 +4452,11 @@ balances for an account, such as when @ref{Archiving Previous Years}. @findex --amount-data @findex --total-data -The @command{register} command displays all the postings occurring -in a single account, line by line. The account regex must be -specified as the only argument to this command. If any regexes occur -after the required account name, the register will contain only those -postings that match. Very useful for hunting down a particular +The @command{register} command displays all the postings occurring in +a single account, line by line. The account regex must be specified as +the only argument to this command. If any regexes occur after the +required account name, the register will contain only those postings +that match, which makes it very useful for hunting down a particular posting. The output from @command{register} is very close to what a typical @@ -4184,8 +4468,8 @@ If you have ``Gnuplot'' installed, you may plot the amount or running total of any register by using the script @file{report}, which is included in the Ledger distribution. The only requirement is that you add either @option{--amount-data (-j)} or @option{--total-data (-J)} to -your register command, in order to plot either the amount or total -column, respectively. +your @command{register} command, in order to plot either the amount or +total column, respectively. @node The @command{print} command, , The @command{register} command, Primary Financial Reports @subsection The @command{print} command @@ -4225,12 +4509,12 @@ file whose formatting has gotten out of hand. @subsubsection The @command{csv} command @findex csv -The @command{csv} command will output print out the desired ledger -transactions in a csv format suitable for import into other programs. +The @command{csv} command prints the desired ledger +transactions in a csv format suitable for importing into other programs. You can specify the transactions to print using all the normal limiting and searching functions. -@node The @command{convert} command, , The @command{csv} command, Comma Separated Values files +@node The @command{convert} command, , The @command{csv} command, Comma Separated Values files @subsubsection The @command{convert} command @cindex csv importing @cindex comma separated variable file reading @@ -4238,12 +4522,12 @@ limiting and searching functions. @findex --input-date-format @var{DATE_FORMAT} The @command{convert} command parses a comma separated value (csv) file -and outputs Ledger transactions. Many banks offer csv file downloads. -Unfortunately, the file formats, aside the from commas, are all +and prints Ledger transactions. Many banks offer csv file downloads. +Unfortunately, the file formats, aside from the commas, are all different. The ledger @command{convert} command tries to help as much as it can. -Your banks csv files will have fields in different orders from other +Your bank's csv files will have fields in different orders from other banks, so there must be a way to tell Ledger what to expect. Insert a line at the beginning of the csv file that describes the fields to Ledger. @@ -4266,9 +4550,10 @@ Transaction Number,Date,Description,Memo,Amount Debit,Amount Credit,Balance,Chec 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 are called -@code{date}, @code{posted}, @code{code}, @code{payee} or @code{desc}, -@code{amount}, @code{cost}, @code{total}, and @code{note}. +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}. Delete the account description lines at the top, and replace the first line in the data above with: @@ -4286,7 +4571,7 @@ $ ledger convert download.csv --input-date-format "%m/%d/%Y" Where the @option{--input-date-format @var{DATE_FORMAT}} option tells ledger how to interpret the dates. -Importing csv files is a lot of work, and but is very amenable to +Importing csv files is a lot of work, but is very amenable to scripting. If there are columns in the bank data you would like to keep in your @@ -4301,20 +4586,20 @@ transid,date,payee,note,amount,,,code, @end smallexample Ledger will include @samp{; transid: 767718} in the first transaction -is from the file above. +from the file above. @findex --invert @findex --account @var{STR} @findex --rich-data -The @command{convert} command accepts three options, the most important -ones are @option{--invert} which inverts the amount field, and +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}. When using the rich-data -switch additional metadata is stored as tags. There is, for example, +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 environment variable @env{LEDGER_FILE}) this entry will not be +via the environment variable @env{LEDGER_FILE}) this entry will not be printed again. You can also use @command{convert} with @code{payee} and @code{account} @@ -4323,7 +4608,7 @@ 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: -@smallexample +@smallexample @c input:validate payee Aldi alias ^ALDI SUED SAGT DANKE account Aufwand:Einkauf:Lebensmittel @@ -4332,7 +4617,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. @@ -4341,7 +4626,7 @@ used. @findex lisp @findex emacs -The @command{lisp} command outputs results in a form that can be read +The @command{lisp} command prints results in a form that can be read directly by Emacs Lisp. The format of the @code{sexp} is: @smallexample @@ -4372,7 +4657,7 @@ commands also appear in the text file. The output can be updated whenever any new ledger entries are added. For instance, the following Org mode text document snippet illustrates -a very naive but still useful of the Babel system: +a very naive but still useful application of the Babel system: @smallexample * A simple test of ledger in an org file @@ -4418,7 +4703,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: @@ -4429,7 +4714,7 @@ I currently do this directly as follows: )) @end smallexample -Once Ledger support in Babel has been enabled, we can use proceed to +Once Ledger support in Babel has been enabled, we can proceed to include Ledger entries within an org file. There are three ways (at least) in which these can be included: @@ -4467,7 +4752,7 @@ The first two are described in more detail in this short tutorial. @node Embedded Ledger example with single source block, Multiple Ledger source blocks with @code{noweb}, Org mode with Babel, Org mode with Babel @subsubsection Embedded Ledger example with single source block -The easiest, albeit possibly less useful, way in which to use Ledger +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: @@ -4706,10 +4991,10 @@ the running total of the assets in our ledger. @node Summary, , Generating a monthly register, Org mode with Babel @subsubsection Summary -This short tutorial shows how Ledger entries can be embedded in a org +This short tutorial shows how Ledger entries can be embedded in an org 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 with a ledger. +examples of more complex operations on a ledger. @node The @command{pricemap} command, The @command{xml} command, Org mode with Babel, Reports in other Formats @subsection The @command{pricemap} command @@ -4721,7 +5006,7 @@ 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 -currencies and multiples investments valued in those currencies. +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 @subsection The @command{xml} command @@ -4744,7 +5029,7 @@ The general format used for Ledger data is: @end smallexample The data stream is enclosed in a @code{ledger} tag, which contains a -series of one or more transactions. Each @code{xact} describes the +series of one or more transactions. Each @code{xact} describes one transaction and contains a series of one or more postings: @smallexample @@ -4789,7 +5074,7 @@ Within the @code{en:postings} tag is a series of one or more </posting> @end smallexample -This is a basic posting. It may also be begin with +This is a basic posting. It may also begin with @code{tr:virtual} and/or @code{tr:generated} tags, to indicate virtual and auto-generated postings. Then follows the @code{tr:account} tag, which contains the full name of the account the posting is @@ -4891,7 +5176,7 @@ report, to display the running average price, or @option{--deviation (-D)} to show each price's deviation from that average. There is also a @command{pricedb} command which outputs the same -information as @command{prices}, but does in a format that can be +information as @command{prices}, but does so in a format that can be parsed by Ledger. This is useful for generating and tidying up pricedb database files. @@ -4913,18 +5198,20 @@ pricedb database files. @subsection @command{accounts} @findex accounts -The @command{accounts} 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. Using the -@option{--count} option will tell you how many entries use each account. +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. +Using the @option{--count} option will tell you how many entries use +each account. @node @command{payees}, @command{commodities}, @command{accounts}, Reports about your Journals @subsection @command{payees} @findex payees -The @command{payees} 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 prefix: +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 +prefix @@: @smallexample $ ledger payees @@Nic @@ -4947,10 +5234,10 @@ you how many entries use each commodity. @findex tags @findex --values -The @command{tags} reports all of the tags in the journal. The output -is sorted by name. Using the @option{--count} option will tell you how -many entries use each tag. Using the @option{--values} option will -report the values used by each tag. +The @command{tags} command reports all of the tags in the journal. The +output is sorted by name. Using the @option{--count} option will tell +you how many entries use each tag. Using the @option{--values} option +will report the values used by each tag. @node @command{xact}, @command{stats}, @command{tags}, Reports about your Journals @subsection @command{xact} @@ -4958,34 +5245,34 @@ report the values used by each tag. @findex entry @findex xact -The @command{xact} command simplify the creation of new transactions. +The @command{xact} command simplifies the creation of new transactions. It works on the principle that 80% of all postings are variants of earlier postings. Here's how it works: Say you currently have this posting in your ledger file: -@smallexample +@smallexample @c input:03ACB97 2004/03/15 * Viva Italiano Expenses:Food $12.45 Expenses:Tips $2.55 Liabilities:MasterCard $-15.00 @end smallexample -Now it's @samp{2004/4/9}, and you've just eating at @samp{Viva Italiano} +Now it's @samp{2004/4/9}, and you've just eaten at @samp{Viva Italiano} again. The exact amounts are different, but the overall form is the same. With the @command{xact} command you can type: -@smallexample +@smallexample @c command:03ACB97 $ ledger xact 2004/4/9 viva food 11 tips 2.50 @end smallexample This produces the following output: -@smallexample +@smallexample @c output:03ACB97 2004/04/09 Viva Italiano - Expenses:Food $11.00 - Expenses:Tips $2.50 - Liabilities:MasterCard $-13.50 + Expenses:Food $11.00 + Expenses:Tips $2.50 + Liabilities:MasterCard @end smallexample It works by finding a past posting matching the regular expression @@ -5037,7 +5324,7 @@ FIX THIS ENTRY @c FIXME thdox @section Basic Usage This chapter describes Ledger's features and options. You may wish to -survey this to get an overview before diving in to the @ref{Ledger +survey this to get an overview before diving into the @ref{Ledger Tutorial} and more detailed examples that follow. Ledger has a very simple command-line interface, named---enticingly @@ -5062,14 +5349,14 @@ instead, precede the regular expression with @samp{payee} or totals for rent, food and movies, but only those whose payee matches Freddie: -@smallexample +@smallexample @c command:validate $ ledger bal rent food movies payee freddie @end smallexample @noindent or -@smallexample +@smallexample @c command:validate $ ledger bal rent food movies @@freddie @end smallexample @@ -5077,7 +5364,7 @@ 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 +@node Command Line Quick Reference, Detailed Option Description, Basic Usage, Command-line Syntax @section Command Line Quick Reference @menu @@ -5090,7 +5377,7 @@ 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 @@ -5108,14 +5395,14 @@ Show all transactions with running total. Show transactions in csv format, for exporting to other programs. @item print -Print transaction in a ledger readable format. +Print transactions in a format readable by ledger. @item xml Produce XML output of the register command. @item lisp @itemx emacs -Produce Emacs lisp output. +Produce s-expression output, suitable for Emacs. @item equity Print account balances as transactions. @@ -5124,7 +5411,8 @@ Print account balances as transactions. Print price history for matching commodities. @item pricedb -Print price history for matching commodities in ledger readable format. +Print price history for matching commodities in a format readable by +ledger. @item xact Generate transactions based on previous postings. @@ -5142,7 +5430,7 @@ Print summary of all options. @item --version @itemx -v -Print version of ledger executable. +Print version information and exit. @item --file @var{FILE} @itemx -f @var{FILE} @@ -5154,7 +5442,7 @@ Redirect output to @file{FILE}. @item --init-file @var{FILE} @itemx -i @var{FILE} -Specify options file. +Specify an options file. @item --account @var{STR} @itemx -a @var{STR} @@ -5169,22 +5457,22 @@ Specify default account @var{STR} for QIF file postings. @item --current @itemx -c -Display transaction on or before the current date. +Display only transactions on or before the current date. @item --begin @var{DATE} @itemx -b @var{DATE} -Begin reports on or after @var{DATE}. +Limit the processing to transactions on or after @var{DATE}. @item --end @var{DATE} @itemx -e @var{DATE} -Limit end date of transactions for report. +Limit the processing to transactions before @var{DATE}. @item --period @var{PERIOD_EXPRESSION} @itemx -p @var{PERIOD_EXPRESSION} -Set report period to @var{PERIOD_EXPRESSION}. +Limit the processing to transactions in @var{PERIOD_EXPRESSION}. @item --period-sort @var{VEXPR} -Sort postings within each period. +Sort postings within each period according to @var{VEXPR}. @item --cleared @itemx -C @@ -5203,7 +5491,7 @@ Display only real postings. @item --actual @itemx -L -Display only actual postings, not automated. +Display only actual postings, not automated ones. @item --related @itemx -r @@ -5213,17 +5501,17 @@ Display related postings. Display how close your postings meet your budget. @item --add-budget -Show un-budgeted postings. +Show unbudgeted postings. @item --unbudgeted -Show only un-budgeted postings. +Show only unbudgeted postings. @item --forecast @var{VEXPR} Project balances into the future. @item --limit @var{EXPR} @itemx -l @var{EXPR} -Limit postings in calculations. +Limit which postings are used in calculations by @var{EXPR}. @item --amount @var{EXPR} @itemx -t @var{EXPR} @@ -5250,7 +5538,8 @@ 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. +commodities and tags. This only works in conjunction with +@option{--strict} or @option{--pedantic}. @item --immediate Instruct ledger to evaluate calculations immediately rather than lazily. @@ -5276,18 +5565,21 @@ Report subtotals by payee. @item --empty @itemx -E -Include empty accounts in report. +Include empty accounts in the report. @item --weekly @itemx -W Report posting totals by week. +@item --quarterly +Report posting totals by quarter. + @item --yearly @itemx -Y Report posting totals by year. @item --dow -Report Posting totals by day of week. +Report posting totals by day of week. @item --sort @var{VEXPR} @itemx -S @var{VEXPR} @@ -5308,11 +5600,11 @@ Direct output to @var{FILE} pager program. @item --average @itemx -A -Report average posting value. +Report the average posting value. @item --deviation @itemx -D -Report each posting deviation from the average. +Report each posting's deviation from the average. @item --percent @itemx -% @@ -5325,21 +5617,21 @@ Produce a pivot table of the @var{TAG} type specified. @item --amount-data @itemx -j -Show only date and value column to format the output for plots. +Show only the date and value columns to format the output for plots. @item --plot-amount-format @var{FORMAT_STRING} Specify the format for the plot output. @item --total-data @itemx -J -Show only dates and totals to format the output for plots. +Show only the date and total columns to format the output for plots. @item --plot-total-format @var{FORMAT_STRING} Specify the format for the plot output. @item --display @var{EXPR} @itemx -d @var{EXPR} -Display only posting that meet the criterias in the @var{EXPR}. +Display only postings that meet the criteria in the @var{EXPR}. @item --date-format @var{DATE_FORMAT} @itemx -y @var{DATE_FORMAT} @@ -5350,11 +5642,7 @@ Change the basic date format used in reports. @itemx --register-format @var{FORMAT_STRING} @itemx --prices-format @var{FORMAT_STRING} @itemx -F @var{FORMAT_STRING} -Set reporting format. - -@item --wide -@itemx -w -Wide. +Set the reporting format for various reports. @item --anon Print the ledger register with anonymized accounts and payees, useful @@ -5395,7 +5683,7 @@ Group by day of weeks. @item --subtotal @itemx -s -Group posting together, similar to balance report. +Group postings together, similar to the balance report. @end ftable @@ -5413,10 +5701,10 @@ Set expected freshness of prices in @var{INT} minutes. @item --download @itemx -Q -Download quotes using named @file{getquote}. +Download quotes using the script named @file{getquote}. @item --getquote @var{FILE} -Sets path to a user defined script to download commodity prices. +Sets the path to a user-defined script to download commodity prices. @item --quantity @itemx -O @@ -5432,11 +5720,11 @@ Report last known market value. @item --gain @itemx -G -Report net gain loss for commodities that have a price history. +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 @@ -5453,7 +5741,7 @@ Report net gain loss for commodities that have a price history. @node Global Options, Session Options, Detailed Option Description, Detailed Option Description @subsection Global Options -Options for Ledger report affect three separate scopes of operation: +Options for Ledger reports affect three separate scopes of operation: Global, Session, and Report. In practice there is very little difference between these scopes. Ledger 3.0 contains provisions for GUIs, which would make use of the different scopes by keeping an @@ -5464,8 +5752,8 @@ sessions with multiple reports per session. @item --args-only Ignore all environment and init-file settings and -use only command-line arguments to control Ledger. Useful for debugs -or testing small Journal files not associated with you main financial +use only command-line arguments to control Ledger. Useful for debugging +or testing small journal files not associated with your main financial database. @item --debug @var{CODE} @@ -5473,7 +5761,7 @@ FIX THIS ENTRY @c FIXME thdox @item --help @itemx -h -Display the info page for ledger. +Display the man page for ledger. @item --init-file @var{FILE} Specify the location of the init file. The default is @file{~/.ledgerrc}. @@ -5513,7 +5801,7 @@ $ ledger --options bal --cleared -f ~/ledger/test/input/drewr3.dat @noindent For the source column, a value starting with a @samp{-} or @samp{--} -indicated the source was a command line argument. It the entry starts +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}. @@ -5542,7 +5830,7 @@ FIX THIS ENTRY @c FIXME thdox @node Session Options, Report Options, Global Options, Detailed Option Description @subsection Session Options -Options for Ledger report affect three separate scopes of operation: +Options for Ledger reports affect three separate scopes of operation: Global, Session, and Report. In practice there is very little difference between these scopes. Ledger 3.0 contains provisions for GUIs, which would make use of the different scopes by keeping an @@ -5562,11 +5850,11 @@ FIX THIS ENTRY @c FIXME thdox @item --decimal-comma Direct Ledger to parse journals using the European standard comma as -decimal separator, vice a period. +a decimal separator, not the usual period. @item --download @itemx -Q -Direct Ledger to download prices using the script defined in +Direct Ledger to download prices using the script defined via the option @option{--getquote @var{FILE}}. @item --explicit @@ -5596,22 +5884,23 @@ Format Codes}). @item --master-account @var{STR} Prepend all account names with the argument. -@smallexample -$ ledger -f test/input/drewr3.dat bal --master-account HUMBUG +@smallexample @c command:A76BB56 +$ ledger -f drewr3.dat bal --no-total --master-account HUMBUG +@end smallexample + +@smallexample @c output:A76BB56 0 HUMBUG $ -3,804.00 Assets $ 1,396.00 Checking $ 30.00 Business $ -5,200.00 Savings - $ 20.00 Books $ -1,000.00 Equity:Opening Balances - $ 6,634.00 Expenses - $ 11,000.00 Auto + $ 6,654.00 Expenses + $ 5,500.00 Auto $ 20.00 Books $ 300.00 Escrow $ 334.00 Food:Groceries $ 500.00 Interest:Mortgage - $ -5,520.00 Assets:Checking $ -2,030.00 Income $ -2,000.00 Salary $ -30.00 Sales @@ -5620,8 +5909,11 @@ $ ledger -f test/input/drewr3.dat bal --master-account HUMBUG $ 200.00 Mortgage:Principal @end smallexample +@item --no-aliases +Ledger does not expand any aliases if this option is specified. + @item --pedantic -FIX THIS ENTRY @c FIXME thdox +Accounts, tags or commodities not previously declared will cause errors. @item --permissive FIX THIS ENTRY @c FIXME thdox @@ -5640,13 +5932,18 @@ considered to be fresh enough. @item --strict Ledger normally silently accepts any account or commodity in a posting, -even if you have misspelled a common used one. The option -@option{--strict} changes that behavior. While running +even if you have misspelled a commonly used one. The option +@option{--strict} changes that behavior. While running with @option{--strict}, Ledger interprets all cleared transactions as -correct, and if it finds a new account or commodity (same as +correct, and if it encounters a new account or commodity (same as 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 +tries to expand the result of alias expansion recursively, until no more +expansions apply. + @item --time-colon The @option{--time-colon} option will display the value for a seconds based commodity as real hours and minutes. @@ -5662,7 +5959,7 @@ FIX THIS ENTRY @c FIXME thdox @node Report Options, Basic options, Session Options, Detailed Option Description @subsection Report Options -Options for Ledger report affect three separate scopes of operation: +Options for Ledger reports affect three separate scopes of operation: Global, Session, and Report. In practice there is very little difference between these scopes. Ledger 3.0 contains provisions for GUIs, which would make use of the different scopes by keeping an @@ -5681,7 +5978,7 @@ desired width. @item --account @var{STR} Prepend @var{STR} to all accounts reported. That is, the option -@samp{--account Personal} would track @samp{Personal:} to the beginning +@samp{--account Personal} would tack @samp{Personal:} to the beginning of every account reported in a balance report or register report. @item --account-width @var{INT} @@ -5690,11 +5987,11 @@ to @var{INT} characters. @item --actual @itemx -L -Report only real transactions, with no automated or virtual -transactions used. +Report only real transactions, ignoring all automated or virtual +transactions. @item --add-budget -Show only un-budgeted postings. +Show only unbudgeted postings. @item --amount @var{EXPR} @itemx -t @var{EXPR} @@ -5704,7 +6001,7 @@ arbitrary transformation to the postings. @item --amount-data @itemx -j -On a register report print only the dates and amount of postings. +On a register report print only the date and amount of postings. Useful for graphing and spreadsheet applications. @item --amount-width @var{INT} @@ -5754,17 +6051,17 @@ that date will be ignored. Print the entire line in bold if the given value expression is true (@pxref{Value Expressions}). -@smallexample -$ ledger reg Expenses --begin Dec --bold-if "amount > 100" +@smallexample @c command:validate +$ ledger reg Expenses --begin Dec --bold-if "amount>100" @end smallexample @noindent -list all transactions since the beginning of December and bold any -posting greater than $100. +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 -displays transaction in the budget, in a balance report this displays +displays transactions in the budget, in a balance report this displays accounts in the budget (@pxref{Budgeting and Forecasting}). @item --budget-format @var{FORMAT_STRING} @@ -5785,7 +6082,7 @@ Group the register report by payee. @item --cleared @itemx -C -Consider only transaction that have been cleared for display and +Consider only transactions that have been cleared for display and calculation. @item --cleared-format @var{FORMAT_STRING} @@ -5807,22 +6104,22 @@ Strings}). The default is: @item --collapse @itemx -n -By default ledger prints all account in an account tree. With -@option{--collapse} it print only the top level account specified. +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 Collapse the account display only if it has a zero balance. @item --color @itemx --ansi -Use color is the tty supports it. +Use color if the terminal supports it. @item --columns @var{INT} Specify the width of the @command{register} report in characters. @item --count Direct ledger to report the number of items when appended to the -commodities, accounts or payees command. +@command{commodities}, @command{accounts} or @command{payees} command. @item --csv-format @var{FORMAT_STRING} Specify the format to use for the @command{csv} report (@pxref{Format @@ -5833,7 +6130,7 @@ Strings}). The default is: "%(quoted(code))," "%(quoted(payee))," "%(quoted(display_account))," -"%(quoted(commodity))," +"%(quoted(commodity(scrub(display_amount))))," "%(quoted(quantity(scrub(display_amount))))," "%(quoted(cleared ? \"*\" : (pending ? \"!\" : \"\")))," "%(quoted(join(note | xact.note)))\n" @@ -5851,8 +6148,8 @@ Transform the date of the transaction using @var{EXPR}. @item --date-format @var{DATE_FORMAT} @itemx -y @var{DATE_FORMAT} -Specify format ledger should use to print dates (@pxref{Date and Time -Format Codes}). +Specify the format ledger should use to read and print dates +(@pxref{Date and Time Format Codes}). @item --date-width @var{INT} Specify the width, in characters, of the date column in the @@ -5863,8 +6160,9 @@ FIX THIS ENTRY @c ASK JOHN @item --dc Display register or balance in debit/credit format If you use -@option{--dc} with either the register (reg) or balance (bal) commands, -you will now get extra columns. The register goes from this: +@option{--dc} with either the @command{register} (reg) or +@command{balance} (bal) commands, you will now get extra columns. +The register goes from this: @smallexample 12-Mar-10 Employer Assets:Cash $100 $100 @@ -5921,9 +6219,9 @@ And with @option{--dc} it becomes this: @item --depth @var{INT} Limit the depth of the account tree. In a balance report, for example, -a @samp{--depth 2} statement will print balances only for account with +a @samp{--depth 2} statement will print balances only for accounts with two levels, i.e. @samp{Expenses:Entertainment} but not -@samp{Expenses:entertainemnt: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 @@ -5931,21 +6229,21 @@ Report each posting’s deviation from the average. It is only meaningful in the register and prices reports. @item --display @var{EXPR} -Display lines that satisfy the expression given. +Display only lines that satisfy the expression @var{EXPR}. @item --display-amount @var{EXPR} -Apply a transform to the @emph{displayed} amount. This occurs after -calculations occur. +Apply a transformation to the @emph{displayed} amount. This happens +after calculations occur. @item --display-total @var{EXPR} -Apply a transform to the @emph{displayed} total. This occurs after +Apply a transformation to the @emph{displayed} total. This happens after calculations occur. @item --dow @itemx --days-of-week -Group transactions by the days of the week. +Group transactions by the day of the week. -@smallexample +@smallexample @c command:validate $ ledger reg Expenses --dow --collapse @end smallexample @@ -5954,11 +6252,11 @@ Will print all Expenses totaled for each day of the week. @item --empty @itemx -E -Include empty accounts in the report. +Include empty accounts in the report and in average calculations. @item --end @var{DATE} -Specify the end @var{DATE} for transaction to be considered in the -report. +Specify the end @var{DATE} for a transaction to be considered in the +report. All transactions on or after this date are ignored. @item --equity Related to the @command{equity} command (@pxref{The @command{equity} @@ -5971,15 +6269,24 @@ FIX THIS ENTRY @c ASK JOHN @item --exchange @var{COMMODITY} @itemx -X @var{COMMODITY} Display values in terms of the given @var{COMMODITY}. The latest -available price is used. +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 +@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 balance report will not use an indented tree. @item --force-color -Output tty color codes even if the tty doesn't support them. Useful -for TTY that don't advertise their capabilities correctly. +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 Force Ledger to paginate its output. @@ -5989,7 +6296,7 @@ Force Ledger to paginate its output. Continue forecasting while @var{VEXPR} is true. @item --forecast-years @var{INT} -Forecast at most @var{INT} years in the future. +Forecast at most @var{INT} years into the future. @item --format @var{FORMAT_STRING} @itemx -F @var{FORMAT_STRING} @@ -6006,14 +6313,14 @@ transactions) in the report, in cases where you normally wouldn't want them. @item --group-by @var{EXPR} -Group transaction together in the @command{register} report. +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. @item --group-title-format @var{FORMAT_STRING} -Set the format for the headers that separate reports section of -a grouped report. Only has effect with a @option{--group-by @var{EXPR}} -register report. +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 $ ledger reg Expenses --group-by "payee" --group-title-format "------------------------ %-20(value) ---------------------\n" @@ -6041,11 +6348,11 @@ FIX THIS ENTRY @c FIXME thdox FIX THIS ENTRY @c FIXME thdox @item --inject -Use @code{Expected} amounts in calculations. In the case that you know -that amount a transaction should be, but the actual transaction has the -wrong value you can use metadata to put in the expected amount: +Use @code{Expected} 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 to specify the expected amount: -@smallexample +@smallexample @c input:validate 2012-03-12 Paycheck Income $-990; Expected:: $-1000.00 Checking @@ -6059,8 +6366,8 @@ Change the sign of all reported values. @item --limit @var{EXPR} @itemx -l @var{EXPR} -Only transactions that satisfy the expression will be considered in the -calculation. +Only transactions that satisfy @var{EXPR} are considered in +calculations and for display. @item --lot-dates Report the date on which each commodity in a balance report was @@ -6097,12 +6404,15 @@ Specify the width of the Meta column used for the @option{--meta @itemx -M Synonym for @samp{--period "monthly"}. +@item --no-aliases +Aliases are completely ignored. + @item --no-color Suppress any color TTY output. @item --no-rounding Don't output @samp{<Rounding>} 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 @option{--amount-data (-j)} and @option{--total-data (-J)} reports. @item --no-titles @@ -6112,7 +6422,7 @@ Suppress the output of group titles. Suppress printing the final total line in a balance report. @item --now @var{DATE} -Define the current date in case to you to do calculate in the past or +Define the current date in case you want to calculate in the past or future using @option{--current}. @item --only @var{FIXME} @@ -6132,22 +6442,22 @@ a date and payee for each transaction. @item --payee-width @var{INT} Set the number of columns dedicated to the payee in the register -report. +report to @var{INT}. @item --pending Use only postings that are marked pending. @item --percent @itemx -% -Calculate the percentage value of each account in a balance reports. -Only works for account that have a single commodity. +Calculate the percentage value of each account in balance reports. +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 the transactions that satisfy the period expression with be displayed. -For a balance report only those transactions will be accounted in the -final balances. +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 @@ -6157,7 +6467,7 @@ identifying which car the purchase was for @samp{; Car: Prius}, then the command: @smallexample -$ ledger bal Fuel --pivot "Car" --period "this year" +$ ledger bal Fuel --pivot "Car" --period "this year" $ 3491.26 Car $ 1084.22 M3:Expenses:Auto:Fuel $ 149.65 MG V11:Expenses:Auto:Fuel @@ -6200,16 +6510,16 @@ Show primary dates for all calculations (@pxref{Effective Dates}). @item --quantity @itemx -O -FIX THIS ENTRY +Report commodity totals (this is the default). @item --quarterly Synonym for @samp{--period "quarterly"}. @item --raw -In the 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 -amounts. +In the @command{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. This can be useful for minor cleanups, like +just aligning amounts. @item --real @itemx -R @@ -6217,11 +6527,11 @@ Account using only real transactions ignoring virtual and automatic transactions. @item --register-format @var{FORMAT_STRING} -FIX THIS ENTRY @c FIXME thdox +Define the output format for the @command{register} report. @item --related -In a register report show the related account. This is the other -@emph{side} of the transaction. +In a @command{register} report show the related account. This is the +other @emph{side} of the transaction. @item --related-all Show all postings in a transaction, similar to @option{--related} but @@ -6241,19 +6551,20 @@ FIX THIS ENTRY FIX THIS ENTRY @c FIXME thdox @item --seed @var{FIXME} -Set the random seed for the @code{generate} command. Used as part of -development testing. +Set the random seed to @var{FIXME} for the @code{generate} command. +Used as part of development testing. @item --sort @var{VEXPR} @itemx -S @var{VEXPR} -Sort the register report based on the value expression given to sort. +Sort the @command{register} report based on the value expression given +to sort. @item --sort-all @var{FIXME} FIX THIS ENTRY @item --sort-xacts @var{VEXPR} @itemx --period-sort @var{VEXPR} -Sort the posting within transactions using the given value expression. +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'' @@ -6266,8 +6577,8 @@ FIX THIS ENTRY @item --tail @var{INT} @itemx --last @var{INT} -Report only the last @var{INT} entries. Only useful on a register -report. +Report only the last @var{INT} entries. Only useful in +a @command{register} report. @item --time-report FIX THIS ENTRY @c FIXME thdox @@ -6278,7 +6589,7 @@ Define a value expression used to calculate the total in reports. @item --total-data @itemx -J -FIX THIS ENTRY +Show only dates and totals to format the output for plots. @item --total-width @var{INT} Set the width of the total field in the register report. @@ -6291,39 +6602,41 @@ as it considers sub-names within the account name (that style is called ``abbreviate''). @item --unbudgeted -FIX THIS ENTRY +Show only unbudgeted postings. @item --uncleared @itemx -U Use only uncleared transactions in calculations and reports. @item --unrealized -FIX THIS ENTRY +Show generated unrealized gain and loss accounts in the balance +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"}. -Often set in one's @file{~/.ledgerrc} file to change default. +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"}. -Often set in one's @file{~/.ledgerrc} file to change default. +Often set in one's @file{~/.ledgerrc} file to change the default. @item --unround Perform all calculations without rounding and display results to full precision. @item --values -FIX THIS ENTRY @c FIXME thdox +Shows the values used by each tag when used in combination with the +@command{tags} command. @item --weekly @itemx -W Synonym for @samp{--period "weekly"}. @item --wide -Let the register report use 132 columns. Identical to @samp{--columns -"132"}. +Let the register report use 132 columns instead of 80 (the default). +Identical to @samp{--columns "132"}. @item --yearly @itemx -Y @@ -6343,19 +6656,17 @@ variables}), instead of using actual command-line options: @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. This help screen -is also printed if ledger is run without a command. +can be a handy way to remember which options do what. @item --version -@itemx -v Print the current version of ledger and exits. This is useful for sending bug reports, to let the author know which version of ledger you are using. @item --file @var{FILE} @itemx -f @var{FILE} -Read @file{FILE} as a ledger file. @var{FILE} can be @samp{-} that is -a synonym of @samp{/dev/stdin}. This command may be used multiple +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. @@ -6369,12 +6680,12 @@ goes to standard output. Causes @file{FILE} to be read by ledger before any other ledger file. This file may not contain any postings, but it may contain option settings. To specify options in the init file, use the same syntax as -the command-line, but put each option on its own line. Here is an +on the command-line, but put each option on its own line. Here is an example init file: @smallexample --price-db ~/finance/.pricedb - +--wide ; ~/.ledgerrc ends here @end smallexample @@ -6411,7 +6722,7 @@ first matching transaction. (Note: This is different from using @item --end @var{DATE} @itemx -e @var{DATE} Constrain the report so that transactions on or after @var{DATE} are -not considered. The ending date is inclusive. +not considered. @item --period @var{PERIOD_EXPRESSION} @itemx -p @var{PERIOD_EXPRESSION} @@ -6419,8 +6730,8 @@ Set the reporting period to @var{STR}. This will subtotal all matching transactions within each period separately, making it easy to see weekly, monthly, quarterly, etc., posting totals. A period string can even specify the beginning and end of the report range, using simple -terms like @samp{last June} or @samp{next month}. For more using period -expressions, see @ref{Period Expressions}. +terms like @samp{last June} or @samp{next month}. For more details on +period expressions, see @ref{Period Expressions}. @item --period-sort @var{VEXPR} Sort the postings within each reporting period using the value @@ -6428,8 +6739,9 @@ expression @var{EXPR}. This is most often useful when reporting monthly expenses, in order to view the highest expense categories at the top of each month: -@smallexample -$ ledger -M --period-sort -At reg ^Expenses +@c TODO: the parameter to --period-sort was -At, which doesn't seem to work any longer +@smallexample @c command:validate +$ ledger -M --period-sort total reg ^Expenses @end smallexample @item --cleared @@ -6450,8 +6762,8 @@ see @ref{Virtual postings} for more information). @item --actual @itemx -L -Display only actual postings, and not those created due to automated -postings. +Display only actual postings, and not those created by automated +transactions. @item --related @itemx -r @@ -6462,7 +6774,7 @@ In the balance report, it shows all the accounts affected by transactions having a related posting. For example, if a file had this transaction: -@smallexample +@smallexample @c input:94C5675 2004/03/20 Safeway Expenses:Food $65.00 Expenses:Cash $20.00 @@ -6471,21 +6783,21 @@ this transaction: And the register command was: -@smallexample -$ ledger -r register food +@smallexample @c command:94C5675 +$ ledger -f example.dat -r register food @end smallexample -The following would be output, showing the postings related to the +The following would be printed, showing the postings related to the posting that matched: -@smallexample -2004/03/20 Safeway Expenses:Cash $-20.00 $-20.00 - Assets:Checking $85.00 $65.00 +@smallexample @c output:94C5675 +04-Mar-20 Safeway Expenses:Cash $20.00 $20.00 + Assets:Checking $-85.00 $-65.00 @end smallexample @item --budget Useful for displaying how close your postings meet your budget. -@option{--add-budget} also shows un-budgeted postings, while +@option{--add-budget} also shows unbudgeted postings, while @option{--unbudgeted} shows only those. @option{--forecast @var{VEXPR}} is a related option that projects your budget into the future, showing how it will affect future balances. @xref{Budgeting and Forecasting}. @@ -6552,7 +6864,7 @@ Set the value expression used for the ``totals'' column in the @c ledger reg food not dining expr 'payee =~ /chang/' @c @end smallexample -@node Output customization, Commodity reporting, Report filtering, Detailed Option Description +@node Output customization, Commodity reporting, Report filtering, Detailed Option Description @subsection Output customization These options affect only the output, but not which postings are @@ -6590,23 +6902,24 @@ Report posting totals by month. @item --yearly @itemx -Y -Report posting totals by year. For more complex period, using the +Report posting totals by year. For more complex periods, use +@option{--period}. @c TODO end this sentence @item --period @var{PERIOD_EXPRESSION} Option described above. @item --dow -Report postings totals for each day of the week. This is an easy way +Report posting totals for each day of the week. This is an easy way to see if weekend spending is more than on weekdays. @item --sort @var{VEXPR} @itemx -S @var{VEXPR} Sort a report by comparing the values determined using the value -expression @var{VEXPR}. For example, using @samp{-S -UT} in the balance -report will sort account balances from greatest to least, using the -absolute value of the total. For more on how to use value expressions, -see @ref{Value Expressions}. +expression @var{VEXPR}. For example, using @samp{-S "-abs(total)"} in +the @command{balance} report will sort account balances from greatest to +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 @@ -6650,7 +6963,7 @@ the parent account. @item --amount-data @itemx -j -Change the @command{register} report so that it outputs nothing but the +Change the @command{register} report so that it prints nothing but the date and the value column, and the latter without commodities. This is only meaningful if the report uses a single commodity. This data can then be fed to other programs, which could plot the date, analyze it, @@ -6658,17 +6971,18 @@ etc. @item --total-data @itemx -J -Change the @command{register} report so that it outputs nothing but the -date and totals column, without commodities. +Change the @command{register} report so that it prints nothing but the +date and total columns, without commodities. @item --display @var{EXPR} @itemx -d @var{EXPR} -Limit which postings or accounts or actually displayed in a report. +Limit which postings or accounts are actually displayed in a report. They might still be calculated, and be part of the running total of a 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 $ ledger -d "d>=[last month]" reg checking @end smallexample @@ -6677,6 +6991,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 $ ledger -p "last month" reg checking @end smallexample @@ -6780,7 +7095,7 @@ Set the format for @command{csv} reports. The default is: %(quoted(code)), %(quoted(payee)), %(quoted(display_account)), - %(quoted(commodity)), + %(quoted(commodity(scrub(display_amount)))), %(quoted(quantity(scrub(display_amount)))), %(quoted(cleared ? \"*\" : (pending ? \"!\" : \"\"))), %(quoted(join(note | xact.note)))\n" @@ -6871,7 +7186,7 @@ There are several different ways that ledger can report the totals it displays. The most flexible way to adjust them is by using value expressions, and the @option{--amount @var{EXPR} (-t)} and @option{--total @var{VEXPR} (-T)} options. However, there are also -several ``default'' reports, which will satisfy most users basic +several ``default'' reports, which will satisfy most users' basic reporting needs: @ftable @code @@ -6918,7 +7233,7 @@ If no @var{VALUE} property is specified, each posting is assumed to have a default, as if you'd specified a global, automated transaction as follows: -@smallexample +@smallexample @c input:validate = expr true ; VALUE:: market(amount, date, exchange) @end smallexample @@ -6932,7 +7247,7 @@ This definition emulates the present day behavior of @option{--market One thing many people have wanted to do is to fixate the valuation of old European currencies in terms of the Euro after a certain date: -@smallexample +@smallexample @c input:validate = expr commodity == "DM" ; VALUE:: date < [Jun 2008] ? market(amount, date, exchange) : 1.44 EUR @end smallexample @@ -6944,7 +7259,7 @@ past June 2008, use a fixed price for converting Deutsch Mark to Euro. Or how about never re-valuating commodities used in Expenses, since they cannot have a different future value: -@smallexample +@smallexample @c input:validate = /^Expenses:/ ; VALUE:: market(amount, post.date, exchange) @end smallexample @@ -6956,7 +7271,7 @@ the value of @option{--now @var{DATE}} (defaults to today). Or how about valuating miles based on a reimbursement rate during a specific time period: -@smallexample +@smallexample @c input:validate = expr commodity == "miles" and date >= [2007] and date < [2008] ; VALUE:: market($1.05, date, exchange) @end smallexample @@ -6970,7 +7285,7 @@ Note that you can have a valuation expression specific to a particular posting or transaction, by overriding these general defaults using specific meta-data: -@smallexample +@smallexample @c input:validate 2010-12-26 Example Expenses:Food $20 ; Just to be silly, always valuate *these* $20 as 30 DM, no matter what @@ -6979,7 +7294,7 @@ specific meta-data: Assets:Cash @end smallexample -This example demonstrates that your VALUE expression should be as +This example demonstrates that your value expression should be as symbolic as possible, using terms like 'amount' and 'date', rather than specific amounts and dates. Also, you should pass the amount along to the function 'market' so it can be further revalued if the user has @@ -6990,7 +7305,9 @@ which allows you to report most everything in EUR if you use @samp{-X EUR}, except for certain accounts or postings which should always be valuated in another currency. For example: -@smallexample +@c TODO is this example missing the actual line to get the effect? +@c it looks like it only contains a match, but no effect +@smallexample @c input:validate = /^Assets:Brokerage:CAD$/ ; Always report the value of commodities in this account in ; terms of present day dollars, despite what was asked for @@ -7026,13 +7343,14 @@ these values: @itemize @item Register Report -For the register report, use the value of that commodity on the date of -the posting being reported, with a @samp{<Revalued>} posting added at -the end of today's value is different from the value of the last -posting. +For the @command{register} report, use the value of that commodity on +the date of the posting being reported, with a @samp{<Revalued>} posting +added at the end if today's value is different from the value of the +last posting. @item Balance Report -For the balance report, use the value of that commodity as of today. +For the @command{balance} report, use the value of that commodity as of +today. @end itemize @@ -7045,6 +7363,17 @@ You can also now use @option{--exchange @var{COMMODITY} (-X)} (and and @option{--price (-I)}, to see valuation reports of just your basis costs or lot prices. +Finally, sometimes, you may seek to only report one (or some subset) of +the commodities in terms of another commodity. In this situation, you +can use the syntax @option{--exchange @var{COMMODITY1}:@var{COMMODITY2}} +to request that ledger always display @var{COMMODITY1} in terms of +@var{COMMODITY2}, but you want no other commodities to be automatically +displayed in terms of @var{COMMODITY2} without additional +@option{--exchange} options. For example, if you wanted to report EUR +and BTC in terms of USD, but report all other commodities without +conversion to USD, you could use: @option{--exchange EUR:USD --exchange +BTC:USD}. + @node Environment variables, , Commodity reporting, Detailed Option Description @subsection Environment variables @@ -7171,11 +7500,11 @@ your expectations. To start keeping a budget, put some periodic transactions (@pxref{Periodic Transactions}) at the top of your ledger file. A -period transaction is almost identical to a regular transaction, except +periodic transaction is almost identical to a regular transaction, except that it begins with a tilde and has a period expression in place of a payee. For example: -@smallexample +@smallexample @c input:validate ~ Monthly Expenses:Rent $500.00 Expenses:Food $450.00 @@ -7192,9 +7521,9 @@ payee. For example: Assets @end smallexample -These two period transactions give the usual monthly expenses, as well +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 expense is for any category, use a command like: +average monthly expenses are for any category, use a command like: @smallexample $ ledger -p "this year" --monthly --average balance ^expenses @@ -7202,26 +7531,26 @@ $ ledger -p "this year" --monthly --average balance ^expenses The reported totals are the current year's average for each account. -Once these period transactions are defined, creating a budget report is +Once these periodic transactions are defined, creating a budget report is as easy as adding @option{--budget} to the command-line. For example, a typical monthly expense report would be: -@smallexample +@smallexample @c command:validate $ ledger --monthly register ^expenses @end smallexample To see the same report balanced against your budget, use: -@smallexample +@smallexample @c command:validate $ ledger --budget --monthly register ^expenses @end smallexample A budget report includes only those accounts that appear in the budget. To see all expenses balanced against the budget, use -@option{--add-budget}. You can even see only the un-budgeted expenses +@option{--add-budget}. You can even see only the unbudgeted expenses using @option{--unbudgeted}: -@smallexample +@smallexample @c command:validate $ ledger --unbudgeted --monthly register ^expenses @end smallexample @@ -7233,21 +7562,21 @@ You can also use these flags with the @command{balance} command. Sometimes it's useful to know what your finances will look like in the future, such as determining when an account will reach zero. Ledger -makes this easy to do, using the same period transactions as are used +makes this easy to do, using the same periodic transactions as are used for budgeting. An example forecast report can be generated with: -@smallexample +@smallexample @c command:validate $ ledger --forecast "T>@{\$-500.00@}" register ^assets ^liabilities @end smallexample This report continues outputting postings until the running total -is greater than $-500.00. A final posting is always output, to -show you what the total afterwards would be. +is greater than $-500.00. A final posting is always shown, to +inform you what the total afterwards would be. -Forecasting can also be used with the balance report, but by date -only, and not against the running total: +Forecasting can also be used with the @command{balance} report, +but by date only, and not against the running total: -@smallexample +@smallexample @c command:validate $ ledger --forecast "d<[2010]" bal ^assets ^liabilities @end smallexample @@ -7257,7 +7586,7 @@ $ ledger --forecast "d<[2010]" bal ^assets ^liabilities Ledger directly supports ``timelog'' entries, which have this form: -@smallexample +@smallexample @c input:validate i 2013/03/28 22:13:00 ACCOUNT[ PAYEE] o 2013/03/29 03:39:00 @end smallexample @@ -7265,21 +7594,21 @@ o 2013/03/29 03:39:00 This records a check-in to the given ACCOUNT, and a check-out. You can be checked-in to multiple accounts at a time, if you wish, and they can span multiple days (use @option{--day-break} to break them up in the -report). The number of seconds between is accumulated as time to that -ACCOUNT. If the checkout uses a capital @samp{O}, the transaction is -marked ``cleared''. You can use an optional PAYEE for whatever meaning -you like. +report). The number of seconds between check-in and check-out is +accumulated as time to that ACCOUNT. If the checkout uses a capital +@samp{O}, the transaction is marked ``cleared''. You can use an +optional PAYEE for whatever meaning you like. Now, there are a few ways to generate this information. You can use the @file{timeclock.el} package, which is part of Emacs. Or you can write a simple script in whichever language you prefer to emit similar information. Or you can use Org mode's time-clocking abilities and -the org2tc script developed by John Wiegley. +the @file{org2tc} script developed by John Wiegley. These timelog entries can appear in a separate file, or directly in -your main ledger file. The initial @samp{i} and @samp{o} count as -Ledger ``directives'', and are accepted anywhere that ordinary -transactions are. +your main ledger file. The initial @samp{i} and @samp{o} characters +count as Ledger ``directives'', and are accepted anywhere that +ordinary transactions are valid. @node Value Expressions, Format Strings, Time Keeping, Top @chapter Value Expressions @@ -7314,7 +7643,7 @@ addition to a set of functions and variables. @c a display predicate that I use with the @command{balance} command: @c @smallexample -@c ledger -d /^Liabilities/?T<0:UT>100 balance +@c ledger -d '/^Liabilities/?T<0:UT>100' balance @c @end smallexample @c The effect is that account totals are displayed only if: 1) A @@ -7332,7 +7661,7 @@ while still calculating the running balance based on all transactions: $ ledger -d "d>[this month]" register checking @end smallexample -This advantage to this command's complexity is that it prints the +The advantage of this command's complexity is that it prints the running total in terms of all transactions in the register. The following, simpler command is similar, but totals only the displayed postings: @@ -7354,9 +7683,9 @@ $ ledger -b "this month" register checking @findex --total @var{VEXPR} Below are the one letter variables available in any value expression. -For the register and print commands, these variables relate to -individual postings, and sometimes the account affected by a -posting. For the balance command, these variables relate to +For the @command{register} and @command{print} commands, these variables +relate to individual postings, and sometimes the account affected by a +posting. For the @command{balance} command, these variables relate to accounts, often with a subtle difference in meaning. The use of each variable for both is specified. @@ -7364,10 +7693,11 @@ variable for both is specified. @item t This maps to whatever the user specified with @option{--amount -@var{EXPR} (-t)}. In a register report, @option{--amount @var{EXPR} -(-t)} changes the value column; in a balance report, it has no meaning -by default. If @option{--amount @var{EXPR} (-t)} was not specified, the -current report style's value expression is used. +@var{EXPR} (-t)}. In a @command{register} report, @option{--amount +@var{EXPR} (-t)} changes the value column; in a @command{balance} +report, it has no meaning by default. If @option{--amount @var{EXPR} +(-t)} was not specified, the current report style's value expression is +used. @item T This maps to whatever the user specified with @option{--total @@ -7404,15 +7734,15 @@ 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. +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}. +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, -it's depth is one. +its depth is one. @item n The index of a posting, or the count of postings affecting an @@ -7538,48 +7868,99 @@ More complicated expressions are possible using: @table @code -@item NUM -A plain integer represents a commodity-less amount. - -@item @{AMOUNT@} -An amount in braces can be any kind of amount supported by ledger, +@item "amount == COMMODITY AMOUNT" +The amount can be any kind of amount supported by ledger, with or without a commodity. Use this for decimal values. @item /REGEX/ -@itemx W/REGEX/ +@itemx account =~ /REGEX/ A regular expression that matches against an account's full name. If a posting, this will match against the account affected by the posting. -@item //REGEX/ -@itemx p/REGEX/ +@item @@/REGEX/ +@itemx expr payee =~ /REGEX/ A regular expression that matches against a transaction's payee name. -@item ///REGEX/ -@itemx w/REGEX/ -A regular expression that matches against an account's base name. If -a posting, this will match against the account affected by the -posting. +@item %/REGEX/ +@itemx tag(REGEX) +A regular expression that matches against a transaction's tags. + +@item expr date =~ /REGEX/ +Useful for specifying a date in plain terms. For example, you could say +@samp{expr date =~ /2014/}. + +@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 +or comment field. For example, @code{ledger reg "expr" "comment =~ +/landline/"} will match: + +@smallexample +2014/1/29 Phone bill + Assets:Checking $50.00 + Expenses:Phone $-50.00 ; landline bill +@end smallexample + +but will not match: + +@smallexample +2014/1/29 Phone bill ; landline bill + ; landline bill + Assets:Checking $50.00 + Expenses:Phone $-50.00 +@end smallexample + +To match the latter, use @samp{ledger reg "expr" "note =~ /landline/"} +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/"} +will match both all the three examples below: + +@smallexample +2014/1/29 Phone bill + Assets:Checking $50.00 + Expenses:Phone $-50.00 ; landline bill +@end smallexample + +@smallexample +2014/1/29 Phone bill ; landline bill + Assets:Checking $50.00 + Expenses:Phone $-50.00 +@end smallexample + +@smallexample +2014/1/29 Phone bill + ; landline bill + Assets:Checking $50.00 + Expenses:Phone $-50.00 +@end smallexample -@item c/REGEX/ -A regular expression that matches against the transaction code (the -text that occurs between parentheses before the payee name). -@item e/REGEX/ -A regular expression that matches against a posting's note, or -comment field. @item (EXPR) A sub-expression is nested in parenthesis. This can be useful passing more complicated arguments to functions, or for overriding the natural precedence order of operators. -@item [DATE] -Useful specifying a date in plain terms. For example, you could say -@samp{[2004/06/01]}. +@item expr base =~ /REGEX/ +A regular expression that matches against an account's base name. If +a posting, this will match against the account affected by the +posting. + +@item expr code =~ /REGEX/ +A regular expression that matches against the transaction code (the +text that occurs between parentheses before the payee). @end table +The @command{query} command can be used to see how Ledger interprets +your query. This can be useful if you are not getting the results you +expect (@pxref{Pre-Commands}). + @menu * Miscellaneous:: @end menu @@ -7758,8 +8139,8 @@ format string, exactly like those supported by @code{strftime}. For example: @samp{%[%Y/%m/%d %H:%M:%S]}. @item S -Insert the pathname of the file from which the transaction's data was -read. Only sensible in a register report. +Insert the path name of the file from which the transaction's data was +read. Only sensible in a @command{register} report. @item B Inserts the beginning character position of that transaction within the @@ -7775,14 +8156,12 @@ file. @item e Inserts the ending line of that transaction within the file. -@c @item D By default, this is the same as @code{%[%Y/%m%/d]}. The date -@c format used can be changed at any time with the @option{--date-format -@c @var{DATE_FORMAT} (-y)} flag, however. Using @code{%D} gives the -@c user more control over the way dates are output. +@item D +Returns the date according to the default format. @item d Returns the date according to the default format. If the transaction -has an effective date, it prints @code{[ACTUAL_DATE=EFFECTIVE_DATE]}. +has an effective date, it prints @code{ACTUAL_DATE=EFFECTIVE_DATE}. @item X If a posting has been cleared, this returns a 1, otherwise returns 0. @@ -7792,8 +8171,8 @@ This is the same as @samp{%X}, except that it only displays a state character if all of the member postings have the same state. @item C -Inserts the transaction type. This is the value specified between -parenthesis on the first line of the transaction. +Inserts the transaction code. This is the value specified between +parentheses on the first line of the transaction. @item P Inserts the payee related to a posting. @@ -7879,7 +8258,7 @@ options: @node Colors, Quantities and Calculations, Field Widths, Formatting Functions and Codes @subsection Colors -The character based formatting ledger can do is limited to the ANSI +The character-based formatting ledger can do is limited to the ANSI terminal character colors and font highlights in a normal TTY session. @multitable @columnfractions .3 .3 .3 @@ -8020,10 +8399,10 @@ weekday, abbreviated Wed. weekday, full Wednesday. @item %d -day of the month (dd), zero padded 10. +day of the month (dd), zero padded up to 10. @item %e -day of the month (dd) 10. +day of the month (dd), no leading zero up to 10. @item %j day of year, zero padded 000–366. @@ -8065,7 +8444,7 @@ Locale’s abbreviated month, for example @samp{02} might be abbreviated as @samp{Feb}. @item %B -Locale’s full month, variable length February. +Locale’s full month, variable length, e.g. February. @end table @@ -8118,7 +8497,7 @@ subsequent lines the width is given by @code{latterwidth}. If 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 justified and padded to the full width of the field. If -@code{colorize} is true then ledger will honor color settings. +@code{colorize} is true, then ledger will honor color settings. @item join(STR) Replaces line feeds in @code{STR} with @samp{\n}. @@ -8142,7 +8521,8 @@ generated the posting. @table @code @item filename -name of ledger data file from whence posting came, abbreviated @samp{S}. +the name of ledger the data file from whence the posting came, +abbreviated @samp{S}. @item beg_pos character position in @code{filename} where entry for posting begins, @@ -8171,47 +8551,47 @@ make sense later. @menu * Basic data traversal:: -* Raw vs. Cooked:: +* Raw versus Cooked:: * Queries:: * Embedded Python:: * Amounts:: @end menu -@node Basic data traversal, Raw vs. Cooked, Extending with Python, Extending with Python +@node Basic data traversal, Raw versus Cooked, Extending with Python, Extending with Python @section Basic data traversal Every interaction with Ledger happens in the context of a Session. Even if you don't create a session manually, one is created for you by the top-level interface functions. The Session is where objects live -like the Commodity's that Amount's refer to. +like the Commodities that Amounts refer to. The make a Session useful, you must read a Journal into it, using the function `@code{read_journal}`. This reads Ledger data from the given file, populates a Journal object within the current Session, and returns a reference to that Journal object. -Within the Journal live all the Transaction's, Posting's, and other -objects related to your data. There are also AutomatedTransaction's -and PeriodicTransaction's, etc. +Within the Journal live all the Transactions, Postings, and other +objects related to your data. There are also AutomatedTransactions +and PeriodicTransactions, etc. Here is how you would traverse all the postings in your data file: @smallexample import ledger -for xact in ledger.read_journal("sample.dat").xacts: - for post in xact.posts: +for xact in ledger.read_journal("sample.dat").xacts(): + for post in xact.posts(): print "Transferring %s to/from %s" % (post.amount, post.account) @end smallexample -@node Raw vs. Cooked, Queries, Basic data traversal, Extending with Python -@section Raw vs. Cooked +@node Raw versus Cooked, Queries, Basic data traversal, Extending with Python +@section Raw versus Cooked Ledger data exists in one of two forms: raw and cooked. Raw objects are what you get from a traversal like the above, and represent exactly what was seen in the data file. Consider this journal: -@smallexample +@smallexample @c input:validate = true (Assets:Cash) $100 @@ -8222,7 +8602,7 @@ was seen in the data file. Consider this journal: In this case, the @emph{raw} regular transaction in this file is: -@smallexample +@smallexample @c input:validate 2012-03-01 KFC Expenses:Food $100 Assets:Credit @@ -8230,7 +8610,7 @@ In this case, the @emph{raw} regular transaction in this file is: While the @emph{cooked} form is: -@smallexample +@smallexample @c input:validate 2012-03-01 KFC Expenses:Food $100 Assets:Credit $-100 @@ -8240,7 +8620,7 @@ While the @emph{cooked} form is: So the easy way to think about raw vs. cooked is that raw is the unprocessed data, and cooked has had all considerations applied. -When you traverse a Journal by iterating its transactions, you are +When you traverse a Journal by iterating over its transactions, you are generally looking at raw data. In order to look at cooked data, you must generate a report of some kind by querying the journal: @@ -8269,7 +8649,7 @@ does it transaction-wise. It relies on the fact that an unsorted report returns postings in the exact order they were parsed from the journal file. -@node Queries, Embedded Python, Raw vs. Cooked, Extending with Python +@node Queries, Embedded Python, Raw versus Cooked, Extending with Python @section Queries The Journal.query() method accepts every argument you can specify on the @@ -8350,7 +8730,7 @@ reused in other projects as needed. @item Commoditized Amounts (amount_t, commodity_t and friends) -An numerical abstraction combining multi-precision rational numbers (via +A numerical abstraction combining multi-precision rational numbers (via GMP) with commodities. These structures can be manipulated like regular numbers in either C++ or Python (as Amount objects). @@ -8406,7 +8786,7 @@ string (cash) down to the corresponding value expression @samp{(account @item Format strings -Format strings let you interpolate value expressions into string, with +Format strings let you interpolate value expressions into strings, with the requirement that any interpolated value have a string representation. Really all this does is calculate the value expression in the current report context, call the resulting value's @@ -8429,7 +8809,7 @@ amount could be an expression, etc. @item Journal transactions -Postings are owned by transactions, always. This subclass of item_t +Postings are owned by transactions, always. This subclass of @code{item_t} knows about the date, the payee, etc. If a date or metadata tag is requested from a posting and it doesn't have that information, the transaction is queried to see if it can provide it. @@ -8444,19 +8824,19 @@ it, but contains relatively little information of its own. Finally, all transactions with their postings, and all accounts, are owned by a @code{journal_t} object. This is the go-to object for -querying ad reporting on your data. +querying and reporting on your data. @item Textual journal parser -There is a textual parser, wholly contained in textual.cc, which knows -how to parse text into journal objects, which then get ``finalized'' and -added to the journal. Finalization is the step that enforces the -double-entry guarantee. +There is a textual parser, wholly contained in @file{textual.cc}, which +knows how to parse text into journal objects, which then get +``finalized'' and added to the journal. Finalization is the step that +enforces the double-entry guarantee. @item Iterators Every journal object is ``iterable'', and these iterators are defined in -iterators.h and iterators.cc. This iteration logic is kept out of the +@file{iterators.h} and @file{iterators.cc}. This iteration logic is kept out of the basic journal objects themselves for the sake of modularity. @item Comparators @@ -8469,8 +8849,8 @@ the user passed to @option{--sort @var{VEXPR}}. Many reports bring pseudo-journal objects into existence, like postings which report totals in a @samp{Total} account. These objects are -created and managed by a temporaries_t object, which gets used in many -places by the reporting filters. +created and managed by a @code{temporaries_t} object, which gets used in +many places by the reporting filters. @item Option handling @@ -8487,7 +8867,7 @@ a separate session. They are all owned by the global scope. @item Report objects -Every time you create report output, a report object is created to +Every time you create any report output, a report object is created to determine what you want to see. In the Ledger REPL, a new report object is created every time a command is executed. In CLI mode, only one report object ever comes into being, as Ledger immediately exits after @@ -8510,7 +8890,7 @@ are filters which compute the running totals; that queue and sort all the input items before playing them back out in a new order; that filter out items which fail to match a predicate, etc. Almost every reporting feature in Ledger is related to one or more filters. Looking at -@file{filters.h}, I see over 25 of them defined currently. +@file{filters.h}, there are over 25 of them defined currently. @item The filter chain @@ -8523,9 +8903,9 @@ exposed this layer to the Python bridge yet. @item Output modules Although filters are great and all, in the end you want to see stuff. -This is the job of special ``leaf'' filters call output modules. They +This is the job of special ``leaf'' filters called output modules. They are implemented just like a regular filter, but they don't have -a ``next'' filter to pass the time on down to. Instead, they are the +a ``next'' filter to pass the data on down to. Instead, they are the end of the line and must do something with the item that results in the user seeing something on their screen or in a file. @@ -8571,7 +8951,7 @@ one or more @dfn{postings}, which describe how @dfn{amounts} flow from one @dfn{account} to another. Here is an example of the simplest of journal files: -@smallexample +@smallexample @c input:validate 2010/05/31 Just an example Expenses:Some:Account $100.00 Income:Another:Account @@ -8580,9 +8960,9 @@ journal files: In this example, there is a transaction date, a payee, or description of the transaction, and two postings. The postings show movement of one hundred dollars from an account within the Income hierarchy, to the -specified expense account. The name and meaning of these accounts in +specified expense account. The name and meaning of these accounts is arbitrary, with no preferences implied, although you will find it useful -to follow standard accounting practice (@pxref{Principles of Accounting +to follow standard accounting practices (@pxref{Principles of Accounting with Ledger}). Since an amount is missing from the second posting, it is assumed to be @@ -8595,7 +8975,7 @@ It is also typical, though not enforced, to think of the first posting as the destination, and the final as the source. Thus, the amount of the first posting is typically positive. Consider: -@smallexample +@smallexample @c input:validate 2010/05/31 An income transaction Assets:Checking $1,000.00 Income:Salary @@ -8630,7 +9010,7 @@ are covered here, though it must be said that sometimes, there are multiple ways to achieve a desired result. @emph{Note:} It is important to note that there must be at least two -spaces between the end of the post and the beginning of the amount +spaces between the end of the account and the beginning of the amount (including a commodity designator). @menu @@ -8643,7 +9023,7 @@ spaces between the end of the post and the beginning of the amount In the simplest form, bare decimal numbers are accepted: -@smallexample +@smallexample @c input:validate 2010/05/31 An income transaction Assets:Checking 1000.00 Income:Salary @@ -8750,10 +9130,10 @@ amount for a posting. But what if the amount you paid for something was in one commodity, and the amount received was another? There are two main ways to express this: -@smallexample +@smallexample @c input:validate 2010/05/31 Farmer's Market Assets:My Larder 100 apples - Assets:Checking $20.00 + Assets:Checking -$20.00 @end smallexample In this example, you have paid twenty dollars for one hundred apples. @@ -8761,18 +9141,18 @@ The cost to you is twenty cents per apple, and Ledger calculates this implied cost for you. You can also make the cost explicit using a @dfn{cost amount}: -@smallexample +@smallexample @c input:validate 2010/05/31 Farmer's Market Assets:My Larder 100 apples @@ $0.200000 Assets:Checking @end smallexample Here the @dfn{per-unit cost} is given explicitly in the form of a cost -amount; and since cost amount are @emph{unobserved}, the use of six +amount; and since cost amounts are @emph{unobserved}, the use of six decimal places has no effect on how dollar amounts are displayed in the final report. You can also specify the @dfn{total cost}: -@smallexample +@smallexample @c input:validate 2010/05/31 Farmer's Market Assets:My Larder 100 apples @@@@ $20 Assets:Checking @@ -8782,7 +9162,7 @@ These three forms have identical meaning. In most cases the first is preferred, but the second two are necessary when more than two postings are involved: -@smallexample +@smallexample @c input:validate 2010/05/31 Farmer's Market Assets:My Larder 100 apples @@ $0.200000 Assets:My Larder 100 pineapples @@ $0.33 @@ -8801,14 +9181,14 @@ posting automatically so that the transaction balances. In every transaction involving more than one commodity, there is always one which is the @dfn{primary commodity}. This commodity should be thought of as the exchange commodity, or the commodity used -to buy and sells units of the other commodity. In the fruit examples +to buy and sell units of the other commodity. In the fruit examples above, dollars are the primary commodity. This is decided by Ledger -on the placement of the commodity in the transaction: +based on the placement of the commodity in the transaction: -@smallexample +@smallexample @c input:validate 2010/05/31 Sample Transaction Expenses 100 secondary - Assets 50 primary + Assets -50 primary 2010/05/31 Sample Transaction Expenses 100 secondary @@ 0.5 primary @@ -8825,7 +9205,7 @@ play is in reports that use the @option{--market (-V)} or shown. If a transaction uses only one commodity, this commodity is also -considered a primary. In fact, when Ledger goes about ensures that +considered a primary. In fact, when Ledger goes about ensuring that all transactions balance to zero, it only ever asks this of primary commodities. @@ -8858,8 +9238,8 @@ nothing for a command line user. @subsection @command{source} @findex source -The @command{source} command take a journal file as an argument and -parses it checking for errors, no other reports are generated, and no +The @command{source} command takes a journal file as an argument and +parses it checking for errors; no other reports are generated, and no other arguments are necessary. Ledger will return success if no errors are found. @@ -8880,31 +9260,33 @@ data during the run. The following are the available @var{CODES} to debug: @multitable @columnfractions .32 .43 .27 -@item @code{account.display} @tab @code{expr.calc.when} @tab @code{org.next_amount} -@item @code{accounts.sorted} @tab @code{expr.compile} @tab @code{org.next_total} -@item @code{amount.convert} @tab @code{filters.changed_value} @tab @code{parser.error} -@item @code{amount.is_zero} @tab @code{filters.changed_value.rounding} @tab @code{pool.commodities} -@item @code{amount.parse} @tab @code{filters.collapse} @tab @code{post.assign} -@item @code{amount.price} @tab @code{filters.forecast} @tab @code{python.init} -@item @code{amount.truncate} @tab @code{filters.revalued} @tab @code{python.interp} -@item @code{amount.unround} @tab @code{format.abbrev} @tab @code{query.mask} -@item @code{amounts.commodities} @tab @code{format.expr} @tab @code{report.predicate} -@item @code{amounts.refs} @tab @code{generate.post} @tab @code{scope.symbols} -@item @code{archive.journal} @tab @code{generate.post.string} @tab @code{textual.include} -@item @code{auto.columns} @tab @code{item.meta} @tab @code{textual.parse} -@item @code{budget.generate} @tab @code{ledger.read} @tab @code{timelog} -@item @code{commodity.annotated.strip} @tab @code{ledger.validate} @tab @code{times.epoch} -@item @code{commodity.annotations} @tab @code{lookup} @tab @code{times.interval} -@item @code{commodity.compare} @tab @code{lookup.account} @tab @code{times.parse} -@item @code{commodity.download} @tab @code{mask.match} @tab @code{value.sort} -@item @code{commodity.prices.add} @tab @code{memory.counts} @tab @code{value.storage.refcount} -@item @code{commodity.prices.find} @tab @code{memory.counts.live} @tab @code{xact.extend} -@item @code{convert.csv} @tab @code{memory.debug} @tab @code{xact.extend.cleared} -@item @code{csv.mappings} @tab @code{op.cons} @tab @code{xact.extend.fail} -@item @code{csv.parse} @tab @code{op.memory} @tab @code{xact.finalize} -@item @code{draft.xact} @tab @code{option.args} -@item @code{expr.calc} @tab @code{option.names} +@item @code{account.display} @tab @code{draft.xact} @tab @code{option.names} +@item @code{account.sorted} @tab @code{expr.calc} @tab @code{org.next_amount} +@item @code{amount.commodities} @tab @code{expr.compile} @tab @code{org.next_total} +@item @code{amount.convert} @tab @code{expr.merged.compile} @tab @code{parser.error} +@item @code{amount.is_zero} @tab @code{filters.changed_value} @tab @code{pool.commodities} +@item @code{amount.parse} @tab @code{filters.changed_value.rounding} @tab @code{post.assign} +@item @code{amount.price} @tab @code{filters.collapse} @tab @code{python.init} +@item @code{amount.refs} @tab @code{filters.forecast} @tab @code{python.interp} +@item @code{amount.roundto} @tab @code{filters.interval} @tab @code{query.mask} +@item @code{amount.truncate} @tab @code{filters.revalued} @tab @code{report.predicate} +@item @code{amount.unround} @tab @code{format.abbrev} @tab @code{scope.search} +@item @code{annotate.less} @tab @code{format.expr} @tab @code{scope.symbols} +@item @code{archive.journal} @tab @code{generate.post} @tab @code{select.parse} +@item @code{auto.columns} @tab @code{generate.post.string} @tab @code{textual.include} +@item @code{budget.generate} @tab @code{history.find} @tab @code{textual.parse} +@item @code{commodity.annotated.strip} @tab @code{history.map} @tab @code{timelog} +@item @code{commodity.annotations} @tab @code{item.meta} @tab @code{times.epoch} +@item @code{commodity.compare} @tab @code{ledger.read} @tab @code{times.interval} +@item @code{commodity.download} @tab @code{ledger.validate} @tab @code{times.parse} +@item @code{commodity.exchange} @tab @code{lookup} @tab @code{value.sort} +@item @code{commodity.price.find} @tab @code{lookup.account} @tab @code{value.storage.refcount} +@item @code{commodity.prices.add} @tab @code{mask.match} @tab @code{xact.extend} +@item @code{commodity.prices.find} @tab @code{memory.debug} @tab @code{xact.extend.cleared} +@item @code{csv.mappings} @tab @code{op.memory} @tab @code{xact.extend.fail} +@item @code{csv.parse} @tab @code{option.args} @tab @code{xact.finalize} @end multitable +@ @item --trace @var{INT} Enable tracing. The @var{INT} specifies the level of trace desired: @@ -8923,14 +9305,15 @@ Enable tracing. The @var{INT} specifies the level of trace desired: @item @code{LOG_TRACE} @tab 10 @item @code{LOG_ALL} @tab 11 @end multitable +@ @item --verbose Print detailed information on the execution of Ledger. @item --verify Enable additional assertions during run-time. This causes a significant -slowdown. When combined with @option{--debug @var{CODE}} ledger will produce -memory trace information. +slowdown. When combined with @option{--debug @var{CODE}} ledger will +produce memory trace information. @item --verify-memory FIX THIS ENTRY @c FIXME thdox @@ -8960,7 +9343,7 @@ apply it against a model transaction. @item generate Randomly generates syntactically valid Ledger data from a seed. Used -by the GenerateTests harness for development testing. +by the @samp{GenerateTests} harness for development testing. @item parse @var{VEXPR} @itemx expr @var{VEXPR} @@ -9034,8 +9417,8 @@ true FIX THIS ENTRY @c FIXME thdox @item template -Shows the insertion template that @command{xact} sub-command generates. -This is a debugging command. +Shows the insertion template that the @command{xact} sub-command +generates. This is a debugging command. @end ftable @@ -9054,13 +9437,13 @@ This is a debugging command. @subsection Testing Framework Ledger source ships with a fairly complete set of tests to verify that -all is well, and no old errors have been resurfaced. Tests are run +all is well, and no old errors have resurfaced. Tests are run individually with @file{ctest}. All tests can be run using @code{make check} or @code{ninja check} depending on which build tool you prefer. Once built, the ledger executable resides under the @file{build} subdirectory in the source tree. Tests are built and stored in the -test subdirectory for the build. For example, +@file{test} subdirectory for the build. For example, @file{~/ledger/build/ledger/opt/test}. @menu @@ -9071,7 +9454,7 @@ test subdirectory for the build. For example, @node Running Tests, Writing Tests, Testing Framework, Testing Framework @subsubsection Running Tests -The complete test sweet can be run from the build directory using the +The complete test suite can be run from the build directory using the check option for the build tool you use. For example, @code{make check}. The entire test suit lasts around a minute for the optimized built and many times longer for the debug version. While developing @@ -9082,9 +9465,9 @@ build location. To execute a single test use @code{ctest -V -R regex}, where the regex matches the name of the test you want to build. There are nearly 300 tests stored under the @file{test} subdirectory -in main source distribution. They are broken into two broad +in the main source distribution. They are broken into two broad categories, baseline and regression. To run the @file{5FBF2ED8} test, -for example, issue @samp{ctest -V -R "5FB"}. +for example, issue @code{ctest -V -R "5FB"}. @node Writing Tests, , Running Tests, Testing Framework @subsubsection Writing Tests @@ -9138,14 +9521,14 @@ is now @env{LEDGER_PRICE_EXP}. @end itemize -@node Example Journal File, Miscellaneous Notes, Major Changes from version 2.6, Top +@node Example Journal File, Miscellaneous Notes, Major Changes from version 2.6, Top @appendix Example Journal File The following journal file is included with the source distribution of ledger. It is called @file{drewr.dat} and exhibits many ledger features, include automatic and virtual transactions, -@smallexample +@smallexample @c input:validate ; -*- ledger -*- = /^Income/ @@ -9234,16 +9617,16 @@ to the main body of the documentation. @smallexample $ ledger --group-by "tag('trip')" bal -$ legder reg --sort "tag('foo')" %foo +$ ledger reg --sort "tag('foo')" %foo $ ledger cleared VWCU NFCU Tithe Misentry $ ledger register Joint --uncleared -$ ledger register Checking --sort d -d 'd>[2011/04/01]' until 2011/05/25 +$ ledger register Checking --sort d -d 'd>[2011/04/01]' until 2011/05/25 @end smallexample @node Ledger Files, , Invoking Ledger, Cookbook @subsection Ledger Files -@smallexample +@smallexample @c input:validate = /^Income:Taxable/ (Liabilities:Tithe Owed) -0.1 = /Noah/ |