From 91dbeedee481d94694bf9b6229115ea60a1cd91f Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 16 Jan 2017 15:53:32 -0800 Subject: [PATCH] doc: document new --pivot [ci skip] --- doc/lib.m4 | 8 +- hledger-lib/doc/hledger_journal.5 | 24 +- hledger-lib/doc/hledger_journal.5.info | 88 ++-- hledger-lib/doc/hledger_journal.5.m4.md | 18 +- hledger-lib/doc/hledger_journal.5.txt | 101 +++-- hledger-ui/doc/hledger-ui.1 | 11 +- hledger-ui/doc/hledger-ui.1.info | 34 +- hledger-ui/doc/hledger-ui.1.txt | 10 +- hledger-web/doc/hledger-web.1 | 11 +- hledger-web/doc/hledger-web.1.info | 10 +- hledger-web/doc/hledger-web.1.txt | 10 +- hledger/Hledger/Cli/CliOptions.hs | 2 +- hledger/doc/examples.m4.md | 17 - hledger/doc/hledger.1 | 123 ++++-- hledger/doc/hledger.1.info | 329 ++++++++------- hledger/doc/hledger.1.txt | 532 +++++++++++++----------- hledger/doc/options.m4.md | 65 ++- 17 files changed, 803 insertions(+), 590 deletions(-) diff --git a/doc/lib.m4 b/doc/lib.m4 index 34f74e61c..bf5d9270b 100644 --- a/doc/lib.m4 +++ b/doc/lib.m4 @@ -147,12 +147,8 @@ m4_define({{_reportingoptions_}}, {{ : convert amounts to their cost at transaction time (using the [transaction price](journal.html#transaction-prices), if any) -`--pivot TAG` -: will transform the journal before any other processing by replacing -the account name of every posting having the tag TAG with content VALUE -by the account name "TAG:VALUE". The TAG will only match if it is a full-length match. -The pivot will only happen if the TAG is on a posting, not if it is on the transaction. -If the tag value is a multi:level:account:name the new account name will be "TAG:multi:level:account:name". +`--pivot TAGNAME` +: organize reports by some tag's value instead of by account `--anon` : show anonymized accounts and payees diff --git a/hledger-lib/doc/hledger_journal.5 b/hledger-lib/doc/hledger_journal.5 index ec9f6f18f..6459dd436 100644 --- a/hledger-lib/doc/hledger_journal.5 +++ b/hledger-lib/doc/hledger_journal.5 @@ -617,7 +617,11 @@ A \f[I]tag\f[] is a word followed by a full colon inside a transaction or posting comment. You can write multiple tags, comma separated. Eg: \f[C];\ a\ comment\ containing\ sometag:,\ anothertag:\f[]. -You can search for tags with the \f[C]tag:\f[] query. +.PD 0 +.P +.PD +You can search for tags with the \f[C]tag:\f[] query, or pivot on them +with \f[C]\-\-pivot\ TAG\f[]. .PP A tag can also have a value, which is any text between the colon and the next comma or newline, excluding leading/trailing whitespace. @@ -639,6 +643,24 @@ posting\-tag): .PP Tags are like Ledger\[aq]s metadata feature, except hledger\[aq]s tag values are simple strings. +.SS Implicit tags +.PP +Some predefined "implicit" tags are also provided: +.IP \[bu] 2 +\f[C]code\f[] \- the transaction\[aq]s code field +.IP \[bu] 2 +\f[C]description\f[] \- the transaction\[aq]s description +.IP \[bu] 2 +\f[C]payee\f[] \- the part of description before \f[C]|\f[], or all of +it +.IP \[bu] 2 +\f[C]note\f[] \- the part of description after \f[C]|\f[], or all of it +.PP +\f[C]payee\f[] and \f[C]note\f[] support descriptions written in a +special \f[C]PAYEE\ |\ NOTE\f[] format, accessing the parts before and +after the pipe character respectively. +For descriptions not containing a pipe character they are the same as +\f[C]description\f[]. .SS Directives .SS Account aliases .PP diff --git a/hledger-lib/doc/hledger_journal.5.info b/hledger-lib/doc/hledger_journal.5.info index cce026fb6..f81e1b758 100644 --- a/hledger-lib/doc/hledger_journal.5.info +++ b/hledger-lib/doc/hledger_journal.5.info @@ -640,8 +640,9 @@ File: hledger_journal.5.info, Node: Tags, Next: Directives, Prev: Comments, A _tag_ is a word followed by a full colon inside a transaction or posting comment. You can write multiple tags, comma separated. Eg: `; a -comment containing sometag:, anothertag:'. You can search for tags with -the `tag:' query. +comment containing sometag:, anothertag:'. +You can search for tags with the `tag:' query, or pivot on them with +`--pivot TAG'. A tag can also have a value, which is any text between the colon and the next comma or newline, excluding leading/trailing whitespace. (So @@ -660,6 +661,31 @@ and the posting has four (A, TAG2, third-tag, posting-tag): Tags are like Ledger's metadata feature, except hledger's tag values are simple strings. +* Menu: + +* Implicit tags:: + + +File: hledger_journal.5.info, Node: Implicit tags, Up: Tags + +1.10.1 Implicit tags +-------------------- + +Some predefined "implicit" tags are also provided: + + * `code' - the transaction's code field + + * `description' - the transaction's description + + * `payee' - the part of description before `|', or all of it + + * `note' - the part of description after `|', or all of it + + `payee' and `note' support descriptions written in a special `PAYEE +| NOTE' format, accessing the parts before and after the pipe character +respectively. For descriptions not containing a pipe character they are +the same as `description'. +  File: hledger_journal.5.info, Node: Directives, Prev: Tags, Up: FILE FORMAT @@ -1025,33 +1051,35 @@ Node: Comments21085 Ref: #comments21207 Node: Tags22319 Ref: #tags22439 -Node: Directives23362 -Ref: #directives23477 -Node: Account aliases23670 -Ref: #account-aliases23816 -Node: Basic aliases24418 -Ref: #basic-aliases24563 -Node: Regex aliases25251 -Ref: #regex-aliases25421 -Node: Multiple aliases26191 -Ref: #multiple-aliases26365 -Node: end aliases26861 -Ref: #end-aliases27003 -Node: account directive27105 -Ref: #account-directive27287 -Node: apply account directive27583 -Ref: #apply-account-directive27781 -Node: Multi-line comments28441 -Ref: #multi-line-comments28633 -Node: commodity directive28760 -Ref: #commodity-directive28946 -Node: Default commodity29819 -Ref: #default-commodity29994 -Node: Default year30530 -Ref: #default-year30697 -Node: Including other files31120 -Ref: #including-other-files31279 -Node: EDITOR SUPPORT31675 -Ref: #editor-support31795 +Node: Implicit tags23427 +Ref: #implicit-tags23535 +Node: Directives24054 +Ref: #directives24169 +Node: Account aliases24362 +Ref: #account-aliases24508 +Node: Basic aliases25110 +Ref: #basic-aliases25255 +Node: Regex aliases25943 +Ref: #regex-aliases26113 +Node: Multiple aliases26883 +Ref: #multiple-aliases27057 +Node: end aliases27553 +Ref: #end-aliases27695 +Node: account directive27797 +Ref: #account-directive27979 +Node: apply account directive28275 +Ref: #apply-account-directive28473 +Node: Multi-line comments29133 +Ref: #multi-line-comments29325 +Node: commodity directive29452 +Ref: #commodity-directive29638 +Node: Default commodity30511 +Ref: #default-commodity30686 +Node: Default year31222 +Ref: #default-year31389 +Node: Including other files31812 +Ref: #including-other-files31971 +Node: EDITOR SUPPORT32367 +Ref: #editor-support32487  End Tag Table diff --git a/hledger-lib/doc/hledger_journal.5.m4.md b/hledger-lib/doc/hledger_journal.5.m4.md index 00e5c1d32..12743200d 100644 --- a/hledger-lib/doc/hledger_journal.5.m4.md +++ b/hledger-lib/doc/hledger_journal.5.m4.md @@ -504,8 +504,9 @@ end comment A *tag* is a word followed by a full colon inside a transaction or posting [comment](#comments). You can write multiple tags, comma -separated. Eg: `; a comment containing sometag:, anothertag:`. You can search for tags -with the [`tag:` query](manual#queries). +separated. Eg: `; a comment containing sometag:, anothertag:`. +You can search for tags with the [`tag:` query](/hledger.html#queries), +or pivot on them with [`--pivot TAG`](/hledger.html#pivoting). A tag can also have a value, which is any text between the colon and the next comma or newline, excluding leading/trailing whitespace. @@ -526,6 +527,19 @@ Tags are like Ledger's [metadata](http://ledger-cli.org/3.0/doc/ledger3.html#Metadata) feature, except hledger's tag values are simple strings. +### Implicit tags + +Some predefined "implicit" tags are also provided: + +- `code` - the transaction's code field +- `description` - the transaction's description +- `payee` - the part of description before `|`, or all of it +- `note` - the part of description after `|`, or all of it + +`payee` and `note` support descriptions written in a special `PAYEE | NOTE` format, +accessing the parts before and after the pipe character respectively. +For descriptions not containing a pipe character they are the same as `description`. + ## Directives ### Account aliases diff --git a/hledger-lib/doc/hledger_journal.5.txt b/hledger-lib/doc/hledger_journal.5.txt index 6ec1acb5a..aa2fff0d9 100644 --- a/hledger-lib/doc/hledger_journal.5.txt +++ b/hledger-lib/doc/hledger_journal.5.txt @@ -470,8 +470,9 @@ FILE FORMAT Tags A tag is a word followed by a full colon inside a transaction or post- ing comment. You can write multiple tags, comma separated. Eg: - ; a comment containing sometag:, anothertag:. You can search for tags - with the tag: query. + ; a comment containing sometag:, anothertag:. + You can search for tags with the tag: query, or pivot on them with + --pivot TAG. A tag can also have a value, which is any text between the colon and the next comma or newline, excluding leading/trailing whitespace. (So @@ -489,9 +490,25 @@ FILE FORMAT Tags are like Ledger's metadata feature, except hledger's tag values are simple strings. + Implicit tags + Some predefined "implicit" tags are also provided: + + o code - the transaction's code field + + o description - the transaction's description + + o payee - the part of description before |, or all of it + + o note - the part of description after |, or all of it + + payee and note support descriptions written in a special PAYEE | NOTE + format, accessing the parts before and after the pipe character respec- + tively. For descriptions not containing a pipe character they are the + same as description. + Directives Account aliases - You can define aliases which rewrite your account names (after reading + You can define aliases which rewrite your account names (after reading the journal, before generating reports). hledger's account aliases can be useful for: @@ -508,8 +525,8 @@ FILE FORMAT See also How to use account aliases. Basic aliases - To set an account alias, use the alias directive in your journal file. - This affects all subsequent journal entries in the current file or its + To set an account alias, use the alias directive in your journal file. + This affects all subsequent journal entries in the current file or its included files. The spaces around the = are optional: alias OLD = NEW @@ -517,53 +534,53 @@ FILE FORMAT Or, you can use the --alias 'OLD=NEW' option on the command line. This affects all entries. It's useful for trying out aliases interactively. - OLD and NEW are full account names. hledger will replace any occur- - rence of the old account name with the new one. Subaccounts are also + OLD and NEW are full account names. hledger will replace any occur- + rence of the old account name with the new one. Subaccounts are also affected. Eg: alias checking = assets:bank:wells fargo:checking # rewrites "checking" to "assets:bank:wells fargo:checking", or "checking:a" to "assets:bank:wells fargo:checking:a" Regex aliases - There is also a more powerful variant that uses a regular expression, - indicated by the forward slashes. (This was the default behaviour in + There is also a more powerful variant that uses a regular expression, + indicated by the forward slashes. (This was the default behaviour in hledger 0.24-0.25): alias /REGEX/ = REPLACEMENT or --alias '/REGEX/=REPLACEMENT'. - REGEX is a case-insensitive regular expression. Anywhere it matches - inside an account name, the matched part will be replaced by REPLACE- - MENT. If REGEX contains parenthesised match groups, these can be ref- + REGEX is a case-insensitive regular expression. Anywhere it matches + inside an account name, the matched part will be replaced by REPLACE- + MENT. If REGEX contains parenthesised match groups, these can be ref- erenced by the usual numeric backreferences in REPLACEMENT. Note, cur- - rently regular expression aliases may cause noticeable slow-downs. + rently regular expression aliases may cause noticeable slow-downs. (And if you use Ledger on your hledger file, they will be ignored.) Eg: alias /^(.+):bank:([^:]+)(.*)/ = \1:\2 \3 # rewrites "assets:bank:wells fargo:checking" to "assets:wells fargo checking" Multiple aliases - You can define as many aliases as you like using directives or com- - mand-line options. Aliases are recursive - each alias sees the result - of applying previous ones. (This is different from Ledger, where + You can define as many aliases as you like using directives or com- + mand-line options. Aliases are recursive - each alias sees the result + of applying previous ones. (This is different from Ledger, where aliases are non-recursive by default). Aliases are applied in the fol- lowing order: - 1. alias directives, most recently seen first (recent directives take + 1. alias directives, most recently seen first (recent directives take precedence over earlier ones; directives not yet seen are ignored) 2. alias options, in the order they appear on the command line end aliases - You can clear (forget) all currently defined aliases with the + You can clear (forget) all currently defined aliases with the end aliases directive: end aliases account directive - The account directive predefines account names, as in Ledger and Bean- - count. This may be useful for your own documentation; hledger doesn't + The account directive predefines account names, as in Ledger and Bean- + count. This may be useful for your own documentation; hledger doesn't make use of it yet. ; account ACCT @@ -578,8 +595,8 @@ FILE FORMAT ; etc. apply account directive - You can specify a parent account which will be prepended to all - accounts within a section of the journal. Use the apply account and + You can specify a parent account which will be prepended to all + accounts within a section of the journal. Use the apply account and end apply account directives like so: apply account home @@ -596,7 +613,7 @@ FILE FORMAT home:food $10 home:cash $-10 - If end apply account is omitted, the effect lasts to the end of the + If end apply account is omitted, the effect lasts to the end of the file. Included files are also affected, eg: apply account business @@ -605,16 +622,16 @@ FILE FORMAT apply account personal include personal.journal - Prior to hledger 1.0, legacy account and end spellings were also sup- + Prior to hledger 1.0, legacy account and end spellings were also sup- ported. Multi-line comments - A line containing just comment starts a multi-line comment, and a line + A line containing just comment starts a multi-line comment, and a line containing just end comment ends it. See comments. commodity directive - The commodity directive predefines commodities (currently this is just - informational), and also it may define the display format for amounts + The commodity directive predefines commodities (currently this is just + informational), and also it may define the display format for amounts in this commodity (overriding the automatically inferred format). It may be written on a single line, like this: @@ -626,8 +643,8 @@ FILE FORMAT ; separating thousands with comma. commodity 1,000.0000 AAAA - or on multiple lines, using the "format" subdirective. In this case - the commodity symbol appears twice and should be the same in both + or on multiple lines, using the "format" subdirective. In this case + the commodity symbol appears twice and should be the same in both places: ; commodity SYMBOL @@ -640,10 +657,10 @@ FILE FORMAT format INR 9,99,99,999.00 Default commodity - The D directive sets a default commodity (and display format), to be + The D directive sets a default commodity (and display format), to be used for amounts without a commodity symbol (ie, plain numbers). (Note - this differs from Ledger's default commodity directive.) The commodity - and display format will be applied to all subsequent commodity-less + this differs from Ledger's default commodity directive.) The commodity + and display format will be applied to all subsequent commodity-less amounts, or until the next D directive. # commodity-less amounts should be treated as dollars @@ -655,8 +672,8 @@ FILE FORMAT b Default year - You can set a default year to be used for subsequent dates which don't - specify a year. This is a line beginning with Y followed by the year. + You can set a default year to be used for subsequent dates which don't + specify a year. This is a line beginning with Y followed by the year. Eg: Y2009 ; set default year to 2009 @@ -676,24 +693,24 @@ FILE FORMAT assets Including other files - You can pull in the content of additional journal files by writing an + You can pull in the content of additional journal files by writing an include directive, like this: include path/to/file.journal - If the path does not begin with a slash, it is relative to the current + If the path does not begin with a slash, it is relative to the current file. Glob patterns (*) are not currently supported. - The include directive can only be used in journal files. It can + The include directive can only be used in journal files. It can include journal, timeclock or timedot files, but not CSV files. EDITOR SUPPORT Add-on modes exist for various text editors, to make working with jour- - nal files easier. They add colour, navigation aids and helpful com- - mands. For hledger users who edit the journal file directly (the + nal files easier. They add colour, navigation aids and helpful com- + mands. For hledger users who edit the journal file directly (the majority), using one of these modes is quite recommended. - These were written with Ledger in mind, but also work with hledger + These were written with Ledger in mind, but also work with hledger files: @@ -710,7 +727,7 @@ EDITOR SUPPORT REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel + Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel or hledger mail list) @@ -724,7 +741,7 @@ COPYRIGHT SEE ALSO - hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1), + hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1), hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time- dot(5), ledger(1) diff --git a/hledger-ui/doc/hledger-ui.1 b/hledger-ui/doc/hledger-ui.1 index abc053b61..01c8cb0af 100644 --- a/hledger-ui/doc/hledger-ui.1 +++ b/hledger-ui/doc/hledger-ui.1 @@ -208,15 +208,8 @@ price, if any) .RS .RE .TP -.B \f[C]\-\-pivot\ TAG\f[] -will transform the journal before any other processing by replacing the -account name of every posting having the tag TAG with content VALUE by -the account name "TAG:VALUE". -The TAG will only match if it is a full\-length match. -The pivot will only happen if the TAG is on a posting, not if it is on -the transaction. -If the tag value is a multi:level:account:name the new account name will -be "TAG:multi:level:account:name". +.B \f[C]\-\-pivot\ TAGNAME\f[] +organize reports by some tag\[aq]s value instead of by account .RS .RE .TP diff --git a/hledger-ui/doc/hledger-ui.1.info b/hledger-ui/doc/hledger-ui.1.info index 6c2c4d79f..2678fab6a 100644 --- a/hledger-ui/doc/hledger-ui.1.info +++ b/hledger-ui/doc/hledger-ui.1.info @@ -142,14 +142,8 @@ the data. convert amounts to their cost at transaction time (using the transaction price, if any) -`--pivot TAG' - will transform the journal before any other processing by - replacing the account name of every posting having the tag TAG - with content VALUE by the account name "TAG:VALUE". The TAG will - only match if it is a full-length match. The pivot will only - happen if the TAG is on a posting, not if it is on the - transaction. If the tag value is a multi:level:account:name the - new account name will be "TAG:multi:level:account:name". +`--pivot TAGNAME' + organize reports by some tag's value instead of by account `--anon' show anonymized accounts and payees @@ -361,17 +355,17 @@ Tag Table: Node: Top88 Node: OPTIONS823 Ref: #options922 -Node: KEYS4001 -Ref: #keys4098 -Node: SCREENS6668 -Ref: #screens6755 -Node: Accounts screen6845 -Ref: #accounts-screen6975 -Node: Register screen9013 -Ref: #register-screen9170 -Node: Transaction screen11058 -Ref: #transaction-screen11218 -Node: Error screen12085 -Ref: #error-screen12209 +Node: KEYS3611 +Ref: #keys3708 +Node: SCREENS6278 +Ref: #screens6365 +Node: Accounts screen6455 +Ref: #accounts-screen6585 +Node: Register screen8623 +Ref: #register-screen8780 +Node: Transaction screen10668 +Ref: #transaction-screen10828 +Node: Error screen11695 +Ref: #error-screen11819  End Tag Table diff --git a/hledger-ui/doc/hledger-ui.1.txt b/hledger-ui/doc/hledger-ui.1.txt index dd580f5c0..40fa91b5d 100644 --- a/hledger-ui/doc/hledger-ui.1.txt +++ b/hledger-ui/doc/hledger-ui.1.txt @@ -136,14 +136,8 @@ OPTIONS convert amounts to their cost at transaction time (using the transaction price, if any) - --pivot TAG - will transform the journal before any other processing by - replacing the account name of every posting having the tag TAG - with content VALUE by the account name "TAG:VALUE". The TAG - will only match if it is a full-length match. The pivot will - only happen if the TAG is on a posting, not if it is on the - transaction. If the tag value is a multi:level:account:name the - new account name will be "TAG:multi:level:account:name". + --pivot TAGNAME + organize reports by some tag's value instead of by account --anon show anonymized accounts and payees diff --git a/hledger-web/doc/hledger-web.1 b/hledger-web/doc/hledger-web.1 index f68161cc0..5bf82439c 100644 --- a/hledger-web/doc/hledger-web.1 +++ b/hledger-web/doc/hledger-web.1 @@ -270,15 +270,8 @@ price, if any) .RS .RE .TP -.B \f[C]\-\-pivot\ TAG\f[] -will transform the journal before any other processing by replacing the -account name of every posting having the tag TAG with content VALUE by -the account name "TAG:VALUE". -The TAG will only match if it is a full\-length match. -The pivot will only happen if the TAG is on a posting, not if it is on -the transaction. -If the tag value is a multi:level:account:name the new account name will -be "TAG:multi:level:account:name". +.B \f[C]\-\-pivot\ TAGNAME\f[] +organize reports by some tag\[aq]s value instead of by account .RS .RE .TP diff --git a/hledger-web/doc/hledger-web.1.info b/hledger-web/doc/hledger-web.1.info index 7a5ab460a..015637814 100644 --- a/hledger-web/doc/hledger-web.1.info +++ b/hledger-web/doc/hledger-web.1.info @@ -190,14 +190,8 @@ before options as shown above. convert amounts to their cost at transaction time (using the transaction price, if any) -`--pivot TAG' - will transform the journal before any other processing by - replacing the account name of every posting having the tag TAG - with content VALUE by the account name "TAG:VALUE". The TAG will - only match if it is a full-length match. The pivot will only - happen if the TAG is on a posting, not if it is on the - transaction. If the tag value is a multi:level:account:name the - new account name will be "TAG:multi:level:account:name". +`--pivot TAGNAME' + organize reports by some tag's value instead of by account `--anon' show anonymized accounts and payees diff --git a/hledger-web/doc/hledger-web.1.txt b/hledger-web/doc/hledger-web.1.txt index 385b85f6c..cf834c550 100644 --- a/hledger-web/doc/hledger-web.1.txt +++ b/hledger-web/doc/hledger-web.1.txt @@ -186,14 +186,8 @@ OPTIONS convert amounts to their cost at transaction time (using the transaction price, if any) - --pivot TAG - will transform the journal before any other processing by - replacing the account name of every posting having the tag TAG - with content VALUE by the account name "TAG:VALUE". The TAG - will only match if it is a full-length match. The pivot will - only happen if the TAG is on a posting, not if it is on the - transaction. If the tag value is a multi:level:account:name the - new account name will be "TAG:multi:level:account:name". + --pivot TAGNAME + organize reports by some tag's value instead of by account --anon show anonymized accounts and payees diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 9d7b5adc8..353da9b79 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -120,7 +120,7 @@ inputflags = [ ,flagReq ["rules-file"] (\s opts -> Right $ setopt "rules-file" s opts) "RFILE" "CSV conversion rules file (default: FILE.rules)" ,flagReq ["alias"] (\s opts -> Right $ setopt "alias" s opts) "OLD=NEW" "display accounts named OLD as NEW" ,flagNone ["ignore-assertions","I"] (setboolopt "ignore-assertions") "ignore any balance assertions in the journal" - ,flagReq ["pivot"] (\s opts -> Right $ setopt "pivot" s opts) "TAG" "Replace the accounts of postings with TAG by TAG:" + ,flagReq ["pivot"] (\s opts -> Right $ setopt "pivot" s opts) "TAGNAME" "organize reports by some tag's value, not by account" ] -- | Common report-related flags: --period, --cost, etc. diff --git a/hledger/doc/examples.m4.md b/hledger/doc/examples.m4.md index 2281e63d9..cce4a3f6c 100644 --- a/hledger/doc/examples.m4.md +++ b/hledger/doc/examples.m4.md @@ -68,20 +68,3 @@ $ hledger reg 'assets:some bank:checking' # show postings to/from this checking $ hledger print desc:shop # show transactions with shop in the description $ hledger activity -W # show transaction counts per week as a bar chart ``` - -With the journal - -```journal -2016/02/16 Member Fee Payment John Doe - assets:bank account 2 EUR - income:member fees -2 EUR - ; member: John Doe -``` - -the --pivot comand will output the following: - -```shells -$ hledger bal --pivot member - 2 EUR assets:bank account - -2 EUR member:John Doe -``` diff --git a/hledger/doc/hledger.1 b/hledger/doc/hledger.1 index 38c03be2e..b52a0ddea 100644 --- a/hledger/doc/hledger.1 +++ b/hledger/doc/hledger.1 @@ -147,27 +147,6 @@ $\ hledger\ print\ desc:shop\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ transacti $\ hledger\ activity\ \-W\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ transaction\ counts\ per\ week\ as\ a\ bar\ chart \f[] .fi -.PP -With the journal -.IP -.nf -\f[C] -2016/02/16\ Member\ Fee\ Payment\ John\ Doe -\ \ \ \ assets:bank\ account\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ EUR -\ \ \ \ income:member\ fees\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR -\ \ \ \ \ \ ;\ member:\ John\ Doe -\f[] -.fi -.PP -the \-\-pivot comand will output the following: -.IP -.nf -\f[C] -$\ hledger\ bal\ \-\-pivot\ member -\ \ \ \ 2\ EUR\ \ assets:bank\ account -\ \ \ \-2\ EUR\ \ member:John\ Doe -\f[] -.fi .SH OPTIONS .PP To see general usage and the command list: \f[C]hledger\ \-h\f[] or just @@ -378,15 +357,8 @@ price, if any) .RS .RE .TP -.B \f[C]\-\-pivot\ TAG\f[] -will transform the journal before any other processing by replacing the -account name of every posting having the tag TAG with content VALUE by -the account name "TAG:VALUE". -The TAG will only match if it is a full\-length match. -The pivot will only happen if the TAG is on a posting, not if it is on -the transaction. -If the tag value is a multi:level:account:name the new account name will -be "TAG:multi:level:account:name". +.B \f[C]\-\-pivot\ TAGNAME\f[] +organize reports by some tag\[aq]s value instead of by account .RS .RE .TP @@ -498,12 +470,6 @@ balance assertions will not see any account balances from previous files .PP If you need those, either use the include directive, or concatenate the files, eg: \f[C]cat\ a.journal\ b.journal\ |\ hledger\ \-f\-\ CMD\f[]. -.SS Depth limiting -.PP -With the \f[C]\-\-depth\ N\f[] option, commands like account, balance -and register will show only the uppermost accounts in the account tree, -down to level N. -Use this when you want a summary with less detail. .SS Smart dates .PP hledger\[aq]s user interfaces accept a flexible "smart date" syntax @@ -789,6 +755,91 @@ Group postings from start of wednesday to end of next tuesday (N is start date and exclusive end date): .PP \f[C]hledger\ register\ checking\ \-p\ "every\ 3rd\ day\ of\ week"\f[] +.SS Depth limiting +.PP +With the \f[C]\-\-depth\ N\f[] option, commands like account, balance +and register will show only the uppermost accounts in the account tree, +down to level N. +Use this when you want a summary with less detail. +.SS Pivoting +.PP +Normally hledger sums amounts, and organizes them in a hierarchy, based +on account name. +The \f[C]\-\-pivot\ TAGNAME\f[] option causes it to sum and organize +hierarchy based on some other field instead. +.PP +TAGNAME is the full, case\-insensitive name of a tag you have defined, +or one of the built\-in implicit tags (like \f[C]code\f[] or +\f[C]payee\f[]). +As with account names, when tag values have +\f[C]multiple:colon\-separated:parts\f[] hledger will build hierarchy, +displayed in tree\-mode reports, summarisable with a depth limit, and so +on. +.PP +\f[C]\-\-pivot\f[] affects all reports, and is one of those options you +can write before the command name if you wish. +You can think of hledger transforming the journal before any other +processing, replacing every posting\[aq]s account name with the value of +the specified tag on that posting, inheriting it from the transaction or +using a blank value if it\[aq]s not present. +.PP +An example: +.IP +.nf +\f[C] +2016/02/16\ Member\ Fee\ Payment +\ \ \ \ assets:bank\ account\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ EUR +\ \ \ \ income:member\ fees\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ ;\ member:\ John\ Doe +\f[] +.fi +.PP +Normal balance report showing account names: +.IP +.nf +\f[C] +$\ hledger\ balance +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ EUR\ \ assets:bank\ account +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ income:member\ fees +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0 +\f[] +.fi +.PP +Pivoted balance report, using member: tag values instead: +.IP +.nf +\f[C] +$\ hledger\ balance\ \-\-pivot\ member +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ EUR +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ John\ Doe +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0 +\f[] +.fi +.PP +One way to show only amounts with a member: value (using a query, +described below): +.IP +.nf +\f[C] +$\ hledger\ balance\ \-\-pivot\ member\ tag:member=. +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ John\ Doe +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR +\f[] +.fi +.PP +Another way (the acct: query matches against the pivoted "account +name"): +.IP +.nf +\f[C] +$\ hledger\ balance\ \-\-pivot\ member\ acct:. +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ John\ Doe +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR +\f[] +.fi .SS Regular expressions .PP hledger uses regular expressions in a number of places: diff --git a/hledger/doc/hledger.1.info b/hledger/doc/hledger.1.info index aee5db6e8..be2dd45bc 100644 --- a/hledger/doc/hledger.1.info +++ b/hledger/doc/hledger.1.info @@ -117,21 +117,6 @@ $ hledger reg 'assets:some bank:checking' # show postings to/from this checking $ hledger print desc:shop # show transactions with shop in the description $ hledger activity -W # show transaction counts per week as a bar chart - With the journal - - -2016/02/16 Member Fee Payment John Doe - assets:bank account 2 EUR - income:member fees -2 EUR - ; member: John Doe - - the -pivot comand will output the following: - - -$ hledger bal --pivot member - 2 EUR assets:bank account - -2 EUR member:John Doe -  File: hledger.1.info, Node: OPTIONS, Next: QUERIES, Prev: EXAMPLES, Up: Top @@ -200,11 +185,12 @@ cur:\\\\$'. * General options:: * Reporting options:: * Input files:: -* Depth limiting:: * Smart dates:: * Report start & end date:: * Report intervals:: * Period expressions:: +* Depth limiting:: +* Pivoting:: * Regular expressions::  @@ -304,14 +290,8 @@ Common reporting options, must be written after COMMAND. convert amounts to their cost at transaction time (using the transaction price, if any) -`--pivot TAG' - will transform the journal before any other processing by - replacing the account name of every posting having the tag TAG - with content VALUE by the account name "TAG:VALUE". The TAG will - only match if it is a full-length match. The pivot will only - happen if the TAG is on a posting, not if it is on the - transaction. If the tag value is a multi:level:account:name the - new account name will be "TAG:multi:level:account:name". +`--pivot TAGNAME' + organize reports by some tag's value instead of by account `--anon' show anonymized accounts and payees @@ -320,7 +300,7 @@ Common reporting options, must be written after COMMAND. last one takes precedence. Eg -p jan -p feb is equivalent to -p feb.  -File: hledger.1.info, Node: Input files, Next: Depth limiting, Prev: Reporting options, Up: OPTIONS +File: hledger.1.info, Node: Input files, Next: Smart dates, Prev: Reporting options, Up: OPTIONS 2.3 Input files =============== @@ -380,19 +360,9 @@ as one big journal. There are some limitations with this: the files, eg: `cat a.journal b.journal | hledger -f- CMD'.  -File: hledger.1.info, Node: Depth limiting, Next: Smart dates, Prev: Input files, Up: OPTIONS +File: hledger.1.info, Node: Smart dates, Next: Report start & end date, Prev: Input files, Up: OPTIONS -2.4 Depth limiting -================== - -With the `--depth N' option, commands like account, balance and -register will show only the uppermost accounts in the account tree, down -to level N. Use this when you want a summary with less detail. - - -File: hledger.1.info, Node: Smart dates, Next: Report start & end date, Prev: Depth limiting, Up: OPTIONS - -2.5 Smart dates +2.4 Smart dates =============== hledger's user interfaces accept a flexible "smart date" syntax (unlike @@ -415,7 +385,7 @@ omitted (defaulting to 1).  File: hledger.1.info, Node: Report start & end date, Next: Report intervals, Prev: Smart dates, Up: OPTIONS -2.6 Report start & end date +2.5 Report start & end date =========================== Most hledger reports show the full span of time represented by the @@ -444,7 +414,7 @@ you need to write the date _after_ the last day you want to include.  File: hledger.1.info, Node: Report intervals, Next: Period expressions, Prev: Report start & end date, Up: OPTIONS -2.7 Report intervals +2.6 Report intervals ==================== A report interval can be specified so that commands like register, @@ -455,9 +425,9 @@ complex intervals may be specified with a period expression. Report intervals can not be specified with a query, currently.  -File: hledger.1.info, Node: Period expressions, Next: Regular expressions, Prev: Report intervals, Up: OPTIONS +File: hledger.1.info, Node: Period expressions, Next: Depth limiting, Prev: Report intervals, Up: OPTIONS -2.8 Period expressions +2.7 Period expressions ====================== The `-p/--period' option accepts period expressions, a shorthand way of @@ -530,10 +500,87 @@ start date and exclusive end date): `hledger register checking -p "every 3rd day of week"'  -File: hledger.1.info, Node: Regular expressions, Prev: Period expressions, Up: OPTIONS +File: hledger.1.info, Node: Depth limiting, Next: Pivoting, Prev: Period expressions, Up: OPTIONS -2.9 Regular expressions -======================= +2.8 Depth limiting +================== + +With the `--depth N' option, commands like account, balance and +register will show only the uppermost accounts in the account tree, down +to level N. Use this when you want a summary with less detail. + + +File: hledger.1.info, Node: Pivoting, Next: Regular expressions, Prev: Depth limiting, Up: OPTIONS + +2.9 Pivoting +============ + +Normally hledger sums amounts, and organizes them in a hierarchy, based +on account name. The `--pivot TAGNAME' option causes it to sum and +organize hierarchy based on some other field instead. + + TAGNAME is the full, case-insensitive name of a tag you have +defined, or one of the built-in implicit tags (like `code' or `payee'). +As with account names, when tag values have +`multiple:colon-separated:parts' hledger will build hierarchy, +displayed in tree-mode reports, summarisable with a depth limit, and so +on. + + `--pivot' affects all reports, and is one of those options you can +write before the command name if you wish. You can think of hledger +transforming the journal before any other processing, replacing every +posting's account name with the value of the specified tag on that +posting, inheriting it from the transaction or using a blank value if +it's not present. + + An example: + + +2016/02/16 Member Fee Payment + assets:bank account 2 EUR + income:member fees -2 EUR ; member: John Doe + + Normal balance report showing account names: + + +$ hledger balance + 2 EUR assets:bank account + -2 EUR income:member fees +-------------------- + 0 + + Pivoted balance report, using member: tag values instead: + + +$ hledger balance --pivot member + 2 EUR + -2 EUR John Doe +-------------------- + 0 + + One way to show only amounts with a member: value (using a query, +described below): + + +$ hledger balance --pivot member tag:member=. + -2 EUR John Doe +-------------------- + -2 EUR + + Another way (the acct: query matches against the pivoted "account +name"): + + +$ hledger balance --pivot member acct:. + -2 EUR John Doe +-------------------- + -2 EUR + + +File: hledger.1.info, Node: Regular expressions, Prev: Pivoting, Up: OPTIONS + +2.10 Regular expressions +======================== hledger uses regular expressions in a number of places: @@ -2282,101 +2329,103 @@ Tag Table: Node: Top82 Node: EXAMPLES1873 Ref: #examples1975 -Node: OPTIONS3979 -Ref: #options4083 -Node: General options6711 -Ref: #general-options6840 -Node: Reporting options7611 -Ref: #reporting-options7764 -Node: Input files9587 -Ref: #input-files9727 -Node: Depth limiting11768 -Ref: #depth-limiting11908 -Node: Smart dates12109 -Ref: #smart-dates12255 -Node: Report start & end date13252 -Ref: #report-start-end-date13424 -Node: Report intervals14500 -Ref: #report-intervals14665 -Node: Period expressions15064 -Ref: #period-expressions15229 -Node: Regular expressions17564 -Ref: #regular-expressions17706 -Node: QUERIES19189 -Ref: #queries19293 -Node: COMMANDS22932 -Ref: #commands23046 -Node: accounts23719 -Ref: #accounts23819 -Node: activity24801 -Ref: #activity24913 -Node: add25272 -Ref: #add25373 -Node: balance28036 -Ref: #balance28149 -Node: Flat mode31162 -Ref: #flat-mode31289 -Node: Depth limited balance reports31708 -Ref: #depth-limited-balance-reports31911 -Node: Multicolumn balance reports32332 -Ref: #multicolumn-balance-reports32534 -Node: Market value37183 -Ref: #market-value37347 -Node: Custom balance output38648 -Ref: #custom-balance-output38821 -Node: Output destination40925 -Ref: #output-destination41090 -Node: CSV output41360 -Ref: #csv-output41479 -Node: balancesheet41876 -Ref: #balancesheet42004 -Node: cashflow42656 -Ref: #cashflow42773 -Node: help43463 -Ref: #help43575 -Node: incomestatement44412 -Ref: #incomestatement44542 -Node: info45269 -Ref: #info45376 -Node: man45738 -Ref: #man45835 -Node: print46238 -Ref: #print46343 -Node: register50092 -Ref: #register50205 -Node: Custom register output54697 -Ref: #custom-register-output54828 -Node: stats56125 -Ref: #stats56231 -Node: test57111 -Ref: #test57198 -Node: ADD-ON COMMANDS57565 -Ref: #add-on-commands57701 -Node: api58989 -Ref: #api59081 -Node: autosync59115 -Ref: #autosync59230 -Node: diff61545 -Ref: #diff61655 -Node: equity62319 -Ref: #equity62433 -Node: interest63761 -Ref: #interest63878 -Node: irr66962 -Ref: #irr67075 -Node: print-unique69450 -Ref: #print-unique69580 -Node: rewrite69838 -Ref: #rewrite69957 -Node: ui70486 -Ref: #ui70586 -Node: web70627 -Ref: #web70715 -Node: TROUBLESHOOTING70748 -Ref: #troubleshooting70867 -Node: Run-time problems70921 -Ref: #run-time-problems71064 -Node: Known limitations73008 -Ref: #known-limitations73151 +Node: OPTIONS3627 +Ref: #options3731 +Node: General options6372 +Ref: #general-options6501 +Node: Reporting options7272 +Ref: #reporting-options7425 +Node: Input files8858 +Ref: #input-files8995 +Node: Smart dates11036 +Ref: #smart-dates11179 +Node: Report start & end date12176 +Ref: #report-start-end-date12348 +Node: Report intervals13424 +Ref: #report-intervals13589 +Node: Period expressions13988 +Ref: #period-expressions14148 +Node: Depth limiting16483 +Ref: #depth-limiting16627 +Node: Pivoting16828 +Ref: #pivoting16961 +Node: Regular expressions18792 +Ref: #regular-expressions18926 +Node: QUERIES20409 +Ref: #queries20513 +Node: COMMANDS24152 +Ref: #commands24266 +Node: accounts24939 +Ref: #accounts25039 +Node: activity26021 +Ref: #activity26133 +Node: add26492 +Ref: #add26593 +Node: balance29256 +Ref: #balance29369 +Node: Flat mode32382 +Ref: #flat-mode32509 +Node: Depth limited balance reports32928 +Ref: #depth-limited-balance-reports33131 +Node: Multicolumn balance reports33552 +Ref: #multicolumn-balance-reports33754 +Node: Market value38403 +Ref: #market-value38567 +Node: Custom balance output39868 +Ref: #custom-balance-output40041 +Node: Output destination42145 +Ref: #output-destination42310 +Node: CSV output42580 +Ref: #csv-output42699 +Node: balancesheet43096 +Ref: #balancesheet43224 +Node: cashflow43876 +Ref: #cashflow43993 +Node: help44683 +Ref: #help44795 +Node: incomestatement45632 +Ref: #incomestatement45762 +Node: info46489 +Ref: #info46596 +Node: man46958 +Ref: #man47055 +Node: print47458 +Ref: #print47563 +Node: register51312 +Ref: #register51425 +Node: Custom register output55917 +Ref: #custom-register-output56048 +Node: stats57345 +Ref: #stats57451 +Node: test58331 +Ref: #test58418 +Node: ADD-ON COMMANDS58785 +Ref: #add-on-commands58921 +Node: api60209 +Ref: #api60301 +Node: autosync60335 +Ref: #autosync60450 +Node: diff62765 +Ref: #diff62875 +Node: equity63539 +Ref: #equity63653 +Node: interest64981 +Ref: #interest65098 +Node: irr68182 +Ref: #irr68295 +Node: print-unique70670 +Ref: #print-unique70800 +Node: rewrite71058 +Ref: #rewrite71177 +Node: ui71706 +Ref: #ui71806 +Node: web71847 +Ref: #web71935 +Node: TROUBLESHOOTING71968 +Ref: #troubleshooting72087 +Node: Run-time problems72141 +Ref: #run-time-problems72284 +Node: Known limitations74228 +Ref: #known-limitations74371  End Tag Table diff --git a/hledger/doc/hledger.1.txt b/hledger/doc/hledger.1.txt index f5d2dc634..94d9f1503 100644 --- a/hledger/doc/hledger.1.txt +++ b/hledger/doc/hledger.1.txt @@ -107,19 +107,6 @@ EXAMPLES $ hledger print desc:shop # show transactions with shop in the description $ hledger activity -W # show transaction counts per week as a bar chart - With the journal - - 2016/02/16 Member Fee Payment John Doe - assets:bank account 2 EUR - income:member fees -2 EUR - ; member: John Doe - - the --pivot comand will output the following: - - $ hledger bal --pivot member - 2 EUR assets:bank account - -2 EUR member:John Doe - OPTIONS To see general usage and the command list: hledger -h or just hledger. To see usage for a specific command: hledger COMMAND -h. @@ -261,14 +248,8 @@ OPTIONS convert amounts to their cost at transaction time (using the transaction price, if any) - --pivot TAG - will transform the journal before any other processing by - replacing the account name of every posting having the tag TAG - with content VALUE by the account name "TAG:VALUE". The TAG - will only match if it is a full-length match. The pivot will - only happen if the TAG is on a posting, not if it is on the - transaction. If the tag value is a multi:level:account:name the - new account name will be "TAG:multi:level:account:name". + --pivot TAGNAME + organize reports by some tag's value instead of by account --anon show anonymized accounts and payees @@ -327,11 +308,6 @@ OPTIONS If you need those, either use the include directive, or concatenate the files, eg: cat a.journal b.journal | hledger -f- CMD. - Depth limiting - With the --depth N option, commands like account, balance and register - will show only the uppermost accounts in the account tree, down to - level N. Use this when you want a summary with less detail. - Smart dates hledger's user interfaces accept a flexible "smart date" syntax (unlike dates in the journal file). Smart dates allow some english words, can @@ -429,6 +405,7 @@ OPTIONS earliest or latest transaction in your journal: + -p "from 2009/1/1" everything after january 1, 2009 -p "from 2009/1" the same @@ -480,59 +457,120 @@ OPTIONS hledger register checking -p "every 3rd day of week" + Depth limiting + With the --depth N option, commands like account, balance and register + will show only the uppermost accounts in the account tree, down to + level N. Use this when you want a summary with less detail. + + Pivoting + Normally hledger sums amounts, and organizes them in a hierarchy, based + on account name. The --pivot TAGNAME option causes it to sum and orga- + nize hierarchy based on some other field instead. + + TAGNAME is the full, case-insensitive name of a tag you have defined, + or one of the built-in implicit tags (like code or payee). As with + account names, when tag values have multiple:colon-separated:parts + hledger will build hierarchy, displayed in tree-mode reports, summaris- + able with a depth limit, and so on. + + --pivot affects all reports, and is one of those options you can write + before the command name if you wish. You can think of hledger trans- + forming the journal before any other processing, replacing every post- + ing's account name with the value of the specified tag on that posting, + inheriting it from the transaction or using a blank value if it's not + present. + + An example: + + 2016/02/16 Member Fee Payment + assets:bank account 2 EUR + income:member fees -2 EUR ; member: John Doe + + Normal balance report showing account names: + + $ hledger balance + 2 EUR assets:bank account + -2 EUR income:member fees + -------------------- + 0 + + Pivoted balance report, using member: tag values instead: + + $ hledger balance --pivot member + 2 EUR + -2 EUR John Doe + -------------------- + 0 + + One way to show only amounts with a member: value (using a query, + described below): + + $ hledger balance --pivot member tag:member=. + -2 EUR John Doe + -------------------- + -2 EUR + + Another way (the acct: query matches against the pivoted "account + name"): + + $ hledger balance --pivot member acct:. + -2 EUR John Doe + -------------------- + -2 EUR + Regular expressions hledger uses regular expressions in a number of places: - o query terms, on the command line and in the hledger-web search form: + o query terms, on the command line and in the hledger-web search form: REGEX, desc:REGEX, cur:REGEX, tag:...=REGEX o CSV rules conditional blocks: if REGEX ... - o account alias directives and options: alias /REGEX/ = REPLACEMENT, + o account alias directives and options: alias /REGEX/ = REPLACEMENT, --alias /REGEX/=REPLACEMENT - hledger's regular expressions come from the regex-tdfa library. In + hledger's regular expressions come from the regex-tdfa library. In general they: o are case insensitive - o are infix matching (do not need to match the entire thing being + o are infix matching (do not need to match the entire thing being matched) o are POSIX extended regular expressions o also support GNU word boundaries (\<, \>, \b, \B) - o and parenthesised capturing groups and numeric backreferences in + o and parenthesised capturing groups and numeric backreferences in replacement strings o do not support mode modifiers like (?s) Some things to note: - o In the alias directive and --alias option, regular expressions must - be enclosed in forward slashes (/REGEX/). Elsewhere in hledger, + o In the alias directive and --alias option, regular expressions must + be enclosed in forward slashes (/REGEX/). Elsewhere in hledger, these are not required. o To match a regular expression metacharacter like $ as a literal char- acter, prepend a backslash. Eg to search for amounts with the dollar sign in hledger-web, write cur:\$. - o On the command line, some metacharacters like $ have a special mean- + o On the command line, some metacharacters like $ have a special mean- ing to the shell and so must be escaped a second time, with single or - double quotes or another backslash. Eg, to match amounts with the + double quotes or another backslash. Eg, to match amounts with the dollar sign from the command line, write cur:'\$' or cur:\\$. QUERIES - One of hledger's strengths is being able to quickly report on precise - subsets of your data. Most commands accept an optional query expres- - sion, written as arguments after the command name, to filter the data - by date, account name or other criteria. The syntax is similar to a + One of hledger's strengths is being able to quickly report on precise + subsets of your data. Most commands accept an optional query expres- + sion, written as arguments after the command name, to filter the data + by date, account name or other criteria. The syntax is similar to a web search: one or more space-separated search terms, quotes to enclose - whitespace, optional prefixes to match specific fields. Multiple + whitespace, optional prefixes to match specific fields. Multiple search terms are combined as follows: - All commands except print: show transactions/postings/accounts which + All commands except print: show transactions/postings/accounts which match (or negatively match) o any of the description terms AND @@ -559,22 +597,22 @@ QUERIES same as above amt:N, amt:N, amt:>=N - match postings with a single-commodity amount that is equal to, - less than, or greater than N. (Multi-commodity amounts are not + match postings with a single-commodity amount that is equal to, + less than, or greater than N. (Multi-commodity amounts are not tested, and will always match.) The comparison has two modes: if N is preceded by a + or - sign (or is 0), the two signed numbers - are compared. Otherwise, the absolute magnitudes are compared, + are compared. Otherwise, the absolute magnitudes are compared, ignoring sign. code:REGEX match by transaction code (eg check number) cur:REGEX - match postings or transactions including any amounts whose cur- - rency/commodity symbol is fully matched by REGEX. (For a par- + match postings or transactions including any amounts whose cur- + rency/commodity symbol is fully matched by REGEX. (For a par- tial match, use .*REGEX.*). Note, to match characters which are regex-significant, like the dollar sign ($), you need to prepend - \. And when using the command line you need to add one more + \. And when using the command line you need to add one more level of quoting to hide it from the shell, so eg do: hledger print cur:'\$' or hledger print cur:\\$. @@ -583,29 +621,29 @@ QUERIES date:PERIODEXPR match dates within the specified period. PERIODEXPR is a period - expression (with no report interval). Examples: date:2016, - date:thismonth, date:2000/2/1-2/15, date:lastweek-. If the - --date2 command line flag is present, this matches secondary + expression (with no report interval). Examples: date:2016, + date:thismonth, date:2000/2/1-2/15, date:lastweek-. If the + --date2 command line flag is present, this matches secondary dates instead. date2:PERIODEXPR match secondary dates within the specified period. depth:N - match (or display, depending on command) accounts at or above + match (or display, depending on command) accounts at or above this depth real:, real:0 match real or virtual postings respectively status:*, status:!, status: - match cleared, pending, or uncleared/pending transactions + match cleared, pending, or uncleared/pending transactions respectively tag:REGEX[=REGEX] - match by tag name, and optionally also by tag value. Note a - tag: query is considered to match a transaction if it matches - any of the postings. Also remember that postings inherit the + match by tag name, and optionally also by tag value. Note a + tag: query is considered to match a transaction if it matches + any of the postings. Also remember that postings inherit the tags of their parent transaction. not: before any of the above negates the match. @@ -613,24 +651,24 @@ QUERIES inacct:ACCTNAME a special term used automatically when you click an account name in hledger-web, specifying the account register we are currently - in (selects the transactions of that account and how to show - them, can be filtered further with acct etc). Not supported + in (selects the transactions of that account and how to show + them, can be filtered further with acct etc). Not supported elsewhere in hledger. Some of these can also be expressed as command-line options (eg depth:2 - is equivalent to --depth 2). Generally you can mix options and query - arguments, and the resulting query will be their intersection (perhaps + is equivalent to --depth 2). Generally you can mix options and query + arguments, and the resulting query will be their intersection (perhaps excluding the -p/--period option). COMMANDS - hledger provides a number of subcommands; hledger with no arguments + hledger provides a number of subcommands; hledger with no arguments shows a list. If you install additional hledger-* packages, or if you put programs or - scripts named hledger-NAME in your PATH, these will also be listed as + scripts named hledger-NAME in your PATH, these will also be listed as subcommands. - Run a subcommand by writing its name as first argument (eg + Run a subcommand by writing its name as first argument (eg hledger incomestatement). You can also write any unambiguous prefix of a command name (hledger inc), or one of the standard short aliases dis- played in the command list (hledger is). @@ -645,14 +683,14 @@ COMMANDS --drop=N in flat mode: omit N leading account name parts - This command lists all account names that are in use (ie, all the - accounts which have at least one transaction posting to them). With + This command lists all account names that are in use (ie, all the + accounts which have at least one transaction posting to them). With query arguments, only matched account names are shown. - It shows a flat list by default. With --tree, it uses indentation to + It shows a flat list by default. With --tree, it uses indentation to show the account hierarchy. - In flat mode you can add --drop N to omit the first few account name + In flat mode you can add --drop N to omit the first few account name components. Examples: @@ -695,8 +733,8 @@ COMMANDS activity Show an ascii barchart of posting counts per interval. - The activity command displays an ascii histogram showing transaction - counts by day, week, month or other reporting interval (by day is the + The activity command displays an ascii histogram showing transaction + counts by day, week, month or other reporting interval (by day is the default). With query arguments, it counts only matched transactions. $ hledger activity --quarterly @@ -709,24 +747,24 @@ COMMANDS Prompt for transactions and add them to the journal. --no-new-accounts - don't allow creating new accounts; helps prevent typos when + don't allow creating new accounts; helps prevent typos when entering account names - Many hledger users edit their journals directly with a text editor, or - generate them from CSV. For more interactive data entry, there is the - add command, which prompts interactively on the console for new trans- - actions, and appends them to the journal file (if there are multiple + Many hledger users edit their journals directly with a text editor, or + generate them from CSV. For more interactive data entry, there is the + add command, which prompts interactively on the console for new trans- + actions, and appends them to the journal file (if there are multiple -f FILE options, the first file is used.) Existing transactions are not - changed. This is the only hledger command that writes to the journal + changed. This is the only hledger command that writes to the journal file. To use it, just run hledger add and follow the prompts. You can add as - many transactions as you like; when you are finished, enter . or press + many transactions as you like; when you are finished, enter . or press control-d or control-c to exit. Features: - o add tries to provide useful defaults, using the most similar recent + o add tries to provide useful defaults, using the most similar recent transaction (by description) as a template. o You can also set the initial defaults with command line arguments. @@ -734,20 +772,20 @@ COMMANDS o Readline-style edit keys can be used during data entry. o The tab key will auto-complete whenever possible - accounts, descrip- - tions, dates (yesterday, today, tomorrow). If the input area is + tions, dates (yesterday, today, tomorrow). If the input area is empty, it will insert the default value. - o If the journal defines a default commodity, it will be added to any + o If the journal defines a default commodity, it will be added to any bare numbers entered. o A parenthesised transaction code may be entered following a date. o Comments and tags may be entered following a description or amount. - o If you make a mistake, enter < at any prompt to restart the transac- + o If you make a mistake, enter < at any prompt to restart the transac- tion. - o Input prompts are displayed in a different colour when the terminal + o Input prompts are displayed in a different colour when the terminal supports it. Example (see the tutorial for a detailed explanation): @@ -784,7 +822,7 @@ COMMANDS show balance change in each period (default) --cumulative - show balance change accumulated across periods (in multicolumn + show balance change accumulated across periods (in multicolumn reports) -H --historical @@ -798,7 +836,7 @@ COMMANDS account is depth-clipped (default in multicolumn reports) -V --value - convert amounts to their market value on the report end date + convert amounts to their market value on the report end date (using the most recent applicable market price, if any) -A --average @@ -823,10 +861,10 @@ COMMANDS select the output format. Supported formats: txt, csv. -o FILE --output-file=FILE - write output to FILE. A file extension matching one of the + write output to FILE. A file extension matching one of the above formats selects that format. - The balance command displays accounts and balances. It is hledger's + The balance command displays accounts and balances. It is hledger's most featureful and most useful command. $ hledger balance @@ -843,24 +881,24 @@ COMMANDS -------------------- 0 - More precisely, the balance command shows the change to each account's + More precisely, the balance command shows the change to each account's balance caused by all (matched) postings. In the common case where you - do not filter by date and your journal sets the correct opening bal- + do not filter by date and your journal sets the correct opening bal- ances, this is the same as the account's ending balance. - By default, accounts are displayed hierarchically, with subaccounts + By default, accounts are displayed hierarchically, with subaccounts indented below their parent. "Boring" accounts, which contain a single interesting subaccount and no balance of their own, are elided into the - following line for more compact output. (Use --no-elide to prevent + following line for more compact output. (Use --no-elide to prevent this.) - Each account's balance is the "inclusive" balance - it includes the + Each account's balance is the "inclusive" balance - it includes the balances of any subaccounts. - Accounts which have zero balance (and no non-zero subaccounts) are + Accounts which have zero balance (and no non-zero subaccounts) are omitted. Use -E/--empty to show them. - A final total is displayed by default; use -N/--no-total to suppress + A final total is displayed by default; use -N/--no-total to suppress it: $ hledger balance -p 2008/6 expenses --no-total @@ -870,9 +908,9 @@ COMMANDS Flat mode To see a flat list of full account names instead of the default hierar- - chical display, use --flat. In this mode, accounts (unless + 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 + 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 @@ -880,9 +918,9 @@ COMMANDS $1 supplies Depth limited balance reports - 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 + 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 @@ -892,12 +930,12 @@ COMMANDS $1 liabilities Multicolumn balance reports - With a reporting interval, multiple balance columns will be shown, one - for each report period. There are three types of multi-column balance + With a reporting interval, multiple balance columns will be shown, one + for each report period. There are three types of multi-column balance report, showing different information: 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: $ hledger balance --quarterly income expenses -E @@ -912,8 +950,8 @@ COMMANDS -------------------++--------------------------------- || $-1 $1 0 0 - 2. With --cumulative: each column shows the ending balance for that - period, accumulating the changes across periods, starting from 0 at + 2. With --cumulative: each column shows the ending balance for that + period, accumulating the changes across periods, starting from 0 at the report start date: $ hledger balance --quarterly income expenses -E --cumulative @@ -929,8 +967,8 @@ COMMANDS || $-1 0 0 0 3. With --historical/-H: each column shows the actual historical ending - balance for that period, accumulating the changes across periods, - starting from the actual balance at the report start date. This is + balance for that period, accumulating the changes across periods, + starting from the actual balance at the report start date. This is useful eg for a multi-period balance sheet, and when you are showing only the data after a certain start date: @@ -946,26 +984,26 @@ COMMANDS ----------------------++------------------------------------- || 0 0 0 - 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. - With a reporting interval (like --quarterly above), the report - start/end dates will be adjusted if necessary so that they encompass + With a reporting interval (like --quarterly above), the report + start/end dates will be adjusted if necessary so that they encompass the displayed report periods. This is so that the first and last peri- ods will be "full" and comparable to the others. - The -E/--empty flag does two things 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 + The -E/--empty flag does two things in multicolumn balance reports: + first, the report will show all columns within the specified report + period (without -E, leading and trailing columns with all zeroes are + not shown). Second, all accounts which existed at the report start + date will be considered, not just the ones with activity during the report period (use -E to include low-activity accounts which would oth- erwise would be omitted). The -T/--row-total flag adds an additional column showing the total for each row. - The -A/--average flag adds a column showing the average value in each + The -A/--average flag adds a column showing the average value in each row. Here's an example of all three: @@ -989,10 +1027,10 @@ COMMANDS Market value The -V/--value flag converts the reported amounts to their market value on the report end date, using the most recent applicable market prices, - when known. Specifically, when there is a market price (P directive) + when known. Specifically, when there is a market price (P directive) for the amount's commodity, dated on or before the report end date (see - hledger -> Report start & end date), the amount will be converted to - the price's commodity. If multiple applicable prices are defined, the + hledger -> Report start & end date), the amount will be converted to + the price's commodity. If multiple applicable prices are defined, the latest-dated one is used (and if dates are equal, the one last parsed). For example: @@ -1024,13 +1062,13 @@ COMMANDS $ hledger -f t.j bal euros -V -e 2016/12/21 $103.00 assets:euros - Currently, hledger's -V only uses market prices recorded with P direc- + Currently, hledger's -V only uses market prices recorded with P direc- tives, not transaction prices (unlike Ledger). Using -B and -V together is allowed. Custom balance output - In simple (non-multi-column) balance reports, you can customise the + In simple (non-multi-column) balance reports, you can customise the output with --format FMT: $ hledger balance --format "%20(account) %12(total)" @@ -1048,7 +1086,7 @@ COMMANDS 0 The FMT format string (plus a newline) specifies the formatting applied - to each account/balance pair. It may contain any suitable text, with + to each account/balance pair. It may contain any suitable text, with data fields interpolated like so: %[MIN][.MAX](FIELDNAME) @@ -1059,14 +1097,14 @@ COMMANDS o FIELDNAME must be enclosed in parentheses, and can be one of: - o depth_spacer - a number of spaces equal to the account's depth, or + o depth_spacer - a number of spaces equal to the account's depth, or if MIN is specified, MIN * depth spaces. o account - the account's name o total - the account's balance/posted total, right justified - Also, FMT can begin with an optional prefix to control how multi-com- + 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) @@ -1075,7 +1113,7 @@ COMMANDS o %, - render on one line, comma-separated - There are some quirks. Eg in one-line mode, %(depth_spacer) has no + There are some quirks. Eg in one-line mode, %(depth_spacer) has no effect, instead %(account) has indentation built in. Experimentation may be needed to get pleasing results. @@ -1083,19 +1121,19 @@ COMMANDS 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 - o %,%-50(account) %25(total) - account name padded to 50 characters, - total padded to 20 characters, with multiple commodities rendered on + o %,%-50(account) %25(total) - account name padded to 50 characters, + total padded to 20 characters, with multiple commodities rendered on one line - o %20(total) %2(depth_spacer)%-(account) - the default format for the + o %20(total) %2(depth_spacer)%-(account) - the default format for the single-column balance report Output destination - The balance, print, register and stats commands can write their output - to a destination other than the console. This is controlled by the + The balance, print, register and stats commands can write their output + to a destination other than the console. This is controlled by the -o/--output-file option. $ hledger balance -o - # write to stdout (the default) @@ -1103,8 +1141,8 @@ COMMANDS CSV output The balance, print and register commands can write their output as CSV. - This is useful for exporting data to other applications, eg to make - charts in a spreadsheet. This is controlled by the -O/--output-format + This is useful for exporting data to other applications, eg to make + charts in a spreadsheet. This is controlled by the -O/--output-format option, or by specifying a .csv file extension with -o/--output-file. $ hledger balance -O csv # write CSV to stdout @@ -1118,8 +1156,8 @@ COMMANDS --drop=N in flat mode: omit N leading account name parts - This command displays a simple balance sheet. It currently assumes - that you have top-level accounts named asset and liability (plural + This command displays a simple balance sheet. It currently assumes + that you have top-level accounts named asset and liability (plural forms also allowed.) $ hledger balancesheet @@ -1149,9 +1187,9 @@ COMMANDS --drop=N in flat mode: omit N leading account name parts - This command displays a simple cashflow statement It shows the change - in all "cash" (ie, liquid assets) accounts for the period. It cur- - rently assumes that cash accounts are under a top-level account named + This command displays a simple cashflow statement It shows the change + in all "cash" (ie, liquid assets) accounts for the period. It cur- + rently assumes that cash accounts are under a top-level account named asset and do not contain receivable or A/R (plural forms also allowed.) $ hledger cashflow @@ -1171,11 +1209,11 @@ COMMANDS help Show any of the hledger manuals. - The help command displays any of the main hledger man pages. (Unlike - hledger --help, which displays only the hledger man page.) Run it with - no arguments to list available topics (their names are shortened for - easier typing), and run hledger help TOPIC to select one. The output - is similar to a man page, but fixed width. It may be long, so you may + The help command displays any of the main hledger man pages. (Unlike + hledger --help, which displays only the hledger man page.) Run it with + no arguments to list available topics (their names are shortened for + easier typing), and run hledger help TOPIC to select one. The output + is similar to a man page, but fixed width. It may be long, so you may wish to pipe it into a pager. See also info and man. $ hledger help @@ -1204,8 +1242,8 @@ COMMANDS --drop=N in flat mode: omit N leading account name parts - This command displays a simple income statement. It currently assumes - that you have top-level accounts named income (or revenue) and expense + This command displays a simple income statement. It currently assumes + that you have top-level accounts named income (or revenue) and expense (plural forms also allowed.) $ hledger incomestatement @@ -1232,23 +1270,23 @@ COMMANDS info Show any of the hledger manuals using info. - The info command displays any of the hledger reference manuals using - the info hypertextual documentation viewer. This can be a very effi- - cient way to browse large manuals. It requires the "info" program to + The info command displays any of the hledger reference manuals using + the info hypertextual documentation viewer. This can be a very effi- + cient way to browse large manuals. It requires the "info" program to be available in your PATH. - As with help, run it with no arguments to list available topics (manu- + As with help, run it with no arguments to list available topics (manu- als). man Show any of the hledger manuals using man. - The man command displays any of the hledger reference manuals using - man, the standard documentation viewer on unix systems. This will fit - the text to your terminal width, and probably invoke a pager automati- + The man command displays any of the hledger reference manuals using + man, the standard documentation viewer on unix systems. This will fit + the text to your terminal width, and probably invoke a pager automati- cally. It requires the "man" program to be available in your PATH. - As with help, run it with no arguments to list available topics (manu- + As with help, run it with no arguments to list available topics (manu- als). print @@ -1258,14 +1296,14 @@ COMMANDS show all amounts explicitly -m STR --match=STR - show the transaction whose description is most similar to STR, + show the transaction whose description is most similar to STR, and is most recent -O FMT --output-format=FMT select the output format. Supported formats: txt, csv. -o FILE --output-file=FILE - write output to FILE. A file extension matching one of the + write output to FILE. A file extension matching one of the above formats selects that format. $ hledger print @@ -1293,23 +1331,23 @@ COMMANDS The print command displays full journal entries (transactions) from the journal file, tidily formatted. - As of hledger 1.2, print's output is always a valid hledger journal. - However it may not preserve all original content, eg it does not print + As of hledger 1.2, print's output is always a valid hledger journal. + However it may not preserve all original content, eg it does not print directives or inter-transaction comments. - Normally, transactions' implicit/explicit amount style is preserved: - when an amount is omitted in the journal, it will be omitted in the - output. You can use the --explicit flag to make all amounts explicit, + Normally, transactions' implicit/explicit amount style is preserved: + when an amount is omitted in the journal, it will be omitted in the + output. You can use the --explicit flag to make all amounts explicit, which can be useful for troubleshooting or for making your journal more - readable and robust against data entry errors. Note, in this mode - postings with a multi-commodity amount (possible with an implicit - amount in a multi-commodity transaction) will be split into multiple + readable and robust against data entry errors. Note, in this mode + postings with a multi-commodity amount (possible with an implicit + amount in a multi-commodity transaction) will be split into multiple single-commodity postings, for valid journal output. - With -B/--cost, amounts with transaction prices are converted to cost + With -B/--cost, amounts with transaction prices are converted to cost (using the transaction price). - The print command also supports output destination and CSV output. + The print command also supports output destination and CSV output. Here's an example of print's CSV output: $ hledger print -Ocsv @@ -1326,20 +1364,20 @@ COMMANDS "5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","","" "5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","","" - o There is one CSV record per posting, with the parent transaction's + o There is one CSV record per posting, with the parent transaction's fields repeated. o The "txnidx" (transaction index) field shows which postings belong to - the same transaction. (This number might change if transactions are - reordered within the file, files are parsed/included in a different + the same transaction. (This number might change if transactions are + reordered within the file, files are parsed/included in a different order, etc.) - o The amount is separated into "commodity" (the symbol) and "amount" + o The amount is separated into "commodity" (the symbol) and "amount" (numeric quantity) fields. o The numeric amount is repeated in either the "credit" or "debit" col- - umn, for convenience. (Those names are not accurate in the account- - ing sense; it just puts negative amounts under credit and zero or + umn, for convenience. (Those names are not accurate in the account- + ing sense; it just puts negative amounts under credit and zero or greater amounts under debit.) register @@ -1349,7 +1387,7 @@ COMMANDS show running total from report start date (default) -H --historical - show historical running total/balance (includes postings before + show historical running total/balance (includes postings before report start date) -A --average @@ -1360,18 +1398,18 @@ COMMANDS show postings' siblings instead -w N --width=N - set output width (default: terminal width or COLUMNS. -wN,M + set output width (default: terminal width or COLUMNS. -wN,M sets description width as well) -O FMT --output-format=FMT select the output format. Supported formats: txt, csv. -o FILE --output-file=FILE - write output to FILE. A file extension matching one of the + write output to FILE. A file extension matching one of the above formats selects that format. The register command displays postings, one per line, and their running - total. This is typically used with a query selecting a particular + total. This is typically used with a query selecting a particular account, to see that account's activity: $ hledger register checking @@ -1380,8 +1418,8 @@ COMMANDS 2008/06/02 save assets:bank:checking $-1 $1 2008/12/31 pay off assets:bank:checking $-1 0 - The --historical/-H flag adds the balance from any undisplayed prior - postings to the running total. This is useful when you want to see + The --historical/-H flag adds the balance from any undisplayed prior + postings to the running total. This is useful when you want to see only recent activity, with a historically accurate running balance: $ hledger register checking -b 2008/6 --historical @@ -1391,23 +1429,23 @@ COMMANDS 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 of the running total (so, the final number displayed is the average for - the whole report period). This flag implies --empty (see below). It - is affected by --historical. It works best when showing just one + the whole report period). This flag implies --empty (see below). It + is affected by --historical. It works best when showing just one account and one commodity. - The --related/-r flag shows the other postings in the transactions of + The --related/-r flag shows the other postings in the transactions of the postings which would normally be shown. - With a reporting interval, register shows summary postings, one per + With a reporting interval, register shows summary postings, one per interval, aggregating the postings to each account: $ hledger register --monthly income 2008/01 income:salary $-1 $-1 2008/06 income:gifts $-1 $-2 - Periods with no activity, and summary postings with a zero amount, are + 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 @@ -1424,7 +1462,7 @@ COMMANDS 2008/11 0 $-2 2008/12 0 $-2 - Often, you'll want to see just one line per interval. The --depth + 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 @@ -1432,19 +1470,19 @@ COMMANDS 2008/06 assets $-1 0 2008/12 assets $-1 $-1 - Note when using report intervals, if you specify start/end dates these - will be adjusted outward if necessary to contain a whole number of - intervals. This ensures that the first and last intervals are full + Note when using report intervals, if you specify start/end dates these + will be adjusted outward if necessary to contain a whole number of + intervals. This ensures that the first and last intervals are full length and comparable to the others in the report. Custom register output - register uses the full terminal width by default, except on windows. - You can override this by setting the COLUMNS environment variable (not + register uses the full terminal width by default, except on windows. + You can override this by setting the COLUMNS environment variable (not a bash shell variable) or by using the --width/-w option. - The description and account columns normally share the space equally - (about half of (width - 40) each). You can adjust this by adding a - description width as part of --width's argument, comma-separated: + The description and account columns normally share the space equally + (about half of (width - 40) each). You can adjust this by adding a + description width as part of --width's argument, comma-separated: --width W,D . Here's a diagram: <--------------------------------- width (W) ----------------------------------> @@ -1460,14 +1498,14 @@ COMMANDS $ hledger reg -w 100,40 # set overall width 100, description width 40 $ hledger reg -w $COLUMNS,40 # use terminal width, and set description width - The register command also supports the -o/--output-file and -O/--out- + The register command also supports the -o/--output-file and -O/--out- put-format options for controlling output destination and CSV output. stats Show some journal statistics. -o FILE --output-file=FILE - write output to FILE. A file extension matching one of the + write output to FILE. A file extension matching one of the above formats selects that format. $ hledger stats @@ -1482,8 +1520,8 @@ COMMANDS Accounts : 8 (depth 3) Commodities : 1 ($) - The stats command displays summary information for the whole journal, - or a matched part of it. With a reporting interval, it shows a report + The stats command displays summary information for the whole journal, + or a matched part of it. With a reporting interval, it shows a report for each report period. The stats command also supports -o/--output-file for controlling output @@ -1495,37 +1533,37 @@ COMMANDS $ hledger test Cases: 74 Tried: 74 Errors: 0 Failures: 0 - This command runs hledger's built-in unit tests and displays a quick + This command runs hledger's built-in unit tests and displays a quick report. With a regular expression argument, it selects only tests with matching names. It's mainly used in development, but it's also nice to be able to check your hledger executable for smoke at any time. ADD-ON COMMANDS - Add-on commands are executables in your PATH whose name starts with - hledger- and ends with any of these file extensions: none, - .hs,.lhs,.pl,.py,.rb,.rkt,.sh,.bat,.com,.exe. Also, an add-on's name + Add-on commands are executables in your PATH whose name starts with + hledger- and ends with any of these file extensions: none, + .hs,.lhs,.pl,.py,.rb,.rkt,.sh,.bat,.com,.exe. Also, an add-on's name may not be the same as any built-in command or alias. - hledger will detect these and include them in the command list and let - you invoke them with hledger ADDONCMD. However there are some limita- + hledger will detect these and include them in the command list and let + you invoke them with hledger ADDONCMD. However there are some limita- tions: o Options appearing before ADDONCMD will be visible only to hledger and will not be passed to the add-on. Eg: hledger -h web shows hledger's usage, hledger web -h shows hledger-web's usage. - o Options understood only by the add-on must go after a -- argument to - hide them from hledger, which would otherwise reject them. Eg: + o Options understood only by the add-on must go after a -- argument to + hide them from hledger, which would otherwise reject them. Eg: hledger web -- --server. - Sometimes it may be more convenient to just run the add-on directly, + Sometimes it may be more convenient to just run the add-on directly, eg: hledger-web --server. - Add-ons which are written in haskell can take advantage of the - hledger-lib library for journal parsing, reporting, command-line + Add-ons which are written in haskell can take advantage of the + hledger-lib library for journal parsing, reporting, command-line options, etc. - Here are some hledger add-ons available from Hackage, the extra direc- + Here are some hledger add-ons available from Hackage, the extra direc- tory in the hledger source, or elsewhere: api @@ -1583,11 +1621,11 @@ ADD-ON COMMANDS WF:4303001832 -$6.00 [assets:business:bank:wf:bchecking:banking] $6.00 - ledger-autosync, which includes a hledger-autosync alias, downloads + ledger-autosync, which includes a hledger-autosync alias, downloads transactions from your bank(s) via OFX, and prints just the new ones as journal entries which you can add to your journal. It can also operate - on .OFX files which you've downloaded manually. It can be a nice - alternative to hledger's built-in CSV reader, especially if your bank + on .OFX files which you've downloaded manually. It can be a nice + alternative to hledger's built-in CSV reader, especially if your bank supports OFX download. diff @@ -1613,9 +1651,9 @@ ADD-ON COMMANDS 2015/02/02 (acct:two) $2 - hledger-diff compares two journal files. Given an account name, it - prints out the transactions affecting that account which are in one - journal file but not in the other. This can be useful for reconciling + hledger-diff compares two journal files. Given an account name, it + prints out the transactions affecting that account which are in one + journal file but not in the other. This can be useful for reconciling existing journals with bank statements. equity @@ -1642,14 +1680,14 @@ ADD-ON COMMANDS equity:opening balances 0 This prints a journal entry which zeroes out the specified accounts (or - all accounts) with a transfer to/from "equity:closing balances" (like - Ledger's equity command). Also, it prints an similar entry with oppo- + all accounts) with a transfer to/from "equity:closing balances" (like + Ledger's equity command). Also, it prints an similar entry with oppo- site sign for restoring the balances from "equity:opening balances". These can be useful for ending one journal file and starting a new one, - respectively. By zeroing your asset and liability accounts at the end + respectively. By zeroing your asset and liability accounts at the end of a file and restoring them at the start of the next one, you will see - correct asset/liability balances whether you run hledger on just one + correct asset/liability balances whether you run hledger on just one file, or on several files concatenated with include. interest @@ -1730,11 +1768,11 @@ ADD-ON COMMANDS Liabilities:Bank EUR 3700.00 hledger-interest computes interests for a given account. Using command - line flags, the program can be configured to use various schemes for - day-counting, such as act/act, 30/360, 30E/360, and 30/360isda. Fur- - thermore, it supports a (small) number of interest schemes, i.e. + line flags, the program can be configured to use various schemes for + day-counting, such as act/act, 30/360, 30E/360, and 30/360isda. Fur- + thermore, it supports a (small) number of interest schemes, i.e. annual interest with a fixed rate and the scheme mandated by the German - BGB288 (Basiszins fr Verbrauchergeschfte). See the package page for + BGB288 (Basiszins fr Verbrauchergeschfte). See the package page for more. irr @@ -1792,11 +1830,11 @@ ADD-ON COMMANDS 2011/04/01 - 2011/05/01: 32.24% 2011/05/01 - 2011/06/01: 95.92% - hledger-irr computes the internal rate of return, also known as the - effective interest rate, of a given investment. After specifying what - account holds the investment, and what account stores the gains (or - losses, or fees, or cost), it calculates the hypothetical annual rate - of fixed rate investment that would have provided the exact same cash + hledger-irr computes the internal rate of return, also known as the + effective interest rate, of a given investment. After specifying what + account holds the investment, and what account stores the gains (or + losses, or fees, or cost), it calculates the hypothetical annual rate + of fixed rate investment that would have provided the exact same cash flow. See the package page for more. print-unique @@ -1817,8 +1855,8 @@ ADD-ON COMMANDS entries. hledger-rewrite.hs, in hledger's extra directory (compilation - optional), adds postings to existing transactions, optionally with an - amount based on the existing transaction's first amount. See the + optional), adds postings to existing transactions, optionally with an + amount based on the existing transaction's first amount. See the script for more details. $ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ... @@ -1833,26 +1871,26 @@ ADD-ON COMMANDS TROUBLESHOOTING Run-time problems - Here are some issues you might encounter when you run hledger (and - remember you can also seek help from the IRC channel, mail list or bug + Here are some issues you might encounter when you run hledger (and + remember you can also seek help from the IRC channel, mail list or bug tracker): Successfully installed, but "No command 'hledger' found" stack and cabal install binaries into a special directory, which should - be added to your PATH environment variable. Eg on unix-like systems, + be added to your PATH environment variable. Eg on unix-like systems, that is ~/.local/bin and ~/.cabal/bin respectively. I set a custom LEDGER_FILE, but hledger is still using the default file - LEDGER_FILE should be a real environment variable, not just a shell - variable. The command env | grep LEDGER_FILE should show it. You may + LEDGER_FILE should be a real environment variable, not just a shell + variable. The command env | grep LEDGER_FILE should show it. You may need to use export. Here's an explanation. - "Illegal byte sequence" or "Invalid or incomplete multibyte or wide + "Illegal byte sequence" or "Invalid or incomplete multibyte or wide character" errors In order to handle non-ascii letters and symbols (like ), hledger needs an appropriate locale. This is usually configured system-wide; you can also configure it temporarily. The locale may need to be one that sup- - ports UTF-8, if you built hledger with GHC < 7.2 (or possibly always, + ports UTF-8, if you built hledger with GHC < 7.2 (or possibly always, I'm not sure yet). Here's an example of setting the locale temporarily, on ubuntu @@ -1871,7 +1909,7 @@ TROUBLESHOOTING $ echo "export LANG=en_US.UTF-8" >>~/.bash_profile $ bash --login - If we preferred to use eg fr_FR.utf8, we might have to install that + If we preferred to use eg fr_FR.utf8, we might have to install that first: $ apt-get install language-pack-fr @@ -1892,45 +1930,45 @@ TROUBLESHOOTING Known limitations Command line interface - Add-on command options, unless they are also understood by the main - hledger executable, must be written after --, like this: + Add-on command options, unless they are also understood by the main + hledger executable, must be written after --, like this: hledger web -- --server Differences from Ledger - Not all of Ledger's journal file syntax is supported. See file format + Not all of Ledger's journal file syntax is supported. See file format differences. - hledger is slower than Ledger, and uses more memory, on large data + hledger is slower than Ledger, and uses more memory, on large data files. Windows limitations - In a windows CMD window, non-ascii characters and colours are not sup- + In a windows CMD window, non-ascii characters and colours are not sup- ported. In a windows Cygwin/MSYS/Mintty window, the tab key is not supported in hledger add. ENVIRONMENT - COLUMNS The screen width used by the register command. Default: the + COLUMNS The screen width used by the register command. Default: the full terminal width. LEDGER_FILE The journal file path when not specified with -f. Default: - ~/.hledger.journal (on windows, perhaps C:/Users/USER/.hledger.jour- + ~/.hledger.journal (on windows, perhaps C:/Users/USER/.hledger.jour- nal). FILES - Reads data from one or more files in hledger journal, timeclock, time- - dot, or CSV format specified with -f, or $LEDGER_FILE, or - $HOME/.hledger.journal (on windows, perhaps + Reads data from one or more files in hledger journal, timeclock, time- + dot, or CSV format specified with -f, or $LEDGER_FILE, or + $HOME/.hledger.journal (on windows, perhaps C:/Users/USER/.hledger.journal). BUGS - The need to precede options with -- when invoked from hledger is awk- + The need to precede options with -- when invoked from hledger is awk- ward. - hledger can't render non-ascii characters when run from a Windows com- + hledger can't render non-ascii characters when run from a Windows com- mand prompt (up to Windows 7 at least). When input data contains non-ascii characters, a suitable system locale @@ -1940,7 +1978,7 @@ BUGS REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel + Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel or hledger mail list) @@ -1954,7 +1992,7 @@ COPYRIGHT SEE ALSO - hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1), + hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1), hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time- dot(5), ledger(1) diff --git a/hledger/doc/options.m4.md b/hledger/doc/options.m4.md index bd62e3599..17bd681e4 100644 --- a/hledger/doc/options.m4.md +++ b/hledger/doc/options.m4.md @@ -121,12 +121,6 @@ There are some limitations with this: If you need those, either use the [include directive](/journal.html#including-other-files), or concatenate the files, eg: `cat a.journal b.journal | hledger -f- CMD`. -## Depth limiting - -With the `--depth N` option, commands like [account](#account), [balance](#balance) -and [register](#register) will show only the uppermost accounts in the account -tree, down to level N. Use this when you want a summary with less detail. - ## Smart dates hledger's user interfaces accept a flexible "smart date" syntax (unlike dates in the journal file). @@ -269,6 +263,65 @@ Group postings from start of wednesday to end of next tuesday (N is start date a `hledger register checking -p "every 3rd day of week"` +## Depth limiting + +With the `--depth N` option, commands like [account](#account), [balance](#balance) +and [register](#register) will show only the uppermost accounts in the account +tree, down to level N. Use this when you want a summary with less detail. + +## Pivoting + +Normally hledger sums amounts, and organizes them in a hierarchy, based on account name. +The `--pivot TAGNAME` option causes it to sum and organize hierarchy based on some other field instead. + +TAGNAME is the full, case-insensitive name of a [tag](/journal.html#tags) you have defined, +or one of the built-in implicit tags (like `code` or `payee`). +As with account names, when tag values have `multiple:colon-separated:parts` hledger will build hierarchy, +displayed in tree-mode reports, summarisable with a depth limit, and so on. + +`--pivot` affects all reports, and is one of those options you can write before the command name if you wish. +You can think of hledger transforming the journal before any other processing, +replacing every posting's account name with the value of the specified tag on that posting, +inheriting it from the transaction or using a blank value if it's not present. + +An example: + +```journal +2016/02/16 Member Fee Payment + assets:bank account 2 EUR + income:member fees -2 EUR ; member: John Doe +``` +Normal balance report showing account names: +```shell +$ hledger balance + 2 EUR assets:bank account + -2 EUR income:member fees +-------------------- + 0 +``` +Pivoted balance report, using member: tag values instead: +```shell +$ hledger balance --pivot member + 2 EUR + -2 EUR John Doe +-------------------- + 0 +``` +One way to show only amounts with a member: value (using a [query](#queries), described below): +```shell +$ hledger balance --pivot member tag:member=. + -2 EUR John Doe +-------------------- + -2 EUR +``` +Another way (the acct: query matches against the pivoted "account name"): +``` +$ hledger balance --pivot member acct:. + -2 EUR John Doe +-------------------- + -2 EUR +``` + ## Regular expressions hledger uses [regular expressions](http://www.regular-expressions.info) in a number of places: