From 4451d68a630fb65859dd500d855ee37aeb272ec3 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 29 Jul 2021 20:40:47 -1000 Subject: [PATCH] ;doc: update manuals --- hledger-ui/hledger-ui.1 | 58 +- hledger-ui/hledger-ui.info | 132 +++- hledger-ui/hledger-ui.txt | 143 ++-- hledger-web/hledger-web.info | 36 +- hledger/hledger.1 | 362 +++++++--- hledger/hledger.info | 1288 +++++++++++++++++++--------------- hledger/hledger.txt | 904 +++++++++++++----------- 7 files changed, 1759 insertions(+), 1164 deletions(-) diff --git a/hledger-ui/hledger-ui.1 b/hledger-ui/hledger-ui.1 index de6e651fa..9ad10b093 100644 --- a/hledger-ui/hledger-ui.1 +++ b/hledger-ui/hledger-ui.1 @@ -302,12 +302,6 @@ There\[aq]s not yet any visual reminder when cost or value mode is active; for now pressing \f[C]b\f[R] \f[C]b\f[R] \f[C]v\f[R] should reliably reset to normal mode. .PP -With \f[C]--watch\f[R] active, if you save an edit to the journal file -while viewing the transaction screen in cost or value mode, the -\f[C]B\f[R]/\f[C]V\f[R] keys will stop working. -To work around, press \f[C]g\f[R] to force a manual reload, or exit the -transaction screen. -.PP \f[C]q\f[R] quits the application. .PP Additional screen-specific keys are described below. @@ -439,6 +433,58 @@ when you press g to reload. Once you have fixed the problem, press g again to reload and resume normal operation. (Or, you can press escape to cancel the reload attempt.) +.SH TIPS +.SS Watch mode +.PP +One of hledger-ui\[aq]s best features is the auto-reloading +\f[C]--watch\f[R] mode. +With this flag, it will update the display automatically whenever +changes are saved to the data files. +.PP +This is very useful when reconciling. +A good workflow is to have your bank\[aq]s online register open in a +browser window, for reference; the journal file open in an editor +window; and hledger-ui in watch mode in a terminal window, eg: +.IP +.nf +\f[C] +$ hledger-ui --watch --register checking -C +\f[R] +.fi +.PP +As you mark things cleared in the editor, you can see the effect +immediately without having to context switch. +This leaves more mental bandwidth for your accounting. +Of course you can still interact with hledger-ui when needed, eg to +toggle cleared mode, or to explore the history. +.SS Watch mode limitations +.PP +There are situations in which it won\[aq]t work, ie the display will not +update when you save a change (because the underlying \f[C]inotify\f[R] +library does not support it). +Here are some that we know of: +.IP \[bu] 2 +Certain editors: saving with \f[C]gedit\f[R], and perhaps any Gnome +application, won\[aq]t be detected (#1617). +Jetbrains IDEs, such as IDEA, also may not work (#911). +.IP \[bu] 2 +Certain unusual filesystems might not be supported. +(All the usual ones on unix, mac and windows are supported.) +.PP +In such cases, the workaround is to switch to the hledger-ui window and +press \f[C]g\f[R] each time you want it to reload. +(Actually, see #1617 for another workaround, and let us know if it works +for you.) +.PP +If you leave \f[C]hledger-ui --watch\f[R] running for days, on certain +platforms (?), perhaps with many transactions in your journal (?), +perhaps with large numbers of other files present (?), you may see it +gradually using more and more memory and CPU over time, as seen in +\f[C]top\f[R] or Activity Monitor or Task Manager. +.PP +A workaround is to \f[C]q\f[R]uit and restart it, or to suspend it +(\f[C]CTRL-z\f[R]) and restart it (\f[C]fg\f[R]) if your shell supports +that. .SH ENVIRONMENT .PP \f[B]COLUMNS\f[R] The screen width to use. diff --git a/hledger-ui/hledger-ui.info b/hledger-ui/hledger-ui.info index 9958474e6..996200a83 100644 --- a/hledger-ui/hledger-ui.info +++ b/hledger-ui/hledger-ui.info @@ -3,7 +3,7 @@ from stdin. INFO-DIR-SECTION User Applications START-INFO-DIR-ENTRY -* hledger-ui: (hledger-ui/hledger-ui). Terminal UI for the hledger accounting tool. +* hledger-ui: (hledger-ui). Terminal UI for the hledger accounting tool. END-INFO-DIR-ENTRY  @@ -45,6 +45,7 @@ enable "forecast mode". * OPTIONS:: * KEYS:: * SCREENS:: +* TIPS:: * ENVIRONMENT:: * FILES:: * BUGS:: @@ -308,17 +309,12 @@ screen, press `/', and add `date:-7/30' to the query. active; for now pressing `b' `b' `v' should reliably reset to normal mode. - With `--watch' active, if you save an edit to the journal file while -viewing the transaction screen in cost or value mode, the `B'/`V' keys -will stop working. To work around, press `g' to force a manual reload, -or exit the transaction screen. - `q' quits the application. Additional screen-specific keys are described below.  -File: hledger-ui.info, Node: SCREENS, Next: ENVIRONMENT, Prev: KEYS, Up: Top +File: hledger-ui.info, Node: SCREENS, Next: TIPS, Prev: KEYS, Up: Top 3 SCREENS ********* @@ -463,9 +459,75 @@ again to reload and resume normal operation. (Or, you can press escape to cancel the reload attempt.)  -File: hledger-ui.info, Node: ENVIRONMENT, Next: FILES, Prev: SCREENS, Up: Top +File: hledger-ui.info, Node: TIPS, Next: ENVIRONMENT, Prev: SCREENS, Up: Top -4 ENVIRONMENT +4 TIPS +****** + +* Menu: + +* Watch mode:: +* Watch mode limitations:: + + +File: hledger-ui.info, Node: Watch mode, Next: Watch mode limitations, Up: TIPS + +4.1 Watch mode +============== + +One of hledger-ui's best features is the auto-reloading `--watch' mode. +With this flag, it will update the display automatically whenever +changes are saved to the data files. + + This is very useful when reconciling. A good workflow is to have your +bank's online register open in a browser window, for reference; the +journal file open in an editor window; and hledger-ui in watch mode in a +terminal window, eg: + + +$ hledger-ui --watch --register checking -C + + As you mark things cleared in the editor, you can see the effect +immediately without having to context switch. This leaves more mental +bandwidth for your accounting. Of course you can still interact with +hledger-ui when needed, eg to toggle cleared mode, or to explore the +history. + + +File: hledger-ui.info, Node: Watch mode limitations, Prev: Watch mode, Up: TIPS + +4.2 Watch mode limitations +========================== + +There are situations in which it won't work, ie the display will not +update when you save a change (because the underlying `inotify' library +does not support it). Here are some that we know of: + + * Certain editors: saving with `gedit', and perhaps any Gnome + application, won't be detected (#1617). Jetbrains IDEs, such as + IDEA, also may not work (#911). + + * Certain unusual filesystems might not be supported. (All the usual + ones on unix, mac and windows are supported.) + + + In such cases, the workaround is to switch to the hledger-ui window +and press `g' each time you want it to reload. (Actually, see #1617 for +another workaround, and let us know if it works for you.) + + If you leave `hledger-ui --watch' running for days, on certain +platforms (?), perhaps with many transactions in your journal (?), +perhaps with large numbers of other files present (?), you may see it +gradually using more and more memory and CPU over time, as seen in +`top' or Activity Monitor or Task Manager. + + A workaround is to `q'uit and restart it, or to suspend it +(`CTRL-z') and restart it (`fg') if your shell supports that. + + +File: hledger-ui.info, Node: ENVIRONMENT, Next: FILES, Prev: TIPS, Up: Top + +5 ENVIRONMENT ************* *COLUMNS* The screen width to use. Default: the full terminal width. @@ -494,7 +556,7 @@ GUI (say, an Emacs dock icon). Eg on MacOS Catalina I have a  File: hledger-ui.info, Node: FILES, Next: BUGS, Prev: ENVIRONMENT, Up: Top -5 FILES +6 FILES ******* Reads data from one or more files in hledger journal, timeclock, @@ -505,7 +567,7 @@ timedot, or CSV format specified with `-f', or `$LEDGER_FILE', or  File: hledger-ui.info, Node: BUGS, Prev: FILES, Up: Top -6 BUGS +7 BUGS ****** The need to precede options with `--' when invoked from hledger is @@ -533,26 +595,32 @@ program is restarted.  Tag Table: -Node: Top243 -Node: OPTIONS1636 -Ref: #options1733 -Node: KEYS6128 -Ref: #keys6223 -Node: SCREENS10519 -Ref: #screens10624 -Node: Accounts screen10714 -Ref: #accounts-screen10842 -Node: Register screen13046 -Ref: #register-screen13201 -Node: Transaction screen15196 -Ref: #transaction-screen15354 -Node: Error screen16221 -Ref: #error-screen16343 -Node: ENVIRONMENT16585 -Ref: #environment16699 -Node: FILES17504 -Ref: #files17603 -Node: BUGS17816 -Ref: #bugs17893 +Node: Top232 +Node: OPTIONS1634 +Ref: #options1731 +Node: KEYS6126 +Ref: #keys6221 +Node: SCREENS10270 +Ref: #screens10368 +Node: Accounts screen10458 +Ref: #accounts-screen10586 +Node: Register screen12790 +Ref: #register-screen12945 +Node: Transaction screen14940 +Ref: #transaction-screen15098 +Node: Error screen15965 +Ref: #error-screen16087 +Node: TIPS16329 +Ref: #tips16428 +Node: Watch mode16480 +Ref: #watch-mode16597 +Node: Watch mode limitations17341 +Ref: #watch-mode-limitations17482 +Node: ENVIRONMENT18615 +Ref: #environment18726 +Node: FILES19531 +Ref: #files19630 +Node: BUGS19843 +Ref: #bugs19920  End Tag Table diff --git a/hledger-ui/hledger-ui.txt b/hledger-ui/hledger-ui.txt index fffb787fb..efee9c6f3 100644 --- a/hledger-ui/hledger-ui.txt +++ b/hledger-ui/hledger-ui.txt @@ -276,55 +276,50 @@ KEYS There's not yet any visual reminder when cost or value mode is active; for now pressing b b v should reliably reset to normal mode. - With --watch active, if you save an edit to the journal file while - viewing the transaction screen in cost or value mode, the B/V keys will - stop working. To work around, press g to force a manual reload, or - exit the transaction screen. - q quits the application. Additional screen-specific keys are described below. SCREENS Accounts screen - This is normally the first screen displayed. It lists accounts and - their balances, like hledger's balance command. By default, it shows - all accounts and their latest ending balances (including the balances - of subaccounts). If you specify a query on the command line, it shows + This is normally the first screen displayed. It lists accounts and + their balances, like hledger's balance command. By default, it shows + all accounts and their latest ending balances (including the balances + of subaccounts). If you specify a query on the command line, it shows just the matched accounts and the balances from matched transactions. - Account names are shown as a flat list by default; press t to toggle - tree mode. In list mode, account balances are exclusive of subac- - counts, except where subaccounts are hidden by a depth limit (see - below). In tree mode, all account balances are inclusive of subac- + Account names are shown as a flat list by default; press t to toggle + tree mode. In list mode, account balances are exclusive of subac- + counts, except where subaccounts are hidden by a depth limit (see + below). In tree mode, all account balances are inclusive of subac- counts. - To see less detail, press a number key, 1 to 9, to set a depth limit. + To see less detail, press a number key, 1 to 9, to set a depth limit. Or use - to decrease and +/= to increase the depth limit. 0 shows even - less detail, collapsing all accounts to a single total. To remove the - depth limit, set it higher than the maximum account depth, or press + less detail, collapsing all accounts to a single total. To remove the + depth limit, set it higher than the maximum account depth, or press ESCAPE. H toggles between showing historical balances or period balances. His- - torical balances (the default) are ending balances at the end of the - report period, taking into account all transactions before that date - (filtered by the filter query if any), including transactions before - the start of the report period. In other words, historical balances - are what you would see on a bank statement for that account (unless - disturbed by a filter query). Period balances ignore transactions + torical balances (the default) are ending balances at the end of the + report period, taking into account all transactions before that date + (filtered by the filter query if any), including transactions before + the start of the report period. In other words, historical balances + are what you would see on a bank statement for that account (unless + disturbed by a filter query). Period balances ignore transactions before the report start date, so they show the change in balance during the report period. They are more useful eg when viewing a time log. U toggles filtering by unmarked status, including or excluding unmarked postings in the balances. Similarly, P toggles pending postings, and C - toggles cleared postings. (By default, balances include all postings; - if you activate one or two status filters, only those postings are + toggles cleared postings. (By default, balances include all postings; + if you activate one or two status filters, only those postings are included; and if you activate all three, the filter is removed.) R toggles real mode, in which virtual postings are ignored. - Z toggles nonzero mode, in which only accounts with nonzero balances - are shown (hledger-ui shows zero items by default, unlike command-line + Z toggles nonzero mode, in which only accounts with nonzero balances + are shown (hledger-ui shows zero items by default, unlike command-line hledger). Press right or enter to view an account's transactions register. @@ -333,66 +328,110 @@ SCREENS This screen shows the transactions affecting a particular account, like a check register. Each line represents one transaction and shows: - o the other account(s) involved, in abbreviated form. (If there are - both real and virtual postings, it shows only the accounts affected + o the other account(s) involved, in abbreviated form. (If there are + both real and virtual postings, it shows only the accounts affected by real postings.) - o the overall change to the current account's balance; positive for an + o the overall change to the current account's balance; positive for an inflow to this account, negative for an outflow. o the running historical total or period total for the current account, - after the transaction. This can be toggled with H. Similar to the - accounts screen, the historical total is affected by transactions - (filtered by the filter query) before the report start date, while + after the transaction. This can be toggled with H. Similar to the + accounts screen, the historical total is affected by transactions + (filtered by the filter query) before the report start date, while the period total is not. If the historical total is not disturbed by - a filter query, it will be the running historical balance you would + a filter query, it will be the running historical balance you would see on a bank register for the current account. - Transactions affecting this account's subaccounts will be included in + Transactions affecting this account's subaccounts will be included in the register if the accounts screen is in tree mode, or if it's in list - mode but this account has subaccounts which are not shown due to a - depth limit. In other words, the register always shows the transac- - tions contributing to the balance shown on the accounts screen. Tree + mode but this account has subaccounts which are not shown due to a + depth limit. In other words, the register always shows the transac- + tions contributing to the balance shown on the accounts screen. Tree mode/list mode can be toggled with t here also. - U toggles filtering by unmarked status, showing or hiding unmarked + U toggles filtering by unmarked status, showing or hiding unmarked transactions. Similarly, P toggles pending transactions, and C toggles - cleared transactions. (By default, transactions with all statuses are - shown; if you activate one or two status filters, only those transac- + cleared transactions. (By default, transactions with all statuses are + shown; if you activate one or two status filters, only those transac- tions are shown; and if you activate all three, the filter is removed.) R toggles real mode, in which virtual postings are ignored. - Z toggles nonzero mode, in which only transactions posting a nonzero - change are shown (hledger-ui shows zero items by default, unlike com- + Z toggles nonzero mode, in which only transactions posting a nonzero + change are shown (hledger-ui shows zero items by default, unlike com- mand-line hledger). Press right (or enter) to view the selected transaction in detail. Transaction screen - This screen shows a single transaction, as a general journal entry, - similar to hledger's print command and journal format (hledger_jour- + This screen shows a single transaction, as a general journal entry, + similar to hledger's print command and journal format (hledger_jour- nal(5)). - The transaction's date(s) and any cleared flag, transaction code, - description, comments, along with all of its account postings are - shown. Simple transactions have two postings, but there can be more + The transaction's date(s) and any cleared flag, transaction code, + description, comments, along with all of its account postings are + shown. Simple transactions have two postings, but there can be more (or in certain cases, fewer). - up and down will step through all transactions listed in the previous - account register screen. In the title bar, the numbers in parentheses - show your position within that account register. They will vary + up and down will step through all transactions listed in the previous + account register screen. In the title bar, the numbers in parentheses + show your position within that account register. They will vary depending on which account register you came from (remember most trans- actions appear in multiple account registers). The #N number preceding them is the transaction's position within the complete unfiltered jour- nal, which is a more stable id (at least until the next reload). Error screen - This screen will appear if there is a problem, such as a parse error, - when you press g to reload. Once you have fixed the problem, press g + This screen will appear if there is a problem, such as a parse error, + when you press g to reload. Once you have fixed the problem, press g again to reload and resume normal operation. (Or, you can press escape to cancel the reload attempt.) +TIPS + Watch mode + One of hledger-ui's best features is the auto-reloading --watch mode. + With this flag, it will update the display automatically whenever + changes are saved to the data files. + + This is very useful when reconciling. A good workflow is to have your + bank's online register open in a browser window, for reference; the + journal file open in an editor window; and hledger-ui in watch mode in + a terminal window, eg: + + $ hledger-ui --watch --register checking -C + + As you mark things cleared in the editor, you can see the effect imme- + diately without having to context switch. This leaves more mental + bandwidth for your accounting. Of course you can still interact with + hledger-ui when needed, eg to toggle cleared mode, or to explore the + history. + + Watch mode limitations + There are situations in which it won't work, ie the display will not + update when you save a change (because the underlying inotify library + does not support it). Here are some that we know of: + + o Certain editors: saving with gedit, and perhaps any Gnome applica- + tion, won't be detected (#1617). Jetbrains IDEs, such as IDEA, also + may not work (#911). + + o Certain unusual filesystems might not be supported. (All the usual + ones on unix, mac and windows are supported.) + + In such cases, the workaround is to switch to the hledger-ui window and + press g each time you want it to reload. (Actually, see #1617 for + another workaround, and let us know if it works for you.) + + If you leave hledger-ui --watch running for days, on certain platforms + (?), perhaps with many transactions in your journal (?), perhaps with + large numbers of other files present (?), you may see it gradually + using more and more memory and CPU over time, as seen in top or Activ- + ity Monitor or Task Manager. + + A workaround is to quit and restart it, or to suspend it (CTRL-z) and + restart it (fg) if your shell supports that. + ENVIRONMENT COLUMNS The screen width to use. Default: the full terminal width. diff --git a/hledger-web/hledger-web.info b/hledger-web/hledger-web.info index 01d9fcc80..6bc5ccf07 100644 --- a/hledger-web/hledger-web.info +++ b/hledger-web/hledger-web.info @@ -3,7 +3,7 @@ from stdin. INFO-DIR-SECTION User Applications START-INFO-DIR-ENTRY -* hledger-web: (hledger-web/hledger-web). Web UI/API for the hledger accounting tool. +* hledger-web: (hledger-web). Web UI/API for the hledger accounting tool. END-INFO-DIR-ENTRY  @@ -612,22 +612,22 @@ awkward.  Tag Table: -Node: Top247 -Node: OPTIONS1887 -Ref: #options1992 -Node: PERMISSIONS9405 -Ref: #permissions9544 -Node: EDITING UPLOADING DOWNLOADING10756 -Ref: #editing-uploading-downloading10937 -Node: RELOADING11768 -Ref: #reloading11902 -Node: JSON API12334 -Ref: #json-api12448 -Node: ENVIRONMENT17937 -Ref: #environment18053 -Node: FILES18785 -Ref: #files18885 -Node: BUGS19098 -Ref: #bugs19176 +Node: Top235 +Node: OPTIONS1875 +Ref: #options1980 +Node: PERMISSIONS9393 +Ref: #permissions9532 +Node: EDITING UPLOADING DOWNLOADING10744 +Ref: #editing-uploading-downloading10925 +Node: RELOADING11756 +Ref: #reloading11890 +Node: JSON API12322 +Ref: #json-api12436 +Node: ENVIRONMENT17925 +Ref: #environment18041 +Node: FILES18773 +Ref: #files18873 +Node: BUGS19086 +Ref: #bugs19164  End Tag Table diff --git a/hledger/hledger.1 b/hledger/hledger.1 index 9aea1fca7..3bdbd6220 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -296,6 +296,11 @@ or: $ hledger register credit\[rs] card \f[R] .fi +.PP +Windows users should keep in mind that \f[C]cmd\f[R] treats single quote +as a regular character, so you should be using double quotes +exclusively. +PowerShell treats both single and double quotes as quotes. .SS Double escaping (regular expression metacharacters) .PP Characters significant in regular expressions (described below) - such @@ -657,6 +662,8 @@ Are all accounts posted to, declared with an \f[C]account\f[R] directive .IP \[bu] 2 Are all commodities declared with a \f[C]commodity\f[R] directive ? (Commodity error checking) +.IP \[bu] 2 +Are all commodity conversions declared explicitly ? .PP You can also use the check command to run these and some additional checks. @@ -754,6 +761,7 @@ T}@T{ 9+ digits beginning with a valid YYYYMMDD gives an error T} .TE +.PP .SS Report start & end date .PP By default, most hledger reports will show the full span of time @@ -1140,18 +1148,171 @@ This flag has the same effect as a \f[C]depth:\f[R] query argument (so \f[C]-2\f[R], \f[C]--depth=2\f[R] or \f[C]depth:2\f[R] are equivalent). .SH QUERIES .PP -One of hledger\[aq]s strengths is being able to quickly report on -precise subsets of your data. -Most commands accept an optional query expression, 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, prefixes to match specific -fields, a not: prefix to negate the match. +One of hledger\[aq]s strengths is being able to quickly report on a +precise subset of your data. +Most hledger commands accept optional query arguments to restrict their +scope. +The syntax is as follows: +.IP \[bu] 2 +Zero or more space-separated query terms. +These are most often account name substrings: +.RS 2 .PP -We do not yet support arbitrary boolean combinations of search terms; -instead most commands show transactions/postings/accounts which match -(or negatively match): +\f[C]utilities food:groceries\f[R] +.RE +.IP \[bu] 2 +Terms with spaces or other special characters should be enclosed in +quotes: +.RS 2 +.PP +\f[C]\[dq]personal care\[dq]\f[R] +.RE +.IP \[bu] 2 +Regular expressions are also supported: +.RS 2 +.PP +\f[C]\[dq]\[ha]expenses\[rs]b\[dq] \[dq]accounts (payable|receivable)\[dq]\f[R] +.RE +.IP \[bu] 2 +Add a query type prefix to match other parts of the data: +.RS 2 +.PP +\f[C]date:202012- desc:amazon cur:USD amt:\[dq]>100\[dq] status:\f[R] +.RE +.IP \[bu] 2 +Add a \f[C]not:\f[R] prefix to negate a term: +.RS 2 +.PP +\f[C]not:cur:USD\f[R] +.RE +.SS Query types +.PP +Here are the types of query term available. +Remember these can also be prefixed with \f[B]\f[CB]not:\f[B]\f[R] to +convert them into a negative match. +.PP +\f[B]\f[CB]acct:REGEX\f[B], \f[CB]REGEX\f[B]\f[R] +.PD 0 +.P +.PD +Match account names containing this (case insensitive) regular +expression. +This is the default query type when there is no prefix, and regular +expression syntax is typically not needed, so usually we just write an +account name substring, like \f[C]expenses\f[R] or \f[C]food\f[R]. +.PP +\f[B]\f[CB]amt:N, amt:N, amt:>=N\f[B]\f[R] +.PD 0 +.P +.PD +Match postings with a single-commodity amount equal to, less than, or +greater than N. +(Postings with 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, ignoring sign. +.PP +\f[B]\f[CB]code:REGEX\f[B]\f[R] +.PD 0 +.P +.PD +Match by transaction code (eg check number). +.PP +\f[B]\f[CB]cur:REGEX\f[B]\f[R] +.PD 0 +.P +.PD +Match postings or transactions including any amounts whose +currency/commodity symbol is fully matched by REGEX. +(For a partial match, use \f[C].*REGEX.*\f[R]). +Note, to match special characters which are regex-significant, you need +to escape them with \f[C]\[rs]\f[R]. +And for characters which are significant to your shell you may need one +more level of escaping. +So eg to match the dollar sign: +.PD 0 +.P +.PD +\f[C]hledger print cur:\[rs]\[rs]$\f[R]. +.PP +\f[B]\f[CB]desc:REGEX\f[B]\f[R] +.PD 0 +.P +.PD +Match transaction descriptions. +.PP +\f[B]\f[CB]date:PERIODEXPR\f[B]\f[R] +.PD 0 +.P +.PD +Match dates (or with the \f[C]--date2\f[R] flag, secondary dates) within +the specified period. +PERIODEXPR is a period expression with no report interval. +Examples: +.PD 0 +.P +.PD +\f[C]date:2016\f[R], \f[C]date:thismonth\f[R], \f[C]date:2/1-2/15\f[R], +\f[C]date:2021-07-27..nextquarter\f[R]. +.PP +\f[B]\f[CB]date2:PERIODEXPR\f[B]\f[R] +.PD 0 +.P +.PD +Match secondary dates within the specified period (independent of the +\f[C]--date2\f[R] flag). +.PP +\f[B]\f[CB]depth:N\f[B]\f[R] +.PD 0 +.P +.PD +Match (or display, depending on command) accounts at or above this +depth. +.PP +\f[B]\f[CB]note:REGEX\f[B]\f[R] +.PD 0 +.P +.PD +Match transaction notes (the part of the description right of +\f[C]|\f[R], or the whole description if there\[aq]s no \f[C]|\f[R]). +.PP +\f[B]\f[CB]payee:REGEX\f[B]\f[R] +.PD 0 +.P +.PD +Match transaction payee/payer names (the part of the description left of +\f[C]|\f[R], or the whole description if there\[aq]s no \f[C]|\f[R]). +.PP +\f[B]\f[CB]real:, real:0\f[B]\f[R] +.PD 0 +.P +.PD +Match real or virtual postings respectively. +.PP +\f[B]\f[CB]status:, status:!, status:*\f[B]\f[R] +.PD 0 +.P +.PD +Match unmarked, pending, or cleared transactions respectively. +.PP +\f[B]\f[CB]tag:REGEX[=REGEX]\f[B]\f[R] +.PD 0 +.P +.PD +Match by tag name, and optionally also by tag value. +(To match only by value, use \f[C]tag:.=REGEX\f[R].) Note that postings +also inherit tags from their transaction, and transactions also acquire +tags from their postings, when querying. +.PP +(\f[B]\f[CB]inacct:ACCTNAME\f[B]\f[R] +.PD 0 +.P +.PD +A special query term used automatically in hledger-web only: tells +hledger-web to show the transaction register for an account.) +.SS Combining query terms +.PP +Most commands select things which match: .IP \[bu] 2 any of the description terms AND .IP \[bu] 2 @@ -1161,7 +1322,7 @@ any of the status terms AND .IP \[bu] 2 all the other terms. .PP -The print command instead shows transactions which: +while the print command shows transactions which: .IP \[bu] 2 match any of the description terms AND .IP \[bu] 2 @@ -1171,89 +1332,49 @@ have no postings matching any of the negative account terms AND .IP \[bu] 2 match all the other terms. .PP -The following kinds of search terms can be used. -Remember these can also be prefixed with \f[B]\f[CB]not:\f[B]\f[R], eg -to exclude a particular subaccount. -.TP -\f[B]\f[R]\f[C]REGEX\f[R]\f[B], \f[R]\f[C]acct:REGEX\f[R]\f[B]\f[R] -match account names by this regular expression. -(With no prefix, \f[C]acct:\f[R] is assumed.) -same as above -.TP -\f[B]\f[R]\f[C]amt:N, amt:N, amt:>=N\f[R]\f[B]\f[R] -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, ignoring sign. -.TP -\f[B]\f[R]\f[C]code:REGEX\f[R]\f[B]\f[R] -match by transaction code (eg check number) -.TP -\f[B]\f[R]\f[C]cur:REGEX\f[R]\f[B]\f[R] -match postings or transactions including any amounts whose -currency/commodity symbol is fully matched by REGEX. -(For a partial match, use \f[C].*REGEX.*\f[R]). -Note, to match characters which are regex-significant, like the dollar -sign (\f[C]$\f[R]), you need to prepend \f[C]\[rs]\f[R]. -And when using the command line you need to add one more level of -quoting to hide it from the shell, so eg do: -\f[C]hledger print cur:\[aq]\[rs]$\[aq]\f[R] or -\f[C]hledger print cur:\[rs]\[rs]$\f[R]. -.TP -\f[B]\f[R]\f[C]desc:REGEX\f[R]\f[B]\f[R] -match transaction descriptions. -.TP -\f[B]\f[R]\f[C]date:PERIODEXPR\f[R]\f[B]\f[R] -match dates within the specified period. -PERIODEXPR is a period expression (with no report interval). -Examples: \f[C]date:2016\f[R], \f[C]date:thismonth\f[R], -\f[C]date:2000/2/1-2/15\f[R], \f[C]date:lastweek-\f[R]. -If the \f[C]--date2\f[R] command line flag is present, this matches -secondary dates instead. -(Report intervals will adjust start/end dates to preceding/following -subperiod boundaries.) -.TP -\f[B]\f[R]\f[C]date2:PERIODEXPR\f[R]\f[B]\f[R] -match secondary dates within the specified period. -.TP -\f[B]\f[R]\f[C]depth:N\f[R]\f[B]\f[R] -match (or display, depending on command) accounts at or above this depth -.TP -\f[B]\f[R]\f[C]note:REGEX\f[R]\f[B]\f[R] -match transaction notes (part of description right of \f[C]|\f[R], or -whole description when there\[aq]s no \f[C]|\f[R]) -.TP -\f[B]\f[R]\f[C]payee:REGEX\f[R]\f[B]\f[R] -match transaction payee/payer names (part of description left of -\f[C]|\f[R], or whole description when there\[aq]s no \f[C]|\f[R]) -.TP -\f[B]\f[R]\f[C]real:, real:0\f[R]\f[B]\f[R] -match real or virtual postings respectively -.TP -\f[B]\f[R]\f[C]status:, status:!, status:*\f[R]\f[B]\f[R] -match unmarked, pending, or cleared transactions respectively -.TP -\f[B]\f[R]\f[C]tag:REGEX[=REGEX]\f[R]\f[B]\f[R] -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. +You can do more powerful queries (such as AND-ing two like terms) by +running a first query with \f[C]print\f[R], and piping the result into a +second hledger command. +Eg: how much of food expenses was paid with cash ? +.IP +.nf +\f[C] +$ hledger print assets:cash | hledger f- -I balance expenses:food +\f[R] +.fi .PP -The following special search term is used automatically in hledger-web, -only: -.TP -\f[B]\f[R]\f[C]inacct:ACCTNAME\f[R]\f[B]\f[R] -tells hledger-web to show the transaction register for this account. -Can be filtered further with \f[C]acct\f[R] etc. +If you are interested in full boolean expressions for queries, see #203. +.SS Queries and command options .PP -Some of these can also be expressed as command-line options (eg -\f[C]depth:2\f[R] is equivalent to \f[C]--depth 2\f[R]). -Generally you can mix options and query arguments, and the resulting -query will be their intersection (perhaps excluding the -\f[C]-p/--period\f[R] option). +Some queries can also be expressed as command-line options: +\f[C]depth:2\f[R] is equivalent to \f[C]--depth 2\f[R], +\f[C]date:2020\f[R] is equivalent to \f[C]-p 2020\f[R], etc. +When you mix command options and query arguments, generally the +resulting query is their intersection. +.SS Queries and account aliases +.PP +When account names are rewritten with \f[C]--alias\f[R] or +\f[C]alias\f[R], \f[C]acct:\f[R] will match either the old or the new +account name. +.SS Queries and valuation +.PP +When amounts are converted to other commodities in cost or value +reports, \f[C]cur:\f[R] and \f[C]amt:\f[R] match the old commodity +symbol and the old amount quantity, not the new ones (except in hledger +1.22.0 where it\[aq]s reversed, see #1625). +.SS Querying with account aliases +.PP +When account names are rewritten with \f[C]--alias\f[R] or +\f[C]alias\f[R], note that \f[C]acct:\f[R] will match either the old or +the new account name. +.SS Querying with cost or value +.PP +When amounts are converted to other commodities in cost or value +reports, note that \f[C]cur:\f[R] matches the new commodity symbol, and +not the old one, and \f[C]amt:\f[R] matches the new quantity, and not +the old one. +Note: this changed in hledger 1.22, previously it was the reverse, see +the discussion at #1625. .SH COSTING .PP The \f[C]-B/--cost\f[R] flag converts amounts to their cost or sale @@ -2783,6 +2904,9 @@ With \f[C]-S/--sort-amount\f[R], accounts with the largest (most positive) balances are shown first. Eg: \f[C]hledger bal expenses -MAS\f[R] shows your biggest averaged monthly expenses first. +When more than one commodity is present, they will be sorted by the +alphabetically earliest commodity first, and then by subsequent +commodities (if an amount is missing a commodity, it is treated as 0). .PP Revenues and liability balances are typically negative, however, so \f[C]-S\f[R] shows these in reverse order. @@ -3255,7 +3379,7 @@ Budget performance in 2020-01-01..2020-01-15: || $400 [80% of $500] \f[R] .fi -.SS Nested budgets +.SS Budgets and subaccounts .PP You can add budgets to any account in your account hierarchy. If you have budgets on both parent account and some of its children, @@ -3357,6 +3481,34 @@ Budget performance in 2019/01: || 0 [ 0] \f[R] .fi +.SS Selecting budget goals +.PP +The budget report evaluates periodic transaction rules to generate +special \[dq]goal transactions\[dq], which generate the goal amounts for +each account in each report subperiod. +When troubleshooting, you can use the print command to show these as +forecasted transactions: +.IP +.nf +\f[C] +$ hledger print --forecast=BUDGETREPORTPERIOD tag:generated +\f[R] +.fi +.PP +By default, the budget report uses all available periodic transaction +rules to generate goals. +This includes rules with a different report interval from your report. +Eg if you have daily, weekly and monthly periodic rules, all of these +will contribute to the goals in a monthly budget report. +.PP +You can select a subset of periodic rules by providing an argument to +the \f[C]--budget\f[R] flag. +\f[C]--budget=DESCPAT\f[R] will match all periodic rules whose +description contains DESCPAT, a case-insensitive substring (not a +regular expression or query). +This means you can give your periodic rules descriptions (remember that +two spaces are needed), and then select from multiple budgets defined in +your journal. .SS Customising single-period balance reports .PP For single-period balance reports displayed in the terminal (only), you @@ -4871,6 +5023,28 @@ Using roi to compute total return of investment in stocks: https://github.com/simonmichael/hledger/blob/master/examples/roi-unrealised.ledger .IP \[bu] 2 Cookbook -> Return on Investment +.SS Spaces and special characters in \f[C]--inv\f[R] and \f[C]--pnl\f[R] +.PP +Note that \f[C]--inv\f[R] and \f[C]--pnl\f[R]\[aq]s argument is a query, +and queries could have several space-separated terms (see QUERIES). +.PP +To indicate that all search terms form single command-line argument, you +will need to put them in quotes (see Special characters): +.IP +.nf +\f[C] +$ hledger roi --inv \[aq]term1 term2 term3 ...\[aq] +\f[R] +.fi +.PP +If any query terms contain spaces themselves, you will need an extra +level of nested quoting, eg: +.IP +.nf +\f[C] +$ hledger roi --inv=\[dq]\[aq]Assets:Test 1\[aq]\[dq] --pnl=\[dq]\[aq]Equity:Unrealized Profit and Loss\[aq]\[dq] +\f[R] +.fi .SS Semantics of \f[C]--inv\f[R] and \f[C]--pnl\f[R] .PP Query supplied to \f[C]--inv\f[R] has to match all transactions that are diff --git a/hledger/hledger.info b/hledger/hledger.info index 9bf247c4f..a584fc245 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -3,7 +3,7 @@ stdin. INFO-DIR-SECTION User Applications START-INFO-DIR-ENTRY -* hledger: (hledger/hledger). Command-line plain text accounting tool. +* hledger: (hledger). Command-line plain text accounting tool. END-INFO-DIR-ENTRY  @@ -334,6 +334,10 @@ $ hledger register 'credit card' $ hledger register credit\ card + Windows users should keep in mind that `cmd' treats single quote as +a regular character, so you should be using double quotes exclusively. +PowerShell treats both single and double quotes as quotes. +  File: hledger.info, Node: Double escaping regular expression metacharacters, Next: Triple escaping for add-on commands, Prev: Single escaping shell metacharacters, Up: Special characters @@ -652,6 +656,8 @@ without a lot of declarations: * Are all commodities declared with a `commodity' directive ? (Commodity error checking) + * Are all commodity conversions declared explicitly ? + You can also use the check command to run these and some additional checks. @@ -928,16 +934,126 @@ File: hledger.info, Node: QUERIES, Next: COSTING, Prev: DEPTH, Up: Top 6 QUERIES ********* -One of hledger's strengths is being able to quickly report on precise -subsets of your data. Most commands accept an optional query expression, -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, -prefixes to match specific fields, a not: prefix to negate the match. +One of hledger's strengths is being able to quickly report on a precise +subset of your data. Most hledger commands accept optional query +arguments to restrict their scope. The syntax is as follows: - We do not yet support arbitrary boolean combinations of search terms; -instead most commands show transactions/postings/accounts which match -(or negatively match): + * Zero or more space-separated query terms. These are most often + account name substrings: + + `utilities food:groceries' + + * Terms with spaces or other special characters should be enclosed in + quotes: + + `"personal care"' + + * Regular expressions are also supported: + + `"^expenses\b" "accounts (payable|receivable)"' + + * Add a query type prefix to match other parts of the data: + + `date:202012- desc:amazon cur:USD amt:">100" status:' + + * Add a `not:' prefix to negate a term: + + `not:cur:USD' + + +* Menu: + +* Query types:: +* Combining query terms:: +* Queries and command options:: +* Queries and account aliases:: +* Queries and valuation:: +* Querying with account aliases:: +* Querying with cost or value:: + + +File: hledger.info, Node: Query types, Next: Combining query terms, Up: QUERIES + +6.1 Query types +=============== + +Here are the types of query term available. Remember these can also be +prefixed with *`not:'* to convert them into a negative match. + + *`acct:REGEX', `REGEX'* +Match account names containing this (case insensitive) regular +expression. This is the default query type when there is no prefix, and +regular expression syntax is typically not needed, so usually we just +write an account name substring, like `expenses' or `food'. + + *`amt:N, amt:N, amt:>=N'* +Match postings with a single-commodity amount equal to, less than, or +greater than N. (Postings with 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, ignoring sign. + + *`code:REGEX'* +Match by transaction code (eg check number). + + *`cur:REGEX'* +Match postings or transactions including any amounts whose +currency/commodity symbol is fully matched by REGEX. (For a partial +match, use `.*REGEX.*'). Note, to match special characters which are +regex-significant, you need to escape them with `\'. And for characters +which are significant to your shell you may need one more level of +escaping. So eg to match the dollar sign: +`hledger print cur:\\$'. + + *`desc:REGEX'* +Match transaction descriptions. + + *`date:PERIODEXPR'* +Match dates (or with the `--date2' flag, secondary dates) within the +specified period. PERIODEXPR is a period expression with no report +interval. Examples: +`date:2016', `date:thismonth', `date:2/1-2/15', +`date:2021-07-27..nextquarter'. + + *`date2:PERIODEXPR'* +Match secondary dates within the specified period (independent of the +`--date2' flag). + + *`depth:N'* +Match (or display, depending on command) accounts at or above this +depth. + + *`note:REGEX'* +Match transaction notes (the part of the description right of `|', or +the whole description if there's no `|'). + + *`payee:REGEX'* +Match transaction payee/payer names (the part of the description left of +`|', or the whole description if there's no `|'). + + *`real:, real:0'* +Match real or virtual postings respectively. + + *`status:, status:!, status:*'* +Match unmarked, pending, or cleared transactions respectively. + + *`tag:REGEX[=REGEX]'* +Match by tag name, and optionally also by tag value. (To match only by +value, use `tag:.=REGEX'.) Note that postings also inherit tags from +their transaction, and transactions also acquire tags from their +postings, when querying. + + (*`inacct:ACCTNAME'* +A special query term used automatically in hledger-web only: tells +hledger-web to show the transaction register for an account.) + + +File: hledger.info, Node: Combining query terms, Next: Queries and command options, Prev: Query types, Up: QUERIES + +6.2 Combining query terms +========================= + +Most commands select things which match: * any of the description terms AND @@ -947,7 +1063,7 @@ instead most commands show transactions/postings/accounts which match * all the other terms. - The print command instead shows transactions which: + while the print command shows transactions which: * match any of the description terms AND @@ -957,82 +1073,67 @@ instead most commands show transactions/postings/accounts which match * match all the other terms. - The following kinds of search terms can be used. Remember these can -also be prefixed with *`not:'*, eg to exclude a particular subaccount. + You can do more powerful queries (such as AND-ing two like terms) by +running a first query with `print', and piping the result into a second +hledger command. Eg: how much of food expenses was paid with cash ? -*`REGEX', `acct:REGEX'* - match account names by this regular expression. (With no prefix, - `acct:' is assumed.) 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 - 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, - ignoring sign. +$ hledger print assets:cash | hledger f- -I balance expenses:food -*`code:REGEX'* - match by transaction code (eg check number) + If you are interested in full boolean expressions for queries, see +#203. -*`cur:REGEX'* - match postings or transactions including any amounts whose - currency/commodity symbol is fully matched by REGEX. (For a partial - 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 level - of quoting to hide it from the shell, so eg do: `hledger print - cur:'\$'' or `hledger print cur:\\$'. + +File: hledger.info, Node: Queries and command options, Next: Queries and account aliases, Prev: Combining query terms, Up: QUERIES -*`desc:REGEX'* - match transaction descriptions. +6.3 Queries and command options +=============================== -*`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 - dates instead. (Report intervals will adjust start/end dates to - preceding/following subperiod boundaries.) +Some queries can also be expressed as command-line options: `depth:2' +is equivalent to `--depth 2', `date:2020' is equivalent to `-p 2020', +etc. When you mix command options and query arguments, generally the +resulting query is their intersection. -*`date2:PERIODEXPR'* - match secondary dates within the specified period. + +File: hledger.info, Node: Queries and account aliases, Next: Queries and valuation, Prev: Queries and command options, Up: QUERIES -*`depth:N'* - match (or display, depending on command) accounts at or above this - depth +6.4 Queries and account aliases +=============================== -*`note:REGEX'* - match transaction notes (part of description right of `|', or whole - description when there's no `|') +When account names are rewritten with `--alias' or `alias', `acct:' +will match either the old or the new account name. -*`payee:REGEX'* - match transaction payee/payer names (part of description left of - `|', or whole description when there's no `|') + +File: hledger.info, Node: Queries and valuation, Next: Querying with account aliases, Prev: Queries and account aliases, Up: QUERIES -*`real:, real:0'* - match real or virtual postings respectively +6.5 Queries and valuation +========================= -*`status:, status:!, status:*'* - match unmarked, pending, or cleared transactions respectively +When amounts are converted to other commodities in cost or value +reports, `cur:' and `amt:' match the old commodity symbol and the old +amount quantity, not the new ones (except in hledger 1.22.0 where it's +reversed, see #1625). -*`tag:REGEX[=REGEX]'* - match by tag name, and optionally also by tag value. Note a tag: - query is considered to match a transaction if it matches any of - the postings. Also remember that postings inherit the tags of - their parent transaction. + +File: hledger.info, Node: Querying with account aliases, Next: Querying with cost or value, Prev: Queries and valuation, Up: QUERIES - The following special search term is used automatically in -hledger-web, only: +6.6 Querying with account aliases +================================= -*`inacct:ACCTNAME'* - tells hledger-web to show the transaction register for this - account. Can be filtered further with `acct' etc. +When account names are rewritten with `--alias' or `alias', note that +`acct:' will match either the old or the new account name. - 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 excluding the `-p/--period' option). + +File: hledger.info, Node: Querying with cost or value, Prev: Querying with account aliases, Up: QUERIES + +6.7 Querying with cost or value +=============================== + +When amounts are converted to other commodities in cost or value +reports, note that `cur:' matches the new commodity symbol, and not the +old one, and `amt:' matches the new quantity, and not the old one. +Note: this changed in hledger 1.22, previously it was the reverse, see +the discussion at #1625.  File: hledger.info, Node: COSTING, Next: VALUATION, Prev: QUERIES, Up: Top @@ -2410,7 +2511,10 @@ File: hledger.info, Node: Sorting by amount, Next: Percentages, Prev: Multi-p With `-S/--sort-amount', accounts with the largest (most positive) balances are shown first. Eg: `hledger bal expenses -MAS' shows your -biggest averaged monthly expenses first. +biggest averaged monthly expenses first. When more than one commodity +is present, they will be sorted by the alphabetically earliest +commodity first, and then by subsequent commodities (if an amount is +missing a commodity, it is treated as 0). Revenues and liability balances are typically negative, however, so `-S' shows these in reverse order. To work around this, you can add @@ -2763,10 +2867,11 @@ Budget performance in 2017/11/01-2017/12/31: * Menu: * Budget report start date:: -* Nested budgets:: +* Budgets and subaccounts:: +* Selecting budget goals::  -File: hledger.info, Node: Budget report start date, Next: Nested budgets, Up: Budget report +File: hledger.info, Node: Budget report start date, Next: Budgets and subaccounts, Up: Budget report 11.5.12.1 Budget report start date .................................. @@ -2813,10 +2918,10 @@ Budget performance in 2020-01-01..2020-01-15: || $400 [80% of $500]  -File: hledger.info, Node: Nested budgets, Prev: Budget report start date, Up: Budget report +File: hledger.info, Node: Budgets and subaccounts, Next: Selecting budget goals, Prev: Budget report start date, Up: Budget report -11.5.12.2 Nested budgets -........................ +11.5.12.2 Budgets and subaccounts +................................. You can add budgets to any account in your account hierarchy. If you have budgets on both parent account and some of its children, then @@ -2904,6 +3009,33 @@ Budget performance in 2019/01: ----------------------------------------++------------------------------- || 0 [ 0] + +File: hledger.info, Node: Selecting budget goals, Prev: Budgets and subaccounts, Up: Budget report + +11.5.12.3 Selecting budget goals +................................ + +The budget report evaluates periodic transaction rules to generate +special "goal transactions", which generate the goal amounts for each +account in each report subperiod. When troubleshooting, you can use the +print command to show these as forecasted transactions: + + +$ hledger print --forecast=BUDGETREPORTPERIOD tag:generated + + By default, the budget report uses all available periodic transaction +rules to generate goals. This includes rules with a different report +interval from your report. Eg if you have daily, weekly and monthly +periodic rules, all of these will contribute to the goals in a monthly +budget report. + + You can select a subset of periodic rules by providing an argument to +the `--budget' flag. `--budget=DESCPAT' will match all periodic rules +whose description contains DESCPAT, a case-insensitive substring (not a +regular expression or query). This means you can give your periodic +rules descriptions (remember that two spaces are needed), and then +select from multiple budgets defined in your journal. +  File: hledger.info, Node: Customising single-period balance reports, Prev: Budget report, Up: balance @@ -4368,13 +4500,37 @@ display, regardless of the length of reporting interval. * Menu: +* Spaces and special characters in --inv and --pnl:: * Semantics of --inv and --pnl:: * IRR and TWR explained::  -File: hledger.info, Node: Semantics of --inv and --pnl, Next: IRR and TWR explained, Up: roi +File: hledger.info, Node: Spaces and special characters in --inv and --pnl, Next: Semantics of --inv and --pnl, Up: roi -11.27.1 Semantics of `--inv' and `--pnl' +11.27.1 Spaces and special characters in `--inv' and +---------------------------------------------------- + +`--pnl' + + Note that `--inv' and `--pnl''s argument is a query, and queries +could have several space-separated terms (see QUERIES). + + To indicate that all search terms form single command-line argument, +you will need to put them in quotes (see Special characters): + + +$ hledger roi --inv 'term1 term2 term3 ...' + + If any query terms contain spaces themselves, you will need an extra +level of nested quoting, eg: + + +$ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'" + + +File: hledger.info, Node: Semantics of --inv and --pnl, Next: IRR and TWR explained, Prev: Spaces and special characters in --inv and --pnl, Up: roi + +11.27.2 Semantics of `--inv' and `--pnl' ---------------------------------------- Query supplied to `--inv' has to match all transactions that are @@ -4433,7 +4589,7 @@ postings in the example below would be classifed as:  File: hledger.info, Node: IRR and TWR explained, Prev: Semantics of --inv and --pnl, Up: roi -11.27.2 IRR and TWR explained +11.27.3 IRR and TWR explained ----------------------------- "ROI" stands for "return on investment". Traditionally this was computed @@ -8963,482 +9119,500 @@ $ LANG=en_US.UTF-8 hledger -f my.journal print  Tag Table: -Node: Top224 -Node: OPTIONS2594 -Ref: #options2695 -Node: General options2837 -Ref: #general-options2962 -Node: Command options6693 -Ref: #command-options6844 -Node: Command arguments7243 -Ref: #command-arguments7401 -Node: Special characters8279 -Ref: #special-characters8442 -Node: Single escaping shell metacharacters8605 -Ref: #single-escaping-shell-metacharacters8846 -Node: Double escaping regular expression metacharacters9248 -Ref: #double-escaping-regular-expression-metacharacters9559 -Node: Triple escaping for add-on commands10085 -Ref: #triple-escaping-for-add-on-commands10345 -Node: Less escaping10991 -Ref: #less-escaping11145 -Node: Unicode characters11471 -Ref: #unicode-characters11636 -Node: Regular expressions13045 -Ref: #regular-expressions13185 -Node: ENVIRONMENT14926 -Ref: #environment15042 -Node: DATA FILES16024 -Ref: #data-files16143 -Node: Data formats16684 -Ref: #data-formats16802 -Node: Multiple files18284 -Ref: #multiple-files18426 -Node: Strict mode18896 -Ref: #strict-mode19011 -Node: TIME PERIODS19662 -Ref: #time-periods19779 -Node: Smart dates19877 -Ref: #smart-dates20003 -Node: Report start & end date21307 -Ref: #report-start-end-date21482 -Node: Report intervals23152 -Ref: #report-intervals23320 -Node: Period expressions24594 -Ref: #period-expressions24734 -Node: DEPTH29113 -Ref: #depth29213 -Node: QUERIES29544 -Ref: #queries29643 -Node: COSTING33692 -Ref: #costing33795 -Node: VALUATION34068 -Ref: #valuation34176 -Node: -V Value34899 -Ref: #v-value35023 -Node: -X Value in specified commodity35217 -Ref: #x-value-in-specified-commodity35410 -Node: Valuation date35559 -Ref: #valuation-date35721 -Node: Market prices36158 -Ref: #market-prices36339 -Node: --infer-market-price market prices from transactions37521 -Ref: #infer-market-price-market-prices-from-transactions37785 -Node: Valuation commodity39134 -Ref: #valuation-commodity39344 -Node: Simple valuation examples40569 -Ref: #simple-valuation-examples40765 -Node: --value Flexible valuation41427 -Ref: #value-flexible-valuation41629 -Node: More valuation examples43271 -Ref: #more-valuation-examples43472 -Node: Effect of valuation on reports45478 -Ref: #effect-of-valuation-on-reports45660 -Node: PIVOTING53557 -Ref: #pivoting53662 -Node: OUTPUT55341 -Ref: #output55443 -Node: Output destination55494 -Ref: #output-destination55627 -Node: Output format56283 -Ref: #output-format56406 -Node: COMMANDS58569 -Ref: #commands58681 -Node: accounts62071 -Ref: #accounts62171 -Node: activity62863 -Ref: #activity62975 -Node: add63357 -Ref: #add63460 -Node: aregister66255 -Ref: #aregister66369 -Node: aregister and custom posting dates68564 -Ref: #aregister-and-custom-posting-dates68730 -Node: balance69551 -Ref: #balance69670 -Node: balance features70583 -Ref: #balance-features70723 -Node: Simple balance report72393 -Ref: #simple-balance-report72575 -Node: Filtered balance report74023 -Ref: #filtered-balance-report74210 -Node: List or tree mode74507 -Ref: #list-or-tree-mode74675 -Node: Depth limiting75992 -Ref: #depth-limiting76158 -Node: Multi-period balance report76916 -Ref: #multi-period-balance-report77108 -Node: Sorting by amount79364 -Ref: #sorting-by-amount79533 -Node: Percentages79995 -Ref: #percentages80151 -Node: Balance change end balance81083 -Ref: #balance-change-end-balance81274 -Node: Balance report types82698 -Ref: #balance-report-types82888 -Node: Useful balance reports87052 -Ref: #useful-balance-reports87233 -Node: Budget report88317 -Ref: #budget-report88501 -Node: Budget report start date93670 -Ref: #budget-report-start-date93839 -Node: Nested budgets95166 -Ref: #nested-budgets95315 -Node: Customising single-period balance reports98702 -Ref: #customising-single-period-balance-reports98911 -Node: balancesheet101068 -Ref: #balancesheet101206 -Node: balancesheetequity102504 -Ref: #balancesheetequity102655 -Node: cashflow104035 -Ref: #cashflow104159 -Node: check105305 -Ref: #check105410 -Node: Basic checks106043 -Ref: #basic-checks106161 -Node: Strict checks106713 -Ref: #strict-checks106854 -Node: Other checks107290 -Ref: #other-checks107430 -Node: Custom checks107787 -Ref: #custom-checks107907 -Node: close108325 -Ref: #close108429 -Node: close and prices110515 -Ref: #close-and-prices110644 -Node: close date111038 -Ref: #close-date111222 -Node: Example close asset/liability accounts for file transition111772 -Ref: #example-close-assetliability-accounts-for-file-transition112073 -Node: Hiding opening/closing transactions112935 -Ref: #hiding-openingclosing-transactions113206 -Node: close and balance assertions114672 -Ref: #close-and-balance-assertions114930 -Node: Example close revenue/expense accounts to retained earnings116284 -Ref: #example-close-revenueexpense-accounts-to-retained-earnings116562 -Node: codes117276 -Ref: #codes117386 -Node: commodities118099 -Ref: #commodities118228 -Node: descriptions118310 -Ref: #descriptions118440 -Node: diff118744 -Ref: #diff118852 -Node: files119897 -Ref: #files119999 -Node: help120145 -Ref: #help120247 -Node: import120970 -Ref: #import121086 -Node: Deduplication121948 -Ref: #deduplication122073 -Node: Import testing123961 -Ref: #import-testing124126 -Node: Importing balance assignments124616 -Ref: #importing-balance-assignments124822 -Node: Commodity display styles125469 -Ref: #commodity-display-styles125642 -Node: incomestatement125771 -Ref: #incomestatement125906 -Node: notes127207 -Ref: #notes127322 -Node: payees127689 -Ref: #payees127797 -Node: prices128323 -Ref: #prices128431 -Node: print128770 -Ref: #print128882 -Node: print-unique134192 -Ref: #print-unique134320 -Node: register134606 -Ref: #register134735 -Node: Custom register output139179 -Ref: #custom-register-output139310 -Node: register-match140647 -Ref: #register-match140783 -Node: rewrite141131 -Ref: #rewrite141248 -Node: Re-write rules in a file143154 -Ref: #re-write-rules-in-a-file143317 -Node: Diff output format144467 -Ref: #diff-output-format144650 -Node: rewrite vs print --auto145742 -Ref: #rewrite-vs.-print---auto145902 -Node: roi146452 -Ref: #roi146552 -Node: Semantics of --inv and --pnl148187 -Ref: #semantics-of---inv-and---pnl148369 -Node: IRR and TWR explained150215 -Ref: #irr-and-twr-explained150375 -Node: stats153437 -Ref: #stats153538 -Node: tags154325 -Ref: #tags154425 -Node: test154942 -Ref: #test155058 -Node: About add-on commands155803 -Ref: #about-add-on-commands155940 -Node: JOURNAL FORMAT157073 -Ref: #journal-format157201 -Node: Transactions159390 -Ref: #transactions159505 -Node: Dates160522 -Ref: #dates160638 -Node: Simple dates160703 -Ref: #simple-dates160823 -Node: Secondary dates161330 -Ref: #secondary-dates161478 -Node: Posting dates162812 -Ref: #posting-dates162935 -Node: Status164304 -Ref: #status164414 -Node: Code166119 -Ref: #code166231 -Node: Description166462 -Ref: #description166590 -Node: Payee and note166908 -Ref: #payee-and-note167016 -Node: Comments167350 -Ref: #comments167472 -Node: Tags168665 -Ref: #tags-1168776 -Node: Postings170174 -Ref: #postings170298 -Node: Virtual postings171322 -Ref: #virtual-postings171433 -Node: Account names172735 -Ref: #account-names172872 -Node: Amounts173358 -Ref: #amounts173495 -Node: Decimal marks digit group marks174453 -Ref: #decimal-marks-digit-group-marks174630 -Node: Commodity175502 -Ref: #commodity175662 -Node: Commodity directives176612 -Ref: #commodity-directives176786 -Node: Commodity display style177272 -Ref: #commodity-display-style177451 -Node: Rounding179559 -Ref: #rounding179679 -Node: Transaction prices180089 -Ref: #transaction-prices180255 -Node: Lot prices lot dates182685 -Ref: #lot-prices-lot-dates182868 -Node: Balance assertions183355 -Ref: #balance-assertions183533 -Node: Assertions and ordering184563 -Ref: #assertions-and-ordering184745 -Node: Assertions and included files185442 -Ref: #assertions-and-included-files185679 -Node: Assertions and multiple -f options186010 -Ref: #assertions-and-multiple--f-options186260 -Node: Assertions and commodities186391 -Ref: #assertions-and-commodities186617 -Node: Assertions and prices187772 -Ref: #assertions-and-prices187980 -Node: Assertions and subaccounts188421 -Ref: #assertions-and-subaccounts188644 -Node: Assertions and virtual postings188968 -Ref: #assertions-and-virtual-postings189204 -Node: Assertions and precision189345 -Ref: #assertions-and-precision189532 -Node: Balance assignments189797 -Ref: #balance-assignments189967 -Node: Balance assignments and prices191130 -Ref: #balance-assignments-and-prices191296 -Node: Directives191522 -Ref: #directives191685 -Node: Directives and multiple files196987 -Ref: #directives-and-multiple-files197183 -Node: Comment blocks197845 -Ref: #comment-blocks198022 -Node: Including other files198197 -Ref: #including-other-files198371 -Node: Default year199295 -Ref: #default-year199453 -Node: Declaring payees199860 -Ref: #declaring-payees200026 -Node: Declaring commodities200271 -Ref: #declaring-commodities200452 -Node: Commodity error checking202828 -Ref: #commodity-error-checking202978 -Node: Default commodity203234 -Ref: #default-commodity203414 -Node: Declaring market prices204288 -Ref: #declaring-market-prices204477 -Node: Declaring accounts205289 -Ref: #declaring-accounts205469 -Node: Account error checking206676 -Ref: #account-error-checking206842 -Node: Account comments208019 -Ref: #account-comments208203 -Node: Account subdirectives208629 -Ref: #account-subdirectives208814 -Node: Account types209129 -Ref: #account-types209303 -Node: Declaring account types210038 -Ref: #declaring-account-types210217 -Node: Auto-detected account types210868 -Ref: #auto-detected-account-types211109 -Node: Interference from auto-detected account types212069 -Ref: #interference-from-auto-detected-account-types212346 -Node: Old account type syntax212829 -Ref: #old-account-type-syntax213026 -Node: Account display order213327 -Ref: #account-display-order213487 -Node: Rewriting accounts214638 -Ref: #rewriting-accounts214817 -Node: Basic aliases215576 -Ref: #basic-aliases215712 -Node: Regex aliases216454 -Ref: #regex-aliases216616 -Node: Combining aliases217336 -Ref: #combining-aliases217519 -Node: Aliases and multiple files218796 -Ref: #aliases-and-multiple-files218995 -Node: end aliases219576 -Ref: #end-aliases219723 -Node: Default parent account219825 -Ref: #default-parent-account220015 -Node: Periodic transactions220899 -Ref: #periodic-transactions221082 -Node: Periodic rule syntax222999 -Ref: #periodic-rule-syntax223199 -Node: Two spaces between period expression and description!223902 -Ref: #two-spaces-between-period-expression-and-description224215 -Node: Forecasting with periodic transactions224900 -Ref: #forecasting-with-periodic-transactions225199 -Node: Budgeting with periodic transactions227245 -Ref: #budgeting-with-periodic-transactions227478 -Node: Auto postings227885 -Ref: #auto-postings228021 -Node: Auto postings and multiple files230204 -Ref: #auto-postings-and-multiple-files230402 -Node: Auto postings and dates230610 -Ref: #auto-postings-and-dates230878 -Node: Auto postings and transaction balancing / inferred amounts / balance assertions231053 -Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions231399 -Node: Auto posting tags231744 -Ref: #auto-posting-tags231953 -Node: CSV FORMAT232590 -Ref: #csv-format232718 -Node: Examples235342 -Ref: #examples235445 -Node: Basic235652 -Ref: #basic235754 -Node: Bank of Ireland236298 -Ref: #bank-of-ireland236435 -Node: Amazon237900 -Ref: #amazon238020 -Node: Paypal239741 -Ref: #paypal239837 -Node: CSV rules247485 -Ref: #csv-rules247603 -Node: skip247936 -Ref: #skip248036 -Node: fields list248408 -Ref: #fields-list248547 -Node: field assignment250052 -Ref: #field-assignment250204 -Node: Field names251130 -Ref: #field-names251270 -Node: date field251649 -Ref: #date-field251769 -Node: date2 field251817 -Ref: #date2-field251960 -Node: status field252016 -Ref: #status-field252161 -Node: code field252210 -Ref: #code-field252357 -Node: description field252402 -Ref: #description-field252564 -Node: comment field252623 -Ref: #comment-field252780 -Node: account field252994 -Ref: #account-field253146 -Node: amount field253720 -Ref: #amount-field253871 -Node: currency field255109 -Ref: #currency-field255264 -Node: balance field255520 -Ref: #balance-field255654 -Node: separator256026 -Ref: #separator256158 -Node: if block256700 -Ref: #if-block256827 -Node: Matching the whole record257225 -Ref: #matching-the-whole-record257402 -Node: Matching individual fields258205 -Ref: #matching-individual-fields258411 -Node: Combining matchers258635 -Ref: #combining-matchers258833 -Node: Rules applied on successful match259147 -Ref: #rules-applied-on-successful-match259340 -Node: if table259997 -Ref: #if-table260118 -Node: end261854 -Ref: #end261968 -Node: date-format262192 -Ref: #date-format262326 -Node: decimal-mark263323 -Ref: #decimal-mark263470 -Node: newest-first263807 -Ref: #newest-first263950 -Node: include264633 -Ref: #include264766 -Node: balance-type265208 -Ref: #balance-type265330 -Node: Tips266030 -Ref: #tips266121 -Node: Rapid feedback266420 -Ref: #rapid-feedback266539 -Node: Valid CSV266998 -Ref: #valid-csv267130 -Node: File Extension267322 -Ref: #file-extension267476 -Node: Reading multiple CSV files267905 -Ref: #reading-multiple-csv-files268092 -Node: Valid transactions268332 -Ref: #valid-transactions268512 -Node: Deduplicating importing269140 -Ref: #deduplicating-importing269321 -Node: Setting amounts270353 -Ref: #setting-amounts270510 -Node: Amount signs272951 -Ref: #amount-signs273105 -Node: Setting currency/commodity273792 -Ref: #setting-currencycommodity273980 -Node: Amount decimal places275160 -Ref: #amount-decimal-places275352 -Node: Referencing other fields275664 -Ref: #referencing-other-fields275863 -Node: How CSV rules are evaluated276761 -Ref: #how-csv-rules-are-evaluated276936 -Node: TIMECLOCK FORMAT278385 -Ref: #timeclock-format278525 -Node: TIMEDOT FORMAT280593 -Ref: #timedot-format280731 -Node: COMMON TASKS284994 -Ref: #common-tasks285123 -Node: Getting help285530 -Ref: #getting-help285664 -Node: Constructing command lines286215 -Ref: #constructing-command-lines286409 -Node: Starting a journal file287108 -Ref: #starting-a-journal-file287308 -Node: Setting opening balances288495 -Ref: #setting-opening-balances288693 -Node: Recording transactions291826 -Ref: #recording-transactions292008 -Node: Reconciling292565 -Ref: #reconciling292710 -Node: Reporting294955 -Ref: #reporting295097 -Node: Migrating to a new file299017 -Ref: #migrating-to-a-new-file299167 -Node: LIMITATIONS299465 -Ref: #limitations299593 -Node: TROUBLESHOOTING300334 -Ref: #troubleshooting300449 +Node: Top216 +Node: OPTIONS2586 +Ref: #options2687 +Node: General options2829 +Ref: #general-options2954 +Node: Command options6685 +Ref: #command-options6836 +Node: Command arguments7235 +Ref: #command-arguments7393 +Node: Special characters8271 +Ref: #special-characters8434 +Node: Single escaping shell metacharacters8597 +Ref: #single-escaping-shell-metacharacters8838 +Node: Double escaping regular expression metacharacters9442 +Ref: #double-escaping-regular-expression-metacharacters9753 +Node: Triple escaping for add-on commands10279 +Ref: #triple-escaping-for-add-on-commands10539 +Node: Less escaping11185 +Ref: #less-escaping11339 +Node: Unicode characters11665 +Ref: #unicode-characters11830 +Node: Regular expressions13239 +Ref: #regular-expressions13379 +Node: ENVIRONMENT15120 +Ref: #environment15236 +Node: DATA FILES16218 +Ref: #data-files16337 +Node: Data formats16878 +Ref: #data-formats16996 +Node: Multiple files18478 +Ref: #multiple-files18620 +Node: Strict mode19090 +Ref: #strict-mode19205 +Node: TIME PERIODS19914 +Ref: #time-periods20031 +Node: Smart dates20129 +Ref: #smart-dates20255 +Node: Report start & end date21559 +Ref: #report-start-end-date21734 +Node: Report intervals23404 +Ref: #report-intervals23572 +Node: Period expressions24846 +Ref: #period-expressions24986 +Node: DEPTH29365 +Ref: #depth29465 +Node: QUERIES29796 +Ref: #queries29895 +Node: Query types30834 +Ref: #query-types30953 +Node: Combining query terms33615 +Ref: #combining-query-terms33790 +Node: Queries and command options34598 +Ref: #queries-and-command-options34801 +Node: Queries and account aliases35050 +Ref: #queries-and-account-aliases35253 +Node: Queries and valuation35373 +Ref: #queries-and-valuation35566 +Node: Querying with account aliases35795 +Ref: #querying-with-account-aliases36004 +Node: Querying with cost or value36134 +Ref: #querying-with-cost-or-value36309 +Node: COSTING36610 +Ref: #costing36713 +Node: VALUATION36986 +Ref: #valuation37094 +Node: -V Value37817 +Ref: #v-value37941 +Node: -X Value in specified commodity38135 +Ref: #x-value-in-specified-commodity38328 +Node: Valuation date38477 +Ref: #valuation-date38639 +Node: Market prices39076 +Ref: #market-prices39257 +Node: --infer-market-price market prices from transactions40439 +Ref: #infer-market-price-market-prices-from-transactions40703 +Node: Valuation commodity42052 +Ref: #valuation-commodity42262 +Node: Simple valuation examples43487 +Ref: #simple-valuation-examples43683 +Node: --value Flexible valuation44345 +Ref: #value-flexible-valuation44547 +Node: More valuation examples46189 +Ref: #more-valuation-examples46390 +Node: Effect of valuation on reports48396 +Ref: #effect-of-valuation-on-reports48578 +Node: PIVOTING56475 +Ref: #pivoting56580 +Node: OUTPUT58259 +Ref: #output58361 +Node: Output destination58412 +Ref: #output-destination58545 +Node: Output format59201 +Ref: #output-format59324 +Node: COMMANDS61487 +Ref: #commands61599 +Node: accounts64989 +Ref: #accounts65089 +Node: activity65781 +Ref: #activity65893 +Node: add66275 +Ref: #add66378 +Node: aregister69173 +Ref: #aregister69287 +Node: aregister and custom posting dates71482 +Ref: #aregister-and-custom-posting-dates71648 +Node: balance72469 +Ref: #balance72588 +Node: balance features73501 +Ref: #balance-features73641 +Node: Simple balance report75311 +Ref: #simple-balance-report75493 +Node: Filtered balance report76941 +Ref: #filtered-balance-report77128 +Node: List or tree mode77425 +Ref: #list-or-tree-mode77593 +Node: Depth limiting78910 +Ref: #depth-limiting79076 +Node: Multi-period balance report79834 +Ref: #multi-period-balance-report80026 +Node: Sorting by amount82282 +Ref: #sorting-by-amount82451 +Node: Percentages83116 +Ref: #percentages83272 +Node: Balance change end balance84204 +Ref: #balance-change-end-balance84395 +Node: Balance report types85819 +Ref: #balance-report-types86009 +Node: Useful balance reports90173 +Ref: #useful-balance-reports90354 +Node: Budget report91438 +Ref: #budget-report91622 +Node: Budget report start date96827 +Ref: #budget-report-start-date97005 +Node: Budgets and subaccounts98332 +Ref: #budgets-and-subaccounts98539 +Node: Selecting budget goals101926 +Ref: #selecting-budget-goals102098 +Node: Customising single-period balance reports103128 +Ref: #customising-single-period-balance-reports103337 +Node: balancesheet105494 +Ref: #balancesheet105632 +Node: balancesheetequity106930 +Ref: #balancesheetequity107081 +Node: cashflow108461 +Ref: #cashflow108585 +Node: check109731 +Ref: #check109836 +Node: Basic checks110469 +Ref: #basic-checks110587 +Node: Strict checks111139 +Ref: #strict-checks111280 +Node: Other checks111716 +Ref: #other-checks111856 +Node: Custom checks112213 +Ref: #custom-checks112333 +Node: close112751 +Ref: #close112855 +Node: close and prices114941 +Ref: #close-and-prices115070 +Node: close date115464 +Ref: #close-date115648 +Node: Example close asset/liability accounts for file transition116198 +Ref: #example-close-assetliability-accounts-for-file-transition116499 +Node: Hiding opening/closing transactions117361 +Ref: #hiding-openingclosing-transactions117632 +Node: close and balance assertions119098 +Ref: #close-and-balance-assertions119356 +Node: Example close revenue/expense accounts to retained earnings120710 +Ref: #example-close-revenueexpense-accounts-to-retained-earnings120988 +Node: codes121702 +Ref: #codes121812 +Node: commodities122525 +Ref: #commodities122654 +Node: descriptions122736 +Ref: #descriptions122866 +Node: diff123170 +Ref: #diff123278 +Node: files124323 +Ref: #files124425 +Node: help124571 +Ref: #help124673 +Node: import125396 +Ref: #import125512 +Node: Deduplication126374 +Ref: #deduplication126499 +Node: Import testing128387 +Ref: #import-testing128552 +Node: Importing balance assignments129042 +Ref: #importing-balance-assignments129248 +Node: Commodity display styles129895 +Ref: #commodity-display-styles130068 +Node: incomestatement130197 +Ref: #incomestatement130332 +Node: notes131633 +Ref: #notes131748 +Node: payees132115 +Ref: #payees132223 +Node: prices132749 +Ref: #prices132857 +Node: print133196 +Ref: #print133308 +Node: print-unique138618 +Ref: #print-unique138746 +Node: register139032 +Ref: #register139161 +Node: Custom register output143605 +Ref: #custom-register-output143736 +Node: register-match145073 +Ref: #register-match145209 +Node: rewrite145557 +Ref: #rewrite145674 +Node: Re-write rules in a file147580 +Ref: #re-write-rules-in-a-file147743 +Node: Diff output format148893 +Ref: #diff-output-format149076 +Node: rewrite vs print --auto150168 +Ref: #rewrite-vs.-print---auto150328 +Node: roi150878 +Ref: #roi150978 +Node: Spaces and special characters in --inv and --pnl152666 +Ref: #spaces-and-special-characters-in---inv-and---pnl152907 +Node: Semantics of --inv and --pnl153400 +Ref: #semantics-of---inv-and---pnl153639 +Node: IRR and TWR explained155485 +Ref: #irr-and-twr-explained155645 +Node: stats158707 +Ref: #stats158808 +Node: tags159595 +Ref: #tags159695 +Node: test160212 +Ref: #test160328 +Node: About add-on commands161073 +Ref: #about-add-on-commands161210 +Node: JOURNAL FORMAT162343 +Ref: #journal-format162471 +Node: Transactions164660 +Ref: #transactions164775 +Node: Dates165792 +Ref: #dates165908 +Node: Simple dates165973 +Ref: #simple-dates166093 +Node: Secondary dates166600 +Ref: #secondary-dates166748 +Node: Posting dates168082 +Ref: #posting-dates168205 +Node: Status169574 +Ref: #status169684 +Node: Code171389 +Ref: #code171501 +Node: Description171732 +Ref: #description171860 +Node: Payee and note172178 +Ref: #payee-and-note172286 +Node: Comments172620 +Ref: #comments172742 +Node: Tags173935 +Ref: #tags-1174046 +Node: Postings175444 +Ref: #postings175568 +Node: Virtual postings176592 +Ref: #virtual-postings176703 +Node: Account names178005 +Ref: #account-names178142 +Node: Amounts178628 +Ref: #amounts178765 +Node: Decimal marks digit group marks179723 +Ref: #decimal-marks-digit-group-marks179900 +Node: Commodity180772 +Ref: #commodity180932 +Node: Commodity directives181882 +Ref: #commodity-directives182056 +Node: Commodity display style182542 +Ref: #commodity-display-style182721 +Node: Rounding184829 +Ref: #rounding184949 +Node: Transaction prices185359 +Ref: #transaction-prices185525 +Node: Lot prices lot dates187955 +Ref: #lot-prices-lot-dates188138 +Node: Balance assertions188625 +Ref: #balance-assertions188803 +Node: Assertions and ordering189833 +Ref: #assertions-and-ordering190015 +Node: Assertions and included files190712 +Ref: #assertions-and-included-files190949 +Node: Assertions and multiple -f options191280 +Ref: #assertions-and-multiple--f-options191530 +Node: Assertions and commodities191661 +Ref: #assertions-and-commodities191887 +Node: Assertions and prices193042 +Ref: #assertions-and-prices193250 +Node: Assertions and subaccounts193691 +Ref: #assertions-and-subaccounts193914 +Node: Assertions and virtual postings194238 +Ref: #assertions-and-virtual-postings194474 +Node: Assertions and precision194615 +Ref: #assertions-and-precision194802 +Node: Balance assignments195067 +Ref: #balance-assignments195237 +Node: Balance assignments and prices196400 +Ref: #balance-assignments-and-prices196566 +Node: Directives196792 +Ref: #directives196955 +Node: Directives and multiple files202257 +Ref: #directives-and-multiple-files202453 +Node: Comment blocks203115 +Ref: #comment-blocks203292 +Node: Including other files203467 +Ref: #including-other-files203641 +Node: Default year204565 +Ref: #default-year204723 +Node: Declaring payees205130 +Ref: #declaring-payees205296 +Node: Declaring commodities205541 +Ref: #declaring-commodities205722 +Node: Commodity error checking208098 +Ref: #commodity-error-checking208248 +Node: Default commodity208504 +Ref: #default-commodity208684 +Node: Declaring market prices209558 +Ref: #declaring-market-prices209747 +Node: Declaring accounts210559 +Ref: #declaring-accounts210739 +Node: Account error checking211946 +Ref: #account-error-checking212112 +Node: Account comments213289 +Ref: #account-comments213473 +Node: Account subdirectives213899 +Ref: #account-subdirectives214084 +Node: Account types214399 +Ref: #account-types214573 +Node: Declaring account types215308 +Ref: #declaring-account-types215487 +Node: Auto-detected account types216138 +Ref: #auto-detected-account-types216379 +Node: Interference from auto-detected account types217339 +Ref: #interference-from-auto-detected-account-types217616 +Node: Old account type syntax218099 +Ref: #old-account-type-syntax218296 +Node: Account display order218597 +Ref: #account-display-order218757 +Node: Rewriting accounts219908 +Ref: #rewriting-accounts220087 +Node: Basic aliases220846 +Ref: #basic-aliases220982 +Node: Regex aliases221724 +Ref: #regex-aliases221886 +Node: Combining aliases222606 +Ref: #combining-aliases222789 +Node: Aliases and multiple files224066 +Ref: #aliases-and-multiple-files224265 +Node: end aliases224846 +Ref: #end-aliases224993 +Node: Default parent account225095 +Ref: #default-parent-account225285 +Node: Periodic transactions226169 +Ref: #periodic-transactions226352 +Node: Periodic rule syntax228269 +Ref: #periodic-rule-syntax228469 +Node: Two spaces between period expression and description!229172 +Ref: #two-spaces-between-period-expression-and-description229485 +Node: Forecasting with periodic transactions230170 +Ref: #forecasting-with-periodic-transactions230469 +Node: Budgeting with periodic transactions232515 +Ref: #budgeting-with-periodic-transactions232748 +Node: Auto postings233155 +Ref: #auto-postings233291 +Node: Auto postings and multiple files235474 +Ref: #auto-postings-and-multiple-files235672 +Node: Auto postings and dates235880 +Ref: #auto-postings-and-dates236148 +Node: Auto postings and transaction balancing / inferred amounts / balance assertions236323 +Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions236669 +Node: Auto posting tags237014 +Ref: #auto-posting-tags237223 +Node: CSV FORMAT237860 +Ref: #csv-format237988 +Node: Examples240612 +Ref: #examples240715 +Node: Basic240922 +Ref: #basic241024 +Node: Bank of Ireland241568 +Ref: #bank-of-ireland241705 +Node: Amazon243170 +Ref: #amazon243290 +Node: Paypal245011 +Ref: #paypal245107 +Node: CSV rules252755 +Ref: #csv-rules252873 +Node: skip253206 +Ref: #skip253306 +Node: fields list253678 +Ref: #fields-list253817 +Node: field assignment255322 +Ref: #field-assignment255474 +Node: Field names256400 +Ref: #field-names256540 +Node: date field256919 +Ref: #date-field257039 +Node: date2 field257087 +Ref: #date2-field257230 +Node: status field257286 +Ref: #status-field257431 +Node: code field257480 +Ref: #code-field257627 +Node: description field257672 +Ref: #description-field257834 +Node: comment field257893 +Ref: #comment-field258050 +Node: account field258264 +Ref: #account-field258416 +Node: amount field258990 +Ref: #amount-field259141 +Node: currency field260379 +Ref: #currency-field260534 +Node: balance field260790 +Ref: #balance-field260924 +Node: separator261296 +Ref: #separator261428 +Node: if block261970 +Ref: #if-block262097 +Node: Matching the whole record262495 +Ref: #matching-the-whole-record262672 +Node: Matching individual fields263475 +Ref: #matching-individual-fields263681 +Node: Combining matchers263905 +Ref: #combining-matchers264103 +Node: Rules applied on successful match264417 +Ref: #rules-applied-on-successful-match264610 +Node: if table265267 +Ref: #if-table265388 +Node: end267124 +Ref: #end267238 +Node: date-format267462 +Ref: #date-format267596 +Node: decimal-mark268593 +Ref: #decimal-mark268740 +Node: newest-first269077 +Ref: #newest-first269220 +Node: include269903 +Ref: #include270036 +Node: balance-type270478 +Ref: #balance-type270600 +Node: Tips271300 +Ref: #tips271391 +Node: Rapid feedback271690 +Ref: #rapid-feedback271809 +Node: Valid CSV272268 +Ref: #valid-csv272400 +Node: File Extension272592 +Ref: #file-extension272746 +Node: Reading multiple CSV files273175 +Ref: #reading-multiple-csv-files273362 +Node: Valid transactions273602 +Ref: #valid-transactions273782 +Node: Deduplicating importing274410 +Ref: #deduplicating-importing274591 +Node: Setting amounts275623 +Ref: #setting-amounts275780 +Node: Amount signs278221 +Ref: #amount-signs278375 +Node: Setting currency/commodity279062 +Ref: #setting-currencycommodity279250 +Node: Amount decimal places280430 +Ref: #amount-decimal-places280622 +Node: Referencing other fields280934 +Ref: #referencing-other-fields281133 +Node: How CSV rules are evaluated282031 +Ref: #how-csv-rules-are-evaluated282206 +Node: TIMECLOCK FORMAT283655 +Ref: #timeclock-format283795 +Node: TIMEDOT FORMAT285863 +Ref: #timedot-format286001 +Node: COMMON TASKS290264 +Ref: #common-tasks290393 +Node: Getting help290800 +Ref: #getting-help290934 +Node: Constructing command lines291485 +Ref: #constructing-command-lines291679 +Node: Starting a journal file292378 +Ref: #starting-a-journal-file292578 +Node: Setting opening balances293765 +Ref: #setting-opening-balances293963 +Node: Recording transactions297096 +Ref: #recording-transactions297278 +Node: Reconciling297835 +Ref: #reconciling297980 +Node: Reporting300225 +Ref: #reporting300367 +Node: Migrating to a new file304287 +Ref: #migrating-to-a-new-file304437 +Node: LIMITATIONS304735 +Ref: #limitations304863 +Node: TROUBLESHOOTING305604 +Ref: #troubleshooting305719  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index 594116d91..78400cee8 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -251,6 +251,10 @@ OPTIONS $ hledger register credit\ card + Windows users should keep in mind that cmd treats single quote as a + regular character, so you should be using double quotes exclusively. + PowerShell treats both single and double quotes as quotes. + Double escaping (regular expression metacharacters) Characters significant in regular expressions (described below) - such as ., ^, $, [, ], (, ), |, and \ - may need to be "regex-escaped" if @@ -499,6 +503,8 @@ DATA FILES o Are all commodities declared with a commodity directive ? (Commodity error checking) + o Are all commodity conversions declared explicitly ? + You can also use the check command to run these and some additional checks. @@ -537,6 +543,7 @@ TIME PERIODS 20181232 8 digits with an invalid day gives an error 201801012 9+ digits beginning with a valid YYYYMMDD gives an error + Report start & end date By default, most hledger reports will show the full span of time repre- sented by the journal data. The report start date will be the earliest @@ -630,8 +637,8 @@ TIME PERIODS also be written as: - -p "1/1 4/1" + -p "january-apr" -p "this year to 4/1" @@ -751,17 +758,104 @@ DEPTH -2, --depth=2 or depth:2 are equivalent). 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 - web search: one or more space-separated search terms, quotes to enclose - whitespace, prefixes to match specific fields, a not: prefix to negate - the match. + One of hledger's strengths is being able to quickly report on a precise + subset of your data. Most hledger commands accept optional query argu- + ments to restrict their scope. The syntax is as follows: - We do not yet support arbitrary boolean combinations of search terms; - instead most commands show transactions/postings/accounts which match - (or negatively match): + o Zero or more space-separated query terms. These are most often + account name substrings: + + utilities food:groceries + + o Terms with spaces or other special characters should be enclosed in + quotes: + + "personal care" + + o Regular expressions are also supported: + + "^expenses\b" "accounts (payable|receivable)" + + o Add a query type prefix to match other parts of the data: + + date:202012- desc:amazon cur:USD amt:">100" status: + + o Add a not: prefix to negate a term: + + not:cur:USD + + Query types + Here are the types of query term available. Remember these can also be + prefixed with not: to convert them into a negative match. + + acct:REGEX, REGEX + Match account names containing this (case insensitive) regular expres- + sion. This is the default query type when there is no prefix, and reg- + ular expression syntax is typically not needed, so usually we just + write an account name substring, like expenses or food. + + amt:N, amt:N, amt:>=N + Match postings with a single-commodity amount equal to, less than, or + greater than N. (Postings with 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. Oth- + erwise, 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 partial + match, use .*REGEX.*). Note, to match special characters which are + regex-significant, you need to escape them with \. And for characters + which are significant to your shell you may need one more level of + escaping. So eg to match the dollar sign: + hledger print cur:\\$. + + desc:REGEX + Match transaction descriptions. + + date:PERIODEXPR + Match dates (or with the --date2 flag, secondary dates) within the + specified period. PERIODEXPR is a period expression with no report + interval. Examples: + date:2016, date:thismonth, date:2/1-2/15, date:2021-07-27..nextquarter. + + date2:PERIODEXPR + Match secondary dates within the specified period (independent of the + --date2 flag). + + depth:N + Match (or display, depending on command) accounts at or above this + depth. + + note:REGEX + Match transaction notes (the part of the description right of |, or the + whole description if there's no |). + + payee:REGEX + Match transaction payee/payer names (the part of the description left + of |, or the whole description if there's no |). + + real:, real:0 + Match real or virtual postings respectively. + + status:, status:!, status:* + Match unmarked, pending, or cleared transactions respectively. + + tag:REGEX[=REGEX] + Match by tag name, and optionally also by tag value. (To match only by + value, use tag:.=REGEX.) Note that postings also inherit tags from + their transaction, and transactions also acquire tags from their post- + ings, when querying. + + (inacct:ACCTNAME + A special query term used automatically in hledger-web only: tells + hledger-web to show the transaction register for an account.) + + Combining query terms + Most commands select things which match: o any of the description terms AND @@ -771,7 +865,7 @@ QUERIES o all the other terms. - The print command instead shows transactions which: + while the print command shows transactions which: o match any of the description terms AND @@ -781,82 +875,41 @@ QUERIES o match all the other terms. - The following kinds of search terms can be used. Remember these can - also be prefixed with not:, eg to exclude a particular subaccount. + You can do more powerful queries (such as AND-ing two like terms) by + running a first query with print, and piping the result into a second + hledger command. Eg: how much of food expenses was paid with cash ? - REGEX, acct:REGEX - match account names by this regular expression. (With no pre- - fix, acct: is assumed.) same as above + $ hledger print assets:cash | hledger f- -I balance expenses:food - amt:N, amt:N, amt:>=N - match postings with a single-commodity amount that is equal to, - less than, or greater than N. (Multi-commodity amounts are not - tested, and 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, - ignoring sign. + If you are interested in full boolean expressions for queries, see + #203. - code:REGEX - match by transaction code (eg check number) + Queries and command options + Some queries can also be expressed as command-line options: depth:2 is + equivalent to --depth 2, date:2020 is equivalent to -p 2020, etc. When + you mix command options and query arguments, generally the resulting + query is their intersection. - cur:REGEX - 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 - level of quoting to hide it from the shell, so eg do: hledger - print cur:'\$' or hledger print cur:\\$. + Queries and account aliases + When account names are rewritten with --alias or alias, acct: will + match either the old or the new account name. - desc:REGEX - match transaction descriptions. + Queries and valuation + When amounts are converted to other commodities in cost or value + reports, cur: and amt: match the old commodity symbol and the old + amount quantity, not the new ones (except in hledger 1.22.0 where it's + reversed, see #1625). - 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 - dates instead. (Report intervals will adjust start/end dates to - preceding/following subperiod boundaries.) + Querying with account aliases + When account names are rewritten with --alias or alias, note that acct: + will match either the old or the new account name. - date2:PERIODEXPR - match secondary dates within the specified period. - - depth:N - match (or display, depending on command) accounts at or above - this depth - - note:REGEX - match transaction notes (part of description right of |, or - whole description when there's no |) - - payee:REGEX - match transaction payee/payer names (part of description left of - |, or whole description when there's no |) - - real:, real:0 - match real or virtual postings respectively - - status:, status:!, status:* - match unmarked, pending, or cleared transactions respectively - - tag:REGEX[=REGEX] - match by tag name, and optionally also by tag value. Note a - tag: query is considered to match a transaction if it matches - any of the postings. Also remember that postings inherit the - tags of their parent transaction. - - The following special search term is used automatically in hledger-web, - only: - - inacct:ACCTNAME - tells hledger-web to show the transaction register for this - account. Can be filtered further with acct etc. - - 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 - excluding the -p/--period option). + Querying with cost or value + When amounts are converted to other commodities in cost or value + reports, note that cur: matches the new commodity symbol, and not the + old one, and amt: matches the new quantity, and not the old one. Note: + this changed in hledger 1.22, previously it was the reverse, see the + discussion at #1625. COSTING The -B/--cost flag converts amounts to their cost or sale amount at @@ -1196,6 +1249,8 @@ VALUATION total/average of displayed of displayed displayed values of displayed of displayed values values values values + + balance (bs, bse, cf, is) balance sums of value at value at posting value at value at @@ -1203,8 +1258,6 @@ VALUATION or today of journal end sums of post- sums of of sums of ings postings postings - - budget like balance like balance like balance like bal- like balance amounts changes changes changes ances changes (--budget) @@ -1951,16 +2004,19 @@ COMMANDS Sorting by amount With -S/--sort-amount, accounts with the largest (most positive) bal- ances are shown first. Eg: hledger bal expenses -MAS shows your big- - gest averaged monthly expenses first. + gest averaged monthly expenses first. When more than one commodity is + present, they will be sorted by the alphabetically earliest commodity + first, and then by subsequent commodities (if an amount is missing a + commodity, it is treated as 0). - Revenues and liability balances are typically negative, however, so -S - shows these in reverse order. To work around this, you can add - --invert to flip the signs. (Or, use one of the higher-level reports, - which flip the sign automatically. Eg: hledger incomestatement -MAS). + Revenues and liability balances are typically negative, however, so -S + shows these in reverse order. To work around this, you can add + --invert to flip the signs. (Or, use one of the higher-level reports, + which flip the sign automatically. Eg: hledger incomestatement -MAS). Percentages - With -%/--percent, balance reports show each account's value expressed + With -%/--percent, balance reports show each account's value expressed as a percentage of the (column) total: $ hledger bal expenses -Q -% @@ -1974,62 +2030,62 @@ COMMANDS || 0 100.0 % 0 0 Note it is not useful to calculate percentages if the amounts in a col- - umn have mixed signs. In this case, make a separate report for each + umn have mixed signs. In this case, make a separate report for each sign, eg: $ hledger bal -% amt:`>0` $ hledger bal -% amt:`<0` - Similarly, if the amounts in a column have mixed commodities, convert - them to one commodity with -B, -V, -X or --value, or make a separate + Similarly, if the amounts in a column have mixed commodities, convert + them to one commodity with -B, -V, -X or --value, or make a separate report for each commodity: $ hledger bal -% cur:\\$ $ hledger bal -% cur:EUR Balance change, end balance - It's important to be clear on the meaning of the numbers shown in bal- + It's important to be clear on the meaning of the numbers shown in bal- ance reports. Here is some terminology we use: - A balance change is the net amount added to, or removed from, an + A balance change is the net amount added to, or removed from, an account during some period. - An end balance is the amount accumulated in an account as of some date - (and some time, but hledger doesn't store that; assume end of day in + An end balance is the amount accumulated in an account as of some date + (and some time, but hledger doesn't store that; assume end of day in your timezone). It is the sum of previous balance changes. - We call it a historical end balance if it includes all balance changes + We call it a historical end balance if it includes all balance changes since the account was created. For a real world account, this means it - will match the "historical record", eg the balances reported in your + will match the "historical record", eg the balances reported in your bank statements or bank web UI. (If they are correct!) - In general, balance changes are what you want to see when reviewing + In general, balance changes are what you want to see when reviewing revenues and expenses, and historical end balances are what you want to see when reviewing or reconciling asset, liability and equity accounts. - balance shows balance changes by default. To see accurate historical + balance shows balance changes by default. To see accurate historical end balances: - 1. Initialise account starting balances with an "opening balances" - transaction (a transfer from equity to the account), unless the + 1. Initialise account starting balances with an "opening balances" + transaction (a transfer from equity to the account), unless the journal covers the account's full lifetime. 2. Include all of of the account's prior postings in the report, by not - specifying a report start date, or by using the -H/--historical + specifying a report start date, or by using the -H/--historical flag. (-H causes report start date to be ignored when summing post- ings.) Balance report types For more flexible reporting, there are three important option groups: - hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] + hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] ... - The first two are the most important: calculation type selects the - basic calculation to perform for each table cell, while accumulation + The first two are the most important: calculation type selects the + basic calculation to perform for each table cell, while accumulation type says which postings should be included in each cell's calculation. - Typically one or both of these are selected by default, so you don't - need to write them explicitly. A valuation type can be added if you + Typically one or both of these are selected by default, so you don't + need to write them explicitly. A valuation type can be added if you want to convert the basic report to value or cost. Calculation type: @@ -2043,20 +2099,20 @@ COMMANDS ues Accumulation type: - Which postings should be included in each cell's calculation. It is + Which postings should be included in each cell's calculation. It is one of: - o --change : postings from column start to column end, ie within the - cell's period. Typically used to see revenues/expenses. (default + o --change : postings from column start to column end, ie within the + cell's period. Typically used to see revenues/expenses. (default for balance, incomestatement) - o --cumulative : postings from report start to column end, eg to show + o --cumulative : postings from report start to column end, eg to show changes accumulated since the report's start date. Rarely used. - o --historical/-H : postings from journal start to column end, ie all + o --historical/-H : postings from journal start to column end, ie all postings from account creation to the end of the cell's period. Typ- ically used to see historical end balances of assets/liabili- - ties/equity. (default for balancesheet, balancesheetequity, cash- + ties/equity. (default for balancesheet, balancesheetequity, cash- flow) Valuation type: @@ -2069,7 +2125,7 @@ COMMANDS o --value=then[,COMM] : show value at transaction dates - o --value=end[,COMM] : show value at period end date(s) (default with + o --value=end[,COMM] : show value at period end date(s) (default with --valuechange) o --value=now[,COMM] : show value at today's date @@ -2078,13 +2134,13 @@ COMMANDS or one of their aliases: --cost/-B, --market/-V or --exchange/-X. - Most combinations of these options should produce reasonable reports, - but if you find any that seem wrong or misleading, let us know. The + Most combinations of these options should produce reasonable reports, + but if you find any that seem wrong or misleading, let us know. The following restrictions are applied: o --valuechange implies --value=end - o --valuechange makes --change the default when used with the bal- + o --valuechange makes --change the default when used with the bal- ancesheet/balancesheetequity commands o --cumulative or --historical disables --row-total/-T @@ -2100,16 +2156,16 @@ COMMANDS v ------------------------------------------------------------------------------------ --change change in period sum of posting- period-end DATE-value of - date market val- value of change change in + date market val- value of change change in ues in period in period period --cumu- change from sum of posting- period-end DATE-value of - lative report start to date market val- value of change change from + lative report start to date market val- value of change change from period end ues from report from report report start start to period start to period to period end end end --his- change from sum of posting- period-end DATE-value of - torical journal start to date market val- value of change change from - /-H period end (his- ues from journal from journal journal start + torical journal start to date market val- value of change change from + /-H period end (his- ues from journal from journal journal start torical end bal- start to period start to period to period end ance) end end @@ -2117,25 +2173,25 @@ COMMANDS Some frequently used balance options/reports are: o bal -M revenues expenses - Show revenues/expenses in each month. Also available as the incomes- + Show revenues/expenses in each month. Also available as the incomes- tatement command. o bal -M -H assets liabilities - Show historical asset/liability balances at each month end. Also + Show historical asset/liability balances at each month end. Also available as the balancesheet command. o bal -M -H assets liabilities equity - Show historical asset/liability/equity balances at each month end. + Show historical asset/liability/equity balances at each month end. Also available as the balancesheetequity command. o bal -M assets not:receivable - Show changes to liquid assets in each month. Also available as the + Show changes to liquid assets in each month. Also available as the cashflow command. Also: o bal -M expenses -2 -SA - Show monthly expenses summarised to depth 2 and sorted by average + Show monthly expenses summarised to depth 2 and sorted by average amount. o bal -M --budget expenses @@ -2149,12 +2205,12 @@ COMMANDS Show top gainers [or losers] last week Budget report - The --budget report type activates extra columns showing any budget - goals for each account and period. The budget goals are defined by - periodic transactions. This is very useful for comparing planned and + The --budget report type activates extra columns showing any budget + goals for each account and period. The budget goals are defined by + periodic transactions. This is very useful for comparing planned and actual income, expenses, time usage, etc. - For example, you can take average monthly expenses in the common + For example, you can take average monthly expenses in the common expense categories to construct a minimal monthly budget: ;; Budget @@ -2201,26 +2257,26 @@ COMMANDS This is different from a normal balance report in several ways: - o Only accounts with budget goals during the report period are shown, + o Only accounts with budget goals during the report period are shown, by default. - o In each column, in square brackets after the actual amount, budget - goal amounts are shown, and the actual/goal percentage. (Note: bud- + o In each column, in square brackets after the actual amount, budget + goal amounts are shown, and the actual/goal percentage. (Note: bud- get goals should be in the same commodity as the actual amount.) - o All parent accounts are always shown, even in list mode. Eg assets, + o All parent accounts are always shown, even in list mode. Eg assets, assets:bank, and expenses above. - o Amounts always include all subaccounts, budgeted or unbudgeted, even + o Amounts always include all subaccounts, budgeted or unbudgeted, even in list mode. This means that the numbers displayed will not always add up! Eg above, - the expenses actual amount includes the gifts and supplies transac- - tions, but the expenses:gifts and expenses:supplies accounts are not + the expenses actual amount includes the gifts and supplies transac- + tions, but the expenses:gifts and expenses:supplies accounts are not shown, as they have no budget amounts declared. - This can be confusing. When you need to make things clearer, use the - -E/--empty flag, which will reveal all accounts including unbudgeted + This can be confusing. When you need to make things clearer, use the + -E/--empty flag, which will reveal all accounts including unbudgeted ones, giving the full picture. Eg: $ hledger balance -M --budget --empty @@ -2262,12 +2318,12 @@ COMMANDS For more examples and notes, see Budgeting. Budget report start date - This might be a bug, but for now: when making budget reports, it's a + This might be a bug, but for now: when making budget reports, it's a good idea to explicitly set the report's start date to the first day of - a reporting period, because a periodic rule like ~ monthly generates - its transactions on the 1st of each month, and if your journal has no - regular transactions on the 1st, the default report start date could - exclude that budget goal, which can be a little surprising. Eg here + a reporting period, because a periodic rule like ~ monthly generates + its transactions on the 1st of each month, and if your journal has no + regular transactions on the 1st, the default report start date could + exclude that budget goal, which can be a little surprising. Eg here the default report period is just the day of 2020-01-15: ~ monthly in 2020 @@ -2286,9 +2342,9 @@ COMMANDS --------------++------------ || $400 - To avoid this, specify the budget report's period, or at least the - start date, with -b/-e/-p/date:, to ensure it includes the budget goal - transactions (periodic transactions) that you want. Eg, adding -b + To avoid this, specify the budget report's period, or at least the + start date, with -b/-e/-p/date:, to ensure it includes the budget goal + transactions (periodic transactions) that you want. Eg, adding -b 2020/1/1 to the above: $ hledger bal expenses --budget -b 2020/1/1 @@ -2300,13 +2356,13 @@ COMMANDS ---------------++------------------------ || $400 [80% of $500] - Nested budgets - You can add budgets to any account in your account hierarchy. If you + Budgets and subaccounts + You can add budgets to any account in your account hierarchy. If you have budgets on both parent account and some of its children, then bud- - get(s) of the child account(s) would be added to the budget of their + get(s) of the child account(s) would be added to the budget of their parent, much like account balances behave. - In the most simple case this means that once you add a budget to any + In the most simple case this means that once you add a budget to any account, all its parents would have budget as well. To illustrate this, consider the following budget: @@ -2316,13 +2372,13 @@ COMMANDS expenses:personal:electronics $100.00 liabilities - With this, monthly budget for electronics is defined to be $100 and - budget for personal expenses is an additional $1000, which implicitly + With this, monthly budget for electronics is defined to be $100 and + budget for personal expenses is an additional $1000, which implicitly means that budget for both expenses:personal and expenses is $1100. - Transactions in expenses:personal:electronics will be counted both - towards its $100 budget and $1100 of expenses:personal , and transac- - tions in any other subaccount of expenses:personal would be counted + Transactions in expenses:personal:electronics will be counted both + towards its $100 budget and $1100 of expenses:personal , and transac- + tions in any other subaccount of expenses:personal would be counted towards only towards the budget of expenses:personal. For example, let's consider these transactions: @@ -2348,9 +2404,9 @@ COMMANDS expenses:personal $30.00 liabilities - As you can see, we have transactions in expenses:personal:electron- - ics:upgrades and expenses:personal:train tickets, and since both of - these accounts are without explicitly defined budget, these transac- + As you can see, we have transactions in expenses:personal:electron- + ics:upgrades and expenses:personal:train tickets, and since both of + these accounts are without explicitly defined budget, these transac- tions would be counted towards budgets of expenses:personal:electronics and expenses:personal accordingly: @@ -2366,7 +2422,7 @@ COMMANDS -------------------------------++------------------------------- || 0 [ 0] - And with --empty, we can get a better picture of budget allocation and + And with --empty, we can get a better picture of budget allocation and consumption: $ hledger balance --budget -M --empty @@ -2383,9 +2439,30 @@ COMMANDS ----------------------------------------++------------------------------- || 0 [ 0] + Selecting budget goals + The budget report evaluates periodic transaction rules to generate spe- + cial "goal transactions", which generate the goal amounts for each + account in each report subperiod. When troubleshooting, you can use + the print command to show these as forecasted transactions: + + $ hledger print --forecast=BUDGETREPORTPERIOD tag:generated + + By default, the budget report uses all available periodic transaction + rules to generate goals. This includes rules with a different report + interval from your report. Eg if you have daily, weekly and monthly + periodic rules, all of these will contribute to the goals in a monthly + budget report. + + You can select a subset of periodic rules by providing an argument to + the --budget flag. --budget=DESCPAT will match all periodic rules + whose description contains DESCPAT, a case-insensitive substring (not a + regular expression or query). This means you can give your periodic + rules descriptions (remember that two spaces are needed), and then + select from multiple budgets defined in your journal. + Customising single-period balance reports For single-period balance reports displayed in the terminal (only), you - can use --format FMT to customise the format and content of each line. + can use --format FMT to customise the format and content of each line. Eg: $ hledger balance --format "%20(account) %12(total)" @@ -2403,7 +2480,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) @@ -2414,14 +2491,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) @@ -2430,34 +2507,34 @@ COMMANDS o %, - render on one line, comma-separated - There are some quirks. Eg in one-line mode, %(depth_spacer) has no - effect, instead %(account) has indentation built in. Experimentation + 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. Some example formats: 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 balancesheet balancesheet, bs - This command displays a balance sheet, showing historical ending bal- + This command displays a balance sheet, showing historical ending bal- ances of asset and liability accounts. (To see equity as well, use the - balancesheetequity command.) Amounts are shown with normal positive + balancesheetequity command.) Amounts are shown with normal positive sign, as in conventional financial statements. The asset and liability accounts shown are those accounts declared with - the Asset or Cash or Liability type, or otherwise all accounts under a - top-level asset or liability account (case insensitive, plurals + the Asset or Cash or Liability type, or otherwise all accounts under a + top-level asset or liability account (case insensitive, plurals allowed). Example: @@ -2482,23 +2559,23 @@ COMMANDS 0 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. - It is similar to hledger balance -H assets liabilities, but with - smarter account detection, and liabilities displayed with their sign + ports many of that command's features, such as multi-period reports. + It is similar to hledger balance -H assets liabilities, but with + smarter account detection, and liabilities displayed with their sign flipped. - This command also supports the output destination and output format - options The output formats supported are txt, csv, html, and (experi- + This command also supports the output destination and output format + options The output formats supported are txt, csv, html, and (experi- mental) json. balancesheetequity balancesheetequity, bse - This command displays a balance sheet, showing historical ending bal- - ances of asset, liability and equity accounts. Amounts are shown with + This command displays a balance sheet, showing historical ending bal- + ances of asset, liability and equity accounts. Amounts are shown with normal positive sign, as in conventional financial statements. - The asset, liability and equity accounts shown are those accounts - declared with the Asset, Cash, Liability or Equity type, or otherwise + The asset, liability and equity accounts shown are those accounts + declared with the Asset, Cash, Liability or Equity type, or otherwise all accounts under a top-level asset, liability or equity account (case insensitive, plurals allowed). @@ -2529,24 +2606,24 @@ COMMANDS 0 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. + ports many of that command's features, such as multi-period reports. It is similar to hledger balance -H assets liabilities equity, but with - smarter account detection, and liabilities/equity displayed with their + smarter account detection, and liabilities/equity displayed with their sign flipped. - This command also supports the output destination and output format - options The output formats supported are txt, csv, html, and (experi- + This command also supports the output destination and output format + options The output formats supported are txt, csv, html, and (experi- mental) json. cashflow cashflow, cf - This command displays a cashflow statement, showing the inflows and - outflows affecting "cash" (ie, liquid) assets. Amounts are shown with + This command displays a cashflow statement, showing the inflows and + outflows affecting "cash" (ie, liquid) assets. Amounts are shown with normal positive sign, as in conventional financial statements. - The "cash" accounts shown are those accounts declared with the Cash - type, or otherwise all accounts under a top-level asset account (case - insensitive, plural allowed) which do not have fixed, investment, + The "cash" accounts shown are those accounts declared with the Cash + type, or otherwise all accounts under a top-level asset account (case + insensitive, plural allowed) which do not have fixed, investment, receivable or A/R in their name. Example: @@ -2566,22 +2643,22 @@ COMMANDS $-1 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. - It is similar to hledger balance assets not:fixed not:investment + ports many of that command's features, such as multi-period reports. + It is similar to hledger balance assets not:fixed not:investment not:receivable, but with smarter account detection. - This command also supports the output destination and output format - options The output formats supported are txt, csv, html, and (experi- + This command also supports the output destination and output format + options The output formats supported are txt, csv, html, and (experi- mental) json. check check Check for various kinds of errors in your data. - hledger provides a number of built-in error checks to help prevent - problems in your data. Some of these are run automatically; or, you - can use this check command to run them on demand, with no output and a - zero exit code if all is well. Specify their names (or a prefix) as + hledger provides a number of built-in error checks to help prevent + problems in your data. Some of these are run automatically; or, you + can use this check command to run them on demand, with no output and a + zero exit code if all is well. Specify their names (or a prefix) as argument(s). Some examples: @@ -2599,27 +2676,27 @@ COMMANDS o parseable - data files are well-formed and can be successfully parsed o balancedwithautoconversion - all transactions are balanced, inferring - missing amounts where necessary, and possibly converting commodities + missing amounts where necessary, and possibly converting commodities using transaction prices or automatically-inferred transaction prices - o assertions - all balance assertions in the journal are passing. + o assertions - all balance assertions in the journal are passing. (This check can be disabled with -I/--ignore-assertions.) Strict checks These additional checks are run when the -s/--strict (strict mode) flag - is used. Or, they can be run by giving their names as arguments to + is used. Or, they can be run by giving their names as arguments to check: o accounts - all account names used by transactions have been declared o commodities - all commodity symbols used have been declared - o balancednoautoconversion - transactions are balanced, possibly using + o balancednoautoconversion - transactions are balanced, possibly using explicit transaction prices but not inferred ones Other checks - These checks can be run only by giving their names as arguments to - check. They are more specialised and not desirable for everyone, + These checks can be run only by giving their names as arguments to + check. They are more specialised and not desirable for everyone, therefore optional: o ordereddates - transactions are ordered by date within each file @@ -2629,13 +2706,13 @@ COMMANDS o uniqueleafnames - all account leaf names are unique Custom checks - A few more checks are are available as separate add-on commands, in + A few more checks are are available as separate add-on commands, in https://github.com/simonmichael/hledger/tree/master/bin: - o hledger-check-tagfiles - all tag values containing / (a forward + o hledger-check-tagfiles - all tag values containing / (a forward slash) exist as file paths - o hledger-check-fancyassertions - more complex balance assertions are + o hledger-check-fancyassertions - more complex balance assertions are passing You could make similar scripts to perform your own custom checks. See: @@ -2643,38 +2720,38 @@ COMMANDS close close, equity - Prints a sample "closing" transaction bringing specified account bal- - ances to zero, and an inverse "opening" transaction restoring the same + Prints a sample "closing" transaction bringing specified account bal- + ances to zero, and an inverse "opening" transaction restoring the same account balances. - If like most people you split your journal files by time, eg by year: - at the end of the year you can use this command to "close out" your - asset and liability (and perhaps equity) balances in the old file, and - reinitialise them in the new file. This helps ensure that report bal- - ances remain correct whether you are including old files or not. - (Because all closing/opening transactions except the very first will + If like most people you split your journal files by time, eg by year: + at the end of the year you can use this command to "close out" your + asset and liability (and perhaps equity) balances in the old file, and + reinitialise them in the new file. This helps ensure that report bal- + ances remain correct whether you are including old files or not. + (Because all closing/opening transactions except the very first will cancel out - see example below.) Some people also use this command to close out revenue and expense bal- - ances at the end of an accounting period. This properly records the - period's profit/loss as "retained earnings" (part of equity), and + ances at the end of an accounting period. This properly records the + period's profit/loss as "retained earnings" (part of equity), and allows the accounting equation (A-L=E) to balance, which you could then check by the bse report's zero total. - You can print just the closing transaction by using the --close flag, + You can print just the closing transaction by using the --close flag, or just the opening transaction with the --open flag. Their descriptions are closing balances and opening balances by - default; you can customise these with the --close-desc and --open-desc + default; you can customise these with the --close-desc and --open-desc options. - Just one balancing equity posting is used by default, with the amount + Just one balancing equity posting is used by default, with the amount left implicit. The default account name is equity:opening/closing bal- - ances. You can customise the account name(s) with --close-acct and - --open-acct. (If you specify only one of these, it will be used for + ances. You can customise the account name(s) with --close-acct and + --open-acct. (If you specify only one of these, it will be used for both.) - With --x/--explicit, the equity posting's amount will be shown explic- + With --x/--explicit, the equity posting's amount will be shown explic- itly, and if it involves multiple commodities, there will be a separate equity posting for each commodity (as in the print command). @@ -2682,20 +2759,20 @@ COMMANDS balances (good for troubleshooting). close and prices - Transaction prices are ignored (and discarded) by closing/opening + Transaction prices are ignored (and discarded) by closing/opening transactions, by default. With --show-costs, they are preserved; there - will be a separate equity posting for each cost in each commodity. - This means balance -B reports will look the same after the transition. + will be a separate equity posting for each cost in each commodity. + This means balance -B reports will look the same after the transition. Note if you have many foreign currency or investment transactions, this will generate very large journal entries. close date - The default closing date is yesterday, or the journal's end date, + The default closing date is yesterday, or the journal's end date, whichever is later. - Unless you are running close on exactly the first day of the new - period, you'll want to override the closing date. This is done by - specifying a report period, where "last day of the report period" will + Unless you are running close on exactly the first day of the new + period, you'll want to override the closing date. This is done by + specifying a report period, where "last day of the report period" will be the closing date. The opening date is always the following day. So to close on 2020-12-31 and open on 2021-01-01, any of these work @@ -2729,17 +2806,17 @@ COMMANDS Hiding opening/closing transactions Although the closing/opening transactions cancel out, they will be vis- - ible in reports like print and register, creating some visual clutter. + ible in reports like print and register, creating some visual clutter. You can exclude them all with a query, like: $ hledger print not:desc:'opening|closing' # less typing $ hledger print not:'equity:opening/closing balances' # more precise - But when reporting on multiple files, this can get a bit tricky; you + But when reporting on multiple files, this can get a bit tricky; you may need to keep the earliest opening balances, for a historical regis- - ter report; or you may need to suppress a closing transaction, to see - year-end balances. If you find yourself needing more precise queries, - here's one solution: add more easily-matched tags to opening/closing + ter report; or you may need to suppress a closing transaction, to see + year-end balances. If you find yourself needing more precise queries, + here's one solution: add more easily-matched tags to opening/closing transactions, like this: ; 2019.journal @@ -2777,18 +2854,18 @@ COMMANDS # 2020 year end balances, easier case close and balance assertions - The closing and opening transactions will include balance assertions, - verifying that the accounts have first been reset to zero and then - restored to their previous balance. These provide valuable error - checking, alerting you when things get out of line, but you can ignore + The closing and opening transactions will include balance assertions, + verifying that the accounts have first been reset to zero and then + restored to their previous balance. These provide valuable error + checking, alerting you when things get out of line, but you can ignore them temporarily with -I or just remove them if you prefer. You probably shouldn't use status or realness filters (like -C or -R or status:) with close, or the generated balance assertions will depend on - these flags. Likewise, if you run this command with --auto, the bal- + these flags. Likewise, if you run this command with --auto, the bal- ance assertions would probably always require --auto. - Multi-day transactions (where some postings have a different date) + Multi-day transactions (where some postings have a different date) break the balance assertions, because the money is temporarily "invisi- ble" while in transit: @@ -2796,8 +2873,8 @@ COMMANDS expenses:food 5 assets:bank:checking -5 ; date: 2021/1/2 - To fix the assertions, you can add a temporary account to track such - in-transit money (splitting the multi-day transaction into two single- + To fix the assertions, you can add a temporary account to track such + in-transit money (splitting the multi-day transaction into two single- day transactions): ; in 2020.journal: @@ -2812,7 +2889,7 @@ COMMANDS Example: close revenue/expense accounts to retained earnings Here, the opening transaction is supressed with --close, as it's proba- - bly not needed. Also you'll want to use a different equity account + bly not needed. Also you'll want to use a different equity account name: $ hledger close -f 2021.journal -p 2021Q1 --close --close-acct='equity:retained earnings' revenues expenses >> 2021.journal @@ -2835,13 +2912,13 @@ COMMANDS codes List the codes seen in transactions, in the order parsed. - This command prints the value of each transaction's code field, in the - order transactions were parsed. The transaction code is an optional - value written in parentheses between the date and description, often + This command prints the value of each transaction's code field, in the + order transactions were parsed. The transaction code is an optional + value written in parentheses between the date and description, often used to store a cheque number, order number or similar. Transactions aren't required to have a code, and missing or empty codes - will not be shown by default. With the -E/--empty flag, they will be + will not be shown by default. With the -E/--empty flag, they will be printed as blank lines. You can add a query to select a subset of transactions. @@ -2881,7 +2958,7 @@ COMMANDS List the unique descriptions that appear in transactions. This command lists the unique descriptions that appear in transactions, - in alphabetic order. You can add a query to select a subset of trans- + in alphabetic order. You can add a query to select a subset of trans- actions. Example: @@ -2893,18 +2970,18 @@ COMMANDS diff diff - Compares a particular account's transactions in two input files. It + Compares a particular account's transactions in two input files. It shows any transactions to this account which are in one file but not in the other. More precisely, for each posting affecting this account in either file, - it looks for a corresponding posting in the other file which posts the - same amount to the same account (ignoring date, description, etc.) + it looks for a corresponding posting in the other file which posts the + same amount to the same account (ignoring date, description, etc.) Since postings not transactions are compared, this also works when mul- tiple bank transactions have been combined into a single journal entry. This is useful eg if you have downloaded an account's transactions from - your bank (eg as CSV data). When hledger and your bank disagree about + your bank (eg as CSV data). When hledger and your bank disagree about the account balance, you can compare the bank data with your journal to find out the cause. @@ -2922,18 +2999,18 @@ COMMANDS files files - List all files included in the journal. With a REGEX argument, only - file names matching the regular expression (case sensitive) are shown. + List all files included in the journal. With a REGEX argument, only + file names matching the regular expression (case sensitive) are shown. help help - Show the hledger user manual in one of several formats, optionally - positioned at a given TOPIC (if possible). TOPIC is any heading, or - heading prefix, in the manual. Some examples: commands, print, 'auto + Show the hledger user manual in one of several formats, optionally + positioned at a given TOPIC (if possible). TOPIC is any heading, or + heading prefix, in the manual. Some examples: commands, print, 'auto postings', periodic. - This command shows the user manual built in to this hledger version. - It can be useful if the correct version of the hledger manual, or the + This command shows the user manual built in to this hledger version. + It can be useful if the correct version of the hledger manual, or the usual viewing tools, are not installed on your system. By default it uses the best viewer it can find in $PATH, in this order: @@ -2943,66 +3020,66 @@ COMMANDS import import - Read new transactions added to each FILE since last run, and add them - to the main journal file. Or with --dry-run, just print the transac- - tions that would be added. Or with --catchup, just mark all of the + Read new transactions added to each FILE since last run, and add them + to the main journal file. Or with --dry-run, just print the transac- + tions that would be added. Or with --catchup, just mark all of the FILEs' transactions as imported, without actually importing any. - Unlike other hledger commands, with import the journal file is an out- + Unlike other hledger commands, with import the journal file is an out- put file, and will be modified, though only by appending (existing data - will not be changed). The input files are specified as arguments, so - to import one or more CSV files to your main journal, you will run + will not be changed). The input files are specified as arguments, so + to import one or more CSV files to your main journal, you will run hledger import bank.csv or perhaps hledger import *.csv. Note you can import from any file format, though CSV files are the most common import source, and these docs focus on that case. Deduplication - As a convenience import does deduplication while reading transactions. + As a convenience import does deduplication while reading transactions. This does not mean "ignore transactions that look the same", but rather "ignore transactions that have been seen before". This is intended for - when you are periodically importing foreign data which may contain - already-imported transactions. So eg, if every day you download bank - CSV files containing redundant data, you can safely run hledger import - bank.csv and only new transactions will be imported. (import is idem- + when you are periodically importing foreign data which may contain + already-imported transactions. So eg, if every day you download bank + CSV files containing redundant data, you can safely run hledger import + bank.csv and only new transactions will be imported. (import is idem- potent.) - Since the items being read (CSV records, eg) often do not come with - unique identifiers, hledger detects new transactions by date, assuming + Since the items being read (CSV records, eg) often do not come with + unique identifiers, hledger detects new transactions by date, assuming that: 1. new items always have the newest dates 2. item dates do not change across reads - 3. and items with the same date remain in the same relative order + 3. and items with the same date remain in the same relative order across reads. - These are often true of CSV files representing transactions, or true - enough so that it works pretty well in practice. 1 is important, but + These are often true of CSV files representing transactions, or true + enough so that it works pretty well in practice. 1 is important, but violations of 2 and 3 amongst the old transactions won't matter (and if - you import often, the new transactions will be few, so less likely to + you import often, the new transactions will be few, so less likely to be the ones affected). - hledger remembers the latest date processed in each input file by sav- + hledger remembers the latest date processed in each input file by sav- ing a hidden ".latest" state file in the same directory. Eg when read- - ing finance/bank.csv, it will look for and update the finance/.lat- - est.bank.csv state file. The format is simple: one or more lines con- - taining the same ISO-format date (YYYY-MM-DD), meaning "I have pro- - cessed transactions up to this date, and this many of them on that + ing finance/bank.csv, it will look for and update the finance/.lat- + est.bank.csv state file. The format is simple: one or more lines con- + taining the same ISO-format date (YYYY-MM-DD), meaning "I have pro- + cessed transactions up to this date, and this many of them on that date." Normally you won't see or manipulate these state files yourself. - But if needed, you can delete them to reset the state (making all - transactions "new"), or you can construct them to "catch up" to a cer- + But if needed, you can delete them to reset the state (making all + transactions "new"), or you can construct them to "catch up" to a cer- tain date. - Note deduplication (and updating of state files) can also be done by + Note deduplication (and updating of state files) can also be done by print --new, but this is less often used. Import testing - With --dry-run, the transactions that will be imported are printed to + With --dry-run, the transactions that will be imported are printed to the terminal, without updating your journal or state files. The output - is valid journal format, like the print command, so you can re-parse - it. Eg, to see any importable transactions which CSV rules have not + is valid journal format, like the print command, so you can re-parse + it. Eg, to see any importable transactions which CSV rules have not categorised: $ hledger import --dry bank.csv | hledger -f- -I print unknown @@ -3012,17 +3089,17 @@ COMMANDS $ ls bank.csv* | entr bash -c 'echo ====; hledger import --dry bank.csv | hledger -f- -I print unknown' Importing balance assignments - Entries added by import will have their posting amounts made explicit - (like hledger print -x). This means that any balance assignments in - imported files must be evaluated; but, imported files don't get to see - the main file's account balances. As a result, importing entries with + Entries added by import will have their posting amounts made explicit + (like hledger print -x). This means that any balance assignments in + imported files must be evaluated; but, imported files don't get to see + the main file's account balances. As a result, importing entries with balance assignments (eg from an institution that provides only balances - and not posting amounts) will probably generate incorrect posting + and not posting amounts) will probably generate incorrect posting amounts. To avoid this problem, use print instead of import: $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE - (If you think import should leave amounts implicit like print does, + (If you think import should leave amounts implicit like print does, please test it and send a pull request.) Commodity display styles @@ -3033,12 +3110,12 @@ COMMANDS incomestatement, is This command displays an income statement, showing revenues and - expenses during one or more periods. Amounts are shown with normal + expenses during one or more periods. Amounts are shown with normal positive sign, as in conventional financial statements. The revenue and expense accounts shown are those accounts declared with - the Revenue or Expense type, or otherwise all accounts under a top- - level revenue or income or expense account (case insensitive, plurals + the Revenue or Expense type, or otherwise all accounts under a top- + level revenue or income or expense account (case insensitive, plurals allowed). Example: @@ -3065,22 +3142,22 @@ COMMANDS 0 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. + ports many of that command's features, such as multi-period reports. It is similar to hledger balance '(revenues|income)' expenses, but with - smarter account detection, and revenues/income displayed with their + smarter account detection, and revenues/income displayed with their sign flipped. - This command also supports the output destination and output format - options The output formats supported are txt, csv, html, and (experi- + This command also supports the output destination and output format + options The output formats supported are txt, csv, html, and (experi- mental) json. notes notes List the unique notes that appear in transactions. - This command lists the unique notes that appear in transactions, in - alphabetic order. You can add a query to select a subset of transac- - tions. The note is the part of the transaction description after a | + This command lists the unique notes that appear in transactions, in + alphabetic order. You can add a query to select a subset of transac- + tions. The note is the part of the transaction description after a | character (or if there is no |, the whole description). Example: @@ -3093,14 +3170,14 @@ COMMANDS payees List the unique payee/payer names that appear in transactions. - This command lists unique payee/payer names which have been declared - with payee directives (--declared), used in transaction descriptions + This command lists unique payee/payer names which have been declared + with payee directives (--declared), used in transaction descriptions (--used), or both (the default). - The payee/payer is the part of the transaction description before a | + The payee/payer is the part of the transaction description before a | character (or if there is no |, the whole description). - You can add query arguments to select a subset of transactions. This + You can add query arguments to select a subset of transactions. This implies --used. Example: @@ -3112,10 +3189,10 @@ COMMANDS prices prices - Print market price directives from the journal. With --costs, also - print synthetic market prices based on transaction prices. With + Print market price directives from the journal. With --costs, also + print synthetic market prices based on transaction prices. With --inverted-costs, also print inverse prices based on transaction - prices. Prices (and postings providing prices) can be filtered by a + prices. Prices (and postings providing prices) can be filtered by a query. Price amounts are always displayed with their full precision. print @@ -3125,17 +3202,17 @@ COMMANDS The print command displays full journal entries (transactions) from the journal file, sorted by date (or with --date2, by secondary date). - Amounts are shown mostly normalised to commodity display style, eg the - placement of commodity symbols will be consistent. All of their deci- + Amounts are shown mostly normalised to commodity display style, eg the + placement of commodity symbols will be consistent. All of their deci- mal places are shown, as in the original journal entry (with one alter- ation: in some cases trailing zeroes are added.) Amounts are shown right-aligned within each transaction (but not across all transactions). - Directives and inter-transaction comments are not shown, currently. + Directives and inter-transaction comments are not shown, currently. This means the print command is somewhat lossy, and if you are using it - to reformat your journal you should take care to also copy over the + to reformat your journal you should take care to also copy over the directives and file-level comments. Eg: @@ -3162,7 +3239,7 @@ COMMANDS liabilities:debts $1 assets:bank:checking $-1 - print's output is usually a valid hledger journal, and you can process + print's output is usually a valid hledger journal, and you can process it again with a second hledger command. This can be useful for certain kinds of search, eg: @@ -3172,39 +3249,39 @@ COMMANDS There are some situations where print's output can become unparseable: - o Valuation affects posting amounts but not balance assertion or bal- + o Valuation affects posting amounts but not balance assertion or bal- ance assignment amounts, potentially causing those to fail. o Auto postings can generate postings with too many missing amounts. Normally, the journal entry's explicit or implicit amount style is pre- served. For example, when an amount is omitted in the journal, it will - not appear in the output. Similarly, when a transaction price is + not appear in the output. Similarly, when a transaction price is implied but not written, it will not appear in the output. You can use - the -x/--explicit flag to make all amounts and transaction prices - explicit, which can be useful for troubleshooting or for making your + the -x/--explicit flag to make all amounts and transaction prices + explicit, which can be useful for troubleshooting or for making your journal more readable and robust against data entry errors. -x is also implied by using any of -B,-V,-X,--value. - Note, -x/--explicit will cause postings with a multi-commodity amount - (these can arise when a multi-commodity transaction has an implicit - amount) to be split into multiple single-commodity postings, keeping + Note, -x/--explicit will cause postings with a multi-commodity amount + (these can arise when a multi-commodity transaction has an implicit + amount) to be split into multiple single-commodity postings, keeping the output parseable. - With -B/--cost, amounts with transaction prices are converted to cost + With -B/--cost, amounts with transaction prices are converted to cost using that price. This can be used for troubleshooting. - With -m/--match and a STR argument, print will show at most one trans- - action: the one one whose description is most similar to STR, and is - most recent. STR should contain at least two characters. If there is + With -m/--match and a STR argument, print will show at most one trans- + action: the one one whose description is most similar to STR, and is + most recent. STR should contain at least two characters. If there is no similar-enough match, no transaction will be shown. - With --new, hledger prints only transactions it has not seen on a pre- - vious run. This uses the same deduplication system as the import com- + With --new, hledger prints only transactions it has not seen on a pre- + vious run. This uses the same deduplication system as the import com- mand. (See import's docs for details.) - This command also supports the output destination and output format - options The output formats supported are txt, csv, and (experimental) + This command also supports the output destination and output format + options The output formats supported are txt, csv, and (experimental) json and sql. Here's an example of print's CSV output: @@ -3223,20 +3300,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.) print-unique @@ -3260,14 +3337,14 @@ COMMANDS Show postings and their running total. The register command displays matched postings, across all accounts, in - date order, with their running total or running historical balance. - (See also the aregister command, which shows matched transactions in a + date order, with their running total or running historical balance. + (See also the aregister command, which shows matched transactions in a specific account.) register normally shows line per posting, but note that multi-commodity amounts will occupy multiple lines (one line per commodity). - It is typically used with a query selecting a particular account, to + It is typically used with a query selecting a particular account, to see that account's activity: $ hledger register checking @@ -3278,8 +3355,8 @@ COMMANDS With --date2, it shows and sorts by secondary date instead. - 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 @@ -3289,30 +3366,30 @@ 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. - The --invert flag negates all amounts. For example, it can be used on + The --invert flag negates all amounts. For example, it can be used on an income account where amounts are normally displayed as negative num- - bers. It's also useful to show postings on the checking account + bers. It's also useful to show postings on the checking account together with the related account: $ hledger register --related --invert assets:checking - 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 @@ -3329,7 +3406,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 @@ -3337,19 +3414,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 (won't display correctly in --help): <--------------------------------- width (W) ----------------------------------> @@ -3365,28 +3442,28 @@ COMMANDS $ hledger reg -w 100,40 # set overall width 100, description width 40 $ hledger reg -w $COLUMNS,40 # use terminal width, & description width 40 - This command also supports the output destination and output format - options The output formats supported are txt, csv, and (experimental) + This command also supports the output destination and output format + options The output formats supported are txt, csv, and (experimental) json. register-match register-match Print the one posting whose transaction description is closest to DESC, - in the style of the register command. If there are multiple equally - good matches, it shows the most recent. Query options (options, not - arguments) can be used to restrict the search space. Helps ledger- + in the style of the register command. If there are multiple equally + good matches, it shows the most recent. Query options (options, not + arguments) can be used to restrict the search space. Helps ledger- autosync detect already-seen transactions when importing. rewrite rewrite Print all transactions, rewriting the postings of matched transactions. - For now the only rewrite available is adding new postings, like print + For now the only rewrite available is adding new postings, like print --auto. This is a start at a generic rewriter of transaction entries. It reads - the default journal and prints the transactions, like print, but adds + the default journal and prints the transactions, like print, but adds one or more specified postings to any transactions matching QUERY. The - posting amounts can be fixed, or a multiplier of the existing transac- + posting amounts can be fixed, or a multiplier of the existing transac- tion's first posting amount. Examples: @@ -3402,7 +3479,7 @@ COMMANDS (reserve:grocery) *0.25 ; reserve 25% for grocery (reserve:) *0.25 ; reserve 25% for grocery - Note the single quotes to protect the dollar sign from bash, and the + Note the single quotes to protect the dollar sign from bash, and the two spaces between account and amount. More: @@ -3412,16 +3489,16 @@ COMMANDS $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"' $ hledger rewrite -- ^income --add-posting '(budget:foreign currency) *0.25 JPY; diversify' - Argument for --add-posting option is a usual posting of transaction - with an exception for amount specification. More precisely, you can + Argument for --add-posting option is a usual posting of transaction + with an exception for amount specification. More precisely, you can use '*' (star symbol) before the amount to indicate that that this is a - factor for an amount of original matched posting. If the amount - includes a commodity name, the new posting amount will be in the new - commodity; otherwise, it will be in the matched posting amount's com- + factor for an amount of original matched posting. If the amount + includes a commodity name, the new posting amount will be in the new + commodity; otherwise, it will be in the matched posting amount's com- modity. Re-write rules in a file - During the run this tool will execute so called "Automated Transac- + During the run this tool will execute so called "Automated Transac- tions" found in any journal it process. I.e instead of specifying this operations in command line you can put them in a journal file. @@ -3436,7 +3513,7 @@ COMMANDS budget:gifts *-1 assets:budget *1 - Note that '=' (equality symbol) that is used instead of date in trans- + Note that '=' (equality symbol) that is used instead of date in trans- actions you usually write. It indicates the query by which you want to match the posting to add new ones. @@ -3449,12 +3526,12 @@ COMMANDS --add-posting 'assets:budget *1' \ > rewritten-tidy-output.journal - It is important to understand that relative order of such entries in - journal is important. You can re-use result of previously added post- + It is important to understand that relative order of such entries in + journal is important. You can re-use result of previously added post- ings. Diff output format - To use this tool for batch modification of your journal files you may + To use this tool for batch modification of your journal files you may find useful output in form of unified diff. $ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax) *.33' @@ -3478,10 +3555,10 @@ COMMANDS If you'll pass this through patch tool you'll get transactions contain- ing the posting that matches your query be updated. Note that multiple - files might be update according to list of input files specified via + files might be update according to list of input files specified via --file options and include directives inside of these files. - Be careful. Whole transaction being re-formatted in a style of output + Be careful. Whole transaction being re-formatted in a style of output from hledger print. See also: @@ -3489,59 +3566,73 @@ COMMANDS https://github.com/simonmichael/hledger/issues/99 rewrite vs. print --auto - This command predates print --auto, and currently does much the same + This command predates print --auto, and currently does much the same thing, but with these differences: - o with multiple files, rewrite lets rules in any file affect all other - files. print --auto uses standard directive scoping; rules affect + o with multiple files, rewrite lets rules in any file affect all other + files. print --auto uses standard directive scoping; rules affect only child files. - o rewrite's query limits which transactions can be rewritten; all are + o rewrite's query limits which transactions can be rewritten; all are printed. print --auto's query limits which transactions are printed. - o rewrite applies rules specified on command line or in the journal. + o rewrite applies rules specified on command line or in the journal. print --auto applies rules specified in the journal. roi roi - Shows the time-weighted (TWR) and money-weighted (IRR) rate of return + Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on your investments. - At a minimum, you need to supply a query (which could be just an - account name) to select your investment(s) with --inv, and another + At a minimum, you need to supply a query (which could be just an + account name) to select your investment(s) with --inv, and another query to identify your profit and loss transactions with --pnl. - If you do not record changes in the value of your investment manually, - or do not require computation of time-weighted return (TWR), --pnl + If you do not record changes in the value of your investment manually, + or do not require computation of time-weighted return (TWR), --pnl could be an empty query (--pnl "" or --pnl STR where STR does not match any of your accounts). - This command will compute and display the internalized rate of return - (IRR) and time-weighted rate of return (TWR) for your investments for - the time period requested. Both rates of return are annualized before + This command will compute and display the internalized rate of return + (IRR) and time-weighted rate of return (TWR) for your investments for + the time period requested. Both rates of return are annualized before display, regardless of the length of reporting interval. - Price directives will be taken into account if you supply appropriate + Price directives will be taken into account if you supply appropriate --cost or --value flags (see VALUATION). Note, in some cases this report can fail, for these reasons: - o Error (NotBracketed): No solution for Internal Rate of Return (IRR). - Possible causes: IRR is huge (>1000000%), balance of investment + o Error (NotBracketed): No solution for Internal Rate of Return (IRR). + Possible causes: IRR is huge (>1000000%), balance of investment becomes negative at some point in time. - o Error (SearchFailed): Failed to find solution for Internal Rate of + o Error (SearchFailed): Failed to find solution for Internal Rate of Return (IRR). Either search does not converge to a solution, or con- verges too slowly. Examples: - o Using roi to compute total return of investment in stocks: + o Using roi to compute total return of investment in stocks: https://github.com/simonmichael/hledger/blob/master/examples/roi- unrealised.ledger o Cookbook -> Return on Investment + Spaces and special characters in --inv and --pnl + Note that --inv and --pnl's argument is a query, and queries could have + several space-separated terms (see QUERIES). + + To indicate that all search terms form single command-line argument, + you will need to put them in quotes (see Special characters): + + $ hledger roi --inv 'term1 term2 term3 ...' + + If any query terms contain spaces themselves, you will need an extra + level of nested quoting, eg: + + $ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'" + Semantics of --inv and --pnl Query supplied to --inv has to match all transactions that are related to your investment. Transactions not matching --inv will be ignored. @@ -4502,10 +4593,6 @@ JOURNAL FORMAT aliases until end of cur- rent file or end directive - - - - apply end apply prepend a common parent to following entries account account account names until end of cur- rent file or end @@ -4514,6 +4601,13 @@ JOURNAL FORMAT ment until end of cur- rent file or end directive + + + + + + + commod- format declare a commodity and its number notation: ity number notation & display following entries style until end of cur-