A reliable, user-friendly Plain Text Accounting tool with command line, terminal and web interfaces.
Go to file
2009-09-22 11:55:11 +00:00
Commands Hlint: Error: Redundant $ 2009-09-22 11:55:11 +00:00
Ledger Hlint: Error: Redundant $ 2009-09-22 11:55:11 +00:00
tests make tests independent of user's default ledger 2009-12-12 03:00:27 +00:00
tools Hlint: Error: Redundant $ 2009-09-22 11:55:11 +00:00
website docs: more site & docs cleanup 2009-11-21 02:01:28 +00:00
bench.tests update benchmark tests 2009-06-13 17:57:40 +00:00
CONTRIBUTORS docs: more site & docs cleanup 2009-11-21 02:01:28 +00:00
HCAR-HOWTO simplify docs infrastructure 2009-06-02 19:54:45 +00:00
hledger-hcar-200811.tex simplify docs infrastructure 2009-06-02 19:54:45 +00:00
hledger-hcar-200905.tex simplify docs infrastructure 2009-06-02 19:54:45 +00:00
hledger.cabal ui: upgrade to vty 4, fixes non-ascii symbol display (issue #3) 2009-09-03 14:29:34 +00:00
hledger.hs Hlint: Error: Redundant $ 2009-09-22 11:55:11 +00:00
HOME docs: more site & docs cleanup 2009-11-21 02:01:28 +00:00
HOME2 docs: more site & docs cleanup 2009-11-21 02:01:28 +00:00
Ledger.hs haddock 2009-06-02 19:57:18 +00:00
LICENSE add LICENSE 2008-10-01 07:52:07 +00:00
Makefile tools: release process updates 2009-12-12 02:55:59 +00:00
NEWS 0.7 release notes 2009-12-12 03:04:55 +00:00
NOTES notes 2009-06-13 15:43:09 +00:00
Options.hs Hlint: Error: Redundant $ 2009-09-22 11:55:11 +00:00
README docs: add commands section, document convert command 2009-12-01 15:13:27 +00:00
sample.ledger update sample.ledger 2008-12-05 11:09:09 +00:00
sample.timelog sample.timelog 2009-06-02 22:05:50 +00:00
SCREENSHOTS docs: more site & docs cleanup 2009-11-21 02:01:28 +00:00
Setup.hs clean up imports whitespace, minimise explicit intra-app import/export declarations for now 2008-10-10 01:53:39 +00:00
Tests.hs Hlint: Error: Redundant $ 2009-09-22 11:55:11 +00:00
Utils.hs Hlint: Warning: Eta reduce 2009-09-22 15:56:59 +00:00
VERSION update version 2009-12-12 03:05:58 +00:00
Version.hs docs: update version numbering policy 2009-12-10 22:43:23 +00:00

hledger manual
==============

This is the official hledger manual. You may also want to visit
the http://hledger.org home page,
the `hledger for techies`_ page,
and possibly `c++ ledger's manual`_ for background.

Introduction
------------

hledger is an accounting tool for tracking money, time, or other commodities using standard accounting principles.
It was inspired by John Wiegley's "ledger" project, which I used and admired.
I wrote hledger because I wanted to build financial tools in the Haskell
programming language rather than C++.

hledger's most basic function is to generate register and balance reports
from a plain text ledger file, at the command line or via the web or
curses interface. You can use it to, eg,

- track spending and income
- see time reports by day/week/month/project
- get accurate numbers for client billing and tax filing
- find unpaid invoices

hledger aims to help both computer experts and every-day users gain clarity in their finances and time management.
For now though, it is most useful to technically-minded folks who are comfortable with command-line tools.

hledger is copyright (c) 2007-2009 Simon Michael <simon@joyful.com> and
contributors and released as Free Software under GPL version 3 or later.

User Guide
----------

Installing
..........

hledger works on all major platforms. One of these pre-built binaries_ might work for you.

If not, please report the problem, then install the `Haskell Platform`_ and type::

 cabal update
 cabal install hledger [-fvty] [-fhapps]

The optional -f flags will download more stuff and include the "ui" and
"web" commands respectively. -fvty will not work on microsoft windows.

Basic usage
...........

hledger looks for your ledger file at ~/.ledger by default. To use a
different file, specify it with the LEDGER environment variable or -f
option (which may be - for standard input). Basic usage is::

 hledger [OPTIONS] [COMMAND [PATTERNS]]

COMMAND is one of balance, print, register, ui, web, test (defaulting to
balance). PATTERNS are zero or more regular expressions used to filter by
account name or transaction description.  Here are some commands to try::

 export LEDGER=sample.ledger
 hledger --help                        # show usage & options
 hledger balance                       # all accounts with aggregated balances
 hledger bal --depth 1                 # only top-level accounts
 hledger register                      # transaction register
 hledger reg income                    # transactions to/from an income account
 hledger reg checking                  # checking transactions
 hledger reg desc:shop                 # transactions with shop in the description
 hledger histogram                     # transactions per day, or other interval
 hledger ui                            # curses ui, if installed with -fvty
 hledger web                           # web ui, if installed with -fhapps
 hledger -f new.ledger add             # record transactions from the command line

Time reporting
..............

hledger will also read timelog files in timeclock.el format.  If you
invoke hledger via a symlink or copy named "hours", it looks for your
timelog file (~/.timelog or $TIMELOG) by default.::

 hours [OPTIONS] [COMMAND [PATTERNS]]

Timelog entries look like this::

 i 2009/03/31 22:21:45 some:project
 o 2009/04/01 02:00:34

The clockin description is treated as an account name. Here are some
queries to try::

 ln -s `which hledger` ~/bin/hours            # set up "hours" in your path
 export TIMELOG=sample.timelog
 hours                                        # show all time balances
 hours -p 'last week'                         # last week
 hours -p thismonth                           # the space is optional
 hours -p 'from 1/15' register project        # project sessions since jan 15
 hours -p 'weekly' reg --depth 1 -E           # weekly time summary

Reference
---------

Feature overview
................

This version of hledger mimics a subset of ledger 3.x, and adds some
features of its own. We currently support regular ledger entries, timelog
entries, multiple commodities, virtual transactions, account and
description filtering, and these commands and options::

   Commands:
   balance  [REGEXP]...   show balance totals for matching accounts
   register [REGEXP]...   show register of matching transactions
   print    [REGEXP]...   print all matching entries

   Basic options:
   -h, --help             show summarized help
   -f, --file FILE        read ledger data from FILE
 
   Report filtering:
   -b, --begin DATE       report on entries on or after this date
   -e, --end DATE         report on entries prior to this date
   -p, --period EXPR      report on entries during the specified period
                          and/or with the specified reporting interval
   -C, --cleared          report only on cleared entries
   -R, --real             report only on real (non-virtual) transactions
 
   Output customization:
   -B, --basis, --cost    report cost of commodities
   -d, --display EXPR     display only transactions matching EXPR (limited support)
   -E, --empty            show empty/zero things which are normally elided
   --no-total             balance report: hide the final total
   -W, --weekly           register report: show weekly summary
   -M, --monthly          register report: show monthly summary
   -Y, --yearly           register report: show yearly summary

   Misc:
   -V, --version          show version information
   -v, --verbose          show verbose test output
   --debug                show some debug output 
   --debug-no-ui          run ui commands with no output

We handle (almost) the full period expression syntax, and very limited
display expressions consisting of a simple date predicate. Also the
following new commands are supported::

   add                    prompt for new transactions and add them to the ledger
   convert                read CSV bank data and display in ledger format
   histogram              show a barchart of transactions per day or other interval
   ui                     run a simple text-based UI (only on unix platforms)
   web                    run a simple web-based UI
   stats                  show various statistics for a ledger
   test                   run self-tests

Commands
........

Convert
,,,,,,,

The convert command converts CSV (comma-separated value) files downloaded
from a bank into ledger format. Doing a bulk import in this way can be a
easier than entering each transaction by hand. The downside is you no
longer have your own data with which to detect errors by the bank.

Usage is different from the other commands, typically it looks like this::

 hledger convert FILE.csv BASEACCOUNT FILE.rules >FILE.ledger
 (review FILE.ledger, then copy and paste into main ledger)

Ie convert the csv data and save the output into a similarly named ledger file.
(It's not required, but convenient to use the same base filename for the
csv, rules and output files as above.)

BASEACCOUNT is the source account for these transactions, eg
``assets:bank:checking``.

FILE.rules contains some rules to help convert the data. Here's an example::

 0,-,4,1

 SPECTRUM
 expenses:health:gym

 ITUNES
 BLKBSTR=BLOCKBUSTER
 expenses:entertainment

 (TO|FROM) SAVINGS
 assets:bank:savings

It must contain:

- paragraphs separated by one blank line.

- The first paragraph is a single line of four comma-separated fields,
  which are numbers indicating the (0-based) csv field positions
  corresponding to the transaction date, code/number, description, and amount.
  If a field does not exist in the csv, use - to specify a default value.

- Other paragraphs consist of one or more regular expression patterns, one
  per line, followed by a line specifying the account to use when a
  transaction's description matches any of these patterns. Patterns may
  optionally have a replacement pattern specified after =, otherwise the
  matching part is used.


Smart dates
...........

hledger accepts "smart dates" in most places a date can be used, such as:
transaction dates, effective dates, -b and -e options, and `period
expressions <#period-expressions>`_. Here are some valid hledger dates:

- 2009/1/1, 2009/01/01, 2009-1-1, 2009.1.1, 2009/1, 2009 (january 1, 2009)
- 1/1, january, jan, this year (january 1, this year)
- next year (january 1, next year)
- this month (the 1st of the current month)
- this week (the most recent monday)
- last week (the monday of the week before this one)
- today, yesterday, tomorrow

Period expressions
..................

hledger supports flexible "period expressions" with the ``-p/--period``
option to select transactions within a period of time (like 2009) and/or
with a reporting interval (like weekly). hledger period expressions are
similar but not identical to c++ ledger's.

Here is a basic period expression specifying the first quarter of 2009
(start date is always included, end date is always excluded)::

 -p "from 2009/1/1 to 2009/4/1"

Keywords like "from" and "to" are optional, and so are the spaces. Just
don't run two dates together::

 -p2009/1/1to2009/4/1
 -p"2009/1/1 2009/4/1"

Dates are `smart dates <#smart-dates>`_, so if the current year is 2009, the above can also
be written as::

 -p "1/1 to 4/1"
 -p "january to apr"
 -p "this year to 4/1"

If you specify only one date, the missing start or end date will be the
earliest or latest transaction in your ledger data::

 -p "from 2009/1/1"  (everything after january 1, 2009)
 -p "from 2009/1"    (the same)
 -p "from 2009"      (the same)
 -p "to 2009"        (everything before january 1, 2009)

A single date with no "from" or "to" defines both the start and end date like so::

 -p "2009"           (the year 2009;    equivalent to "2009/1/1 to 2010/1/1")
 -p "2009/1"         (the month of jan; equivalent to "2009/1/1 to 2009/2/1")
 -p "2009/1/1"       (just that day;    equivalent to "2009/1/1 to 2009/1/2")

You can also specify a reporting interval, which causes the "register"
command to summarise the transactions in each interval. It goes before the
dates, and can be: "daily", "weekly", "monthly", "quarterly", or
"yearly". An "in" keyword is optional, and so are the dates::

 -p "weekly from 2009/1/1 to 2009/4/1"
 -p "monthly in 2008"
 -p "monthly from 2008"
 -p "quarterly"

Display expressions
...................

A display expression with the ``-d/--display`` option selects which
transactions will be displayed (unlike a `period expression
<#period-expressions>`_, which selects the transactions to be used for
calculation).

hledger currently supports a very small subset of c++ ledger's display
expressions, namely: transactions before or after a date. This is useful
for displaying your recent check register with an accurate running total.
Note the use of >= here to include the first of the month::

 hledger register -d "d>=[this month]"

Differences from c++ ledger
---------------------------

hledger is written in the Haskell programming language, which supports a
coding style known as pure functional programming. This can help
programmers to produce more robust software and write fewer lines of code.

Features not supported
......................

ledger features not currently supported include: modifier and periodic
entries, and the following options and commands::

   Basic options:
   -o, --output FILE      write output to FILE
   -i, --init-file FILE   initialize ledger using FILE (default: ~/.ledgerrc)
   -a, --account NAME     use NAME for the default account (useful with QIF)
 
   Report filtering:
   -c, --current          show only current and past entries (not future)
       --period-sort EXPR sort each report period's entries by EXPR
   -U, --uncleared        consider only uncleared transactions
   -L, --actual           consider only actual (non-automated) transactions
   -r, --related          calculate report using related transactions
       --budget           generate budget entries based on periodic entries
       --add-budget       show all transactions plus the budget
       --unbudgeted       show only unbudgeted transactions
       --forecast EXPR    generate forecast entries while EXPR is true
   -l, --limit EXPR       calculate only transactions matching EXPR
   -t, --amount EXPR      use EXPR to calculate the displayed amount
   -T, --total EXPR       use EXPR to calculate the displayed total
 
   Output customization:
   -n, --collapse         Only show totals in the top-most accounts.
   -s, --subtotal         other: show subtotals
   -P, --by-payee         show summarized totals by payee
   -x, --comm-as-payee    set commodity name as the payee, for reporting
       --dow              show a days-of-the-week report
   -S, --sort EXPR        sort report according to the value expression EXPR
   -w, --wide             for the default register report, use 132 columns
       --head COUNT       show only the first COUNT entries (negative inverts)
       --tail COUNT       show only the last COUNT entries (negative inverts)
       --pager PAGER      send all output through the given PAGER program
   -A, --average          report average transaction amount
   -D, --deviation        report deviation from the average
   -%, --percentage       report balance totals as a percentile of the parent
       --totals           in the "xml" report, include running total
   -j, --amount-data      print only raw amount data (useful for scripting)
   -J, --total-data       print only raw total data
   -y, --date-format STR  use STR as the date format (default: %Y/%m/%d)
   -F, --format STR       use STR as the format; for each report type, use:
       --balance-format      --register-format       --print-format
       --plot-amount-format  --plot-total-format     --equity-format
       --prices-format       --wide-register-format
 
   Commodity reporting:
       --price-db FILE    sets the price database to FILE (def: ~/.pricedb)
   -L, --price-exp MINS   download quotes only if newer than MINS (def: 1440)
   -Q, --download         download price information when needed
   -O, --quantity         report commodity totals (this is the default)
   -V, --market           report last known market value
   -g, --performance      report gain/loss for each displayed transaction
   -G, --gain             report net gain/loss
 
   Commands:
   xml      [REGEXP]...   print matching entries in XML format
   equity   [REGEXP]...   output equity entries for matching accounts
   prices   [REGEXP]...   display price history for matching commodities
   entry DATE PAYEE AMT   output a derived entry, based on the arguments

Other differences
.................

* hledger calls the "note" field "description"
* hledger recognises description and negative patterns by  "desc:" and "not:" prefixes,
  unlike ledger 3's free-form parser
* hledger keeps differently-priced amounts of the same commodity separate
* hledger doesn't require a space before command-line option values, eg: -f-
* hledger's weekly reporting intervals always start on mondays
* hledger shows start and end dates of the intervals requested, not just the span containing data
* hledger period expressions don't support "biweekly", "bimonthly", or "every N days/weeks/..." 
* hledger always shows timelog balances in hours
* hledger splits multi-day timelog sessions at midnight
* hledger register report always sorts transactions by date
* hledger doesn't show description comments as part of the description
* hledger print puts a blank line after a transaction, not before it
* hledger doesn't print trailing spaces after amount-elided postings


.. _hledger for techies:  HOME2.html
.. _c++ ledger's manual:  http://joyful.com/repos/ledger/doc/ledger.html
.. _binaries:             http://hledger.org/binaries/
.. _Haskell Platform:     http://hackage.haskell.org/platform/