diff options
author | John Wiegley <johnw@newartisans.com> | 2009-10-25 23:08:07 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-10-25 23:11:30 -0400 |
commit | 1f5ceb0db50df9ad0f9048ee02ad749507cbd737 (patch) | |
tree | a8609fdcd28aa4d371aebf8a9867e43014e652f1 /doc/Ledger.scriv/QuickLook | |
parent | 9dadaebfeb461ba795124281018d0f7eac200cf4 (diff) | |
download | fork-ledger-1f5ceb0db50df9ad0f9048ee02ad749507cbd737.tar.gz fork-ledger-1f5ceb0db50df9ad0f9048ee02ad749507cbd737.tar.bz2 fork-ledger-1f5ceb0db50df9ad0f9048ee02ad749507cbd737.zip |
Added beginning draft of manual for 3.0
This is being kept in Scrivener format, for ease of writing.
Diffstat (limited to 'doc/Ledger.scriv/QuickLook')
-rw-r--r-- | doc/Ledger.scriv/QuickLook/Preview.html | 563 | ||||
-rw-r--r-- | doc/Ledger.scriv/QuickLook/Thumbnail.jpg | bin | 0 -> 33306 bytes |
2 files changed, 563 insertions, 0 deletions
diff --git a/doc/Ledger.scriv/QuickLook/Preview.html b/doc/Ledger.scriv/QuickLook/Preview.html new file mode 100644 index 00000000..81db790e --- /dev/null +++ b/doc/Ledger.scriv/QuickLook/Preview.html @@ -0,0 +1,563 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<meta http-equiv="Content-Style-Type" content="text/css"> +<title></title> +<meta name="Generator" content="Cocoa HTML Writer"> +<meta name="CocoaVersion" content="1038"> +<style type="text/css"> +p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Courier; background-color: #dee4ea} +p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier} +p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier; min-height: 14.0px} +</style> +</head> +<body> +<p class="p1"><b>• Front Matter</b></p> +<p class="p2">\input texinfo<span class="Apple-converted-space"> </span>@c -*-texinfo-*-<span class="Apple-converted-space"> </span>@setfilename ledger.info @settitle Ledger: Command-Line Accounting<span class="Apple-converted-space"> </span>@dircategory User Applications</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@copying Copyright (c) 2003-2009, John Wiegley.<span class="Apple-converted-space"> </span>All rights reserved.<span class="Apple-converted-space"> </span>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:<span class="Apple-converted-space"> </span>- Redistributions of source code must retain the above copyright <span class="Apple-converted-space"> </span>notice, this list of conditions and the following disclaimer.<span class="Apple-converted-space"> </span>- Redistributions in binary form must reproduce the above copyright <span class="Apple-converted-space"> </span>notice, this list of conditions and the following disclaimer in the <span class="Apple-converted-space"> </span>documentation a...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Introduction</b></p> +<p class="p2">@chapter Introduction</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Ledger is an accounting tool with the moxie to exist.<span class="Apple-converted-space"> </span>It provides no bells or whistles, and returns the user to the days before user interfaces were even a twinkling in their father's CRT.<span class="Apple-converted-space"> </span>What it does offer is a double-entry accounting ledger with all the flexibility and muscle of its modern day cousins, without any of the fat.<span class="Apple-converted-space"> </span>Think of it as the Bran Muffin of accounting tools.<span class="Apple-converted-space"> </span>To use it, you need to start keeping a ledger.<span class="Apple-converted-space"> </span>This is the basis of all accounting, and if you haven't started y...</p> +<p class="p3"><br></p> +<p class="p1"><b>• More introduction</b></p> +<p class="p2">@section More introduction</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The most important part of accounting is keeping a good ledger.<span class="Apple-converted-space"> </span>If you have a good ledger, tools can be written to work whatever mathematically tricks you need to better understand your spending patterns.<span class="Apple-converted-space"> </span>Without a good ledger, no tool, however smart, can help you.<span class="Apple-converted-space"> </span>The Ledger program aims at making ledger transaction as simple as possible. Since it is a command-line tool, it does not provide a user interface for keeping a ledger.<span class="Apple-converted-space"> </span>If you like, you may use GnuCash to maintain your ledger, in w...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Building the program</b></p> +<p class="p2">@section Building the program</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Ledger is written in ANSI C++, and should compile on any platform.<span class="Apple-converted-space"> </span>It depends on the GNU multiprecision integer library (libgmp), and the Perl regular expression library (libpcre).<span class="Apple-converted-space"> </span>It was developed using GNU make and gcc 3.3, on a PowerBook running OS/X.<span class="Apple-converted-space"> </span>To build and install once you have these libraries on your system, enter these commands:<span class="Apple-converted-space"> </span>@example ./configure && make install @end example</p> +<p class="p3"><br></p> +<p class="p1"><b>• Getting help</b></p> +<p class="p2">@section Getting help</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">If you need help on how to use Ledger, or run into problems, you can just the Ledger mailing list at the following Web address:<span class="Apple-converted-space"> </span>@example https://lists.sourceforge.net/lists/listinfo/ledger-discuss @end example<span class="Apple-converted-space"> </span>You can also find help at the @samp{#ledger} channel on the IRC server @samp{irc.freenode.net}.</p> +<p class="p3"><br></p> +<p class="p1"><b>• Quick Reference</b></p> +<p class="p2">@chapter Quick Reference</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">This chapter describes ledger's features and serves as a quick reference. You may wish to survey this to get an overview before diving in to the @ref{Ledger Tutorial} and more detailed examples that follow.<span class="Apple-converted-space"> </span>Ledger has a very simple command-line interface, named---enticing enough---@command{ledger}.<span class="Apple-converted-space"> </span>It supports a few reporting commands, and a large number of options for refining the output from those commands. The basic syntax of any ledger command is:<span class="Apple-converted-space"> </span>@example ledger [OPTIONS...] COMMAND [ARG...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Commands</b></p> +<p class="p2">@section Commands</p> +<p class="p3"><br></p> +<p class="p1"><b>• balance</b></p> +<p class="p2">@subsection balance</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The @command{balance} command reports the current balance of all accounts.<span class="Apple-converted-space"> </span>It accepts a list of optional regexps, which confine the balance report to the matching accounts.<span class="Apple-converted-space"> </span>If an account contains multiple types of commodities, each commodity's total is reported separately.<span class="Apple-converted-space"> </span></p> +<p class="p3"><br></p> +<p class="p1"><b>• register</b></p> +<p class="p2">@subsection register</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The @command{register} command displays all the postings occurring in a single account, line by line.<span class="Apple-converted-space"> </span>The account regexp must be specified as the only argument to this command.<span class="Apple-converted-space"> </span>If any regexps occur after the required account name, the register will contain only those postings that match.<span class="Apple-converted-space"> </span>Very useful for hunting down a particular posting.<span class="Apple-converted-space"> </span>The output from @command{register} is very close to what a typical checkbook, or single-account ledger, would look like.<span class="Apple-converted-space"> </span>It also shows a running balance.<span class="Apple-converted-space"> </span>...</p> +<p class="p3"><br></p> +<p class="p1"><b>• print</b></p> +<p class="p2">@subsection print</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The @command{print} command prints out ledger transactions in a textual format that can be parsed by Ledger.<span class="Apple-converted-space"> </span>They will be properly formatted, and output in the most economic form possible.<span class="Apple-converted-space"> </span>The ``print'' command also takes a list of optional regexps, which will cause only those postings which match in some way to be printed.<span class="Apple-converted-space"> </span>The @command{print} command can be a handy way to clean up a ledger file whose formatting has gotten out of hand.</p> +<p class="p3"><br></p> +<p class="p1"><b>• output</b></p> +<p class="p2">@subsection output</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The @command{output} command is very similar to the @command{print} command, except that it attempts to replicate the specified ledger file epostly.<span class="Apple-converted-space"> </span>The format of the command is:<span class="Apple-converted-space"> </span>@example ledger -f FILENAME output FILENAME @end example<span class="Apple-converted-space"> </span>Where @file{FILENAME} is the name of the ledger file to output.<span class="Apple-converted-space"> </span>The reason for specifying this command is that only transactions contained within that file will be output, and not an included transactions (as can happen with the @command{print} command).</p> +<p class="p3"><br></p> +<p class="p1"><b>• xml</b></p> +<p class="p2">@subsection xml</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The @command{xml} command outputs results similar to what @command{print} and @command{register} display, but as an XML form. This data can then be read in and processed.<span class="Apple-converted-space"> </span>Use the @option{--totals} option to include the running total with each posting.</p> +<p class="p3"><br></p> +<p class="p1"><b>• emacs</b></p> +<p class="p2">@subsection emacs</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The @command{emacs} command outputs results in a form that can be read directly by Emacs Lisp.<span class="Apple-converted-space"> </span>The format of the sexp is:<span class="Apple-converted-space"> </span>@example ((BEG-POS CLEARED DATE CODE PAYEE <span class="Apple-converted-space"> </span>(ACCOUNT AMOUNT)...)<span class="Apple-converted-space"> </span>; list of postings<span class="Apple-converted-space"> </span>...) <span class="Apple-converted-space"> </span>; list of transactions @end example</p> +<p class="p3"><br></p> +<p class="p1"><b>• equity</b></p> +<p class="p2">@subsection equity</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The @command{equity} command prints out accounts balances as if they were transactions.<span class="Apple-converted-space"> </span>This makes it easy to establish the starting balances for an account, such as when @ref{Archiving previous years}.</p> +<p class="p3"><br></p> +<p class="p1"><b>• prices</b></p> +<p class="p2">@subsection prices</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The @command{prices} command displays the price history for matching commodities.<span class="Apple-converted-space"> </span>The @option{-A} flag is useful with this report, to display the running average price, or @option{-D} to show each price's deviation from that average.<span class="Apple-converted-space"> </span>There is also a @command{pricesdb} command which outputs the same information as @command{prices}, but does in a format that can be parsed by Ledger.</p> +<p class="p3"><br></p> +<p class="p1"><b>• xact</b></p> +<p class="p2">@subsection xact</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The @command{xact} commands simplifies the creation of new transactions. It works on the principle that 80% of all postings are variants of earlier postings.<span class="Apple-converted-space"> </span>Here's how it works:<span class="Apple-converted-space"> </span>Say you currently have this posting in your ledger file:<span class="Apple-converted-space"> </span>@smallexample 2004/03/15 * Viva Italiano <span class="Apple-converted-space"> </span>Expenses:Food <span class="Apple-converted-space"> </span>$12.45 <span class="Apple-converted-space"> </span>Expenses:Tips<span class="Apple-converted-space"> </span>$2.55 <span class="Apple-converted-space"> </span>Liabilities:MasterCard <span class="Apple-converted-space"> </span>$-15.00 @end smallexample<span class="Apple-converted-space"> </span>Now it's @samp{2004/4/9}, and you've just eating at @samp{Vi...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Options</b></p> +<p class="p2">@section Options</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">With all of the reports, command-line options are useful to modify the output generated.<span class="Apple-converted-space"> </span>These command-line options always occur before the command word.<span class="Apple-converted-space"> </span>This is done to distinguish options from exclusive regular expressions, which also begin with a dash.<span class="Apple-converted-space"> </span>The basic form for most commands is:<span class="Apple-converted-space"> </span>@example ledger [OPTIONS] COMMAND [REGEXPS...] [-- [REGEXPS...]] @end example<span class="Apple-converted-space"> </span>The @var{OPTIONS} and @var{REGEXPS} expressions are both optional. You could just use @samp{ledger balance}, without any opt...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Basic options</b></p> +<p class="p2">@subsection Basic options</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">These are the most basic command options.<span class="Apple-converted-space"> </span>Most likely, the user will want to set them using environment variables (see @ref{Options}), instead of using actual command-line options:<span class="Apple-converted-space"> </span>@option{--help} (@option{-h}) prints a summary of all the options, and what they are used for.<span class="Apple-converted-space"> </span>This can be a handy way to remember which options do what.<span class="Apple-converted-space"> </span>This help screen is also printed if ledger is run without a command.<span class="Apple-converted-space"> </span>@option{--version} (@option{-v}) prints the current version of ledger and exits.<span class="Apple-converted-space"> </span>This is u...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Report filtering</b></p> +<p class="p2">@subsection Report filtering</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">These options change which postings affect the outcome of a report, in ways other than just using regular expressions:<span class="Apple-converted-space"> </span>@option{--current}(@option{-c}) displays only transactions occurring on or before the current date.<span class="Apple-converted-space"> </span>@option{--begin DATE} (@option{-b DATE}) constrains the report to transactions on or after @var{DATE}.<span class="Apple-converted-space"> </span>Only transactions after that date will be calculated, which means that the running total in the balance report will always start at zero with the first matching transaction.<span class="Apple-converted-space"> </span>...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Output customization</b></p> +<p class="p2">@subsection Output customization</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">These options affect only the output, but not which postings are used to create it:<span class="Apple-converted-space"> </span>@option{--collapse} (@option{-n}) causes transactions in a @command{register} report with multiple postings to be collapsed into a single, subtotaled transaction.<span class="Apple-converted-space"> </span>@option{--subtotal} (@option{-s}) causes all transactions in a @command{register} report to be collapsed into a single, subtotaled transaction.<span class="Apple-converted-space"> </span>@option{--by-payee} (@option{-P}) reports subtotals by payee.<span class="Apple-converted-space"> </span>@option{--comm-as-payee} (@option{-x}) chan...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Commodity reporting</b></p> +<p class="p2">@subsection Commodity reporting</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">These options affect how commodity values are displayed:<span class="Apple-converted-space"> </span>@option{--price-db FILE} sets the file that is used for recording downloaded commodity prices.<span class="Apple-converted-space"> </span>It is always read on startup, to determine historical prices.<span class="Apple-converted-space"> </span>Other settings can be placed in this file manually, to prevent downloading quotes for a specific, for example.<span class="Apple-converted-space"> </span>This is done by adding a line like the following:<span class="Apple-converted-space"> </span>@example ; Don't download quotes for the dollar, or timelog values N $ N h @end example<span class="Apple-converted-space"> </span>@option{--price-exp MINS} (@opt...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Environment variables</b></p> +<p class="p2">@subsection Environment variables</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Every option to ledger may be set using an environment variable.<span class="Apple-converted-space"> </span>If an option has a long name such @option{--this-option}, setting the environment variable @env{LEDGER_THIS_OPTION} will have the same affect as specifying that option on the command-line.<span class="Apple-converted-space"> </span>Options on the command-line always take precedence over environment variable settings, however.<span class="Apple-converted-space"> </span>Note that you may also permanently specify option values by placing option settings in the file @file{~/.ledgerrc}, for example:<span class="Apple-converted-space"> </span>@example --cache ...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Period expressions</b></p> +<p class="p2">@section Period expressions</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">A period expression indicates a span of time, or a reporting interval, or both.<span class="Apple-converted-space"> </span>The full syntax is:<span class="Apple-converted-space"> </span>@example [INTERVAL] [BEGIN] [END] @end example<span class="Apple-converted-space"> </span>The optional @var{INTERVAL} part may be any one of:<span class="Apple-converted-space"> </span>@example every day every week every monthly every quarter every year every N days <span class="Apple-converted-space"> </span># N is any integer every N weeks every N months every N quarters every N years daily weekly biweekly monthly bimonthly quarterly yearly @end example<span class="Apple-converted-space"> </span>After the interval, a begin time, end time, both or neither m...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Format strings</b></p> +<p class="p2">@section Format strings</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Format strings may be used to change the output format of reports. They are specified by passing a formatting string to the @option{--format} (@option{-F}) option.<span class="Apple-converted-space"> </span>Within that string, constructs are allowed which make it possible to display the various parts of an account or posting in custom ways.<span class="Apple-converted-space"> </span>Within a format strings, a substitution is specified using a percent character (@samp{%}).<span class="Apple-converted-space"> </span>The basic format of all substitutions is:<span class="Apple-converted-space"> </span>@example %[-][MIN WIDTH][.MAX WIDTH]EXPR @end example<span class="Apple-converted-space"> </span>If the o...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Value expressions</b></p> +<p class="p2">@section Value expressions</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Value expressions are an expression language used by Ledger to calculate values used by the program for many different purposes:<span class="Apple-converted-space"> </span>@enumerate @item The values displayed in reports @item For predicates (where truth is anything non-zero), to determine which postings are calculated (@option{-l}) or displayed (@option{-d}). @item For sorting criteria, to yield the sort key. @item In the matching criteria used by automated postings. @end enumerate<span class="Apple-converted-space"> </span>Value expressions support most simple math and logic ...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Variables</b></p> +<p class="p2">@subsection Variables</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">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.<span class="Apple-converted-space"> </span>For the balance command, these variables relate to accounts---often with a subtle difference in meaning.<span class="Apple-converted-space"> </span>The use of each variable for both is specified.<span class="Apple-converted-space"> </span>@table @code @item t This maps to whatever the user specified with @option{-t}.<span class="Apple-converted-space"> </span>In a register report, @option{-t} changes the value column; ...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Posting/account details</b></p> +<p class="p2">@subsubsection Posting/account details</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@table @code @item d A posting's date, as the number of seconds past the epoch.<span class="Apple-converted-space"> </span>This is always ``today'' for an account.<span class="Apple-converted-space"> </span>@item a The posting's amount; the balance of an account, without considering children.<span class="Apple-converted-space"> </span>@item b The cost of a posting; the cost of an account, without its children.<span class="Apple-converted-space"> </span>@item v The market value of a posting, or an account without its children.<span class="Apple-converted-space"> </span>@item g The net gain (market value minus cost basis), for a posting or an account without its children.<span class="Apple-converted-space"> </span>It is the same as @samp{v-b}. ...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Calculated totals</b></p> +<p class="p2">@subsubsection Calculated totals</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@table @code @item O The total of all postings seen so far, or the total of an account and all its children.<span class="Apple-converted-space"> </span>@item N The total count of postings affecting an account and all its children.<span class="Apple-converted-space"> </span>@item B The total cost of all postings seen so far; the total cost of an account and all its children.<span class="Apple-converted-space"> </span>@item V The market value of all postings seen so far, or of an account and all its children.<span class="Apple-converted-space"> </span>@item G The total net gain (market value minus cost basis), for a series of postings, or an account and its chil...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Functions</b></p> +<p class="p2">@subsection Functions</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The available one letter functions are:<span class="Apple-converted-space"> </span>@table @code @item - Negates the argument.<span class="Apple-converted-space"> </span>@item U The absolute (unsigned) value of the argument.<span class="Apple-converted-space"> </span>@item S Strips the commodity from the argument.<span class="Apple-converted-space"> </span>@item A The arithmetic mean of the argument; @samp{Ax} is the same as @samp{x/n}.<span class="Apple-converted-space"> </span>@item P The present market value of the argument.<span class="Apple-converted-space"> </span>The syntax @samp{P(x,d)} is supported, which yields the market value at time @samp{d}.<span class="Apple-converted-space"> </span>If no date is given, then the current moment is used. @end table</p> +<p class="p3"><br></p> +<p class="p1"><b>• Operators</b></p> +<p class="p2">@subsection Operators</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The binary and ternary operators, in order of precedence, are:<span class="Apple-converted-space"> </span>@enumerate @item @samp{* /} @item @samp{+ -} @item @samp{! < > =} @item @samp{& | ?:} @end enumerate</p> +<p class="p3"><br></p> +<p class="p1"><b>• Complex expressions</b></p> +<p class="p2">@subsection Complex expressions</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">More complicated expressions are possible using:<span class="Apple-converted-space"> </span>@table @code @item NUM A plain integer represents a commodity-less amount.<span class="Apple-converted-space"> </span>@item @{AMOUNT@} An amount in braces can be any kind of amount supported by ledger, with or without a commodity.<span class="Apple-converted-space"> </span>Use this for decimal values.<span class="Apple-converted-space"> </span>@item /REGEXP/ @item W/REGEXP/ A regular expression that matches against an account's full name.<span class="Apple-converted-space"> </span>If a posting, this will match against the account affected by the posting.<span class="Apple-converted-space"> </span>@item //REGEXP/ @item p/REGEXP/ A regular expression tha...</p> +<p class="p3"><br></p> +<p class="p1"><b>• File format</b></p> +<p class="p2">@section File format</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The ledger file format is quite simple, but also very flexible.<span class="Apple-converted-space"> </span>It supports many options, though typically the user can ignore most of them.<span class="Apple-converted-space"> </span>They are summarized below.<span class="Apple-converted-space"> </span>The initial character of each line determines what the line means, and how it should be interpreted.<span class="Apple-converted-space"> </span>Allowable initial characters are:<span class="Apple-converted-space"> </span>@table @code @item NUMBER A line beginning with a number denotes a transaction.<span class="Apple-converted-space"> </span>It may be followed by any number of lines, each beginning with whitespace, to denote the transaction's account ...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Ledger Tutorial</b></p> +<p class="p2">@chapter Ledger Tutorial</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">This chapter presents a series of recipes, gradually introducing all of the command-line features of Ledger.<span class="Apple-converted-space"> </span>For the purpose of these examples, assume the environment variable @var{LEDGER} is set to the file @file{sample.dat} (which is included in the distribution), and that the contents of that file are:<span class="Apple-converted-space"> </span>@smallexample = /^Expenses:Books/ <span class="Apple-converted-space"> </span>(Liabilities:Taxes) <span class="Apple-converted-space"> </span>-0.10<span class="Apple-converted-space"> </span>~ Monthly <span class="Apple-converted-space"> </span>Assets:Bank:Checking<span class="Apple-converted-space"> </span>$500.00 <span class="Apple-converted-space"> </span>Income:Salary<span class="Apple-converted-space"> </span>2004/05/01 * Checking balance <span class="Apple-converted-space"> </span>Assets:Bank:Check...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Checking balances</b></p> +<p class="p2">@section Checking balances</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Ledger has seven basic commands, but by far the most often used are @command{balance} and @command{register}.<span class="Apple-converted-space"> </span>To see a summary balance of all accounts, use:<span class="Apple-converted-space"> </span>@example ledger bal @end example<span class="Apple-converted-space"> </span>@command{bal} is a short-hand for @command{balance}.<span class="Apple-converted-space"> </span>This command prints out the summary totals of the five parent accounts used in @file{sample.dat}:<span class="Apple-converted-space"> </span>@smallexample<span class="Apple-converted-space"> </span>$1,480.00<span class="Apple-converted-space"> </span>50 AAPL<span class="Apple-converted-space"> </span>Assets <span class="Apple-converted-space"> </span>$-2,500.00<span class="Apple-converted-space"> </span>Equity <span class="Apple-converted-space"> </span>$20.00<span class="Apple-converted-space"> </span>Expenses <span class="Apple-converted-space"> </span>$-500.00<span class="Apple-converted-space"> </span>Income<span class="Apple-converted-space"> </span>...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Sub-account balances</b></p> +<p class="p2">@subsection Sub-account balances</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The totals reported by the balance command are only the topmost parent accounts.<span class="Apple-converted-space"> </span>To see the totals of all child accounts as well, use the @option{-s} option:<span class="Apple-converted-space"> </span>@example ledger --real -B -s bal @end example<span class="Apple-converted-space"> </span>This reports:<span class="Apple-converted-space"> </span>@smallexample<span class="Apple-converted-space"> </span>$2,980.00<span class="Apple-converted-space"> </span>Assets<span class="Apple-converted-space"> </span>$1,480.00<span class="Apple-converted-space"> </span>Bank:Checking<span class="Apple-converted-space"> </span>$1,500.00<span class="Apple-converted-space"> </span>Brokerage <span class="Apple-converted-space"> </span>$-2,500.00<span class="Apple-converted-space"> </span>Equity:Opening Balances <span class="Apple-converted-space"> </span>$20.00<span class="Apple-converted-space"> </span>Expenses:Books <span class="Apple-converted-space"> </span>$-500.00<span class="Apple-converted-space"> </span>Income:Salary @end smallexample<span class="Apple-converted-space"> </span>This shows that the @samp...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Specific account balances</b></p> +<p class="p2">@subsection Specific account balances</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">While reporting the totals for all accounts can be useful, most often you will want to check the balance of a specific account or accounts. To do this, put one or more account names after the balance command. Since these names are really regular expressions, you can use partial names if you wish:<span class="Apple-converted-space"> </span>@example ledger bal checking @end example<span class="Apple-converted-space"> </span>Reports:<span class="Apple-converted-space"> </span>@smallexample<span class="Apple-converted-space"> </span>$1,480.00<span class="Apple-converted-space"> </span>Assets:Bank:Checking @end smallexample<span class="Apple-converted-space"> </span>Any number of names may be used:<span class="Apple-converted-space"> </span>@example ledger bal checking broker li...</p> +<p class="p3"><br></p> +<p class="p1"><b>• The register report</b></p> +<p class="p2">@section The register report</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">While the @command{balance} command can be very handy for checking account totals, by far the most powerful of Ledger's reporting tools is the @command{register} command.<span class="Apple-converted-space"> </span>In fact, internally both commands use the same logic, but report the results differently: @command{balance} shows the summary totals, while @command{register} reports each posting and how it contributes to that total.<span class="Apple-converted-space"> </span>Paradoxically, the most basic form of @command{register} is almost never used, since it displays every postin...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Specific register queries</b></p> +<p class="p2">@subsection Specific register queries</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The most common use of the register command is to summarize postings based on the account(s) they affect.<span class="Apple-converted-space"> </span>Using @file{sample.dat} as as example, we could look at all book purchases using:<span class="Apple-converted-space"> </span>@example ledger reg books @end example<span class="Apple-converted-space"> </span>Reports:<span class="Apple-converted-space"> </span>@smallexample 2004/05/29 Book Store <span class="Apple-converted-space"> </span>Expenses:Books <span class="Apple-converted-space"> </span>$20.00 <span class="Apple-converted-space"> </span>$20.00 @end smallexample<span class="Apple-converted-space"> </span>If a double-dash (@samp{--}) occurs in the list of regular expressions, any following arguments are matched against payee names, instead of accoun...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Selecting postings</b></p> +<p class="p2">@section Selecting postings</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Although the easiest way to use the register is to report all the postings affecting a set of accounts, it can often result in more information than you want.<span class="Apple-converted-space"> </span>To cope with an ever-growing amount of data, there are several options which can help you pinpoint your report to epostly the postings that interest you most.<span class="Apple-converted-space"> </span>This is called the ``calculation'' phase of Ledger.<span class="Apple-converted-space"> </span>All of its related options are documented under @option{--help-calc}.</p> +<p class="p3"><br></p> +<p class="p1"><b>• By date</b></p> +<p class="p2">@subsection By date</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@c<span class="Apple-converted-space"> </span>-c, --current<span class="Apple-converted-space"> </span>show only current and past transactions (not future)<span class="Apple-converted-space"> </span>@option{--current}(@option{-c}) displays transactions occurring on or before the current date.<span class="Apple-converted-space"> </span>Any transaction recorded for a future date will be ignored, as if it had not been seen.<span class="Apple-converted-space"> </span>This is useful if you happen to pre-record transactions, but still wish to view your balances in terms of what is available today.<span class="Apple-converted-space"> </span>@c<span class="Apple-converted-space"> </span>-b, --begin DATE <span class="Apple-converted-space"> </span>set report begin date @c<span class="Apple-converted-space"> </span>-e, --end DATE <span class="Apple-converted-space"> </span>set report end date<span class="Apple-converted-space"> </span>@opti...</p> +<p class="p3"><br></p> +<p class="p1"><b>• By status</b></p> +<p class="p2">@subsection By status</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">By default, all regular postings are included in each report.<span class="Apple-converted-space"> </span>To limit the report to certain kinds of postings, use one or more of the following options:<span class="Apple-converted-space"> </span>@table @option @item -C, --cleared Consider only cleared postings. @item -U, --uncleared Consider only uncleared and pending postings. @item -R, --real Consider only real (non-virtual) postings. @item -L, --actual Consider only actual (non-automated) postings. @end table<span class="Apple-converted-space"> </span>Cleared postings are indicated by an asterix placed just before the pay...</p> +<p class="p3"><br></p> +<p class="p1"><b>• By relationship</b></p> +<p class="p2">@subsection By relationship</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@c<span class="Apple-converted-space"> </span>-r, --related<span class="Apple-converted-space"> </span>calculate report using related postings<span class="Apple-converted-space"> </span>Normally, a register report includes only the postings that match the regular expressions specified after the command word.<span class="Apple-converted-space"> </span>For example, to report all expenses:<span class="Apple-converted-space"> </span>@example ledger reg ^expenses @end example<span class="Apple-converted-space"> </span>This reports:<span class="Apple-converted-space"> </span>@smallexample 2004/05/29 Book Store <span class="Apple-converted-space"> </span>Expenses:Books <span class="Apple-converted-space"> </span>$20.00 <span class="Apple-converted-space"> </span>$20.00 @end smallexample<span class="Apple-converted-space"> </span>Using @option{--related} (@option{-r}) reports the postings that did not match your query, but o...</p> +<p class="p3"><br></p> +<p class="p1"><b>• By budget</b></p> +<p class="p2">@subsection By budget</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@c<span class="Apple-converted-space"> </span>--budget <span class="Apple-converted-space"> </span>generate budget transactions based on FILE<span class="Apple-converted-space"> </span>There is more information about budgeting and forecasting in @ref{Budgeting and forecasting}.<span class="Apple-converted-space"> </span>Basically, if you have any period transactions in your ledger file, you can use these options.<span class="Apple-converted-space"> </span>A period transaction looks like:<span class="Apple-converted-space"> </span>@example ~ Monthly <span class="Apple-converted-space"> </span>Assets:Bank:Checking <span class="Apple-converted-space"> </span>$500.00 <span class="Apple-converted-space"> </span>Income:Salary @end example<span class="Apple-converted-space"> </span>The difference from a regular transaction is that the first line begins with a tilde (~), and instead of a payee the...</p> +<p class="p3"><br></p> +<p class="p1"><b>• By value expression</b></p> +<p class="p2">@subsection By value expression</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@c<span class="Apple-converted-space"> </span>-l, --limit EXPR <span class="Apple-converted-space"> </span>calculate only postings matching EXPR<span class="Apple-converted-space"> </span>Value expressions can be quite complex, and are treated more fully in @ref{Value expressions}.<span class="Apple-converted-space"> </span>They can be used for limiting a report with @option{--limit} (@option{-l}).<span class="Apple-converted-space"> </span>The following command report income since august, but expenses since october:<span class="Apple-converted-space"> </span>@example ledger -l '(/income/&d>=[aug])|(/expenses/&d>=[oct])' reg @end example<span class="Apple-converted-space"> </span>The basic form of this value expression is @samp{(A&B)|(A&B)}.<span class="Apple-converted-space"> </span>The @samp{A} in each part matches aga...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Massaging register output</b></p> +<p class="p2">@section Massaging register output</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Even after filtering down your data to just the postings you're interested in, the default reporting method of one posting per line is often still too much.<span class="Apple-converted-space"> </span>To combat this complexity, it is possible to ask Ledger to report the details to you in many different forms, summarized in various ways.<span class="Apple-converted-space"> </span>This is the ``display'' phase of Ledger, and is documented under @option{--help-disp}.</p> +<p class="p3"><br></p> +<p class="p1"><b>• Summarizing</b></p> +<p class="p2">@subsection Summarizing</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@c<span class="Apple-converted-space"> </span>-n, --collapse <span class="Apple-converted-space"> </span>register: collapse transactions with multiple postings<span class="Apple-converted-space"> </span>When multiple postings relate to a single transaction, they are reported as part of that transaction.<span class="Apple-converted-space"> </span>For example, in the case of @file{sample.dat}:<span class="Apple-converted-space"> </span>@example ledger reg -- book @end example<span class="Apple-converted-space"> </span>Reports:<span class="Apple-converted-space"> </span>@smallexample 2004/05/29 Book Store <span class="Apple-converted-space"> </span>Expenses:Books <span class="Apple-converted-space"> </span>$20.00 <span class="Apple-converted-space"> </span>$20.00 <span class="Apple-converted-space"> </span>Liabilities:MasterCard<span class="Apple-converted-space"> </span>$-20.00<span class="Apple-converted-space"> </span>0 <span class="Apple-converted-space"> </span>(Liabi...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Quick periods</b></p> +<p class="p2">@subsection Quick periods</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Although the @option{-p} option (also @option{--period}) is much more versatile, there are other options to make the most common period reports easier:<span class="Apple-converted-space"> </span>@table @option @item -W, --weekly Show weekly sub-totals.<span class="Apple-converted-space"> </span>Same as @samp{-p weekly}. @item -M, --monthly Show monthly sub-totals.<span class="Apple-converted-space"> </span>Same as @samp{-p monthly}. @item -Y, --yearly Show yearly sub-totals.<span class="Apple-converted-space"> </span>Same as @samp{-p yearly}. @end table<span class="Apple-converted-space"> </span>@c<span class="Apple-converted-space"> </span>--dow<span class="Apple-converted-space"> </span>show a days-of-the-week report<span class="Apple-converted-space"> </span>There is one kind of period report cannot be don...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Ordering and width</b></p> +<p class="p2">@subsection Ordering and width</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@c<span class="Apple-converted-space"> </span>-S, --sort EXPR<span class="Apple-converted-space"> </span>sort report according to the value expression EXPR<span class="Apple-converted-space"> </span>The postings displayed in a report are shown in the same order as they appear in the ledger file.<span class="Apple-converted-space"> </span>To change the order and sort a report, use the @option{--sort} option.<span class="Apple-converted-space"> </span>@option{--sort} takes a value expression to determine the value to sort against, making it possible to sort according to complex criteria.<span class="Apple-converted-space"> </span>Here are some simple and useful examples:<span class="Apple-converted-space"> </span>@example ledger --sort d reg ^exp<span class="Apple-converted-space"> </span># sort by date ledger --sort t...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Averages and percentages</b></p> +<p class="p2">@subsection Averages and percentages</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@c<span class="Apple-converted-space"> </span>-A, --average<span class="Apple-converted-space"> </span>report average posting amount<span class="Apple-converted-space"> </span>To see the running total changed to a running average, use @option{-A}.<span class="Apple-converted-space"> </span>The final posting's total will be the overall average of all displayed postings.<span class="Apple-converted-space"> </span>The works in conjunction with period reporting, so that you can see your monthly average expenses with:<span class="Apple-converted-space"> </span>@example ledger -AM<span class="Apple-converted-space"> </span>reg ^expenses:food ledger -AMn reg ^expenses @end example<span class="Apple-converted-space"> </span>This works in the balance report too:<span class="Apple-converted-space"> </span>@example ledger -AM<span class="Apple-converted-space"> </span>bal ^expenses:food ledger -AMs bal ^expens...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Reporting total data</b></p> +<p class="p2">@subsection Reporting total data</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@c<span class="Apple-converted-space"> </span>--totals <span class="Apple-converted-space"> </span>in the "xml" report, include running total<span class="Apple-converted-space"> </span>Normally in the @command{xml} report, only posting amounts are printed.<span class="Apple-converted-space"> </span>To include the running total under a @samp{<total>} tag, use @option{--totals}.<span class="Apple-converted-space"> </span>This does not affect any other report.<span class="Apple-converted-space"> </span>@c<span class="Apple-converted-space"> </span>-j, --amount-data<span class="Apple-converted-space"> </span>print only raw amount data (useful for scripting) @c<span class="Apple-converted-space"> </span>-J, --total-data <span class="Apple-converted-space"> </span>print only raw total data<span class="Apple-converted-space"> </span>In the register report only, the output can be changed with @option{-j} to show only the date and the am...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Display by value expression</b></p> +<p class="p2">@subsection Display by value expression</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@c<span class="Apple-converted-space"> </span>-d, --display EXPR <span class="Apple-converted-space"> </span>display only postings matching EXPR<span class="Apple-converted-space"> </span>With @option{-d} you can decide which postings (or accounts in the balance report) are displayed, according to a value expression.<span class="Apple-converted-space"> </span>The computed total is not affected, only the display.<span class="Apple-converted-space"> </span>This can be very useful for shortening a report without changing the running total:<span class="Apple-converted-space"> </span>@example ledger -d 'd>=[last month]' reg checking @end example<span class="Apple-converted-space"> </span>This command shows the checking account's register, beginning from last month, but with the running ...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Change report format</b></p> +<p class="p2">@subsection Change report format</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">@c<span class="Apple-converted-space"> </span>-y, --date-format STR<span class="Apple-converted-space"> </span>use STR as the date format (default: %Y/%m/%d)<span class="Apple-converted-space"> </span>When dates are printed in any report, the default format is @samp{%Y/%m/%d}, which yields dates of the form @samp{YYYY/mm/dd}. This can be changed with @option{-y}, whose argument is a @code{strftime} string---see your system's C library documentation for the allowable codes.<span class="Apple-converted-space"> </span>Mostly you will want to use @samp{%Y}, @samp{%m} and @samp{%d}, in whatever combination is convenient for your locale.<span class="Apple-converted-space"> </span>@c<span class="Apple-converted-space"> </span>-F, --format STR <span class="Apple-converted-space"> </span>...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Standard queries</b></p> +<p class="p2">@section Standard queries</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">If your ledger file uses the standard top-level accounts: Assets, Liabilities, Income, Expenses, Equity: then the following queries will enable you to generate some typical accounting reports from your data.<span class="Apple-converted-space"> </span>Your @emph{net worth} can be determined by balancing assets against liabilities:<span class="Apple-converted-space"> </span>@example ledger bal ^assets ^liab @end example<span class="Apple-converted-space"> </span>By removing long-term investment and loan accounts, you can see your current net liquidity (or liquid net worth):<span class="Apple-converted-space"> </span>@example ledger bal ^assets ^liab -retirement ...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Reporting balance totals</b></p> +<p class="p2">@section Reporting balance totals</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The balance command prints out the summarized balances of all my top-level accounts, excluding sub-accounts.<span class="Apple-converted-space"> </span>In order to see the balances for a specific account, just specify a regular expression after the balance command:<span class="Apple-converted-space"> </span>@example ledger balance expenses:food @end example<span class="Apple-converted-space"> </span>This will show all the money that's been spent on food, since the beginning of the ledger.<span class="Apple-converted-space"> </span>For food spending just this month (September), use:<span class="Apple-converted-space"> </span>@example ledger -p sep balance expenses:food @end example<span class="Apple-converted-space"> </span>Or maybe you want t...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Reporting percentages</b></p> +<p class="p2">@section Reporting percentages</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">There is no built-in way to report posting amounts or account balances in terms of percentages.</p> +<p class="p3"><br></p> +<p class="p1"><b>• Ledger in Practice</b></p> +<p class="p2">@chapter Ledger in Practice</p> +<p class="p3"><br></p> +<p class="p1"><b>• Stating where money goes</b></p> +<p class="p2">@section Stating where money goes</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Accountants will talk of ``credits'' and ``debits'', but the meaning is often different from the layman's understanding.<span class="Apple-converted-space"> </span>To avoid confusion, Ledger uses only subtractions and additions, although the underlying intent is the same as standard accounting principles.<span class="Apple-converted-space"> </span>Recall that every posting will involve two or more accounts. Money is transferred from one or more accounts to one or more other accounts.<span class="Apple-converted-space"> </span>To record the posting, an amount is @emph{subtracted} from the source accounts, and @emph{adde...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Assets and Liabilities</b></p> +<p class="p2">@section Assets and Liabilities</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Assets are money that you have, and Liabilities are money that you owe.<span class="Apple-converted-space"> </span>``Liabilities'' is just a more inclusive name for Debts.<span class="Apple-converted-space"> </span>An Asset is typically increased by transferring money from an Income account, such as when you get paid.<span class="Apple-converted-space"> </span>Here is a typical transaction:<span class="Apple-converted-space"> </span>@smallexample 2004/09/29<span class="Apple-converted-space"> </span>My Employer <span class="Apple-converted-space"> </span>Assets:Checking <span class="Apple-converted-space"> </span>$500.00 <span class="Apple-converted-space"> </span>Income:Salary @end smallexample<span class="Apple-converted-space"> </span>Money, here, comes from an Income account belonging to ``My Employer'', and is transferred to your checking accoun...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Tracking reimbursable expenses</b></p> +<p class="p2">@subsection Tracking reimbursable expenses</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Sometimes you will want to spend money on behalf of someone else, which will eventually get repaid.<span class="Apple-converted-space"> </span>Since the money is still ``yours'', it is really an asset.<span class="Apple-converted-space"> </span>And since the expenditure was for someone else, you don't want it contaminating your Expenses reports.<span class="Apple-converted-space"> </span>You will need to keep an account for tracking reimbursements.<span class="Apple-converted-space"> </span>This is fairly easy to do in ledger.<span class="Apple-converted-space"> </span>When spending the money, spend it @emph{to} your Assets:Reimbursements, using a different account for each person or business that you...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Typical queries</b></p> +<p class="p2">@section Typical queries</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">A query such as the following shows all expenses since last October, sorted by total:<span class="Apple-converted-space"> </span>@example ledger -b "last oct" -s -S T bal ^expenses @end example<span class="Apple-converted-space"> </span>From left to right the options mean: Show transactions since October, 2003; show all sub-accounts; sort by the absolute value of the total; and report the balance for all expenses.</p> +<p class="p3"><br></p> +<p class="p1"><b>• Reporting monthly expenses</b></p> +<p class="p2">@subsection Reporting monthly expenses</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The following query makes it easy to see monthly expenses, with each month's expenses sorted by the amount:<span class="Apple-converted-space"> </span>@example ledger -M --period-sort t reg ^expenses @end example<span class="Apple-converted-space"> </span>Now, you might wonder where the money came from to pay for these things.<span class="Apple-converted-space"> </span>To see that report, add @option{-r}, which shows the ``related account'' postings:<span class="Apple-converted-space"> </span>@example ledger -M --period-sort t -r reg ^expenses @end example<span class="Apple-converted-space"> </span>But maybe this prints too much information.<span class="Apple-converted-space"> </span>You might just want to see how much you're spending with yo...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Visualizing with Gnuplot</b></p> +<p class="p2">@subsection Visualizing with Gnuplot</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">If you have @command{Gnuplot} installed, you can graph any of the above register reports.<span class="Apple-converted-space"> </span>The script to do this is included in the ledger distribution, and is named @file{scripts/report}.<span class="Apple-converted-space"> </span>Install @file{report} anywhere along your @env{PATH}, and then use @command{report} instead of @command{ledger} when doing a register report.<span class="Apple-converted-space"> </span>The only thing to keep in mind is that you must specify @option{-j} or @option{-J} to indicate whether Gnuplot should plot the amount, or the running total.<span class="Apple-converted-space"> </span>For examp...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Typical plots</b></p> +<p class="p2">@subsubsection Typical plots</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Here are some useful plots:<span class="Apple-converted-space"> </span>@smallexample report -j -M reg ^expenses <span class="Apple-converted-space"> </span># monthly expenses report -J reg checking <span class="Apple-converted-space"> </span># checking account balance report -J reg ^income ^expenses<span class="Apple-converted-space"> </span># cash flow report<span class="Apple-converted-space"> </span># net worth report, ignoring non-$ postings<span class="Apple-converted-space"> </span>report -J -l "Ua>=@{\$0.01@}" reg ^assets ^liab<span class="Apple-converted-space"> </span># net worth report starting last February.<span class="Apple-converted-space"> </span>the use of a display # predicate (-d) is needed, otherwise the balance will start at # zero, and thus the y-axis will not reflect the true balance<span class="Apple-converted-space"> </span>...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Budgeting and forecasting</b></p> +<p class="p2">@section Budgeting and forecasting</p> +<p class="p3"><br></p> +<p class="p1"><b>• Budgeting</b></p> +<p class="p2">@subsection Budgeting</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Keeping a budget allows you to pay closer attention to your income and expenses, by reporting how far your actual financial activity is from your expectations.<span class="Apple-converted-space"> </span>To start keeping a budget, put some period transactions at the top of your ledger file.<span class="Apple-converted-space"> </span>A period 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.<span class="Apple-converted-space"> </span>For example:<span class="Apple-converted-space"> </span>@smallexample ~ Monthly <span class="Apple-converted-space"> </span>Expenses:Rent <span class="Apple-converted-space"> </span>$500.00 <span class="Apple-converted-space"> </span>Expenses:Food <span class="Apple-converted-space"> </span>...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Forecasting</b></p> +<p class="p2">@subsection Forecasting</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Sometimes it's useful to know what your finances will look like in the future, such as determining when an account will reach zero.<span class="Apple-converted-space"> </span>Ledger makes this easy to do, using the same period transactions as are used for budgeting.<span class="Apple-converted-space"> </span>An example forecast report can be generated with:<span class="Apple-converted-space"> </span>@example ledger --forecast "T>@{\$-500.00@}" register ^assets ^liabilities @end example<span class="Apple-converted-space"> </span>This report continues outputting postings until the running total is greater than $-500.00.<span class="Apple-converted-space"> </span>A final posting is always output, to show...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Commodities and Currencies</b></p> +<p class="p2">@section Commodities and Currencies</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Ledger makes no assumptions about the commodities you use; it only requires that you specify a commodity.<span class="Apple-converted-space"> </span>The commodity may be any non-numeric string that does not contain a period, comma, forward slash or at-sign.<span class="Apple-converted-space"> </span>It may appear before or after the amount, although it is assumed that symbols appearing before the amount refer to currencies, while non-joined symbols appearing after the amount refer to commodities.<span class="Apple-converted-space"> </span>Here are some valid currency and commodity specifiers:<span class="Apple-converted-space"> </span>@example $20.00 <span class="Apple-converted-space"> </span>;...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Commodity price histories</b></p> +<p class="p2">@subsection Commodity price histories</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Whenever a commodity is purchased using a different commodity (such as a share of common stock using dollars), it establishes a price for that commodity on that day.<span class="Apple-converted-space"> </span>It is also possible, by recording price details in a ledger file, to specify other prices for commodities at any given time.<span class="Apple-converted-space"> </span>Such price transactions might look like those below:<span class="Apple-converted-space"> </span>@smallexample 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 P 2004/06/21 02:18:01 FEQTX $22.49...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Commodity equivalencies</b></p> +<p class="p2">@subsection Commodity equivalencies</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Sometimes a commodity has several forms which are all equivalent.<span class="Apple-converted-space"> </span>An example of this is time.<span class="Apple-converted-space"> </span>Whether tracked in terms of minutes, hours or days, it should be possible to convert between the various forms. Doing this requires the use of commodity equivalencies.<span class="Apple-converted-space"> </span>For example, you might have the following two postings, one which transfers an hour of time into a @samp{Billable} account, and another which decreases the same account by ten minutes.<span class="Apple-converted-space"> </span>The resulting report will indicate that fifty min...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Accounts and Inventories</b></p> +<p class="p2">@section Accounts and Inventories</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Since Ledger's accounts and commodity system is so flexible, you can have accounts that don't really exist, and use commodities that no one else recognizes.<span class="Apple-converted-space"> </span>For example, let's say you are buying and selling various items in EverQuest, and want to keep track of them using a ledger.<span class="Apple-converted-space"> </span>Just add items of whatever quantity you wish into your EverQuest account:<span class="Apple-converted-space"> </span>@smallexample 9/29<span class="Apple-converted-space"> </span>Get some stuff at the Inn <span class="Apple-converted-space"> </span>Places:Black's Tavern <span class="Apple-converted-space"> </span>-3 Apples <span class="Apple-converted-space"> </span>Places:Black's Tavern<span class="Apple-converted-space"> </span>...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Understanding Equity</b></p> +<p class="p2">@section Understanding Equity</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The most confusing transaction in any ledger will be your equity account--- because starting balances can't come out of nowhere.<span class="Apple-converted-space"> </span>When you first start your ledger, you will likely already have money in some of your accounts.<span class="Apple-converted-space"> </span>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?<span class="Apple-converted-space"> </span>The answer: your equity.<span class="Apple-converted-space"> </span>@smallexample 10/2<span class="Apple-converted-space"> </span>Opening Balance <span class="Apple-converted-space"> </span>Assets:Checking <span class="Apple-converted-space"> </span>$100.00 <span class="Apple-converted-space"> </span>Equity:Opening B...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Dealing with Petty Cash</b></p> +<p class="p2">@section Dealing with Petty Cash</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Something that stops many people from keeping a ledger at all is the insanity of tracking small cash expenses.<span class="Apple-converted-space"> </span>They rarely generate a receipt, and there are often a lot of small postings, rather than a few large ones, as with checks.<span class="Apple-converted-space"> </span>One solution is: don't bother.<span class="Apple-converted-space"> </span>Move your spending to a debit card, but in general ignore cash.<span class="Apple-converted-space"> </span>Once you withdraw it from the ATM, mark it as already spent to an @samp{Expenses:Cash} category:<span class="Apple-converted-space"> </span>@smallexample 2004/03/15 ATM <span class="Apple-converted-space"> </span>Expenses:Cash<span class="Apple-converted-space"> </span>$...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Working with multiple funds and accounts</b></p> +<p class="p2">@section Working with multiple funds and accounts</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">There are situations when the accounts you're tracking are different between your clients and the financial institutions where money is kept.<span class="Apple-converted-space"> </span>An example of this is working as the treasurer for a religious institution.<span class="Apple-converted-space"> </span>From the secular point of view, you might be working with three different accounts:<span class="Apple-converted-space"> </span>@itemize @item Checking @item Savings @item Credit Card @end itemize<span class="Apple-converted-space"> </span>From a religious point of view, the community expects to divide its resources into multiple ``funds'', from which it makes pu...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Archiving previous years</b></p> +<p class="p2">@section Archiving previous years</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">After a while, your ledger can get to be pretty large.<span class="Apple-converted-space"> </span>While this will not slow down the ledger program much---it's designed to process ledger files very quickly---things can start to feel ``messy''; and it's a universal complaint that when finances feel messy, people avoid them.<span class="Apple-converted-space"> </span>Thus, archiving the data from previous years into their own files can offer a sense of completion, and freedom from the past.<span class="Apple-converted-space"> </span>But how to best accomplish this with the ledger program?<span class="Apple-converted-space"> </span>There are two commands that make...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Virtual postings</b></p> +<p class="p2">@section Virtual postings</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">A virtual posting is when you, in your mind, see money as moving to a certain place, when in reality that money has not moved at all. There are several scenarios in which this type of tracking comes in handy, and each of them will be discussed in detail.<span class="Apple-converted-space"> </span>To enter a virtual posting, surround the account name in parentheses.<span class="Apple-converted-space"> </span>This form of usage does not need to balance.<span class="Apple-converted-space"> </span>However, if you want to ensure the virtual posting balances with other virtual postings in the same transaction, use square bra...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Automated postings</b></p> +<p class="p2">@section Automated postings</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">As a Bahá'í, I need to compute Huqúqu'lláh whenever I acquire assets. It is similar to tithing for Jews and Christians, or to Zakát for Muslims.<span class="Apple-converted-space"> </span>The epost details of computing Huqúqu'lláh are somewhat complex, but if you have further interest, please consult the Web.<span class="Apple-converted-space"> </span>Ledger makes this otherwise difficult law very easy.<span class="Apple-converted-space"> </span>Just set up an automated posting at the top of your ledger file:<span class="Apple-converted-space"> </span>@smallexample ; This automated transaction will compute Huqúqu'lláh based on this ; journal's postings.<span class="Apple-converted-space"> </span>Any t...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Using Emacs to Keep Your Ledger</b></p> +<p class="p2">@section Using Emacs to Keep Your Ledger</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">In the Ledger tarball is an Emacs module, @file{ledger.el}.<span class="Apple-converted-space"> </span>This module makes the process of keeping a text ledger much easier for Emacs users.<span class="Apple-converted-space"> </span>I recommend putting this at the top of your ledger file:<span class="Apple-converted-space"> </span>@example ; -*-ledger-*- @end example<span class="Apple-converted-space"> </span>And this in your @file{.emacs} file, after copying @file{ledger.el} to your @file{site-lisp} directory:<span class="Apple-converted-space"> </span>@example (load "ledger") @end example<span class="Apple-converted-space"> </span>Now when you edit your ledger file, it will be in @command{ledger-mode}.<span class="Apple-converted-space"> </span>@command{ledger-mode} adds these command...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Using GnuCash to Keep Your Ledger</b></p> +<p class="p2">@section Using GnuCash to Keep Your Ledger</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The Ledger tool is fast and simple, but it offers no custom method for actually editing the ledger.<span class="Apple-converted-space"> </span>It assumes you know how to use a text editor, and like doing so.<span class="Apple-converted-space"> </span>There is, at least, an Emacs mode that makes editing Ledger's data files much easier.<span class="Apple-converted-space"> </span>You are also free to use GnuCash to maintain your ledger, and the Ledger program for querying and reporting on the contents of that ledger.<span class="Apple-converted-space"> </span>It takes a little longer to parse the XML data format that GnuCash uses, but the end result is identical....</p> +<p class="p3"><br></p> +<p class="p1"><b>• Using timeclock to record billable time</b></p> +<p class="p2">@section Using timeclock to record billable time</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The timeclock tool makes it easy to track time events, like clocking into and out of a particular job.<span class="Apple-converted-space"> </span>These events accumulate in a timelog file.<span class="Apple-converted-space"> </span>Each in/out event may have an optional description.<span class="Apple-converted-space"> </span>If the ``in'' description is a ledger account name, these in/out pairs may be viewed as virtual postings, adding time commodities (hours) to that account.<span class="Apple-converted-space"> </span>For example, the command-line version of the timeclock tool could be used to begin a timelog file like:<span class="Apple-converted-space"> </span>@example export TIMELOG=$HOME/.timelog...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Using XML</b></p> +<p class="p2">@section Using XML</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">By default, Ledger uses a human-readable data format, and displays its reports in a manner meant to be read on screen.<span class="Apple-converted-space"> </span>For the purpose of writing tools which use Ledger, however, it is possible to read and display data using XML.<span class="Apple-converted-space"> </span>This section documents that format.<span class="Apple-converted-space"> </span>The general format used for Ledger data is:<span class="Apple-converted-space"> </span>@smallexample <?xml version="1.0"?> <ledger> <span class="Apple-converted-space"> </span><xact>...</xact> <span class="Apple-converted-space"> </span><xact>...</xact> <span class="Apple-converted-space"> </span><xact>...</xact>... </ledger> @end smallexample<span class="Apple-converted-space"> </span>The data stream is enclosed in a @samp{ledger} tag, ...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Random things</b></p> +<p class="p2">@chapter Random things</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Whenever a commodity is exchanged for another in a posting, one of the two is considered @emph{primary}, and the other secondary. Primariness of a commodity is remembered, since the @option{--market} option only renders balances into secondary commodities, never primaries.<span class="Apple-converted-space"> </span>To render primaries, use the @option{--exchange=COMMODITY} option.<span class="Apple-converted-space"> </span>In all of the following examples, the P commodity is considered primary and the S is secondary (the P at the beginning of the line indicates a price-setting ...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Anatomy of a journal file</b></p> +<p class="p2">@chapter Anatomy of a journal file</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Everything begins with a journal file---the anatomy of which is covered in detail in chapter one.<span class="Apple-converted-space"> </span>To review: a @emph{journal} contains one or more @emph{transactions}, each of which refers to two or more @emph{postings}.<span class="Apple-converted-space"> </span>A @emph{posting} specifies that a given @emph{amount} is added to, or subtracted from, an @emph{account}. (@emph{Accounts} may be nested hierarchically by separating the elements using a colon).<span class="Apple-converted-space"> </span>Lastly, an @emph{amount} is a figure representing a given @emph{quantity} of a @e...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Example accounting practices</b></p> +<p class="p2">@chapter Example accounting practices</p> +<p class="p3"><br></p> +<p class="p1"><b>• Generating useful reports</b></p> +<p class="p2">@chapter Generating useful reports</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Once you have a journal file representing a recent history of your finances, the next step is to generate reports in order to give richer meaning to this data.<span class="Apple-converted-space"> </span>For example: Where do you spend your money?<span class="Apple-converted-space"> </span>Do you have enough to cover upcoming expenses?<span class="Apple-converted-space"> </span>Are you creating or losing net worth?<span class="Apple-converted-space"> </span>Are your investment performing well?<span class="Apple-converted-space"> </span>All of these questions can be answered easily with Ledger---if you know how to ask them.<span class="Apple-converted-space"> </span>Preparing complex reports is not a simple task, but neither is it a difficult o...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Value expressions</b></p> +<p class="p2">@chapter Value expressions</p> +<p class="p3"><br></p> +<p class="p1"><b>• Format strings</b></p> +<p class="p2">@chapter Format strings</p> +<p class="p3"><br></p> +<p class="p1"><b>• Scripting in Python</b></p> +<p class="p2">@chapter Scripting in Python</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">Ledger is, at heart, just a sophisticated calculator.<span class="Apple-converted-space"> </span>In addition to summing values within “accounts”, it guarantees that every transaction balances to zero to confirm these values are correctly transferred between accounts.<span class="Apple-converted-space"> </span>In addition to using this calculator from the command-line to generate reports, you may also access it from the Python scripting language, in order to manipulate the figures however you wish.<span class="Apple-converted-space"> </span>The following chapter presents the ideas you will need to know to accomplish thi...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Creating a session</b></p> +<p class="p2">@section Creating a session</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">All interactions with the Ledger library take place in the context of a @var{Session}.<span class="Apple-converted-space"> </span>You may create as many sessions as you like, though typically only one is needed during the lifetime of a scriptAn example where more might be needed is a GUI program that opens multiple Ledger files in different windows, and creates reports for each file separately.<span class="Apple-converted-space"> </span>Ledger provides a pre-initialized session named @var{session}, but others can still be created.<span class="Apple-converted-space"> </span>Creating a session is trivial, but before it m...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Initialize a session</b></p> +<p class="p2">Example of creating a session, reading some journal data, and generating a simplistic report.</p> +<p class="p3"><br></p> +<p class="p1"><b>• The design of Ledger</b></p> +<p class="p2">@chapter The design of Ledger</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The following sections discuss how Ledger is architected, from the ground up, and will show how to use the various parts of the Ledger library from your own scripts.<span class="Apple-converted-space"> </span>Ledger essentially follows five steps in reporting data to the user:<span class="Apple-converted-space"> </span>@enumerate @item Parse journal file into an internal representation @item Perform any implied math within the journal file @item ``Face'' this internal representation as a virtual document @item Apply a series of transforms to the virtual document @item Display t...</p> +<p class="p3"><br></p> +<p class="p1"><b>• Numerics</b></p> +<p class="p2">@section Numerics</p> +<p class="p3"><br></p> +<p class="p1"><b>• Basic amounts</b></p> +<p class="p2">@subsection Basic amounts</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">The most fundamental type in Ledger is the amount, which may or may not have a commodity attached to it.<span class="Apple-converted-space"> </span>First, we'll deal with the bare case, just to show how the amount type works.<span class="Apple-converted-space"> </span>In C++, most all of Ledger's internal types end in @code{_t}; in Python, the same type name is used, but the @code{_t} suffix is dropped.<span class="Apple-converted-space"> </span>Examples of usage in both languages will be presented throughout.<span class="Apple-converted-space"> </span>amount_t commodity_t updater_t datetime_t balance_t balance_pair_t value_t valexpr_t format_t mask_t</p> +<p class="p3"><br></p> +<p class="p1"><b>• Journal Representation</b></p> +<p class="p2">@section Journal Representation</p> +<p class="p3"><br></p> +<p class="p1"><b>• Content</b></p> +<p class="p2">journal_t account_t xact_t post_t parser_t</p> +<p class="p3"><br></p> +<p class="p1"><b>• Reporting</b></p> +<p class="p2">@section Reporting</p> +<p class="p3"><br></p> +<p class="p1"><b>• Terminal Interface</b></p> +<p class="p2">@section Terminal Interface</p> +<p class="p3"><br></p> +<p class="p1"><b>• General Utility</b></p> +<p class="p2">@section General Utility</p> +<p class="p3"><br></p> +<p class="p1"><b>• End Matter</b></p> +<p class="p2">@bye</p> +<p class="p3"><br></p> +</body> +</html> diff --git a/doc/Ledger.scriv/QuickLook/Thumbnail.jpg b/doc/Ledger.scriv/QuickLook/Thumbnail.jpg Binary files differnew file mode 100644 index 00000000..e4764531 --- /dev/null +++ b/doc/Ledger.scriv/QuickLook/Thumbnail.jpg |