Module documentation for 0.26
lightweight, portable, dependable accounting tools
hledger is a computer program for easily tracking money, time, or other commodities, on unix, mac and windows (and web-capable mobile devices, to some extent).
It is first a command-line tool, but there are also curses-style and web interfaces, and a Haskell library (http://hackage.haskell.org/package/hledger-lib) for building your own programs and scripts (hledger is written in Haskell). hledger was inspired by and is largely compatible with Ledger. hledger is free software available under the GNU General Public License v3+.
hledger aims to help both computer experts and regular folks to gain clarity and control in their finances and time management, but currently it is a bit more suited to techies. I use it every day to:
- track spending and income
- see time reports by day/week/month/project
- get accurate numbers for client billing and tax filing
- track invoices
Though limited in features, hledger is lightweight, usable and reliable. For some, it is a simpler, less distracting, more future-proof alternative to Quicken or GnuCash.
For more, see http://hledger.org.
Support us with a monthly donation and help us continue our activities. [Become a backer]
Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]
See also the project change log.
# 1.4 (2017/9/30)
* cli: a @FILE argument reads flags & args from FILE, one per line
* cli: reorganized commands list, added some new command aliases:
print: p, txns
* cli: accept -NUM as a shortcut for --depth=NUM (eg: -2)
* cli: improve command-line help for --date2 (#604)
* cli: make --help and -h the same, drop --man and --info for now (#579)
* help: offers multiple formats, accepts topic substrings.
The separate info/man commands have been dropped. help now
chooses an appropriate documentation format as follows:
- it uses info if available,
- otherwise man if available,
- otherwise $PAGER if defined,
- otherwise less if available,
- otherwise it prints on stdout
- (and it always prints on stdout when piped).
You can override this with the `--info`/`--man`/`--pager`/`--cat` flags.
* bal/bs/cf/is: --sort-amount/-S sorts by largest amount instead of
* bs/cf/is: support --output-file and --output-format=txt|csv
The CSV output should be reasonably ok for dragging into a
spreadsheet and reformatting.
* bal/bs/cf/is: consistent double space between columns, consistent
single final blank line. Previously, amounts wider than the column
headings would be separated by only a single space.
* bs/is: don't let an empty subreport disable the grand totals (fixes #588)
* cf: exclude asset accounts with ":fixed" in their name (Christian G. Warden, Simon Michael, #584)
* new balancesheetequity command: like balancesheet but also shows
equity accounts (Nicholas Niro)
* new import command: adds new transactions seen in one or more input
files to the main journal file
* print: --new shows only transactions added since last time
(saves state in .latest.JOURNALFILE file)
* new tags command: lists tags in matched transactions
* most addons formerly shipped in bin/ are now builtin commands. These
include: check-dates, check-dupes, equity, prices, print-unique,
* refactor: new Commands module and subdirectory.
Builtin commands are now gathered more tightly in a single module,
Hledger.Cli.Commands, facilitating change. The legacy "convert"
command has been dropped.
* refactor: BalanceView -> CompoundBalanceCommand
* deps: drop support for directory < 1.2
* deps: allow ansi-terminal 0.7
* deps: drop oldtime flag, require time 1.5+
* deps: simplify shakespeare bounds
* deps: remove ghc < 7.6 support
# 1.3.1 (2017/8/25)
* bs/is: don't let an empty subreport disable the grand totals (#588)
* allow megaparsec 6 (#594)
* allow megaparsec-6.1 (Hans-Peter Deifel)
* restore upper bounds on hledger packages
# 1.3 (2017/6/30)
The "uncleared" transaction/posting status, and associated UI flags
and keys, have been renamed to "unmarked" to remove ambiguity and
confusion. This means that we have dropped the `--uncleared` flag,
and our `-U` flag now matches only unmarked things and not pending
ones. See the issue and linked mail list discussion for more
Also the -P short flag has been added for --pending, and the -U/-P/-C
flags can be combined.
bs/is: fix "Ratio has zero denominator" error (#535)
bs/is/cf: fix --flat (#552) (Justin Le, Simon Michael)
bal/bs/is/cf: show negative amounts in red (Simon Michael, Justin Le).
These commands now shows negative amounts in red, when hledger detects
that ANSI codes are supported, (ie when TERM is not "dumb" and stdout
is not being redirected or piped).
print: show pending mark on postings (fixes #563).
A pending mark on postings is now displayed, just like a cleared mark.
Also there will now be a space between the mark and account name.
print: amounts are now better aligned, eg when there are posting
status marks or virtual postings
# 1.2 (2017/3/31)
"hledger" and "hledger -h" now print a better organised commands list
and general usage message respectively (#297).
The common reporting flags can now be used anywhere on the command line.
Fixed deduplication of addons in commands list.
Fixed ugly stack traces in command line parse error messages.
The -V/--value flag is now a global report flag, so it works with
balance, print, register, balancesheet, incomestatement, cashflow,
etc. (Justin Le)
The `--pivot` global reporting option replaces all account names with
the value of some other field or tag. It has been improved, eg:
- we don't add the field/tag name name as a prefix
- when pivoting on a tag, if the tag is missing we show a blank
(rather than showing mixed tag values and account names)
- a pipe character delimiter may be used in descriptions to get a more accurate
and useful payee report (`hledger balance --pivot payee`)
move add-ons and example scripts to bin/,
convert to stack scripts,
add a build script to install all deps,
add some functional tests,
test add-ons with Travis CI,
add installation docs to download page.
all addons now contain their own documentation. Most of them (all but
hledger-budget) use a new reduced-boilerplate declaration format
and can show short (-h) and long (--help) command line help.
(Long help is declared with pre and postambles to the generated
options help, short help is that truncated at the start of the hledger
`hledger` now shows a cleaner list of addon commands, showing only the
compiled version of an addon when both source and compiled versions
are in $PATH. (Addons with .exe extension or no extension are
considered compiled. Modification time is not checked, ie, an old
compiled addon will override a newer source version. If there are
three or more versions of an addon, all are shown. )
New addons added/included:
- autosync - example symlink to ledger-autosync
- budget - experimental budget reporting command supporting Ledger-like periodic transactions and automated transactions (Mykola Orliuk)
- chart - pie-chart-generating prototype, a repackaging of the old hledger-chart tool
- check - more powerful balance assertions (Michael Walker)
- check-dupes - find accounts sharing the same leaf name (Stefano Rodighiero)
- prices - show all market price records (Mykola Orliuk)
- register-match - a helper for ledger-autosync's deduplication, finds best match for a transaction description
The equity command now always generates a valid journal transaction,
handles prices better, and adds balance assertions (Mykola Orliuk).
The rewrite command is more robust and powerful (Mykola Orliuk):
- in addition to command-line rewrite options, it understands rewrite rules
defined in the journal, similar to Ledger's automated transactions (#99).
- it can generate diff output, allowing easier review of the proposed
changes, and safe modification of original journal files (preserving
file-level comments and directives). Eg:
hledger-rewrite --diff Agency --add-posting 'Expenses:Taxes *0.17' | patch
- rewrites can affect multiple postings in a transaction, not just one.
- posting-specific dates are handled better
A new --pretty-tables option uses unicode characters for rendering
table borders in multicolumn reports (#522) (Moritz Kiefer)
These commands are now more powerful, able to show multicolumn reports
and generally having the same features as the balance command. (Justin Le)
balancesheet has always ignored a begin date specified with a `-b` or
`-p` option; now it also ignores a begin date specified with a `date:`
query. (Related discussion at #531)
The output of print is now always a valid journal (fixes #465) (Mykola Orliuk).
print now tries to preserves the format of implicit/explicit balancing
amounts and prices, by default. To print with all amounts explicit,
use the new `--explicit/-x` flag (fixes #442). (Mykola Orliuk)
Don't lose the commodity of zero amounts/zero balance assertions (fixes #475) (Mykola Orliuk)
Fix a regression in the readability of option parsing errors (#478) (Hans-Peter Deifel)
Fix an example in Cli/Main.hs (Steven R. Baker)
Allow megaparsec 5.2 (#503)
# 1.1 (2016/12/31)
- with -V, don't ignore market prices in the future (#453, #403)
- with -V and multiple same-date market prices, use the last parsed not the highest price (#403)
- fix non-existent "oldtime" dependency (#431)
- extra/hledger-equity.hs now generates valid journal format when there are multiple commodities
# 1.0.1 (2016/10/27)
- allow megaparsec 5.0 or 5.1
- fix benchmark build failure (#423)
# 1.0 (2016/10/26)
- suggest only one commodity at a time as default amount (#383)
(since we currently can't input more than one at a time)
- added --change flag for consistency
- -H/--historical now also affects single-column balance reports with a start date (#392).
This has the same effect as just omitting the start date, but adds consistency.
- in CSV output, render amounts in one-line format (#336)
- fix an infinite loop (#393)
- in CSV output, fix and rename the transaction id field
- fix a sorting regression with --date2 (#326)
- --average/-A is now affected by --historical/-H
- added --cumulative flag for consistency
- in CSV output, include the transaction id and rename the total field (#391)
- fixed an issue with ordering of include files
- --pivot option added, groups postings by tag instead of account (#323) (Malte Brandy)
- --anon option added, obfuscates account names and descriptions (#265) (Brian Scott)
(Only affects the hledger tool, for now.)
- try to clarify balance/register's various report modes,
kinds of "balance" displayed, and related options and language.
- with multiple --change/--cumulative/--historical flags, use the last one instead of complaining
- don't add the "d" suffix when displaying day periods
- stack-ify extra/hledger-rewrite.hs
- Regular expression account aliases are now fast enough that you can
use lots of them without slowing things down. They now take
O(aliases x accounts) time, instead of O(aliases x transactions);
also, regular expressions are no longer recompiled unnecessarily.
- The hledger packages now have man pages, based on the current user
manual, thanks to the mighty pandoc (#282).
- Dates must now begin with a digit (not /, eg).
- The comment directive longer requires an end comment, and will
extend to the end of the file(s) without it.
- Output (balance reports, register reports, print output etc.)
containing wide characters, eg chinese/japanese/korean characters,
should now align correctly, when viewed in apps and fonts that show
wide characters as double width (#242).
- The argument for --depth or depth: must now be positive.
- Journal entries are now written with all amounts explicit, to avoid
losing price info (#283).
- Fixed a bug which sometimes (when the same letter pair was repeated)
caused it not to pick the most similar past transaction for defaults.
- There is now a -V/--value flag to report current market value (as in Ledger).
It converts all reported amounts using their "default market price".
"Market price" is the new name for "historical prices", defined with the P directive.
The default market price for a commodity is the most recent one found in the journal on or before the report end date.
Unlike Ledger, hledger's -V uses only the market prices recorded
with P directives; it does not use the "transaction prices"
recorded as part of posting amounts (which are used by -B/--cost).
Also, using both -B and -V at the same time is supported.
- Fixed a bug in amount normalization which caused amount styles
(commodity symbol placement, decimal point character, etc.) to be
lost in certain cases (#230, #276).
- The balance command's --format option can now adjust the rendering
style of multi-commodity amounts, if you begin the format string
with one of:
%_ - renders amounts on multiple lines, bottom-aligned (the default)
%^ - renders amounts on multiple lines, top-aligned
%, - renders amounts on one line, comma-separated
- The balance report's final total (and the line above it) now adapt
themselves to a custom --format.
- The --match option prints the journal entry that best matches a
description (ie whose description field is most similar to the value
given, and if there are several equally similar, the most recent).
This was originally an add-on I used to guess account names for
ledger-autosync. It's nice for quickly looking up a recent
transaction from a guessed or partial description.
- print now always right-aligns the amounts in an entry, even when
they are wider than 12 characters. (If there is a price, it's
considered part of the amount for right-alignment.)
- Amount columns now resize automatically, using more space if it's
needed and available.
- Account aliases are once again non-regular-expression-based, by default. (#252)
The regex account aliases added in 0.24 trip up people switching between
hledger and Ledger. (Also they are currently slow).
This change makes the old non-regex aliases the default; they are
unsurprising, useful, and pretty close in functionality to Ledger's.
The new regex aliases are still available; they must be enclosed
in forward slashes. (Ledger effectively ignores these.)
- We now parse, and also print, journal entries with no postings, as
proposed on the mail lists. These are not well-formed General
Journal entries/transactions, but here is my rationale:
- Ledger and beancount parse them
- if they are parsed, they should be printed
- they provide a convenient way to record (and report) non-transaction events
- they permit more gradual introduction and learning of the concepts.
So eg a beginner can keep a simple journal before learning about accounts and postings.
- Trailing whitespace after a `comment` directive is now ignored.
- The -f/file option may now be used multiple times.
This is equivalent to concatenating the input files before running hledger.
The add command adds entries to the first file specified.
- real: (no argument) is now a synonym for real:1
- tag: now matches tag names with a regular expression, like most other queries
- empty: is no longer supported, as it overlaps a bit confusingly with
amt:0. The --empty flag is still available.
- You can now match on pending status (#250)
A transaction/posting status of ! (pending) was effectively equivalent
to * (cleared). Now it's a separate state, not matched by --cleared.
The new Ledger-compatible --pending flag matches it, and so does
The relevant search query terms are now status:*, status:! and
status: (the old status:1 and status:0 spellings are deprecated).
Since we interpret --uncleared and status: as "any state except cleared",
it's not currently possible to match things which are neither cleared
- activity no longer excludes 0-amount postings by default.
- Don't show quotes around the journal file path in the "Creating..."
message, for consistency with the subsequent "Adding..." message.
- Accounts beginning with "debt" or now also recognised as liabilities.
- We now limit the display precision of inferred prices. (#262)
When a transaction posts to two commodities without specifying the
conversion price, we generate a price which makes it balance (cf
http://hledger.org/manual.html#prices). The print command showed
this with full precision (so that manual calculations with the
displayed numbers would look right), but this sometimes meant we
showed 255 digits (when there are multiple postings in the
commodity being priced, and the averaged unit price is an
irrational number). In this case we now set the price's display
precision to the sum of the (max) display precisions of the
commodities involved. An example:
hledgerdev -f- print
c C 10.00
c C 11.00
d D -320.00
c C 10.00 @ D 15.2381
c C 11.00 @ D 15.2381
d D -320.00
There might still be cases where this will show more price decimal
places than necessary.
- We now show inferred unit prices with at least 2 decimal places.
When inferring prices, if the commodities involved have low
display precisions, we don't do a good job of rendering
accurate-looking unit prices. Eg if the journal doesn't use any
decimal places, any inferred unit prices are also displayed with
no decimal places, which makes them look wrong to the user. Now,
we always give inferred unit prices a minimum display precision of
2, which helps a bit.
- Postings with no amounts could give a runtime error in some obscure case, now fixed.
- stats now supports -o/--outputfile, like register/balance/print.
- An O(n^2) performance slowdown has been fixed, it's now much faster on large journals.
| || 0.25 | 0.26 |
| -f data/100x100x10.journal stats || 0.10 | 0.16 |
| -f data/1000x1000x10.journal stats || 0.45 | 0.21 |
| -f data/10000x1000x10.journal stats || 58.92 | 2.16 |
- The June 30 day span was not being rendered correctly; fixed. (#272)
- The bench script invoked by "cabal bench" or "stack bench" now runs
some simple benchmarks.
You can get more accurate benchmark times by running with --criterion.
This will usually give much the same numbers and takes much longer.
Or with --simplebench, it benchmarks whatever commands are
configured in bench/default.bench. This mode uses the first
"hledger" executable in $PATH.
- The deprecated shakespeare-text dependency has been removed more thoroughly.
- timelog: support the description field (#247)
- GHC 7.10 compatibility (#239)
- build with terminfo support on POSIX systems by default
On non-windows systems, we now build with terminfo support by
default, useful for detecting terminal width and other things.
This requires the C curses dev libaries, which makes POSIX
installation slightly harder; if it causes problems you can
disable terminfo support with the new `curses` cabal flag, eg:
cabal install -f-curses ... (or cabal might try this
automatically, I'm not sure).
- register: use the full terminal width, respect COLUMNS, allow column width adjustment
On POSIX systems, register now uses the full terminal width by
default. Specifically, the output width is set from:
1. a --width option
2. or a COLUMNS environment variable (NB: not the same as a bash shell var)
3. or on POSIX (non-windows) systems, the current terminal width
4. or the default, 80 characters.
Also, register's --width option now accepts an optional
description column width following the overall width (--width
WIDTH[,DESCWIDTH]). This also sets the account column width, since
the available space (WIDTH-41) is divided up between these two
columns. Here's a diagram:
<--------------------------------- width (W) ---------------------------------->
date (10) description (D) account (W-41-D) amount (12) balance (12)
DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA
$ hledger reg # use terminal width on posix
$ hledger reg -w 100 # width 100, equal description/account widths
$ hledger reg -w 100,40 # width 100, wider description
$ hledger reg -w $COLUMNS,100 # terminal width and set description width
- balance: new -T/--row-total and -A/--average options
In multicolumn balance reports, -T/--row-total now shows a row totals
column and -A/--average shows a row averages column.
This helps eg to see monthly average expenses (hledger bal ^expenses -MA).
NB our use of -T deviates from Ledger's UI, where -T sets a custom
final total expression.
- balance: -N is now short for --no-total
- balance: fix partially-visible totals row with --no-total
A periodic (not using --cumulative or --historical) balance report
with --no-total now hides the totals row properly.
- journal, csv: comment lines can also start with *
As in Ledger. This means you can embed emacs org/outline-mode nodes in
your journal file and manipulate it like an outline.
- journal: fix balance accumulation across assertions (#195)
A sequence of balance assertions asserting first one commodity, then
another, then the first again, was not working.
- timelog: show hours with two decimal places instead of one (#237)
- in weekly reports, simplify week 52's heading like the others
- disallow trailing garbage in a number of parsers
Trailing garbage is no longer ignored when parsing the following:
balance --format option, register --width option, hledger-rewrite
options, hledger add's inputs, CSV amounts, posting amounts,
posting dates in tags.
- allow utf8-string-1 (fpco/stackage/#426)
- fix redundant compilation when cabal installing the hledger packages
- switch to Decimal for representing amounts (#118)
- report interval headings (eg in balance, register reports) are shown
compactly when possible
- general speedups
- detect decimal point and digit groups more robustly (#196)
- check that transaction dates are followed by whitespace or newline
- check that dates use a consistent separator character
- balance assertions now are specific to a single commodity, like
- support multi-line comments using "comment", "end comment"
directives, like Ledger
- reading CSV data from stdin now works better
- the rules file include directive is now relative to the current
file's directory (#198)
- the original order of same-day transactions is now usually preserved
(if the records appear to be in reverse date order, we reverse them
before finally sorting by transaction date)
- CSV output is now built in to the balance, print, and register
commands, controlled by -O/--output-format (and -o/--output-file,
- the --width and --debug options now require their argument (#149)
- when an option is repeated, the last value takes precedence (#219).
This is helpful eg for customising your reporting command aliases on
- smart dates (used in -p/-b/-e/date:/date2:) now must use a
consistent separator character, and must be parseable to the end
- output destination and format selection is now built in to the
balance, print and register commands, controlled by -o/--output-file
and -O/--output-format options. Notes:
- -o - means stdout
- an output file name suffix matching a supported format will also
set the output format, unless overridden by --output-format
- commands' supported output formats are listed in their
command-line help. Two formats are currently available:
txt (the default) and csv.
- balance assertions can be disabled with --ignore-assertions
- all matching account aliases are now applied, not just one directive
and one option
- account aliases now match by case insensitive regular expressions
matching anywhere in the account name
- account aliases can replace multiple occurrences of the pattern
within an account name
- an account alias replacement pattern can reference matched groups
- date:/date2: with a malformed date now reports an error instead of
- amt: now supports >= or <=
- clarify status: docs and behaviour; "*" is no longer a synonym for
"1" (fixes #227)
- fix: in tree mode, --drop is ignored instead of showing empty account names
- a depth limit of 0 now shows summary items with account name "...",
instead of an empty report (#206)
- in multicolumn balance reports, -E now also shows posting-less
accounts with a non-zero balance during the period (in addition to
showing leading & trailing empty columns)
- in multicolumn reports, multi-commodity amounts are rendered on one
line for better layout (#186)
- multicolumn reports' title now includes the report span
- runs faster with large output
- supports date2:, and date:/date2: combined with --date2, better (fixes
#201, #221, #222)
- a depth limit of 0 now shows summary items (see balance)
- -A/--average now implies -E/--empty
- postings with multi-commodity amounts are now top-aligned, like
- hledger-equity: fix end date in title; print closing entry too
- hledger-check-dates: added
- allow text 1.2+ (#207)
- register: also fix date sorting of postings (#184)
- register: fix a refactoring-related regression that the tests
missed: if transactions were not ordered by date in the journal,
register could include postings before the report start date in the
- add: don't apply a default commodity to amounts on entry (#138)
- cli: options before the add-on command name are now also passed to it (#182)
- csv: allow the first name in a fields list to be empty (#178)
- csv: don't validate fields count in skipped lines (#177)
- A # (hash) in column 0 is now also supported for starting a top-level journal comment, like Ledger.
- The "too many missing amounts" error now reminds about the 2-space rule.
- Fix: . (period) is no longer parsed as a valid amount.
- Fix: default commodity directives no longer limit the maximum display precision (#169).
- Fix: + before an amount is no longer parsed as part of the commodity (#181).
- Command-line help cleanups, layout improvements.
- Descriptions are shown for known add-ons in the command list.
- Command aliases have been simplified.
- Add-ons can now have any of these file extensions:
none, hs, lhs, pl, py, rb, rkt, sh, bat, com, exe.
- Add-ons are displayed without their file extensions when possible.
- Add-ons with the same name as a built-in command or alias are ignored.
- Fix: add-on detection and invocation now works on windows.
- Fix: add-ons with digits in the name are now found.
- Fix: add-on arguments containing a single quote now work.
- Fix: when -- is used to hide add-on options from the main program,
it is no longer passed through as an add-on argument.
- The currency/commodity query prefix (sym:) has been renamed to cur:.
- Currency/commodity queries are applied more strongly in register and
balance reports, filtering out unwanted currencies entirely. Eg
hledger balance cur:'\$' now reports only the dollar amounts even if
there are multi-currency transactions or postings.
- Amount queries like amt:N, amt:<N and amt:>N, where N is not 0, now do an unsigned
comparison of the amount and N. That is, they compare the absolute magnitude.
To do a signed comparison instead, write N with its sign (eg amt:+N, amt:<+N, amt:>-N).
- Fix: amount queries no longer give false positives on multi-commodity amounts.
- An accounts command has been added, similar to Ledger's, for listing account names
in flat or hierarchical mode.
- Tab completion now works at all prompts, and will insert the default if the input area is empty.
- Account and amount defaults are more robust and useful.
- Transactions may also be completed by the enter key, when there are no more default postings.
- Input prompts are displayed in a different colour when supported.
- Balance reports in flat mode now always show exclusive (subaccount-excluding) balances.
- Balance reports in flat mode with --depth now aggregate deeper accounts at the depth limit instead of excluding them.
- Multicolumn reports in flat mode now support --drop.
- Multicolumn balance reports can now show the account hierarchy with --tree.
- Multicolumn report start/end dates are adjusted to encompass the displayed
report periods, so the first and last periods are "full" and comparable to the others.
- Fix: zero-balance leaf accounts below a non-zero-balance parent are no longer always shown (#170).
- Fix: multicolumn reports now support --date2 (cf #174).
balancesheet, cashflow, incomestatement:
- These commands now support --flat and --drop.
- Tag queries (tag:) will now match a transaction if any of its postings match.
- The --display option has been dropped. To see an accurate running total which
includes the prior starting balance, use --historical/-H (like balance).
- With a report interval, report start/end dates are adjusted to encompass the displayed
periods, so the first and last periods are "full" and comparable to the others.
- Fix: --date2 now works with report intervals (fixes #174).
- Default report dates now derive from the secondary dates when --date2 is in effect.
- Default report dates now notice any posting dates outside the transaction dates' span.
- Debug output improvements.
- New add-on example: extra/hledger-rewrite.hs, adds postings to matched entries.
- Compatible with GHC 7.2 (#155) - GHC 7.8, shakespeare 2
- display years before 1000 with four digits, not three
- avoid pretty-show to build with GHC < 7.4
- allow text 1.1, drop data-pprint to build with GHC 7.8.x
0.22.1 (2014/1/6) and older: see http://hledger.org/release-notes or doc/release-notes.md.