doc: manual cleanups

use simpler markup
use pre blocks more consistently
pandoc table experiments
no more right-floating examples, use columns if needed
doc edits
style tweaks
This commit is contained in:
Simon Michael 2016-04-17 19:28:16 -07:00
parent 0c74dcde67
commit 6a3a5c60c5
11 changed files with 768 additions and 725 deletions

View File

@ -19,6 +19,7 @@ hledger is a cross\-platform program for tracking money, time, or any
other commodity, using double\-entry accounting and a simple, editable
file format.
hledger is inspired by and largely compatible with ledger(1).
.PP
hledger\-ui is hledger\[aq]s curses\-style interface.
It reads a hledger journal file
.PP

View File

@ -14,8 +14,10 @@ DDEESSCCRRIIPPTTIIOONN
hledger is a cross-platform program for tracking money, time, or any
other commodity, using double-entry accounting and a simple, editable
file format. hledger is inspired by and largely compatible with
ledger(1). hledger-ui is hledger's curses-style interface. It reads a
hledger journal file
ledger(1).
hledger-ui is hledger's curses-style interface. It reads a hledger
journal file
(~/.hledger.journal, $LEDGER_FILE, or -f FILE; see hledger(1) or
hledger_journal(5))

View File

@ -44,7 +44,7 @@ txt, csv.
The balance command displays accounts and balances.
It is hledger's most featureful and most useful command.
``` {.shell .right}
```shell
$ hledger balance
$-1 assets
$1 bank:saving
@ -76,30 +76,34 @@ balances of any subaccounts.
Accounts which have zero balance (and no non-zero subaccounts) are
omitted. Use `-E/--empty` to show them.
``` {.shell .right .clear}
A final total is displayed by default; use `-N/--no-total` to suppress it:
```shell
$ hledger balance -p 2008/6 expenses --no-total
$2 expenses
$1 food
$1 supplies
```
A final total is displayed by default; use `-N/--no-total` to suppress it.
### Flat mode
``` {.shell .right}
$ hledger balance -p 2008/6 expenses -N --flat --drop 1
$1 food
$1 supplies
```
To see a flat list of full account names instead of the default hierarchical display, use `--flat`.
In this mode, accounts (unless depth-clipped) show their "exclusive" balance, excluding any subaccount balances.
In this mode, you can also use `--drop N` to omit the first few account name components.
```shell
$ hledger balance -p 2008/6 expenses -N --flat --drop 1
$1 food
$1 supplies
```
### Depth limiting
``` {.shell .right}
With `--depth N`, balance shows accounts only to the specified depth.
This is very useful to show a complex charts of accounts in less detail.
In flat mode, balances from accounts below the depth limit will be shown as part of a parent account at the depth limit.
```shell
$ hledger balance -N --depth 1
$-1 assets
$2 expenses
@ -107,10 +111,6 @@ $ hledger balance -N --depth 1
$1 liabilities
```
With `--depth N`, balance shows accounts only to the specified depth.
This is very useful to show a complex charts of accounts in less detail.
In flat mode, balances from accounts below the depth limit will be shown as part of a parent account at the depth limit.
<!-- $ for y in 2006 2007 2008 2009 2010; do echo; echo $y; hledger -f $y.journal balance ^expenses --depth 2; done -->
### Multicolumn balance reports
@ -119,24 +119,9 @@ With a [reporting interval](#reporting-interval), multiple balance
columns will be shown, one for each report period.
There are three types of multi-column balance report, showing different information:
``` {.shell .right}
$ hledger balance --quarterly income expenses -E
Balance changes in 2008:
|| 2008q1 2008q2 2008q3 2008q4
===================++=================================
expenses:food || 0 $1 0 0
expenses:supplies || 0 $1 0 0
income:gifts || 0 $-1 0 0
income:salary || $-1 0 0 0
-------------------++---------------------------------
|| $-1 $1 0 0
```
1. By default: each column shows the sum of postings in that period,
ie the account's change of balance in that period. This is useful eg
for a monthly income statement.
for a monthly income statement:
<!--
multi-column income statement:
@ -147,63 +132,87 @@ or cashflow statement:
$ hledger balance ^assets ^liabilities 'not:(receivable|payable)' -p 'weekly this month'
-->
<div style="clear:both;"></div>
``` {.shell .right}
$ hledger balance --quarterly income expenses -E --cumulative
Ending balances (cumulative) in 2008:
```shell
$ hledger balance --quarterly income expenses -E
Balance changes in 2008:
|| 2008/03/31 2008/06/30 2008/09/30 2008/12/31
===================++=================================================
expenses:food || 0 $1 $1 $1
expenses:supplies || 0 $1 $1 $1
income:gifts || 0 $-1 $-1 $-1
income:salary || $-1 $-1 $-1 $-1
-------------------++-------------------------------------------------
|| $-1 0 0 0
|| 2008q1 2008q2 2008q3 2008q4
===================++=================================
expenses:food || 0 $1 0 0
expenses:supplies || 0 $1 0 0
income:gifts || 0 $-1 0 0
income:salary || $-1 0 0 0
-------------------++---------------------------------
|| $-1 $1 0 0
```
```
2. With `--cumulative`: each column shows the ending balance for that
period, accumulating the changes across periods, starting from 0 at
the report start date. This mode is not often used.
the report start date:
<div style="clear:both;"></div>
``` {.shell .right}
$ hledger balance ^assets ^liabilities -Q
Balance changes in 2008:
```shell
$ hledger balance --quarterly income expenses -E --cumulative
Ending balances (cumulative) in 2008:
|| 2008q1 2008q2 2008q3 2008q4
======================++=================================
assets:bank:checking || $1 0 0 $-1
assets:bank:saving || 0 $1 0 0
assets:cash || 0 $-2 0 0
liabilities:debts || 0 0 0 $1
----------------------++---------------------------------
|| $1 $-1 0 0
|| 2008/03/31 2008/06/30 2008/09/30 2008/12/31
===================++=================================================
expenses:food || 0 $1 $1 $1
expenses:supplies || 0 $1 $1 $1
income:gifts || 0 $-1 $-1 $-1
income:salary || $-1 $-1 $-1 $-1
-------------------++-------------------------------------------------
|| $-1 0 0 0
$ hledger balance ^assets ^liabilities --quarterly --historical --begin 2008/4/1
Ending balances (historical) in 2008/04/01-2008/12/31:
|| 2008/06/30 2008/09/30 2008/12/31
======================++=====================================
assets:bank:checking || $1 $1 0
assets:bank:saving || $1 $1 $1
assets:cash || $-2 $-2 $-2
liabilities:debts || 0 0 $1
----------------------++-------------------------------------
|| 0 0 0
```
```
3. With `--historical/-H`: each column shows the actual historical
ending balance for that period, accumulating the changes across
periods, starting from the actual balance at the report start date.
This is useful eg for a multi-period balance sheet, and when
you are showing only the data after a certain start date.
you are showing only the data after a certain start date:
<div style="clear:both;"></div>
``` {.shell .right}
$ hledger balance -Q income expenses --tree -E -TA
```shell
$ hledger balance ^assets ^liabilities --quarterly --historical --begin 2008/4/1
Ending balances (historical) in 2008/04/01-2008/12/31:
|| 2008/06/30 2008/09/30 2008/12/31
======================++=====================================
assets:bank:checking || $1 $1 0
assets:bank:saving || $1 $1 $1
assets:cash || $-2 $-2 $-2
liabilities:debts || 0 0 $1
----------------------++-------------------------------------
|| 0 0 0
```
Multi-column balance reports display accounts in flat mode by default;
to see the hierarchy, use `--tree`.
With a reporting interval (like `--quarterly` above), the report
start/end dates will be adjusted if necessary so that they encompass
the displayed report periods. This is so that the first and last
periods will be "full" and comparable to the others.
The `-E/--empty` flag does two things in multicolumn balance reports:
first, the report will show all columns within the specified report
period (without -E, leading and trailing columns with all zeroes are
not shown). Second, all accounts which existed at the report start
date will be considered, not just the ones with activity during the
report period (use -E to include low-activity accounts which would
otherwise would be omitted).
The `-T/--row-total` flag adds an additional column showing the total
for each row.
The `-A/--average` flag adds a column showing the average value in
each row.
Here's an example of all three:
```shell
$ hledger balance -Q income expenses --tree -ETA
Balance changes in 2008:
|| 2008q1 2008q2 2008q3 2008q4 Total Average
@ -221,27 +230,6 @@ Balance changes in 2008:
```
Multi-column balance reports display accounts in flat mode by default;
to see the hierarchy, use `--tree`.
Note that with a reporting interval, the report start/end dates will
be "enlarged" if necessary so that they encompass the displayed report
periods. This is so that the first and last periods will be "full" and
comparable to the others.
The `-E/--empty` flag does two things here: first, the report will
show all columns within the specified report period (without -E,
leading and trailing columns with all zeroes are not shown). Second,
all accounts which existed at the report start date will be
considered, not just the ones with activity during the report period
(use -E to include low-activity accounts which would otherwise would
be omitted).
The `-T/--row-total` flag adds an additional column showing the total
for each row. The `-A/--average` flag adds a column showing the
average value in each row. Note in `--H/--historical` mode only the
average is useful, and in `--cumulative` mode neither is useful.
### Market value
The `-V/--value` flag converts all the reported amounts to their
@ -254,15 +242,12 @@ Unlike Ledger, hledger's -V only uses the market prices recorded with
P directives, ignoring transaction prices recorded as part of posting
amounts (which -B/--cost uses). Using -B and -V together is allowed.
<!--
``` {.shell .right}
$ hledger balance -V ...
```
-->
### Custom balance output
``` {.shell .right}
In simple (non-multi-column) balance reports, you can customise the
output with `--format FMT`:
```shell
$ hledger balance --format "%20(account) %12(total)"
assets $-1
bank:saving $1
@ -278,65 +263,62 @@ $ hledger balance --format "%20(account) %12(total)"
0
```
In simple (non-multi-column) balance reports, you can customise the
output with `--format FMT`. FMT (plus a newline) will be displayed for
each account/balance pair. It is a format string with data fields
interpolated by
The FMT format string (plus a newline) specifies the formatting
applied to each account/balance pair. It may contain any suitable
text, with data fields interpolated like so:
`%[MIN][.MAX](FIELDNAME)`
where MIN means pad with spaces to at least this width, and MAX means
truncate at this width. The field name must be enclosed in
parentheses. Three fields are available:
- MIN pads with spaces to at least this width (optional)
- MAX truncates at this width (optional)
- FIELDNAME must be enclosed in parentheses, and can be one of:
- `depth_spacer` - a number of spaces equal to the account's depth, or if MIN is specified, MIN * depth spaces.
- `account` - the account's name
- `total` - the account's balance/posted total, right justified
- `depth_spacer` - a number of spaces equal to the account's depth, or if MIN is specified, MIN * depth spaces.
- `account` - the account's name
- `total` - the account's balance/posted total, right justified
When the total has multiple commodities, by default each commodity is
displayed on a separate line, and the report item will be bottom
aligned. You can change how such multi-line values are rendered by
beginning the format with a special prefix:
Also, FMT can begin with an optional prefix to control how
multi-commodity amounts are rendered:
- `%_` - render on multiple lines, bottom-aligned (the default)
- `%^` - render on multiple lines, top-aligned
- `%,` - render on one line, with multi-line values comma-separated
- `%,` - render on one line, comma-separated
There are some quirks, and experimentation may be needed to get pleasing output.
In one-line mode, `%(depth_spacer)` has no effect, instead `%(account)` has indentation built in.
There are some quirks. Eg in one-line mode, `%(depth_spacer)` has no
effect, instead `%(account)` has indentation built in.
<!-- XXX retest:
Consistent column widths are not well enforced, causing ragged edges unless you set suitable widths.
Beware of specifying a maximum width; it will clip account names and amounts that are too wide, with no visible indication.
-->
Experimentation may be needed to get pleasing results.
Examples:
Some example formats:
- `%(total)` - the account's total
- `%-20.20(account)` - the account's name, left justified, padded to 20 characters and clipped at 20 characters
- `%20(total) %2(depth_spacer)%-(account)` - default format for the single-column balance report
- `%,%-50(account) %25(total)` - account name padded to 50 characters, total padded to 20 characters, with multiple commodities rendered on one line
- `%20(total) %2(depth_spacer)%-(account)` - the default format for the single-column balance report
### Output destination
```{.shell .bold .right}
$ hledger balance -o - # write to stdout (the default)
$ hledger balance -o FILE # write to FILE
```
The balance, print, register and stats commands can write their output to a
destination other than the console. This is controlled by the
`-o/--output-file` option.
### CSV output
```{.shell .bold .right}
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
```shell
$ hledger balance -o - # write to stdout (the default)
$ hledger balance -o FILE # write to FILE
```
### CSV output
The balance, print and register commands can write their output as
CSV. This is useful for exporting data to other applications, eg to
make charts in a spreadsheet. This is controlled by the
`-O/--output-format` option, or by specifying a `.csv` file extension
with `-o/--output-file`.
```shell
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
```

View File

@ -13,6 +13,7 @@ command name (`hledger inc`), or one of the standard short aliases
displayed in the command list (`hledger is`).
---
# comment:
# for each command: name, synopsis, description, examples.
...
@ -90,15 +91,13 @@ The activity command displays an ascii histogram showing
transaction counts by day, week, month or other reporting interval
(by day is the default). With query arguments, it counts only matched transactions.
_col3_({{
_shell_({{
```shell
$ hledger activity --quarterly
2008-01-01 **
2008-04-01 *******
2008-07-01
2008-10-01 **
}})
}})
```
## add
Prompt for transactions and add them to the journal.
@ -178,8 +177,7 @@ This command displays a simple
assumes that you have top-level accounts named `asset` and `liability`
(plural forms also allowed.)
_col3_({{
_shell_({{
```shell
$ hledger balancesheet
Balance Sheet
@ -198,8 +196,7 @@ Liabilities:
Total:
--------------------
0
}})
}})
```
## cashflow
Show a cashflow statement. Alias: cf.
@ -217,8 +214,7 @@ period. It currently assumes that cash accounts are under a top-level
account named `asset` and do not contain `receivable` or `A/R` (plural
forms also allowed.)
_col3_({{
_shell_({{
```shell
$ hledger cashflow
Cashflow Statement
@ -232,8 +228,7 @@ Cash flows:
Total:
--------------------
$-1
}})
}})
```
## help
Show detailed help.
@ -280,8 +275,7 @@ This command displays a simple
currently assumes that you have top-level accounts named `income` (or
`revenue`) and `expense` (plural forms also allowed.)
_col3_({{
_shell_({{
```shell
$ hledger incomestatement
Income Statement
@ -302,8 +296,7 @@ Expenses:
Total:
--------------------
0
}})
}})
```
## print
Show transactions from the journal.
@ -318,21 +311,7 @@ Show transactions from the journal.
: select the output format. Supported formats:
txt, csv.
The print command displays full transactions from the journal file,
tidily formatted and showing all amounts explicitly. The output of
print is always a valid hledger journal, but it does always not
preserve all original content exactly (eg directives).
hledger's print command also shows all unit prices in effect, or (with
-B/--cost) shows cost amounts.
The print command also supports
[output destination](#output-destination)
and
[CSV output](#csv-output).
_col3_({{
_shell_({{
```shell
$ hledger print
2008/01/01 income
assets:bank:checking $1
@ -354,9 +333,20 @@ $ hledger print
2008/12/31 * pay off
liabilities:debts $1
assets:bank:checking $-1
```
}})
}})
The print command displays full transactions from the journal file,
tidily formatted and showing all amounts explicitly. The output of
print is always a valid hledger journal, but it does always not
preserve all original content exactly (eg directives).
hledger's print command also shows all unit prices in effect, or (with
-B/--cost) shows cost amounts.
The print command also supports
[output destination](#output-destination)
and
[CSV output](#csv-output).
## register
Show postings and their running total. Alias: reg.
@ -380,7 +370,11 @@ Show postings and their running total. Alias: reg.
: select the output format. Supported formats:
txt, csv.
```{.shell .right}
The register command displays postings, one per line, and their
running total. This is typically used with a [query](#queries)
selecting a particular account, to see that account's activity:
```shell
$ hledger register checking
2008/01/01 income assets:bank:checking $1 $1
2008/06/01 gift assets:bank:checking $1 $2
@ -388,21 +382,17 @@ $ hledger register checking
2008/12/31 pay off assets:bank:checking $-1 0
```
The register command displays postings, one per line, and their
running total. This is typically used with a [query](#queries)
selecting a particular account, to see that account's activity.
The `--historical`/`-H` flag adds the balance from any undisplayed
prior postings to the running total. This is useful when you want to
see only recent activity, with a historically accurate running balance:
```{.shell .right .clear}
```shell
$ hledger register checking -b 2008/6 --historical
2008/06/01 gift assets:bank:checking $1 $2
2008/06/02 save assets:bank:checking $-1 $1
2008/12/31 pay off assets:bank:checking $-1 0
```
The `--historical`/`-H` flag adds the balance from any prior postings
to the running total, to show the actual historical running balance.
This is useful when you want to see just the recent activity.
The `--depth` option limits the amount of sub-account detail displayed.
The `--average`/`-A` flag shows the running average posting amount
@ -413,12 +403,18 @@ It works best when showing just one account and one commodity.
The `--related`/`-r` flag shows the *other* postings in the transactions
of the postings which would normally be shown.
```{.shell .right}
With a [reporting interval](#reporting-interval), register shows
summary postings, one per interval, aggregating the postings to each account:
```shell
$ hledger register --monthly income
2008/01 income:salary $-1 $-1
2008/06 income:gifts $-1 $-2
```
```{.shell .right}
Periods with no activity, and summary postings with a zero amount, are
not shown by default; use the `--empty`/`-E` flag to see them:
```shell
$ hledger register --monthly income -E
2008/01 income:salary $-1 $-1
2008/02 0 $-1
@ -433,22 +429,17 @@ $ hledger register --monthly income -E
2008/11 0 $-2
2008/12 0 $-2
```
```{.shell .right .clear}
$ hledger register --monthly assets --depth 1 # cashflow (changes to assets) by month
Often, you'll want to see just one line per interval.
The `--depth` option helps with this, causing subaccounts to be aggregated:
```shell
$ hledger register --monthly assets --depth 1h
2008/01 assets $1 $1
2008/06 assets $-1 0
2008/12 assets $-1 $-1
```
With a [reporting interval](#reporting-interval), register shows
summary postings, one per interval, aggregating the postings to each account.
Periods with no activity, and summary postings with a zero amount, are
not shown by default; use the `--empty`/`-E` flag to see them.
Often, you'll want to see just one line per interval.
The `--depth` option helps with this, causing subaccounts to be aggregated.
Note when using report intervals, if you specify start/end dates these
will be adjusted outward if necessary to contain a whole number of
intervals. This ensures that the first and last intervals are full
@ -470,13 +461,13 @@ date (10) description (D) account (W-41-D) amount (12) balance (12)
DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA
```
and some examples:
```{.shell .bold}
$ hledger reg # use terminal width (or 80 on windows)
$ hledger reg -w 100 # use width 100
$ COLUMNS=100 hledger reg # set with one-time environment variable
$ export COLUMNS=100; hledger reg # set till session end (or window resize)
$ hledger reg -w 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
```shell
$ hledger reg # use terminal width (or 80 on windows)
$ hledger reg -w 100 # use width 100
$ COLUMNS=100 hledger reg # set with one-time environment variable
$ export COLUMNS=100; hledger reg # set till session end (or window resize)
$ hledger reg -w 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
```
The register command also supports the
@ -489,7 +480,7 @@ Show some journal statistics.
`-o FILE[.FMT] --output-file=FILE[.FMT]`
: write output to FILE instead of stdout. A recognised FMT suffix influences the format.
```{.shell .right}
```shell
$ hledger stats
Main journal file : /src/hledger/data/sample.journal
Included journal files :
@ -513,7 +504,7 @@ for controlling [output destination](#output-destination).
## test
Run built-in unit tests.
```{.shell .right}
```shell
$ hledger test
Cases: 74 Tried: 74 Errors: 0 Failures: 0
```
@ -553,7 +544,7 @@ Web API server, see [hledger-api](hledger-api.html).
## autosync
Download OFX bank data and/or convert OFX to hledger journal format.
``` {.shell .right}
```shell
$ hledger autosync --help
usage: hledger-autosync [-h] [-m MAX] [-r] [-a ACCOUNT] [-l LEDGER] [-i INDENT]
[--initial] [--fid FID] [--assertions] [-d] [--hledger]
@ -617,7 +608,7 @@ download.
## diff
Show transactions present in one journal file but not another
```{.shell .right}
```shell
$ hledger diff --help
Usage: hledger-diff account:name left.journal right.journal
$ cat a.journal
@ -649,7 +640,7 @@ journals with bank statements.
## equity
Print a journal entry that resets account balances to zero.
```{.shell .right}
```shell
$ hledger balance --flat -E assets liabilities
0 assets:bank:checking
$1 assets:bank:saving
@ -687,7 +678,7 @@ just one file, or on several files concatenated with [include](#include).
## interest
Generate interest transactions.
```{.shell .right}
```shell
$ hledger interest --help
Usage: hledger-interest [OPTION...] ACCOUNT
-h --help print this message and exit
@ -708,7 +699,7 @@ Usage: hledger-interest [OPTION...] ACCOUNT
--ing-diba compute interest according for Ing-Diba Tagesgeld account
```
```{.shell .right .clear}
```shell
$ cat interest.journal
2008/09/26 Loan
Assets:Bank EUR 10000.00
@ -727,7 +718,7 @@ $ cat interest.journal
Liabilities:Bank
```
```{.shell .right .clear}
```shell
$ hledger interest -- -f interest.journal --source=Expenses:Interest \
--target=Liabilities:Bank --30-360 --annual=0.05 Liabilities:Bank
2008/09/26 Loan
@ -779,7 +770,7 @@ with a fixed rate and the scheme mandated by the German BGB288
## irr
Calculate internal rate of return.
```{.shell .right}
```shell
$ hledger irr --help
Usage: hledger-irr [OPTION...]
-h --help print this message and exit
@ -796,7 +787,7 @@ Usage: hledger-irr [OPTION...]
-Y --yearly calculate interest for each year
```
```{.shell .right .clear}
```shell
$ cat irr.journal
2011-01-01 Some wild speculation I wonder if it pays off
Speculation €100.00
@ -828,7 +819,7 @@ $ cat irr.journal
Rate Gain -€ 5.00
```
```{.shell .right .clear}
```shell
$ hledger-irr -f irr.journal -t "Rate Gain" -i Speculation --monthly
2011/01/01 - 2011/02/01: 12.49%
2011/02/01 - 2011/03/01: 41.55%
@ -848,7 +839,7 @@ See the package page for more.
## print-unique
Print only only journal entries which have a unique description.
```{.shell .right}
```shell
$ cat unique.journal
1/1 test
(acct:one) 1
@ -864,7 +855,7 @@ $ LEDGER_FILE=unique.journal hledger print-unique
## rewrite
Prints all journal entries, adding specified custom postings to matched entries.
```{.shell .right .bold}
```shell
$ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ...
$ hledger rewrite -- ^income --add-posting '(liabilities:tax) *.33'
$ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"'

View File

@ -24,6 +24,7 @@ $ hledger print
expenses:food $10
assets:cash $-10
```
```shell
$ hledger accounts --tree
assets
@ -33,6 +34,7 @@ expenses
income
gifts
```
```shell
$ hledger balance
$10 assets:cash
@ -41,13 +43,16 @@ $ hledger balance
--------------------
0
```
```shell
$ hledger register cash
2015/09/30 gift received assets:cash $20 $20
2015/10/16 farmers market assets:cash $-10 $10
```
```{.shell .bold}
More commands:
```shell
$ hledger # show available commands
$ hledger add # add more transactions to the journal file
$ hledger balance # all accounts with aggregated balances

View File

@ -125,6 +125,8 @@ $\ hledger\ register\ cash
2015/10/16\ farmers\ market\ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-10\ \ \ \ \ \ \ \ \ \ \ $10
\f[]
.fi
.PP
More commands:
.IP
.nf
\f[C]
@ -324,10 +326,10 @@ Examples:
.PP
.TS
tab(@);
lw(33.7n) lw(36.3n).
l l.
T{
\f[C]2009/1/1\f[], \f[C]2009/01/01\f[], \f[C]2009\-1\-1\f[],
\f[C]2009.1.1\f[] \
\f[C]2009.1.1\f[]
T}@T{
simple dates, several separators allowed
T}
@ -394,58 +396,97 @@ hledger\[aq]s period expressions are similar to Ledger\[aq]s, though not
identical.
Here\[aq]s a basic period expression specifying the first quarter of
2009.
Note hledger always treats start dates as inclusive and end dates as
Note, hledger always treats start dates as inclusive and end dates as
exclusive:
.IP
.nf
\f[C]
\-p\ "from\ 2009/1/1\ to\ 2009/4/1"
\f[]
.fi
.PP
Keywords like "from" and "to" are optional, and so are the spaces.
Just don\[aq]t run two dates together:
.IP
.nf
\f[C]
\-p2009/1/1to2009/4/1
\-p"2009/1/1\ 2009/4/1"
\f[]
.fi
\f[C]\-p\ "from\ 2009/1/1\ to\ 2009/4/1"\f[]
.PP
Keywords like "from" and "to" are optional, and so are the spaces, as
long as you don\[aq]t run two dates together.
"to" can also be written as "\-".
These are equivalent to the above:
.PP
.TS
tab(@);
l.
T{
\f[C]\-p\ "2009/1/1\ 2009/4/1"\f[]
T}
T{
\f[C]\-p2009/1/1to2009/4/1\f[]
T}
T{
\f[C]\-p2009/1/1\-2009/4/1\f[]
T}
.TE
.PP
Dates are smart dates, so if the current year is 2009, the above can
also be written as:
.IP
.nf
\f[C]
\-p\ "1/1\ to\ 4/1"
\-p\ "january\ to\ apr"
\-p\ "this\ year\ to\ 4/1"
\f[]
.fi
.PP
.TS
tab(@);
l.
T{
\f[C]\-p\ "1/1\ 4/1"\f[]
T}
T{
\f[C]\-p\ "january\-apr"\f[]
T}
T{
\f[C]\-p\ "this\ year\ to\ 4/1"\f[]
T}
.TE
.PP
If you specify only one date, the missing start or end date will be the
earliest or latest transaction in your journal:
.IP
.nf
\f[C]
\-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)
\f[]
.fi
.PP
.TS
tab(@);
l l.
T{
\f[C]\-p\ "from\ 2009/1/1"\f[]
T}@T{
everything after january 1, 2009
T}
T{
\f[C]\-p\ "from\ 2009/1"\f[]
T}@T{
the same
T}
T{
\f[C]\-p\ "from\ 2009"\f[]
T}@T{
the same
T}
T{
\f[C]\-p\ "to\ 2009"\f[]
T}@T{
everything before january 1, 2009
T}
.TE
.PP
A single date with no "from" or "to" defines both the start and end date
like so:
.IP
.nf
\f[C]
\-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")
\f[]
.fi
.PP
.TS
tab(@);
l l.
T{
\f[C]\-p\ "2009"\f[]
T}@T{
the year 2009; equivalent to "2009/1/1 to 2010/1/1"
T}
T{
\f[C]\-p\ "2009/1"\f[]
T}@T{
the month of jan; equivalent to "2009/1/1 to 2009/2/1"
T}
T{
\f[C]\-p\ "2009/1/1"\f[]
T}@T{
just that day; equivalent to "2009/1/1 to 2009/1/2"
T}
.TE
.PP
Period expressions can also start with (or be) a reporting interval:
\f[C]daily\f[], \f[C]weekly\f[], \f[C]monthly\f[], \f[C]quarterly\f[],
@ -453,19 +494,35 @@ Period expressions can also start with (or be) a reporting interval:
Optionally the word \f[C]in\f[] may appear between the reporting
interval and the start/end dates.
Examples:
.IP
.nf
\f[C]
\-p\ "weekly\ from\ 2009/1/1\ to\ 2009/4/1"
\-p\ "monthly\ in\ 2008"
\-p\ "bimonthly\ from\ 2008"
\-p\ "quarterly"
\-p\ "every\ 2\ weeks"
\-p\ "every\ 5\ days\ from\ 1/3"
\-p\ "every\ 15th\ day\ of\ month"
\-p\ "every\ 4th\ day\ of\ week"
\f[]
.fi
.PP
.TS
tab(@);
l.
T{
\f[C]\-p\ "weekly\ from\ 2009/1/1\ to\ 2009/4/1"\f[]
T}
T{
\f[C]\-p\ "monthly\ in\ 2008"\f[]
T}
T{
\f[C]\-p\ "bimonthly\ from\ 2008"\f[]
T}
T{
\f[C]\-p\ "quarterly"\f[]
T}
T{
\f[C]\-p\ "every\ 2\ weeks"\f[]
T}
T{
\f[C]\-p\ "every\ 5\ days\ from\ 1/3"\f[]
T}
T{
\f[C]\-p\ "every\ 15th\ day\ of\ month"\f[]
T}
T{
\f[C]\-p\ "every\ 4th\ day\ of\ week"\f[]
T}
.TE
.SS Regular Expressions
.PP
hledger uses regular expressions in a number of places:
@ -937,6 +994,9 @@ balances of any subaccounts.
Accounts which have zero balance (and no non\-zero subaccounts) are
omitted.
Use \f[C]\-E/\-\-empty\f[] to show them.
.PP
A final total is displayed by default; use \f[C]\-N/\-\-no\-total\f[] to
suppress it:
.IP
.nf
\f[C]
@ -946,10 +1006,14 @@ $\ hledger\ balance\ \-p\ 2008/6\ expenses\ \-\-no\-total
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ supplies
\f[]
.fi
.PP
A final total is displayed by default; use \f[C]\-N/\-\-no\-total\f[] to
suppress it.
.SS Flat mode
.PP
To see a flat list of full account names instead of the default
hierarchical display, use \f[C]\-\-flat\f[].
In this mode, accounts (unless depth\-clipped) show their "exclusive"
balance, excluding any subaccount balances.
In this mode, you can also use \f[C]\-\-drop\ N\f[] to omit the first
few account name components.
.IP
.nf
\f[C]
@ -958,14 +1022,13 @@ $\ hledger\ balance\ \-p\ 2008/6\ expenses\ \-N\ \-\-flat\ \-\-drop\ 1
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ supplies
\f[]
.fi
.PP
To see a flat list of full account names instead of the default
hierarchical display, use \f[C]\-\-flat\f[].
In this mode, accounts (unless depth\-clipped) show their "exclusive"
balance, excluding any subaccount balances.
In this mode, you can also use \f[C]\-\-drop\ N\f[] to omit the first
few account name components.
.SS Depth limiting
.PP
With \f[C]\-\-depth\ N\f[], balance shows accounts only to the specified
depth.
This is very useful to show a complex charts of accounts in less detail.
In flat mode, balances from accounts below the depth limit will be shown
as part of a parent account at the depth limit.
.IP
.nf
\f[C]
@ -976,18 +1039,17 @@ $\ hledger\ balance\ \-N\ \-\-depth\ 1
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ liabilities
\f[]
.fi
.PP
With \f[C]\-\-depth\ N\f[], balance shows accounts only to the specified
depth.
This is very useful to show a complex charts of accounts in less detail.
In flat mode, balances from accounts below the depth limit will be shown
as part of a parent account at the depth limit.
.SS Multicolumn balance reports
.PP
With a reporting interval, multiple balance columns will be shown, one
for each report period.
There are three types of multi\-column balance report, showing different
information:
.IP "1." 3
By default: each column shows the sum of postings in that period, ie the
account\[aq]s change of balance in that period.
This is useful eg for a monthly income statement:
.RS 4
.IP
.nf
\f[C]
@ -1004,10 +1066,12 @@ Balance\ changes\ in\ 2008:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\
\f[]
.fi
.IP "1." 3
By default: each column shows the sum of postings in that period, ie the
account\[aq]s change of balance in that period.
This is useful eg for a monthly income statement.
.RE
.IP "2." 3
With \f[C]\-\-cumulative\f[]: each column shows the ending balance for
that period, accumulating the changes across periods, starting from 0 at
the report start date:
.RS 4
.IP
.nf
\f[C]
@ -1024,26 +1088,18 @@ Ending\ balances\ (cumulative)\ in\ 2008:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\
\f[]
.fi
.IP "2." 3
With \f[C]\-\-cumulative\f[]: each column shows the ending balance for
that period, accumulating the changes across periods, starting from 0 at
the report start date.
This mode is not often used.
.RE
.IP "3." 3
With \f[C]\-\-historical/\-H\f[]: each column shows the actual
historical ending balance for that period, accumulating the changes
across periods, starting from the actual balance at the report start
date.
This is useful eg for a multi\-period balance sheet, and when you are
showing only the data after a certain start date:
.RS 4
.IP
.nf
\f[C]
$\ hledger\ balance\ ^assets\ ^liabilities\ \-Q\
Balance\ changes\ in\ 2008:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008q1\ \ 2008q2\ \ 2008q3\ \ 2008q4\
======================++=================================
\ assets:bank:checking\ ||\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ $\-1\
\ assets:bank:saving\ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\
\ assets:cash\ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ $\-2\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\
\ liabilities:debts\ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ $1\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\
$\ hledger\ balance\ ^assets\ ^liabilities\ \-\-quarterly\ \-\-historical\ \-\-begin\ 2008/4/1
Ending\ balances\ (historical)\ in\ 2008/04/01\-2008/12/31:
@ -1057,17 +1113,37 @@ Ending\ balances\ (historical)\ in\ 2008/04/01\-2008/12/31:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\
\f[]
.fi
.IP "3." 3
With \f[C]\-\-historical/\-H\f[]: each column shows the actual
historical ending balance for that period, accumulating the changes
across periods, starting from the actual balance at the report start
date.
This is useful eg for a multi\-period balance sheet, and when you are
showing only the data after a certain start date.
.RE
.PP
Multi\-column balance reports display accounts in flat mode by default;
to see the hierarchy, use \f[C]\-\-tree\f[].
.PP
With a reporting interval (like \f[C]\-\-quarterly\f[] above), the
report start/end dates will be adjusted if necessary so that they
encompass the displayed report periods.
This is so that the first and last periods will be "full" and comparable
to the others.
.PP
The \f[C]\-E/\-\-empty\f[] flag does two things in multicolumn balance
reports: first, the report will show all columns within the specified
report period (without \-E, leading and trailing columns with all zeroes
are not shown).
Second, all accounts which existed at the report start date will be
considered, not just the ones with activity during the report period
(use \-E to include low\-activity accounts which would otherwise would
be omitted).
.PP
The \f[C]\-T/\-\-row\-total\f[] flag adds an additional column showing
the total for each row.
.PP
The \f[C]\-A/\-\-average\f[] flag adds a column showing the average
value in each row.
.PP
Here\[aq]s an example of all three:
.IP
.nf
\f[C]
$\ hledger\ balance\ \-Q\ income\ expenses\ \-\-tree\ \-E\ \-TA
$\ hledger\ balance\ \-Q\ income\ expenses\ \-\-tree\ \-ETA
Balance\ changes\ in\ 2008:
\ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008q1\ \ 2008q2\ \ 2008q3\ \ 2008q4\ \ \ \ Total\ \ Average\
@ -1084,30 +1160,6 @@ Balance\ changes\ in\ 2008:
#\ Average\ is\ rounded\ to\ the\ dollar\ here\ since\ all\ journal\ amounts\ are
\f[]
.fi
.PP
Multi\-column balance reports display accounts in flat mode by default;
to see the hierarchy, use \f[C]\-\-tree\f[].
.PP
Note that with a reporting interval, the report start/end dates will be
"enlarged" if necessary so that they encompass the displayed report
periods.
This is so that the first and last periods will be "full" and comparable
to the others.
.PP
The \f[C]\-E/\-\-empty\f[] flag does two things here: first, the report
will show all columns within the specified report period (without \-E,
leading and trailing columns with all zeroes are not shown).
Second, all accounts which existed at the report start date will be
considered, not just the ones with activity during the report period
(use \-E to include low\-activity accounts which would otherwise would
be omitted).
.PP
The \f[C]\-T/\-\-row\-total\f[] flag adds an additional column showing
the total for each row.
The \f[C]\-A/\-\-average\f[] flag adds a column showing the average
value in each row.
Note in \f[C]\-\-H/\-\-historical\f[] mode only the average is useful,
and in \f[C]\-\-cumulative\f[] mode neither is useful.
.SS Market value
.PP
The \f[C]\-V/\-\-value\f[] flag converts all the reported amounts to
@ -1121,6 +1173,9 @@ with P directives, ignoring transaction prices recorded as part of
posting amounts (which \-B/\-\-cost uses).
Using \-B and \-V together is allowed.
.SS Custom balance output
.PP
In simple (non\-multi\-column) balance reports, you can customise the
output with \f[C]\-\-format\ FMT\f[]:
.IP
.nf
\f[C]
@ -1140,17 +1195,18 @@ $\ hledger\ balance\ \-\-format\ "%20(account)\ %12(total)"
\f[]
.fi
.PP
In simple (non\-multi\-column) balance reports, you can customise the
output with \f[C]\-\-format\ FMT\f[].
FMT (plus a newline) will be displayed for each account/balance pair.
It is a format string with data fields interpolated by
The FMT format string (plus a newline) specifies the formatting applied
to each account/balance pair.
It may contain any suitable text, with data fields interpolated like so:
.PP
\f[C]%[MIN][.MAX](FIELDNAME)\f[]
.PP
where MIN means pad with spaces to at least this width, and MAX means
truncate at this width.
The field name must be enclosed in parentheses.
Three fields are available:
.IP \[bu] 2
MIN pads with spaces to at least this width (optional)
.IP \[bu] 2
MAX truncates at this width (optional)
.IP \[bu] 2
FIELDNAME must be enclosed in parentheses, and can be one of:
.RS 2
.IP \[bu] 2
\f[C]depth_spacer\f[] \- a number of spaces equal to the account\[aq]s
depth, or if MIN is specified, MIN * depth spaces.
@ -1159,39 +1215,40 @@ depth, or if MIN is specified, MIN * depth spaces.
.IP \[bu] 2
\f[C]total\f[] \- the account\[aq]s balance/posted total, right
justified
.RE
.PP
When the total has multiple commodities, by default each commodity is
displayed on a separate line, and the report item will be bottom
aligned.
You can change how such multi\-line values are rendered by beginning the
format with a special prefix:
Also, FMT can begin with an optional prefix to control how
multi\-commodity amounts are rendered:
.IP \[bu] 2
\f[C]%_\f[] \- render on multiple lines, bottom\-aligned (the default)
.IP \[bu] 2
\f[C]%^\f[] \- render on multiple lines, top\-aligned
.IP \[bu] 2
\f[C]%,\f[] \- render on one line, with multi\-line values
comma\-separated
\f[C]%,\f[] \- render on one line, comma\-separated
.PP
There are some quirks, and experimentation may be needed to get pleasing
output.
In one\-line mode, \f[C]%(depth_spacer)\f[] has no effect, instead
There are some quirks.
Eg in one\-line mode, \f[C]%(depth_spacer)\f[] has no effect, instead
\f[C]%(account)\f[] has indentation built in.
Experimentation may be needed to get pleasing results.
.PP
Examples:
Some example formats:
.IP \[bu] 2
\f[C]%(total)\f[] \- the account\[aq]s total
.IP \[bu] 2
\f[C]%\-20.20(account)\f[] \- the account\[aq]s name, left justified,
padded to 20 characters and clipped at 20 characters
.IP \[bu] 2
\f[C]%20(total)\ \ %2(depth_spacer)%\-(account)\f[] \- default format
for the single\-column balance report
.IP \[bu] 2
\f[C]%,%\-50(account)\ \ %25(total)\f[] \- account name padded to 50
characters, total padded to 20 characters, with multiple commodities
rendered on one line
.IP \[bu] 2
\f[C]%20(total)\ \ %2(depth_spacer)%\-(account)\f[] \- the default
format for the single\-column balance report
.SS Output destination
.PP
The balance, print, register and stats commands can write their output
to a destination other than the console.
This is controlled by the \f[C]\-o/\-\-output\-file\f[] option.
.IP
.nf
\f[C]
@ -1199,18 +1256,7 @@ $\ hledger\ balance\ \-o\ \-\ \ \ \ \ #\ write\ to\ stdout\ (the\ default)
$\ hledger\ balance\ \-o\ FILE\ \ #\ write\ to\ FILE
\f[]
.fi
.PP
The balance, print, register and stats commands can write their output
to a destination other than the console.
This is controlled by the \f[C]\-o/\-\-output\-file\f[] option.
.SS CSV output
.IP
.nf
\f[C]
$\ hledger\ balance\ \-O\ csv\ \ \ \ \ \ \ #\ write\ CSV\ to\ stdout
$\ hledger\ balance\ \-o\ FILE.csv\ \ #\ write\ CSV\ to\ FILE.csv
\f[]
.fi
.PP
The balance, print and register commands can write their output as CSV.
This is useful for exporting data to other applications, eg to make
@ -1218,6 +1264,13 @@ charts in a spreadsheet.
This is controlled by the \f[C]\-O/\-\-output\-format\f[] option, or by
specifying a \f[C]\&.csv\f[] file extension with
\f[C]\-o/\-\-output\-file\f[].
.IP
.nf
\f[C]
$\ hledger\ balance\ \-O\ csv\ \ \ \ \ \ \ #\ write\ CSV\ to\ stdout
$\ hledger\ balance\ \-o\ FILE.csv\ \ #\ write\ CSV\ to\ FILE.csv
\f[]
.fi
.SS balancesheet
.PP
Show a balance sheet.
@ -1399,16 +1452,6 @@ select the output format.
Supported formats: txt, csv.
.RS
.RE
.PP
The print command displays full transactions from the journal file,
tidily formatted and showing all amounts explicitly.
The output of print is always a valid hledger journal, but it does
always not preserve all original content exactly (eg directives).
.PP
hledger\[aq]s print command also shows all unit prices in effect, or
(with \-B/\-\-cost) shows cost amounts.
.PP
The print command also supports output destination and CSV output.
.IP
.nf
\f[C]
@ -1435,6 +1478,16 @@ $\ hledger\ print
\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1
\f[]
.fi
.PP
The print command displays full transactions from the journal file,
tidily formatted and showing all amounts explicitly.
The output of print is always a valid hledger journal, but it does
always not preserve all original content exactly (eg directives).
.PP
hledger\[aq]s print command also shows all unit prices in effect, or
(with \-B/\-\-cost) shows cost amounts.
.PP
The print command also supports output destination and CSV output.
.SS register
.PP
Show postings and their running total.
@ -1472,6 +1525,11 @@ select the output format.
Supported formats: txt, csv.
.RS
.RE
.PP
The register command displays postings, one per line, and their running
total.
This is typically used with a query selecting a particular account, to
see that account\[aq]s activity:
.IP
.nf
\f[C]
@ -1483,10 +1541,10 @@ $\ hledger\ register\ checking
\f[]
.fi
.PP
The register command displays postings, one per line, and their running
total.
This is typically used with a query selecting a particular account, to
see that account\[aq]s activity.
The \f[C]\-\-historical\f[]/\f[C]\-H\f[] flag adds the balance from any
undisplayed prior postings to the running total.
This is useful when you want to see only recent activity, with a
historically accurate running balance:
.IP
.nf
\f[C]
@ -1497,11 +1555,6 @@ $\ hledger\ register\ checking\ \-b\ 2008/6\ \-\-historical
\f[]
.fi
.PP
The \f[C]\-\-historical\f[]/\f[C]\-H\f[] flag adds the balance from any
prior postings to the running total, to show the actual historical
running balance.
This is useful when you want to see just the recent activity.
.PP
The \f[C]\-\-depth\f[] option limits the amount of sub\-account detail
displayed.
.PP
@ -1514,6 +1567,9 @@ It works best when showing just one account and one commodity.
The \f[C]\-\-related\f[]/\f[C]\-r\f[] flag shows the \f[I]other\f[]
postings in the transactions of the postings which would normally be
shown.
.PP
With a reporting interval, register shows summary postings, one per
interval, aggregating the postings to each account:
.IP
.nf
\f[C]
@ -1522,6 +1578,10 @@ $\ hledger\ register\ \-\-monthly\ income
2008/06\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ $\-2
\f[]
.fi
.PP
Periods with no activity, and summary postings with a zero amount, are
not shown by default; use the \f[C]\-\-empty\f[]/\f[C]\-E\f[] flag to
see them:
.IP
.nf
\f[C]
@ -1540,27 +1600,20 @@ $\ hledger\ register\ \-\-monthly\ income\ \-E
2008/12\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ $\-2
\f[]
.fi
.PP
Often, you\[aq]ll want to see just one line per interval.
The \f[C]\-\-depth\f[] option helps with this, causing subaccounts to be
aggregated:
.IP
.nf
\f[C]
$\ hledger\ register\ \-\-monthly\ assets\ \-\-depth\ 1\ \ #\ cashflow\ (changes\ to\ assets)\ by\ month
$\ hledger\ register\ \-\-monthly\ assets\ \-\-depth\ 1h
2008/01\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ \ $1
2008/06\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ \ \ 0
2008/12\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ $\-1
\f[]
.fi
.PP
With a reporting interval, register shows summary postings, one per
interval, aggregating the postings to each account.
.PP
Periods with no activity, and summary postings with a zero amount, are
not shown by default; use the \f[C]\-\-empty\f[]/\f[C]\-E\f[] flag to
see them.
.PP
Often, you\[aq]ll want to see just one line per interval.
The \f[C]\-\-depth\f[] option helps with this, causing subaccounts to be
aggregated.
.PP
Note when using report intervals, if you specify start/end dates these
will be adjusted outward if necessary to contain a whole number of
intervals.
@ -1591,12 +1644,12 @@ and some examples:
.IP
.nf
\f[C]
$\ hledger\ reg\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ use\ terminal\ width\ (or\ 80\ on\ windows)
$\ hledger\ reg\ \-w\ 100\ \ \ \ \ \ \ \ \ \ #\ use\ width\ 100
$\ COLUMNS=100\ hledger\ reg\ \ \ \ \ #\ set\ with\ one\-time\ environment\ variable
$\ export\ COLUMNS=100;\ hledger\ reg\ \ #\ set\ till\ session\ end\ (or\ window\ resize)
$\ hledger\ reg\ \-w\ 100,40\ \ \ \ \ \ \ #\ set\ overall\ width\ 100,\ description\ width\ 40
$\ hledger\ reg\ \-w\ $COLUMNS,40\ \ #\ use\ terminal\ width,\ and\ set\ description\ width
$\ hledger\ reg\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ use\ terminal\ width\ (or\ 80\ on\ windows)
$\ hledger\ reg\ \-w\ 100\ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ use\ width\ 100
$\ COLUMNS=100\ hledger\ reg\ \ \ \ \ \ \ \ \ #\ set\ with\ one\-time\ environment\ variable
$\ export\ COLUMNS=100;\ hledger\ reg\ #\ set\ till\ session\ end\ (or\ window\ resize)
$\ hledger\ reg\ \-w\ 100,40\ \ \ \ \ \ \ \ \ \ \ #\ set\ overall\ width\ 100,\ description\ width\ 40
$\ hledger\ reg\ \-w\ $COLUMNS,40\ \ \ \ \ \ #\ use\ terminal\ width,\ and\ set\ description\ width
\f[]
.fi
.PP

View File

@ -90,6 +90,8 @@ EEXXAAMMPPLLEESS
2015/09/30 gift received assets:cash $20 $20
2015/10/16 farmers market assets:cash $-10 $10
More commands:
$ hledger # show available commands
$ hledger add # add more transactions to the journal file
$ hledger balance # all accounts with aggregated balances
@ -222,15 +224,15 @@ OOPPTTIIOONNSS
Examples:
tab(@); lw(33.7n) lw(36.3n). T{ 2009/1/1, 2009/01/01, 2009-1-1,
2009.1.1 T}@T{ simple dates, several separators allowed T} T{ 2009/1,
2009 T}@T{ same as above - a missing day or month defaults to 1 T} T{
1/1, january, jan, this year T}@T{ relative dates, meaning january 1 of
the current year T} T{ next year T}@T{ january 1 of next year T} T{
this month T}@T{ the 1st of the current month T} T{ this week T}@T{ the
most recent monday T} T{ last week T}@T{ the monday of the week before
this one T} T{ lastweek T}@T{ spaces are optional T} T{ today, yester-
day, tomorrow T}@T{ T}
tab(@); l l. T{ 2009/1/1, 2009/01/01, 2009-1-1, 2009.1.1 T}@T{ simple
dates, several separators allowed T} T{ 2009/1, 2009 T}@T{ same as
above - a missing day or month defaults to 1 T} T{ 1/1, january, jan,
this year T}@T{ relative dates, meaning january 1 of the current year
T} T{ next year T}@T{ january 1 of next year T} T{ this month T}@T{ the
1st of the current month T} T{ this week T}@T{ the most recent monday
T} T{ last week T}@T{ the monday of the week before this one T} T{
lastweek T}@T{ spaces are optional T} T{ today, yesterday, tomorrow
T}@T{ T}
RReeppoorrttiinngg iinntteerrvvaall
A reporting interval can be specified so that commands like register,
@ -247,106 +249,107 @@ OOPPTTIIOONNSS
hledger's period expressions are similar to Ledger's, though not iden-
tical. Here's a basic period expression specifying the first quarter
of 2009. Note hledger always treats start dates as inclusive and end
of 2009. Note, hledger always treats start dates as inclusive and end
dates as exclusive:
-p "from 2009/1/1 to 2009/4/1"
-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:
Keywords like "from" and "to" are optional, and so are the spaces, as
long as you don't run two dates together. "to" can also be written as
"-". These are equivalent to the above:
-p2009/1/1to2009/4/1
-p"2009/1/1 2009/4/1"
tab(@); l. T{ -p "2009/1/1 2009/4/1" T} T{ -p2009/1/1to2009/4/1 T} T{
-p2009/1/1-2009/4/1 T}
Dates are 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"
tab(@); l. T{ -p "1/1 4/1" T} T{ -p "january-apr" T} T{
-p "this year to 4/1" T}
If you specify only one date, the missing start or end date will be the
earliest or latest transaction in your journal:
-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
tab(@); l l. T{ -p "from 2009/1/1" T}@T{ everything after january 1,
2009 T} T{ -p "from 2009/1" T}@T{ the same T} T{ -p "from 2009" T}@T{
the same T} T{ -p "to 2009" T}@T{ everything before january 1, 2009 T}
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")
tab(@); l l. T{ -p "2009" T}@T{ the year 2009; equivalent to "2009/1/1
to 2010/1/1" T} T{ -p "2009/1" T}@T{ the month of jan; equivalent to
"2009/1/1 to 2009/2/1" T} T{ -p "2009/1/1" T}@T{ just that day; equiva-
lent to "2009/1/1 to 2009/1/2" T}
Period expressions can also start with (or be) a reporting interval:
daily, weekly, monthly, quarterly, yearly, or one of the every ...
expressions below. Optionally the word in may appear between the
reporting interval and the start/end dates. Examples:
-p "weekly from 2009/1/1 to 2009/4/1"
-p "monthly in 2008"
-p "bimonthly from 2008"
-p "quarterly"
-p "every 2 weeks"
-p "every 5 days from 1/3"
-p "every 15th day of month"
-p "every 4th day of week"
tab(@); l. T{ -p "weekly from 2009/1/1 to 2009/4/1" T} T{
-p "monthly in 2008" T} T{ -p "bimonthly from 2008" T} T{ -p "quar-
terly" T} T{ -p "every 2 weeks" T} T{ -p "every 5 days from 1/3" T} T{
-p "every 15th day of month" T} T{ -p "every 4th day of week" T}
RReegguullaarr EExxpprreessssiioonnss
hledger uses regular expressions in a number of places:
+o query terms, on the command line and in the hledger-web search form:
+o query terms, on the command line and in the hledger-web search form:
REGEX, desc:REGEX, cur:REGEX, tag:...=REGEX
+o CSV rules conditional blocks: if REGEX ...
+o account alias directives and options: alias /REGEX/ = REPLACEMENT,
+o account alias directives and options: alias /REGEX/ = REPLACEMENT,
--alias /REGEX/=REPLACEMENT
hledger's regular expressions come from the regex-tdfa library. In
hledger's regular expressions come from the regex-tdfa library. In
general they:
+o are case insensitive
+o are infix matching (do not need to match the entire thing being
+o are infix matching (do not need to match the entire thing being
matched)
+o are POSIX extended regular expressions
+o also support GNU word boundaries (\<, \>, \b, \B)
+o and parenthesised capturing groups and numeric backreferences in
+o and parenthesised capturing groups and numeric backreferences in
replacement strings
+o do not support mode modifiers like (?s)
Some things to note:
+o In the alias directive and --alias option, regular expressions must
be enclosed in forward slashes (/REGEX/). Elsewhere in hledger,
+o In the alias directive and --alias option, regular expressions must
be enclosed in forward slashes (/REGEX/). Elsewhere in hledger,
these are not required.
+o To match a regular expression metacharacter like $ as a literal char-
acter, prepend a backslash. Eg to search for amounts with the dollar
sign in hledger-web, write cur:\$.
+o On the command line, some metacharacters like $ have a special mean-
+o On the command line, some metacharacters like $ have a special mean-
ing to the shell and so must be escaped a second time, with single or
double quotes or another backslash. Eg, to match amounts with the
double quotes or another backslash. Eg, to match amounts with the
dollar sign from the command line, write cur:'\$' or cur:\\$.
QQUUEERRIIEESS
One of hledger's strengths is being able to quickly report on precise
subsets of your data. Most commands accept an optional query expres-
sion, written as arguments after the command name, to filter the data
by date, account name or other criteria. The syntax is similar to a
One of hledger's strengths is being able to quickly report on precise
subsets of your data. Most commands accept an optional query expres-
sion, written as arguments after the command name, to filter the data
by date, account name or other criteria. The syntax is similar to a
web search: one or more space-separated search terms, quotes to enclose
whitespace, optional prefixes to match specific fields. Multiple
whitespace, optional prefixes to match specific fields. Multiple
search terms are combined as follows:
All commands except print: show transactions/postings/accounts which
All commands except print: show transactions/postings/accounts which
match (or negatively match)
+o any of the description terms AND
@ -373,22 +376,22 @@ QQUUEERRIIEESS
same as above
aammtt::NN,, aammtt::<<NN,, aammtt::<<==NN,, aammtt::>>NN,, aammtt::>>==NN
match postings with a single-commodity amount that is equal to,
less than, or greater than N. (Multi-commodity amounts are not
match postings with a single-commodity amount that is equal to,
less than, or greater than N. (Multi-commodity amounts are not
tested, and will always match.) The comparison has two modes: if
N is preceded by a + or - sign (or is 0), the two signed numbers
are compared. Otherwise, the absolute magnitudes are compared,
are compared. Otherwise, the absolute magnitudes are compared,
ignoring sign.
ccooddee::RREEGGEEXX
match by transaction code (eg check number)
ccuurr::RREEGGEEXX
match postings or transactions including any amounts whose cur-
rency/commodity symbol is fully matched by REGEX. (For a par-
match postings or transactions including any amounts whose cur-
rency/commodity symbol is fully matched by REGEX. (For a par-
tial match, use .*REGEX.*). Note, to match characters which are
regex-significant, like the dollar sign ($), you need to prepend
\. And when using the command line you need to add one more
\. And when using the command line you need to add one more
level of quoting to hide it from the shell, so eg do:
hledger print cur:'\$' or hledger print cur:\\$.
@ -396,27 +399,27 @@ QQUUEERRIIEESS
match transaction descriptions
ddaattee::PPEERRIIOODDEEXXPPRR
match dates within the specified period (which should not
match dates within the specified period (which should not
include a reporting interval
ddaattee22::PPEERRIIOODDEEXXPPRR
as above, but match secondary dates
ddeepptthh::NN
match (or display, depending on command) accounts at or above
match (or display, depending on command) accounts at or above
this depth
rreeaall::,, rreeaall::00
match real or virtual postings respectively
ssttaattuuss::**,, ssttaattuuss::!!,, ssttaattuuss::
match cleared, pending, or uncleared/pending transactions
match cleared, pending, or uncleared/pending transactions
respectively
ttaagg::RREEGGEEXX[[==RREEGGEEXX]]
match by tag name, and optionally also by tag value. Note a
tag: query is considered to match a transaction if it matches
any of the postings. Also remember that postings inherit the
match by tag name, and optionally also by tag value. Note a
tag: query is considered to match a transaction if it matches
any of the postings. Also remember that postings inherit the
tags of their parent transaction.
nnoott:: before any of the above negates the match.
@ -424,19 +427,19 @@ QQUUEERRIIEESS
* * * * *
Some of these can also be expressed as command-line options (eg depth:2
is equivalent to --depth 2). Generally you can mix options and query
arguments, and the resulting query will be their intersection (perhaps
is equivalent to --depth 2). Generally you can mix options and query
arguments, and the resulting query will be their intersection (perhaps
excluding the -p/--period option).
CCOOMMMMAANNDDSS
hledger provides a number of subcommands; hledger with no arguments
hledger provides a number of subcommands; hledger with no arguments
shows a list.
If you install additional hledger-* packages, or if you put programs or
scripts named hledger-NAME in your PATH, these will also be listed as
scripts named hledger-NAME in your PATH, these will also be listed as
subcommands.
Run a subcommand by writing its name as first argument (eg
Run a subcommand by writing its name as first argument (eg
hledger incomestatement). You can also write any unambiguous prefix of
a command name (hledger inc), or one of the standard short aliases dis-
played in the command list (hledger is).
@ -451,14 +454,14 @@ CCOOMMMMAANNDDSS
----ddrroopp==NN
in flat mode: omit N leading account name parts
This command lists all account names that are in use (ie, all the
accounts which have at least one transaction posting to them). With
This command lists all account names that are in use (ie, all the
accounts which have at least one transaction posting to them). With
query arguments, only matched account names are shown.
It shows a flat list by default. With --tree, it uses indentation to
It shows a flat list by default. With --tree, it uses indentation to
show the account hierarchy.
In flat mode you can add --drop N to omit the first few account name
In flat mode you can add --drop N to omit the first few account name
components.
Examples:
@ -501,8 +504,8 @@ CCOOMMMMAANNDDSS
aaccttiivviittyy
Show an ascii barchart of posting counts per interval.
The activity command displays an ascii histogram showing transaction
counts by day, week, month or other reporting interval (by day is the
The activity command displays an ascii histogram showing transaction
counts by day, week, month or other reporting interval (by day is the
default). With query arguments, it counts only matched transactions.
$ hledger activity --quarterly
@ -515,23 +518,23 @@ CCOOMMMMAANNDDSS
Prompt for transactions and add them to the journal.
----nnoo--nneeww--aaccccoouunnttss
don't allow creating new accounts; helps prevent typos when
don't allow creating new accounts; helps prevent typos when
entering account names
Many hledger users edit their journals directly with a text editor, or
generate them from CSV. For more interactive data entry, there is the
add command, which prompts interactively on the console for new trans-
actions, and appends them to the journal file (existing transactions
are not changed). This is the only hledger command that writes to the
Many hledger users edit their journals directly with a text editor, or
generate them from CSV. For more interactive data entry, there is the
add command, which prompts interactively on the console for new trans-
actions, and appends them to the journal file (existing transactions
are not changed). This is the only hledger command that writes to the
journal file.
To use it, just run hledger add and follow the prompts. You can add as
many transactions as you like; when you are finished, enter . or press
many transactions as you like; when you are finished, enter . or press
control-d or control-c to exit.
Features:
+o add tries to provide useful defaults, using the most similar recent
+o add tries to provide useful defaults, using the most similar recent
transaction (by description) as a template.
+o You can also set the initial defaults with command line arguments.
@ -539,20 +542,20 @@ CCOOMMMMAANNDDSS
+o Readline-style edit keys can be used during data entry.
+o The tab key will auto-complete whenever possible - accounts, descrip-
tions, dates (yesterday, today, tomorrow). If the input area is
tions, dates (yesterday, today, tomorrow). If the input area is
empty, it will insert the default value.
+o If the journal defines a default commodity, it will be added to any
+o If the journal defines a default commodity, it will be added to any
bare numbers entered.
+o A parenthesised transaction code may be entered following a date.
+o Comments and tags may be entered following a description or amount.
+o If you make a mistake, enter < at any prompt to restart the transac-
+o If you make a mistake, enter < at any prompt to restart the transac-
tion.
+o Input prompts are displayed in a different colour when the terminal
+o Input prompts are displayed in a different colour when the terminal
supports it.
Example (see the tutorial for a detailed explanation):
@ -624,7 +627,7 @@ CCOOMMMMAANNDDSS
--OO FFMMTT ----oouuttppuutt--ffoorrmmaatt==FFMMTT
select the output format. Supported formats: txt, csv.
The balance command displays accounts and balances. It is hledger's
The balance command displays accounts and balances. It is hledger's
most featureful and most useful command.
$ hledger balance
@ -641,168 +644,163 @@ CCOOMMMMAANNDDSS
--------------------
0
More precisely, the balance command shows the _c_h_a_n_g_e to each account's
More precisely, the balance command shows the _c_h_a_n_g_e to each account's
balance caused by all (matched) postings. In the common case where you
do not filter by date and your journal sets the correct opening bal-
do not filter by date and your journal sets the correct opening bal-
ances, this is the same as the account's ending balance.
By default, accounts are displayed hierarchically, with subaccounts
By default, accounts are displayed hierarchically, with subaccounts
indented below their parent. "Boring" accounts, which contain a single
interesting subaccount and no balance of their own, are elided into the
following line for more compact output. (Use --no-elide to prevent
following line for more compact output. (Use --no-elide to prevent
this.)
Each account's balance is the "inclusive" balance - it includes the
Each account's balance is the "inclusive" balance - it includes the
balances of any subaccounts.
Accounts which have zero balance (and no non-zero subaccounts) are
Accounts which have zero balance (and no non-zero subaccounts) are
omitted. Use -E/--empty to show them.
A final total is displayed by default; use -N/--no-total to suppress
it:
$ hledger balance -p 2008/6 expenses --no-total
$2 expenses
$1 food
$1 supplies
A final total is displayed by default; use -N/--no-total to suppress
it.
FFllaatt mmooddee
To see a flat list of full account names instead of the default hierar-
chical display, use --flat. In this mode, accounts (unless
depth-clipped) show their "exclusive" balance, excluding any subaccount
balances. In this mode, you can also use --drop N to omit the first
few account name components.
$ hledger balance -p 2008/6 expenses -N --flat --drop 1
$1 food
$1 supplies
To see a flat list of full account names instead of the default hierar-
chical display, use --flat. In this mode, accounts (unless
depth-clipped) show their "exclusive" balance, excluding any subaccount
balances. In this mode, you can also use --drop N to omit the first
few account name components.
DDeepptthh lliimmiittiinngg
With --depth N, balance shows accounts only to the specified depth.
This is very useful to show a complex charts of accounts in less
detail. In flat mode, balances from accounts below the depth limit
will be shown as part of a parent account at the depth limit.
$ hledger balance -N --depth 1
$-1 assets
$2 expenses
$-2 income
$1 liabilities
With --depth N, balance shows accounts only to the specified depth.
This is very useful to show a complex charts of accounts in less
detail. In flat mode, balances from accounts below the depth limit
will be shown as part of a parent account at the depth limit.
MMuullttiiccoolluummnn bbaallaannccee rreeppoorrttss
With a reporting interval, multiple balance columns will be shown, one
for each report period. There are three types of multi-column balance
With a reporting interval, multiple balance columns will be shown, one
for each report period. There are three types of multi-column balance
report, showing different information:
$ hledger balance --quarterly income expenses -E
Balance changes in 2008:
|| 2008q1 2008q2 2008q3 2008q4
===================++=================================
expenses:food || 0 $1 0 0
expenses:supplies || 0 $1 0 0
income:gifts || 0 $-1 0 0
income:salary || $-1 0 0 0
-------------------++---------------------------------
|| $-1 $1 0 0
1. By default: each column shows the sum of postings in that period, ie
the account's change of balance in that period. This is useful eg
for a monthly income statement.
the account's change of balance in that period. This is useful eg
for a monthly income statement:
$ hledger balance --quarterly income expenses -E --cumulative
Ending balances (cumulative) in 2008:
$ hledger balance --quarterly income expenses -E
Balance changes in 2008:
|| 2008/03/31 2008/06/30 2008/09/30 2008/12/31
===================++=================================================
expenses:food || 0 $1 $1 $1
expenses:supplies || 0 $1 $1 $1
income:gifts || 0 $-1 $-1 $-1
income:salary || $-1 $-1 $-1 $-1
-------------------++-------------------------------------------------
|| $-1 0 0 0
|| 2008q1 2008q2 2008q3 2008q4
===================++=================================
expenses:food || 0 $1 0 0
expenses:supplies || 0 $1 0 0
income:gifts || 0 $-1 0 0
income:salary || $-1 0 0 0
-------------------++---------------------------------
|| $-1 $1 0 0
2. With --cumulative: each column shows the ending balance for that
period, accumulating the changes across periods, starting from 0 at
the report start date. This mode is not often used.
2. With --cumulative: each column shows the ending balance for that
period, accumulating the changes across periods, starting from 0 at
the report start date:
$ hledger balance ^assets ^liabilities -Q
Balance changes in 2008:
$ hledger balance --quarterly income expenses -E --cumulative
Ending balances (cumulative) in 2008:
|| 2008q1 2008q2 2008q3 2008q4
======================++=================================
assets:bank:checking || $1 0 0 $-1
assets:bank:saving || 0 $1 0 0
assets:cash || 0 $-2 0 0
liabilities:debts || 0 0 0 $1
----------------------++---------------------------------
|| $1 $-1 0 0
$ hledger balance ^assets ^liabilities --quarterly --historical --begin 2008/4/1
Ending balances (historical) in 2008/04/01-2008/12/31:
|| 2008/06/30 2008/09/30 2008/12/31
======================++=====================================
assets:bank:checking || $1 $1 0
assets:bank:saving || $1 $1 $1
assets:cash || $-2 $-2 $-2
liabilities:debts || 0 0 $1
----------------------++-------------------------------------
|| 0 0 0
|| 2008/03/31 2008/06/30 2008/09/30 2008/12/31
===================++=================================================
expenses:food || 0 $1 $1 $1
expenses:supplies || 0 $1 $1 $1
income:gifts || 0 $-1 $-1 $-1
income:salary || $-1 $-1 $-1 $-1
-------------------++-------------------------------------------------
|| $-1 0 0 0
3. With --historical/-H: each column shows the actual historical ending
balance for that period, accumulating the changes across periods,
starting from the actual balance at the report start date. This is
balance for that period, accumulating the changes across periods,
starting from the actual balance at the report start date. This is
useful eg for a multi-period balance sheet, and when you are showing
only the data after a certain start date.
only the data after a certain start date:
$ hledger balance -Q income expenses --tree -E -TA
Balance changes in 2008:
$ hledger balance ^assets ^liabilities --quarterly --historical --begin 2008/4/1
Ending balances (historical) in 2008/04/01-2008/12/31:
|| 2008q1 2008q2 2008q3 2008q4 Total Average
============++===================================================
expenses || 0 $2 0 0 $2 $1
food || 0 $1 0 0 $1 0
supplies || 0 $1 0 0 $1 0
income || $-1 $-1 0 0 $-2 $-1
gifts || 0 $-1 0 0 $-1 0
salary || $-1 0 0 0 $-1 0
------------++---------------------------------------------------
|| $-1 $1 0 0 0 0
|| 2008/06/30 2008/09/30 2008/12/31
======================++=====================================
assets:bank:checking || $1 $1 0
assets:bank:saving || $1 $1 $1
assets:cash || $-2 $-2 $-2
liabilities:debts || 0 0 $1
----------------------++-------------------------------------
|| 0 0 0
# Average is rounded to the dollar here since all journal amounts are
Multi-column balance reports display accounts in flat mode by default;
Multi-column balance reports display accounts in flat mode by default;
to see the hierarchy, use --tree.
Note that with a reporting interval, the report start/end dates will be
"enlarged" if necessary so that they encompass the displayed report
periods. This is so that the first and last periods will be "full" and
comparable to the others.
With a reporting interval (like --quarterly above), the report
start/end dates will be adjusted if necessary so that they encompass
the displayed report periods. This is so that the first and last peri-
ods will be "full" and comparable to the others.
The -E/--empty flag does two things here: first, the report will show
all columns within the specified report period (without -E, leading and
trailing columns with all zeroes are not shown). Second, all accounts
which existed at the report start date will be considered, not just the
ones with activity during the report period (use -E to include
low-activity accounts which would otherwise would be omitted).
The -E/--empty flag does two things in multicolumn balance reports:
first, the report will show all columns within the specified report
period (without -E, leading and trailing columns with all zeroes are
not shown). Second, all accounts which existed at the report start
date will be considered, not just the ones with activity during the
report period (use -E to include low-activity accounts which would oth-
erwise would be omitted).
The -T/--row-total flag adds an additional column showing the total for
each row. The -A/--average flag adds a column showing the average
value in each row. Note in --H/--historical mode only the average is
useful, and in --cumulative mode neither is useful.
each row.
The -A/--average flag adds a column showing the average value in each
row.
Here's an example of all three:
$ hledger balance -Q income expenses --tree -ETA
Balance changes in 2008:
|| 2008q1 2008q2 2008q3 2008q4 Total Average
============++===================================================
expenses || 0 $2 0 0 $2 $1
food || 0 $1 0 0 $1 0
supplies || 0 $1 0 0 $1 0
income || $-1 $-1 0 0 $-2 $-1
gifts || 0 $-1 0 0 $-1 0
salary || $-1 0 0 0 $-1 0
------------++---------------------------------------------------
|| $-1 $1 0 0 0 0
# Average is rounded to the dollar here since all journal amounts are
MMaarrkkeett vvaalluuee
The -V/--value flag converts all the reported amounts to their "current
market value" using their default market price. That is the latest
market price (P directive) found in the journal (or an included file),
market value" using their default market price. That is the latest
market price (P directive) found in the journal (or an included file),
for the amount's commodity, dated on or before the report end date.
Unlike Ledger, hledger's -V only uses the market prices recorded with P
directives, ignoring transaction prices recorded as part of posting
directives, ignoring transaction prices recorded as part of posting
amounts (which -B/--cost uses). Using -B and -V together is allowed.
CCuussttoomm bbaallaannccee oouuttppuutt
In simple (non-multi-column) balance reports, you can customise the
output with --format FMT:
$ hledger balance --format "%20(account) %12(total)"
assets $-1
bank:saving $1
@ -817,70 +815,69 @@ CCOOMMMMAANNDDSS
---------------------------------
0
In simple (non-multi-column) balance reports, you can customise the
output with --format FMT. FMT (plus a newline) will be displayed for
each account/balance pair. It is a format string with data fields
interpolated by
The FMT format string (plus a newline) specifies the formatting applied
to each account/balance pair. It may contain any suitable text, with
data fields interpolated like so:
%[MIN][.MAX](FIELDNAME)
where MIN means pad with spaces to at least this width, and MAX means
truncate at this width. The field name must be enclosed in parenthe-
ses. Three fields are available:
+o MIN pads with spaces to at least this width (optional)
+o depth_spacer - a number of spaces equal to the account's depth, or if
MIN is specified, MIN * depth spaces.
+o MAX truncates at this width (optional)
+o account - the account's name
+o FIELDNAME must be enclosed in parentheses, and can be one of:
+o total - the account's balance/posted total, right justified
+o depth_spacer - a number of spaces equal to the account's depth, or
if MIN is specified, MIN * depth spaces.
When the total has multiple commodities, by default each commodity is
displayed on a separate line, and the report item will be bottom
aligned. You can change how such multi-line values are rendered by
beginning the format with a special prefix:
+o account - the account's name
+o total - the account's balance/posted total, right justified
Also, FMT can begin with an optional prefix to control how multi-com-
modity amounts are rendered:
+o %_ - render on multiple lines, bottom-aligned (the default)
+o %^ - render on multiple lines, top-aligned
+o %, - render on one line, with multi-line values comma-separated
+o %, - render on one line, comma-separated
There are some quirks, and experimentation may be needed to get pleas-
ing output. In one-line mode, %(depth_spacer) has no effect, instead
%(account) has indentation built in.
There are some quirks. Eg in one-line mode, %(depth_spacer) has no
effect, instead %(account) has indentation built in.
Experimentation may be needed to get pleasing results.
Examples:
Some example formats:
+o %(total) - the account's total
+o %-20.20(account) - the account's name, left justified, padded to 20
characters and clipped at 20 characters
+o %20(total) %2(depth_spacer)%-(account) - default format for the sin-
gle-column balance report
+o %,%-50(account) %25(total) - account name padded to 50 characters,
total padded to 20 characters, with multiple commodities rendered on
+o %,%-50(account) %25(total) - account name padded to 50 characters,
total padded to 20 characters, with multiple commodities rendered on
one line
OOuuttppuutt ddeessttiinnaattiioonn
$ hledger balance -o - # write to stdout (the default)
$ hledger balance -o FILE # write to FILE
+o %20(total) %2(depth_spacer)%-(account) - the default format for the
single-column balance report
OOuuttppuutt ddeessttiinnaattiioonn
The balance, print, register and stats commands can write their output
to a destination other than the console. This is controlled by the
-o/--output-file option.
CCSSVV oouuttppuutt
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
$ hledger balance -o - # write to stdout (the default)
$ hledger balance -o FILE # write to FILE
CCSSVV oouuttppuutt
The balance, print and register commands can write their output as CSV.
This is useful for exporting data to other applications, eg to make
charts in a spreadsheet. This is controlled by the -O/--output-format
option, or by specifying a .csv file extension with -o/--output-file.
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
bbaallaanncceesshheeeett
Show a balance sheet. Alias: bs.
@ -1014,16 +1011,6 @@ CCOOMMMMAANNDDSS
--OO FFMMTT ----oouuttppuutt--ffoorrmmaatt==FFMMTT
select the output format. Supported formats: txt, csv.
The print command displays full transactions from the journal file,
tidily formatted and showing all amounts explicitly. The output of
print is always a valid hledger journal, but it does always not pre-
serve all original content exactly (eg directives).
hledger's print command also shows all unit prices in effect, or (with
-B/--cost) shows cost amounts.
The print command also supports output destination and CSV output.
$ hledger print
2008/01/01 income
assets:bank:checking $1
@ -1046,6 +1033,16 @@ CCOOMMMMAANNDDSS
liabilities:debts $1
assets:bank:checking $-1
The print command displays full transactions from the journal file,
tidily formatted and showing all amounts explicitly. The output of
print is always a valid hledger journal, but it does always not pre-
serve all original content exactly (eg directives).
hledger's print command also shows all unit prices in effect, or (with
-B/--cost) shows cost amounts.
The print command also supports output destination and CSV output.
rreeggiisstteerr
Show postings and their running total. Alias: reg.
@ -1070,25 +1067,25 @@ CCOOMMMMAANNDDSS
--OO FFMMTT ----oouuttppuutt--ffoorrmmaatt==FFMMTT
select the output format. Supported formats: txt, csv.
The register command displays postings, one per line, and their running
total. This is typically used with a query selecting a particular
account, to see that account's activity:
$ hledger register checking
2008/01/01 income assets:bank:checking $1 $1
2008/06/01 gift assets:bank:checking $1 $2
2008/06/02 save assets:bank:checking $-1 $1
2008/12/31 pay off assets:bank:checking $-1 0
The register command displays postings, one per line, and their running
total. This is typically used with a query selecting a particular
account, to see that account's activity.
The --historical/-H flag adds the balance from any undisplayed prior
postings to the running total. This is useful when you want to see
only recent activity, with a historically accurate running balance:
$ hledger register checking -b 2008/6 --historical
2008/06/01 gift assets:bank:checking $1 $2
2008/06/02 save assets:bank:checking $-1 $1
2008/12/31 pay off assets:bank:checking $-1 0
The --historical/-H flag adds the balance from any prior postings to
the running total, to show the actual historical running balance. This
is useful when you want to see just the recent activity.
The --depth option limits the amount of sub-account detail displayed.
The --average/-A flag shows the running average posting amount instead
@ -1099,10 +1096,16 @@ CCOOMMMMAANNDDSS
The --related/-r flag shows the _o_t_h_e_r postings in the transactions of
the postings which would normally be shown.
With a reporting interval, register shows summary postings, one per
interval, aggregating the postings to each account:
$ hledger register --monthly income
2008/01 income:salary $-1 $-1
2008/06 income:gifts $-1 $-2
Periods with no activity, and summary postings with a zero amount, are
not shown by default; use the --empty/-E flag to see them:
$ hledger register --monthly income -E
2008/01 income:salary $-1 $-1
2008/02 0 $-1
@ -1117,20 +1120,14 @@ CCOOMMMMAANNDDSS
2008/11 0 $-2
2008/12 0 $-2
$ hledger register --monthly assets --depth 1 # cashflow (changes to assets) by month
Often, you'll want to see just one line per interval. The --depth
option helps with this, causing subaccounts to be aggregated:
$ hledger register --monthly assets --depth 1h
2008/01 assets $1 $1
2008/06 assets $-1 0
2008/12 assets $-1 $-1
With a reporting interval, register shows summary postings, one per
interval, aggregating the postings to each account.
Periods with no activity, and summary postings with a zero amount, are
not shown by default; use the --empty/-E flag to see them.
Often, you'll want to see just one line per interval. The --depth
option helps with this, causing subaccounts to be aggregated.
Note when using report intervals, if you specify start/end dates these
will be adjusted outward if necessary to contain a whole number of
intervals. This ensures that the first and last intervals are full
@ -1152,12 +1149,12 @@ CCOOMMMMAANNDDSS
and some examples:
$ hledger reg # use terminal width (or 80 on windows)
$ hledger reg -w 100 # use width 100
$ COLUMNS=100 hledger reg # set with one-time environment variable
$ export COLUMNS=100; hledger reg # set till session end (or window resize)
$ hledger reg -w 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
$ hledger reg # use terminal width (or 80 on windows)
$ hledger reg -w 100 # use width 100
$ COLUMNS=100 hledger reg # set with one-time environment variable
$ export COLUMNS=100; hledger reg # set till session end (or window resize)
$ hledger reg -w 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
The register command also supports the -o/--output-file and -O/--out-
put-format options for controlling output destination and CSV output.

View File

@ -10,7 +10,8 @@ COMMAND, not before it.
Also, when invoking external add-on commands, their options must be
written after a double hyphen. (Or, you can invoke the external command
directly.) Eg:
_shellbold_({{
_shell_({{
$ hledger ui -- --register cash
$ hledger-ui --register cash
}})
@ -120,17 +121,17 @@ hledger's user interfaces accept a flexible "smart date" syntax (unlike dates in
Examples:
|
|--------------------------------------------------|------------------------------------------------------|
| `2009/1/1`, `2009/01/01`, `2009-1-1`, `2009.1.1` &nbsp; | simple dates, several separators allowed |
| `2009/1`, `2009` | same as above - a missing day or month defaults to 1 |
| `1/1`, `january`, `jan`, `this year` | relative dates, meaning january 1 of the current year|
| `next year` | january 1 of 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 |
| `lastweek` | spaces are optional |
| `today`, `yesterday`, `tomorrow` | |
------------------------------------------------- ------------------------------------------------------
`2009/1/1`, `2009/01/01`, `2009-1-1`, `2009.1.1` simple dates, several separators allowed
`2009/1`, `2009` same as above - a missing day or month defaults to 1
`1/1`, `january`, `jan`, `this year` relative dates, meaning january 1 of the current year
`next year` january 1 of 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
`lastweek` spaces are optional
`today`, `yesterday`, `tomorrow`
---
## Reporting interval
@ -149,38 +150,48 @@ once. Note a period expression on the command line will cause any other date
flags (`-b`/`-e`/`-D`/`-W`/`-M`/`-Q`/`-Y`) to be ignored.
hledger's period expressions are similar to Ledger's, though not identical.
Here's a basic period expression specifying the first quarter of 2009. Note
Here's a basic period expression specifying the first quarter of 2009. Note,
hledger always treats start dates as inclusive and end dates as exclusive:
-p "from 2009/1/1 to 2009/4/1"
`-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:
Keywords like "from" and "to" are optional, and so are the spaces, as long
as you don't run two dates together. "to" can also be written as "-".
These are equivalent to the above:
-p2009/1/1to2009/4/1
-p"2009/1/1 2009/4/1"
------------------------------
`-p "2009/1/1 2009/4/1"`
`-p2009/1/1to2009/4/1`
`-p2009/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"
------------------------------
`-p "1/1 4/1"`
`-p "january-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 journal:
-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)
---------------------------- ---------------------------------
`-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")
--------------------- ------------------------------------------------------
`-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"
--------------------- ------------------------------------------------------
Period expressions can also start with (or be) a reporting interval:
`daily`, `weekly`, `monthly`, `quarterly`, `yearly`, or one of the
@ -188,14 +199,16 @@ Period expressions can also start with (or be) a reporting interval:
between the reporting interval and the start/end dates.
Examples:
-p "weekly from 2009/1/1 to 2009/4/1"
-p "monthly in 2008"
-p "bimonthly from 2008"
-p "quarterly"
-p "every 2 weeks"
-p "every 5 days from 1/3"
-p "every 15th day of month"
-p "every 4th day of week"
------------------------------------------
`-p "weekly from 2009/1/1 to 2009/4/1"`
`-p "monthly in 2008"`
`-p "bimonthly from 2008"`
`-p "quarterly"`
`-p "every 2 weeks"`
`-p "every 5 days from 1/3"`
`-p "every 15th day of month"`
`-p "every 4th day of week"`
------------------------------------------
## Regular Expressions

View File

@ -26,15 +26,12 @@ show transactions which
The following kinds of search terms can be used:
**`REGEX`**
: match account names by this regular expression
**`acct:REGEX`**
: same as above
**`amt:N, amt:<N, amt:<=N, amt:>N, amt:>=N`**
: match postings with a single-commodity amount that is equal to, less
than, or greater than N. (Multi-commodity amounts are not tested, and
@ -43,11 +40,9 @@ a + or - sign (or is 0), the two signed numbers are
compared. Otherwise, the absolute magnitudes are compared, ignoring
sign.
**`code:REGEX`**
: match by transaction code (eg check number)
**`cur:REGEX`**
: match postings or transactions including any amounts whose
currency/commodity symbol is fully matched by REGEX. (For a partial
@ -57,39 +52,31 @@ And when using the command line you need to add one more level of
quoting to hide it from the shell, so eg do: `hledger print cur:'\$'`
or `hledger print cur:\\$`.
**`desc:REGEX`**
: match transaction descriptions
**`date:PERIODEXPR`**
: match dates within the specified period (which should not include a
reporting interval
**`date2:PERIODEXPR`**
: as above, but match secondary dates
**`depth:N`**
: match (or display, depending on command) accounts at or above this depth
**`real:, real:0`**
: match real or virtual postings respectively
**`status:*, status:!, status:`**
: match cleared, pending, or uncleared/pending transactions respectively
**`tag:REGEX[=REGEX]`**
: match by tag name, and optionally also by tag value. Note a
tag: query is considered to match a transaction if it matches any of
the postings. Also remember that postings inherit the tags of their
parent transaction.
**`not:`**
: before any of the above negates the match.

View File

@ -27,7 +27,7 @@ I'm not sure yet).
Here's an example of setting the locale temporarily, on ubuntu gnu/linux:
```{.shell}
```shell
$ file my.journal
my.journal: UTF-8 Unicode text # <- the file is UTF8-encoded
$ locale -a
@ -39,14 +39,14 @@ $ LANG=en_US.utf8 hledger -f my.journal print # <- use it for this command
Here's one way to set it permanently, there are probably better ways:
```{.shell}
```shell
$ echo "export LANG=en_US.UTF-8" >>~/.bash_profile
$ bash --login
```
If we preferred to use eg `fr_FR.utf8`, we might have to install that first:
```{.shell}
```shell
$ apt-get install language-pack-fr
$ locale -a
C

View File

@ -1,16 +1,23 @@
table {
margin-bottom:1em;
}
code {
background-color:inherit;
color: inherit;
}
pre {
font-size:small;
margin-left:2em;
}
pre.shell, pre.journal, pre.csv, pre.rules, pre.timeclock, pre.timedot {
/* clear:both; */
background-color:inherit;
border:none;
/* margin-left:1em; */
/* margin-right:2em; */
border-radius:6px;
display:inline-block;
/* display:table; */
/* display:inline-block; */
display:table;
/* background-color:#e0e0e0; */
font-size:small;
/* white-space:nowrap; */
@ -18,6 +25,9 @@ pre {
pre > code {
white-space:pre;
}
pre.shell::first-line {
font-weight:bold;
}
.clear {
clear:both;
}
@ -27,27 +37,32 @@ h4, h5, h6 {
.display-table {
display:table;
}
.journal {
pre.journal {
background-color:#efe;
border:thin solid #cec;
/* border:none; */
}
.timeclock {
background-color:#ffe;
border:thin solid #eec;
/* border:none; */
}
.csv {
pre.csv {
background-color:#cce;
border:thin solid #aad;
/* border:none; */
}
.rules {
pre.rules {
background-color:#eef;
border:thin solid #cce;
/* border:none; */
}
.shell {
pre.timeclock {
background-color:#ffe;
border:thin solid #eec;
/* border:none; */
}
pre.timedot {
background-color:#ffe;
border:thin solid #eec;
/* border:none; */
}
pre.shell {
background-color:white;
border:none;
border-left:2px solid black;
@ -58,9 +73,6 @@ h4, h5, h6 {
/* padding-bottom:0; */
}
.shell::first-line {
font-weight:bold;
}
.shell.continued {
background-color:white;
border-top:none;