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 other commodity, using double\-entry accounting and a simple, editable
file format. file format.
hledger is inspired by and largely compatible with ledger(1). hledger is inspired by and largely compatible with ledger(1).
.PP
hledger\-ui is hledger\[aq]s curses\-style interface. hledger\-ui is hledger\[aq]s curses\-style interface.
It reads a hledger journal file It reads a hledger journal file
.PP .PP

View File

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

View File

@ -44,7 +44,7 @@ txt, csv.
The balance command displays accounts and balances. The balance command displays accounts and balances.
It is hledger's most featureful and most useful command. It is hledger's most featureful and most useful command.
``` {.shell .right} ```shell
$ hledger balance $ hledger balance
$-1 assets $-1 assets
$1 bank:saving $1 bank:saving
@ -76,30 +76,34 @@ 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. 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 $ hledger balance -p 2008/6 expenses --no-total
$2 expenses $2 expenses
$1 food $1 food
$1 supplies $1 supplies
``` ```
A final total is displayed by default; use `-N/--no-total` to suppress it.
### Flat mode ### 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`. 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, 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. 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 ### 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 $ hledger balance -N --depth 1
$-1 assets $-1 assets
$2 expenses $2 expenses
@ -107,10 +111,6 @@ $ hledger balance -N --depth 1
$1 liabilities $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 --> <!-- $ for y in 2006 2007 2008 2009 2010; do echo; echo $y; hledger -f $y.journal balance ^expenses --depth 2; done -->
### Multicolumn balance reports ### Multicolumn balance reports
@ -119,24 +119,9 @@ With a [reporting interval](#reporting-interval), multiple balance
columns will be shown, one for each report period. columns will be shown, one for each report period.
There are three types of multi-column balance report, showing different information: 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, 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 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: multi-column income statement:
@ -147,63 +132,87 @@ or cashflow statement:
$ hledger balance ^assets ^liabilities 'not:(receivable|payable)' -p 'weekly this month' $ hledger balance ^assets ^liabilities 'not:(receivable|payable)' -p 'weekly this month'
--> -->
<div style="clear:both;"></div> ```shell
``` {.shell .right} $ hledger balance --quarterly income expenses -E
$ hledger balance --quarterly income expenses -E --cumulative Balance changes in 2008:
Ending balances (cumulative) in 2008:
|| 2008/03/31 2008/06/30 2008/09/30 2008/12/31 || 2008q1 2008q2 2008q3 2008q4
===================++================================================= ===================++=================================
expenses:food || 0 $1 $1 $1 expenses:food || 0 $1 0 0
expenses:supplies || 0 $1 $1 $1 expenses:supplies || 0 $1 0 0
income:gifts || 0 $-1 $-1 $-1 income:gifts || 0 $-1 0 0
income:salary || $-1 $-1 $-1 $-1 income:salary || $-1 0 0 0
-------------------++------------------------------------------------- -------------------++---------------------------------
|| $-1 0 0 0 || $-1 $1 0 0
``` ```
2. With `--cumulative`: each column shows the ending balance for that 2. With `--cumulative`: each column shows the ending balance for that
period, accumulating the changes across periods, starting from 0 at 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
``` {.shell .right} $ hledger balance --quarterly income expenses -E --cumulative
$ hledger balance ^assets ^liabilities -Q Ending balances (cumulative) in 2008:
Balance changes in 2008:
|| 2008q1 2008q2 2008q3 2008q4 || 2008/03/31 2008/06/30 2008/09/30 2008/12/31
======================++================================= ===================++=================================================
assets:bank:checking || $1 0 0 $-1 expenses:food || 0 $1 $1 $1
assets:bank:saving || 0 $1 0 0 expenses:supplies || 0 $1 $1 $1
assets:cash || 0 $-2 0 0 income:gifts || 0 $-1 $-1 $-1
liabilities:debts || 0 0 0 $1 income:salary || $-1 $-1 $-1 $-1
----------------------++--------------------------------- -------------------++-------------------------------------------------
|| $1 $-1 0 0 || $-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 3. With `--historical/-H`: each column shows the actual historical
ending balance for that period, accumulating the changes across ending balance for that period, accumulating the changes across
periods, starting from the actual balance at the report start date. periods, starting from the actual balance at the report start date.
This is useful eg for a multi-period balance sheet, and when 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
``` {.shell .right} $ hledger balance ^assets ^liabilities --quarterly --historical --begin 2008/4/1
$ hledger balance -Q income expenses --tree -E -TA 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: Balance changes in 2008:
|| 2008q1 2008q2 2008q3 2008q4 Total Average || 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 ### Market value
The `-V/--value` flag converts all the reported amounts to their 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 P directives, ignoring transaction prices recorded as part of posting
amounts (which -B/--cost uses). Using -B and -V together is allowed. amounts (which -B/--cost uses). Using -B and -V together is allowed.
<!--
``` {.shell .right}
$ hledger balance -V ...
```
-->
### Custom balance output ### 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)" $ hledger balance --format "%20(account) %12(total)"
assets $-1 assets $-1
bank:saving $1 bank:saving $1
@ -278,65 +263,62 @@ $ hledger balance --format "%20(account) %12(total)"
0 0
``` ```
In simple (non-multi-column) balance reports, you can customise the The FMT format string (plus a newline) specifies the formatting
output with `--format FMT`. FMT (plus a newline) will be displayed for applied to each account/balance pair. It may contain any suitable
each account/balance pair. It is a format string with data fields text, with data fields interpolated like so:
interpolated by
`%[MIN][.MAX](FIELDNAME)` `%[MIN][.MAX](FIELDNAME)`
where MIN means pad with spaces to at least this width, and MAX means - MIN pads with spaces to at least this width (optional)
truncate at this width. The field name must be enclosed in - MAX truncates at this width (optional)
parentheses. Three fields are available: - 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. - `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 - `account` - the account's name
- `total` - the account's balance/posted total, right justified - `total` - the account's balance/posted total, right justified
When the total has multiple commodities, by default each commodity is Also, FMT can begin with an optional prefix to control how
displayed on a separate line, and the report item will be bottom multi-commodity amounts are rendered:
aligned. You can change how such multi-line values are rendered by
beginning the format with a special prefix:
- `%_` - render on multiple lines, bottom-aligned (the default) - `%_` - render on multiple lines, bottom-aligned (the default)
- `%^` - render on multiple lines, top-aligned - `%^` - 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. There are some quirks. Eg in one-line mode, `%(depth_spacer)` has no
In one-line mode, `%(depth_spacer)` has no effect, instead `%(account)` has indentation built in. effect, instead `%(account)` has indentation built in.
<!-- XXX retest: <!-- XXX retest:
Consistent column widths are not well enforced, causing ragged edges unless you set suitable widths. 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. 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 - `%(total)` - the account's total
- `%-20.20(account)` - the account's name, left justified, padded to 20 characters and clipped at 20 characters - `%-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 - `%,%-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 ### 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 The balance, print, register and stats commands can write their output to a
destination other than the console. This is controlled by the destination other than the console. This is controlled by the
`-o/--output-file` option. `-o/--output-file` option.
### CSV output ```shell
$ hledger balance -o - # write to stdout (the default)
```{.shell .bold .right} $ hledger balance -o FILE # write to FILE
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
``` ```
### CSV output
The balance, print and register commands can write their output as The balance, print and register commands can write their output as
CSV. This is useful for exporting data to other applications, eg to CSV. This is useful for exporting data to other applications, eg to
make charts in a spreadsheet. This is controlled by the make charts in a spreadsheet. This is controlled by the
`-O/--output-format` option, or by specifying a `.csv` file extension `-O/--output-format` option, or by specifying a `.csv` file extension
with `-o/--output-file`. 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`). displayed in the command list (`hledger is`).
--- ---
# comment:
# for each command: name, synopsis, description, examples. # 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 transaction counts by day, week, month or other reporting interval
(by day is the default). With query arguments, it counts only matched transactions. (by day is the default). With query arguments, it counts only matched transactions.
_col3_({{ ```shell
_shell_({{
$ hledger activity --quarterly $ hledger activity --quarterly
2008-01-01 ** 2008-01-01 **
2008-04-01 ******* 2008-04-01 *******
2008-07-01 2008-07-01
2008-10-01 ** 2008-10-01 **
}}) ```
}})
## add ## add
Prompt for transactions and add them to the journal. 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` assumes that you have top-level accounts named `asset` and `liability`
(plural forms also allowed.) (plural forms also allowed.)
_col3_({{ ```shell
_shell_({{
$ hledger balancesheet $ hledger balancesheet
Balance Sheet Balance Sheet
@ -198,8 +196,7 @@ Liabilities:
Total: Total:
-------------------- --------------------
0 0
}}) ```
}})
## cashflow ## cashflow
Show a cashflow statement. Alias: cf. 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 account named `asset` and do not contain `receivable` or `A/R` (plural
forms also allowed.) forms also allowed.)
_col3_({{ ```shell
_shell_({{
$ hledger cashflow $ hledger cashflow
Cashflow Statement Cashflow Statement
@ -232,8 +228,7 @@ Cash flows:
Total: Total:
-------------------- --------------------
$-1 $-1
}}) ```
}})
## help ## help
Show detailed help. Show detailed help.
@ -280,8 +275,7 @@ This command displays a simple
currently assumes that you have top-level accounts named `income` (or currently assumes that you have top-level accounts named `income` (or
`revenue`) and `expense` (plural forms also allowed.) `revenue`) and `expense` (plural forms also allowed.)
_col3_({{ ```shell
_shell_({{
$ hledger incomestatement $ hledger incomestatement
Income Statement Income Statement
@ -302,8 +296,7 @@ Expenses:
Total: Total:
-------------------- --------------------
0 0
}}) ```
}})
## print ## print
Show transactions from the journal. Show transactions from the journal.
@ -318,21 +311,7 @@ Show transactions from the journal.
: select the output format. Supported formats: : select the output format. Supported formats:
txt, csv. txt, csv.
The print command displays full transactions from the journal file, ```shell
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_({{
$ hledger print $ hledger print
2008/01/01 income 2008/01/01 income
assets:bank:checking $1 assets:bank:checking $1
@ -354,9 +333,20 @@ $ hledger print
2008/12/31 * pay off 2008/12/31 * pay off
liabilities:debts $1 liabilities:debts $1
assets:bank:checking $-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 ## register
Show postings and their running total. Alias: reg. 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: : select the output format. Supported formats:
txt, csv. 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 $ hledger register checking
2008/01/01 income assets:bank:checking $1 $1 2008/01/01 income assets:bank:checking $1 $1
2008/06/01 gift assets:bank:checking $1 $2 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 2008/12/31 pay off assets:bank:checking $-1 0
``` ```
The register command displays postings, one per line, and their The `--historical`/`-H` flag adds the balance from any undisplayed
running total. This is typically used with a [query](#queries) prior postings to the running total. This is useful when you want to
selecting a particular account, to see that account's activity. see only recent activity, with a historically accurate running balance:
```{.shell .right .clear} ```shell
$ hledger register checking -b 2008/6 --historical $ hledger register checking -b 2008/6 --historical
2008/06/01 gift assets:bank:checking $1 $2 2008/06/01 gift assets:bank:checking $1 $2
2008/06/02 save assets:bank:checking $-1 $1 2008/06/02 save assets:bank:checking $-1 $1
2008/12/31 pay off assets:bank:checking $-1 0 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 `--depth` option limits the amount of sub-account detail displayed.
The `--average`/`-A` flag shows the running average posting amount 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 The `--related`/`-r` flag shows the *other* postings in the transactions
of the postings which would normally be shown. 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 $ hledger register --monthly income
2008/01 income:salary $-1 $-1 2008/01 income:salary $-1 $-1
2008/06 income:gifts $-1 $-2 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 $ hledger register --monthly income -E
2008/01 income:salary $-1 $-1 2008/01 income:salary $-1 $-1
2008/02 0 $-1 2008/02 0 $-1
@ -433,22 +429,17 @@ $ hledger register --monthly income -E
2008/11 0 $-2 2008/11 0 $-2
2008/12 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/01 assets $1 $1
2008/06 assets $-1 0 2008/06 assets $-1 0
2008/12 assets $-1 $-1 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 Note when using report intervals, if you specify start/end dates these
will be adjusted outward if necessary to contain a whole number of will be adjusted outward if necessary to contain a whole number of
intervals. This ensures that the first and last intervals are full 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 DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA
``` ```
and some examples: and some examples:
```{.shell .bold} ```shell
$ hledger reg # use terminal width (or 80 on windows) $ hledger reg # use terminal width (or 80 on windows)
$ hledger reg -w 100 # use width 100 $ hledger reg -w 100 # use width 100
$ COLUMNS=100 hledger reg # set with one-time environment variable $ COLUMNS=100 hledger reg # set with one-time environment variable
$ export COLUMNS=100; hledger reg # set till session end (or window resize) $ 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 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width $ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
``` ```
The register command also supports the The register command also supports the
@ -489,7 +480,7 @@ Show some journal statistics.
`-o FILE[.FMT] --output-file=FILE[.FMT]` `-o FILE[.FMT] --output-file=FILE[.FMT]`
: write output to FILE instead of stdout. A recognised FMT suffix influences the format. : write output to FILE instead of stdout. A recognised FMT suffix influences the format.
```{.shell .right} ```shell
$ hledger stats $ hledger stats
Main journal file : /src/hledger/data/sample.journal Main journal file : /src/hledger/data/sample.journal
Included journal files : Included journal files :
@ -513,7 +504,7 @@ for controlling [output destination](#output-destination).
## test ## test
Run built-in unit tests. Run built-in unit tests.
```{.shell .right} ```shell
$ hledger test $ hledger test
Cases: 74 Tried: 74 Errors: 0 Failures: 0 Cases: 74 Tried: 74 Errors: 0 Failures: 0
``` ```
@ -553,7 +544,7 @@ Web API server, see [hledger-api](hledger-api.html).
## autosync ## autosync
Download OFX bank data and/or convert OFX to hledger journal format. Download OFX bank data and/or convert OFX to hledger journal format.
``` {.shell .right} ```shell
$ hledger autosync --help $ hledger autosync --help
usage: hledger-autosync [-h] [-m MAX] [-r] [-a ACCOUNT] [-l LEDGER] [-i INDENT] usage: hledger-autosync [-h] [-m MAX] [-r] [-a ACCOUNT] [-l LEDGER] [-i INDENT]
[--initial] [--fid FID] [--assertions] [-d] [--hledger] [--initial] [--fid FID] [--assertions] [-d] [--hledger]
@ -617,7 +608,7 @@ download.
## diff ## diff
Show transactions present in one journal file but not another Show transactions present in one journal file but not another
```{.shell .right} ```shell
$ hledger diff --help $ hledger diff --help
Usage: hledger-diff account:name left.journal right.journal Usage: hledger-diff account:name left.journal right.journal
$ cat a.journal $ cat a.journal
@ -649,7 +640,7 @@ journals with bank statements.
## equity ## equity
Print a journal entry that resets account balances to zero. Print a journal entry that resets account balances to zero.
```{.shell .right} ```shell
$ hledger balance --flat -E assets liabilities $ hledger balance --flat -E assets liabilities
0 assets:bank:checking 0 assets:bank:checking
$1 assets:bank:saving $1 assets:bank:saving
@ -687,7 +678,7 @@ just one file, or on several files concatenated with [include](#include).
## interest ## interest
Generate interest transactions. Generate interest transactions.
```{.shell .right} ```shell
$ hledger interest --help $ hledger interest --help
Usage: hledger-interest [OPTION...] ACCOUNT Usage: hledger-interest [OPTION...] ACCOUNT
-h --help print this message and exit -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 --ing-diba compute interest according for Ing-Diba Tagesgeld account
``` ```
```{.shell .right .clear} ```shell
$ cat interest.journal $ cat interest.journal
2008/09/26 Loan 2008/09/26 Loan
Assets:Bank EUR 10000.00 Assets:Bank EUR 10000.00
@ -727,7 +718,7 @@ $ cat interest.journal
Liabilities:Bank Liabilities:Bank
``` ```
```{.shell .right .clear} ```shell
$ hledger interest -- -f interest.journal --source=Expenses:Interest \ $ hledger interest -- -f interest.journal --source=Expenses:Interest \
--target=Liabilities:Bank --30-360 --annual=0.05 Liabilities:Bank --target=Liabilities:Bank --30-360 --annual=0.05 Liabilities:Bank
2008/09/26 Loan 2008/09/26 Loan
@ -779,7 +770,7 @@ with a fixed rate and the scheme mandated by the German BGB288
## irr ## irr
Calculate internal rate of return. Calculate internal rate of return.
```{.shell .right} ```shell
$ hledger irr --help $ hledger irr --help
Usage: hledger-irr [OPTION...] Usage: hledger-irr [OPTION...]
-h --help print this message and exit -h --help print this message and exit
@ -796,7 +787,7 @@ Usage: hledger-irr [OPTION...]
-Y --yearly calculate interest for each year -Y --yearly calculate interest for each year
``` ```
```{.shell .right .clear} ```shell
$ cat irr.journal $ cat irr.journal
2011-01-01 Some wild speculation I wonder if it pays off 2011-01-01 Some wild speculation I wonder if it pays off
Speculation €100.00 Speculation €100.00
@ -828,7 +819,7 @@ $ cat irr.journal
Rate Gain -€ 5.00 Rate Gain -€ 5.00
``` ```
```{.shell .right .clear} ```shell
$ hledger-irr -f irr.journal -t "Rate Gain" -i Speculation --monthly $ hledger-irr -f irr.journal -t "Rate Gain" -i Speculation --monthly
2011/01/01 - 2011/02/01: 12.49% 2011/01/01 - 2011/02/01: 12.49%
2011/02/01 - 2011/03/01: 41.55% 2011/02/01 - 2011/03/01: 41.55%
@ -848,7 +839,7 @@ See the package page for more.
## print-unique ## print-unique
Print only only journal entries which have a unique description. Print only only journal entries which have a unique description.
```{.shell .right} ```shell
$ cat unique.journal $ cat unique.journal
1/1 test 1/1 test
(acct:one) 1 (acct:one) 1
@ -864,7 +855,7 @@ $ LEDGER_FILE=unique.journal hledger print-unique
## rewrite ## rewrite
Prints all journal entries, adding specified custom postings to matched entries. Prints all journal entries, adding specified custom postings to matched entries.
```{.shell .right .bold} ```shell
$ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ... $ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ...
$ hledger rewrite -- ^income --add-posting '(liabilities:tax) *.33' $ hledger rewrite -- ^income --add-posting '(liabilities:tax) *.33'
$ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"' $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"'

View File

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

View File

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

View File

@ -26,15 +26,12 @@ show transactions which
The following kinds of search terms can be used: The following kinds of search terms can be used:
**`REGEX`** **`REGEX`**
: match account names by this regular expression : match account names by this regular expression
**`acct:REGEX`** **`acct:REGEX`**
: same as above : same as above
**`amt:N, amt:<N, amt:<=N, amt:>N, amt:>=N`** **`amt:N, amt:<N, amt:<=N, amt:>N, amt:>=N`**
: match postings with a single-commodity amount that is equal to, less : match postings with a single-commodity amount that is equal to, less
than, or greater than N. (Multi-commodity amounts are not tested, and 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 compared. Otherwise, the absolute magnitudes are compared, ignoring
sign. sign.
**`code:REGEX`** **`code:REGEX`**
: match by transaction code (eg check number) : match by transaction code (eg check number)
**`cur:REGEX`** **`cur:REGEX`**
: match postings or transactions including any amounts whose : match postings or transactions including any amounts whose
currency/commodity symbol is fully matched by REGEX. (For a partial 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:'\$'` quoting to hide it from the shell, so eg do: `hledger print cur:'\$'`
or `hledger print cur:\\$`. or `hledger print cur:\\$`.
**`desc:REGEX`** **`desc:REGEX`**
: match transaction descriptions : match transaction descriptions
**`date:PERIODEXPR`** **`date:PERIODEXPR`**
: match dates within the specified period (which should not include a : match dates within the specified period (which should not include a
reporting interval reporting interval
**`date2:PERIODEXPR`** **`date2:PERIODEXPR`**
: as above, but match secondary dates : as above, but match secondary dates
**`depth:N`** **`depth:N`**
: match (or display, depending on command) accounts at or above this depth : match (or display, depending on command) accounts at or above this depth
**`real:, real:0`** **`real:, real:0`**
: match real or virtual postings respectively : match real or virtual postings respectively
**`status:*, status:!, status:`** **`status:*, status:!, status:`**
: match cleared, pending, or uncleared/pending transactions respectively : match cleared, pending, or uncleared/pending transactions respectively
**`tag:REGEX[=REGEX]`** **`tag:REGEX[=REGEX]`**
: match by tag name, and optionally also by tag value. Note a : 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 tag: query is considered to match a transaction if it matches any of
the postings. Also remember that postings inherit the tags of their the postings. Also remember that postings inherit the tags of their
parent transaction. parent transaction.
**`not:`** **`not:`**
: before any of the above negates the match. : 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: Here's an example of setting the locale temporarily, on ubuntu gnu/linux:
```{.shell} ```shell
$ file my.journal $ file my.journal
my.journal: UTF-8 Unicode text # <- the file is UTF8-encoded my.journal: UTF-8 Unicode text # <- the file is UTF8-encoded
$ locale -a $ 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: Here's one way to set it permanently, there are probably better ways:
```{.shell} ```shell
$ echo "export LANG=en_US.UTF-8" >>~/.bash_profile $ echo "export LANG=en_US.UTF-8" >>~/.bash_profile
$ bash --login $ bash --login
``` ```
If we preferred to use eg `fr_FR.utf8`, we might have to install that first: If we preferred to use eg `fr_FR.utf8`, we might have to install that first:
```{.shell} ```shell
$ apt-get install language-pack-fr $ apt-get install language-pack-fr
$ locale -a $ locale -a
C C

View File

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