From 152b20413ccac6809b1f52fcdfb81ba872b494f2 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 29 May 2024 14:45:29 -1000 Subject: [PATCH] doc: update manuals --- hledger-lib/.date.m4 | 2 +- hledger-ui/.date.m4 | 2 +- hledger-ui/hledger-ui.1 | 258 +- hledger-ui/hledger-ui.info | 388 +- hledger-ui/hledger-ui.txt | 248 +- hledger-web/.date.m4 | 2 +- hledger-web/hledger-web.1 | 276 +- hledger-web/hledger-web.info | 292 +- hledger-web/hledger-web.txt | 232 +- hledger/.date.m4 | 2 +- hledger/hledger.1 | 3647 ++++++++-------- hledger/hledger.info | 7591 +++++++++++++++++----------------- hledger/hledger.txt | 5585 +++++++++++++------------ 13 files changed, 8970 insertions(+), 9555 deletions(-) diff --git a/hledger-lib/.date.m4 b/hledger-lib/.date.m4 index 1506ce24f..4e27a7647 100644 --- a/hledger-lib/.date.m4 +++ b/hledger-lib/.date.m4 @@ -1,2 +1,2 @@ m4_dnl Date to show in man pages. Updated by "Shake manuals" -m4_define({{_monthyear_}}, {{April 2024}})m4_dnl +m4_define({{_monthyear_}}, {{May 2024}})m4_dnl diff --git a/hledger-ui/.date.m4 b/hledger-ui/.date.m4 index 1506ce24f..4e27a7647 100644 --- a/hledger-ui/.date.m4 +++ b/hledger-ui/.date.m4 @@ -1,2 +1,2 @@ m4_dnl Date to show in man pages. Updated by "Shake manuals" -m4_define({{_monthyear_}}, {{April 2024}})m4_dnl +m4_define({{_monthyear_}}, {{May 2024}})m4_dnl diff --git a/hledger-ui/hledger-ui.1 b/hledger-ui/hledger-ui.1 index 885cde5e8..06514c595 100644 --- a/hledger-ui/hledger-ui.1 +++ b/hledger-ui/hledger-ui.1 @@ -1,5 +1,5 @@ -.TH "HLEDGER\-UI" "1" "April 2024" "hledger-ui-1.33.99 " "hledger User Manuals" +.TH "HLEDGER\-UI" "1" "May 2024" "hledger-ui-1.33.99 " "hledger User Manuals" @@ -81,163 +81,89 @@ show accounts as a tree .PP hledger\-ui also supports many of hledger\[aq]s general options (and the hledger manual\[aq]s command line tips also apply here): -.SS General help options -.TP -\f[CR]\-h \-\-help\f[R] -show general or COMMAND help -.TP -\f[CR]\-\-man\f[R] -show general or COMMAND user manual with man -.TP -\f[CR]\-\-info\f[R] -show general or COMMAND user manual with info -.TP -\f[CR]\-\-version\f[R] -show general or ADDONCMD version -.TP -\f[CR]\-\-debug[=N]\f[R] -show debug output (levels 1\-9, default: 1) -.SS General input options -.TP -\f[CR]\-f FILE \-\-file=FILE\f[R] -use a different input file. -For stdin, use \- (default: \f[CR]$LEDGER_FILE\f[R] or -\f[CR]$HOME/.hledger.journal\f[R]) -.TP -\f[CR]\-\-rules\-file=RULESFILE\f[R] -Conversion rules file to use when reading CSV (default: FILE.rules) -.TP -\f[CR]\-\-separator=CHAR\f[R] -Field separator to expect when reading CSV (default: \[aq],\[aq]) -.TP -\f[CR]\-\-alias=OLD=NEW\f[R] -rename accounts named OLD to NEW -.TP -\f[CR]\-\-pivot FIELDNAME\f[R] -use some other field or tag for the account name -.TP -\f[CR]\-I \-\-ignore\-assertions\f[R] -disable balance assertion checks (note: does not disable balance -assignments) -.TP -\f[CR]\-s \-\-strict\f[R] -do extra error checking (check that all posted accounts are declared) -.SS General reporting options -.TP -\f[CR]\-b \-\-begin=DATE\f[R] -include postings/txns on or after this date (will be adjusted to -preceding subperiod start when using a report interval) -.TP -\f[CR]\-e \-\-end=DATE\f[R] -include postings/txns before this date (will be adjusted to following -subperiod end when using a report interval) -.TP -\f[CR]\-D \-\-daily\f[R] -multiperiod/multicolumn report by day -.TP -\f[CR]\-W \-\-weekly\f[R] -multiperiod/multicolumn report by week -.TP -\f[CR]\-M \-\-monthly\f[R] -multiperiod/multicolumn report by month -.TP -\f[CR]\-Q \-\-quarterly\f[R] -multiperiod/multicolumn report by quarter -.TP -\f[CR]\-Y \-\-yearly\f[R] -multiperiod/multicolumn report by year -.TP -\f[CR]\-p \-\-period=PERIODEXP\f[R] -set start date, end date, and/or reporting interval all at once using -period expressions syntax -.TP -\f[CR]\-\-date2\f[R] -match the secondary date instead (see command help for other effects) -.TP -\f[CR]\-\-today=DATE\f[R] -override today\[aq]s date (affects relative smart dates, for -tests/examples) -.TP -\f[CR]\-U \-\-unmarked\f[R] -include only unmarked postings/txns (can combine with \-P or \-C) -.TP -\f[CR]\-P \-\-pending\f[R] -include only pending postings/txns -.TP -\f[CR]\-C \-\-cleared\f[R] -include only cleared postings/txns -.TP -\f[CR]\-R \-\-real\f[R] -include only non\-virtual postings -.TP -\f[CR]\-NUM \-\-depth=NUM\f[R] -hide/aggregate accounts or postings more than NUM levels deep -.TP -\f[CR]\-E \-\-empty\f[R] -show items with zero amount, normally hidden (and vice\-versa in -hledger\-ui/hledger\-web) -.TP -\f[CR]\-B \-\-cost\f[R] -convert amounts to their cost/selling amount at transaction time -.TP -\f[CR]\-V \-\-market\f[R] -convert amounts to their market value in default valuation commodities -.TP -\f[CR]\-X \-\-exchange=COMM\f[R] -convert amounts to their market value in commodity COMM -.TP -\f[CR]\-\-value\f[R] -convert amounts to cost or market value, more flexibly than \-B/\-V/\-X -.TP -\f[CR]\-\-infer\-equity\f[R] -infer conversion equity postings from costs -.TP -\f[CR]\-\-infer\-costs\f[R] -infer costs from conversion equity postings -.TP -\f[CR]\-\-infer\-market\-prices\f[R] -use costs as additional market prices, as if they were P directives -.TP -\f[CR]\-\-forecast\f[R] -generate transactions from periodic rules, -between the latest recorded txn and 6 months from today, -or during the specified PERIOD (= is required). -Auto posting rules will be applied to these transactions as well. -Also, in hledger\-ui make future\-dated transactions visible. -.TP -\f[CR]\-\-auto\f[R] -generate extra postings by applying auto posting rules to all txns (not -just forecast txns) -.TP -\f[CR]\-\-verbose\-tags\f[R] -add visible tags indicating transactions or postings which have been -generated/modified -.TP -\f[CR]\-\-commodity\-style\f[R] -Override the commodity style in the output for the specified commodity. -For example \[aq]EUR1.000,00\[aq]. -.TP -\f[CR]\-\-color=WHEN (or \-\-colour=WHEN)\f[R] -Should color\-supporting commands use ANSI color codes in text output. -\[aq]auto\[aq] (default): whenever stdout seems to be a -color\-supporting terminal. -\[aq]always\[aq] or \[aq]yes\[aq]: always, useful eg when piping output -into \[aq]less \-R\[aq]. -\[aq]never\[aq] or \[aq]no\[aq]: never. -A NO_COLOR environment variable overrides this. -.TP -\f[CR]\-\-pretty[=WHEN]\f[R] -Show prettier output, e.g. -using unicode box\-drawing characters. -Accepts \[aq]yes\[aq] (the default) or \[aq]no\[aq] (\[aq]y\[aq], -\[aq]n\[aq], \[aq]always\[aq], \[aq]never\[aq] also work). -If you provide an argument you must use \[aq]=\[aq], e.g. -\[aq]\-\-pretty=yes\[aq]. -.PP -When a reporting option appears more than once in the command line, the -last one takes precedence. -.PP -Some reporting options can also be written as query arguments. +.SS General options +.IP +.EX +General input/data transformation flags: + \-f \-\-file=FILE Read data from FILE, or from stdin if \-. Can be + specified more than once. If not specified, reads + from $LEDGER_FILE or $HOME/.hledger.journal. + \-\-rules\-file=RULEFILE Use conversion rules from this file for + converting subsequent CSV/SSV/TSV files. If not + specified, uses FILE.rules for each such FILE. + \-\-alias=A=B|/RGX/=RPL transform account names from A to B, or by + replacing regular expression matches + \-\-auto generate extra postings by applying auto posting + rules (\[dq]=\[dq]) to all transactions + \-\-forecast[=PERIOD] Generate extra transactions from periodic rules + (\[dq]\[ti]\[dq]), from after the latest ordinary transaction + until 6 months from now. Or, during the specified + PERIOD (the equals is required). Auto posting rules + will also be applied to these transactions. In + hledger\-ui, also make future\-dated transactions + visible at startup. + \-I \-\-ignore\-assertions don\[aq]t check balance assertions by default + \-\-infer\-costs infer conversion equity postings from costs + \-\-infer\-equity infer costs from conversion equity postings + \-\-infer\-market\-prices infer market prices from costs + \-\-pivot=TAGNAME use a different field or tag as account names + \-s \-\-strict do extra error checks (and override \-I) + \-\-verbose\-tags add tags indicating generated/modified data + +General output/reporting flags (supported by some commands): + \-b \-\-begin=DATE include postings/transactions on/after this date + \-e \-\-end=DATE include postings/transactions before this date + (with a report interval, will be adjusted to + following subperiod end) + \-D \-\-daily multiperiod report with 1 day interval + \-W \-\-weekly multiperiod report with 1 week interval + \-M \-\-monthly multiperiod report with 1 month interval + \-Q \-\-quarterly multiperiod report with 1 quarter interval + \-Y \-\-yearly multiperiod report with 1 year interval + \-p \-\-period=PERIODEXP set begin date, end date, and/or report interval, + with more flexibility + \-\-today=DATE override today\[aq]s date (affects relative dates) + \-\-date2 match/use secondary dates instead (deprecated) + \-U \-\-unmarked include only unmarked postings/transactions + \-P \-\-pending include only pending postings/transactions + \-C \-\-cleared include only cleared postings/transactions + (\-U/\-P/\-C can be combined) + \-R \-\-real include only non\-virtual postings + \-\-depth=NUM or \-NUM: show only top NUM levels of accounts + \-E \-\-empty Show zero items, which are normally hidden. + In hledger\-ui & hledger\-web, do the opposite. + \-B \-\-cost show amounts converted to their cost/sale amount + \-V \-\-market Show amounts converted to their value at period + end(s) in their default valuation commodity. + Equivalent to \-\-value=end. + \-X \-\-exchange=COMM Show amounts converted to their value at period + end(s) in the specified commodity. + Equivalent to \-\-value=end,COMM. + \-\-value=WHEN[,COMM] show amounts converted to their value on the + specified date(s) in their default valuation + commodity or a specified commodity. WHEN can be: + \[aq]then\[aq]: value on transaction dates + \[aq]end\[aq]: value at period end(s) + \[aq]now\[aq]: value today + YYYY\-MM\-DD: value on given date + \-c \-\-commodity\-style=S Override a commodity\[aq]s display style. + Eg: \-c \[aq].\[aq] or \-c \[aq]1.000,00 EUR\[aq] + \-\-color=YN \-\-colour Use ANSI color codes in text output? Can be: + \[aq]yes\[aq] or \[aq]always\[aq], + \[aq]no\[aq] or \[aq]never\[aq] (a NO_COLOR env var forces this), + \[aq]auto\[aq] (the default: when using a color terminal). + \-\-pretty[=YN] Use box\-drawing characters in text output? Can be + \[aq]yes\[aq] (the default argument for \-\-pretty) or \[aq]no\[aq]. + If YN is specified, the equals is required. + \-\-debug=[N] show debug output (levels 1\-9, default: 1) + +General help flags: + \-h \-\-help show command line help + \-\-tldr show command examples with tldr + \-\-info show the hledger manual with info + \-\-man show the hledger manual with man + \-\-version show version information +.EE .SH MOUSE In most modern terminals, you can navigate through the screens with a mouse or touchpad: @@ -375,32 +301,32 @@ Or you can use \f[CR]ESC\f[R] to return directly to the top menu screen. You can also use a command line flag to specific a different startup screen (\f[CR]\-\-cs\f[R], \f[CR]\-\-bs\f[R], \f[CR]\-\-is\f[R], \f[CR]\-\-all\f[R], or \f[CR]\-\-register=ACCT\f[R]). -.SS Menu +.SS Menu screen This is the top\-most screen. From here you can navigate to several screens listing accounts of various types. Note some of these may not show anything until you have configured account types. -.SS Cash accounts +.SS Cash accounts screen This screen shows \[dq]cash\[dq] (ie, liquid asset) accounts (like \f[CR]hledger balancesheet type:c\f[R]). It always shows balances (historical ending balances on the date shown in the title line). -.SS Balance sheet accounts +.SS Balance sheet accounts screen This screen shows asset, liability and equity accounts (like \f[CR]hledger balancesheetequity\f[R]). It always shows balances. -.SS Income statement accounts +.SS Income statement accounts screen This screen shows revenue and expense accounts (like \f[CR]hledger incomestatement\f[R]). It always shows changes (balance changes in the period shown in the title line). -.SS All accounts +.SS All accounts screen This screen shows all accounts in your journal (unless filtered by a query; like \f[CR]hledger balance\f[R]). It shows balances by default; you can toggle showing changes with the \f[CR]H\f[R] key. -.SS Register +.SS Register screen This screen shows the transactions affecting a particular account. Each line represents one transaction, and shows: .IP \[bu] 2 @@ -454,7 +380,7 @@ nonzero change are shown (hledger\-ui shows zero items by default, unlike command\-line hledger). .PP Press \f[CR]RIGHT\f[R] to view the selected transaction in detail. -.SS Transaction +.SS Transaction screen This screen shows a single transaction, as a general journal entry, similar to hledger\[aq]s print command and journal format (hledger_journal(5)). @@ -485,7 +411,7 @@ must: \- press \f[CR]E\f[R], edit and save the file, then exit the editor, returning to hledger\-ui \- press \f[CR]g\f[R] to reload the file (or use \f[CR]\-w/\-\-watch\f[R] mode) \- press \f[CR]LEFT\f[R] then \f[CR]RIGHT\f[R] to exit and re\-enter the transaction screen. -.SS Error +.SS 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 again to reload and resume diff --git a/hledger-ui/hledger-ui.info b/hledger-ui/hledger-ui.info index 4acbc7aff..638e8f8de 100644 --- a/hledger-ui/hledger-ui.info +++ b/hledger-ui/hledger-ui.info @@ -103,183 +103,93 @@ hledger manual's command line tips also apply here): * Menu: -* General help options:: -* General input options:: -* General reporting options:: +* General options::  -File: hledger-ui.info, Node: General help options, Next: General input options, Up: OPTIONS +File: hledger-ui.info, Node: General options, Up: OPTIONS -1.1 General help options -======================== +1.1 General options +=================== -'-h --help' +General input/data transformation flags: + -f --file=FILE Read data from FILE, or from stdin if -. Can be + specified more than once. If not specified, reads + from $LEDGER_FILE or $HOME/.hledger.journal. + --rules-file=RULEFILE Use conversion rules from this file for + converting subsequent CSV/SSV/TSV files. If not + specified, uses FILE.rules for each such FILE. + --alias=A=B|/RGX/=RPL transform account names from A to B, or by + replacing regular expression matches + --auto generate extra postings by applying auto posting + rules ("=") to all transactions + --forecast[=PERIOD] Generate extra transactions from periodic rules + ("~"), from after the latest ordinary transaction + until 6 months from now. Or, during the specified + PERIOD (the equals is required). Auto posting rules + will also be applied to these transactions. In + hledger-ui, also make future-dated transactions + visible at startup. + -I --ignore-assertions don't check balance assertions by default + --infer-costs infer conversion equity postings from costs + --infer-equity infer costs from conversion equity postings + --infer-market-prices infer market prices from costs + --pivot=TAGNAME use a different field or tag as account names + -s --strict do extra error checks (and override -I) + --verbose-tags add tags indicating generated/modified data - show general or COMMAND help -'--man' +General output/reporting flags (supported by some commands): + -b --begin=DATE include postings/transactions on/after this date + -e --end=DATE include postings/transactions before this date + (with a report interval, will be adjusted to + following subperiod end) + -D --daily multiperiod report with 1 day interval + -W --weekly multiperiod report with 1 week interval + -M --monthly multiperiod report with 1 month interval + -Q --quarterly multiperiod report with 1 quarter interval + -Y --yearly multiperiod report with 1 year interval + -p --period=PERIODEXP set begin date, end date, and/or report interval, + with more flexibility + --today=DATE override today's date (affects relative dates) + --date2 match/use secondary dates instead (deprecated) + -U --unmarked include only unmarked postings/transactions + -P --pending include only pending postings/transactions + -C --cleared include only cleared postings/transactions + (-U/-P/-C can be combined) + -R --real include only non-virtual postings + --depth=NUM or -NUM: show only top NUM levels of accounts + -E --empty Show zero items, which are normally hidden. + In hledger-ui & hledger-web, do the opposite. + -B --cost show amounts converted to their cost/sale amount + -V --market Show amounts converted to their value at period + end(s) in their default valuation commodity. + Equivalent to --value=end. + -X --exchange=COMM Show amounts converted to their value at period + end(s) in the specified commodity. + Equivalent to --value=end,COMM. + --value=WHEN[,COMM] show amounts converted to their value on the + specified date(s) in their default valuation + commodity or a specified commodity. WHEN can be: + 'then': value on transaction dates + 'end': value at period end(s) + 'now': value today + YYYY-MM-DD: value on given date + -c --commodity-style=S Override a commodity's display style. + Eg: -c '.' or -c '1.000,00 EUR' + --color=YN --colour Use ANSI color codes in text output? Can be: + 'yes' or 'always', + 'no' or 'never' (a NO_COLOR env var forces this), + 'auto' (the default: when using a color terminal). + --pretty[=YN] Use box-drawing characters in text output? Can be + 'yes' (the default argument for --pretty) or 'no'. + If YN is specified, the equals is required. + --debug=[N] show debug output (levels 1-9, default: 1) - show general or COMMAND user manual with man -'--info' - - show general or COMMAND user manual with info -'--version' - - show general or ADDONCMD version -'--debug[=N]' - - show debug output (levels 1-9, default: 1) - - -File: hledger-ui.info, Node: General input options, Next: General reporting options, Prev: General help options, Up: OPTIONS - -1.2 General input options -========================= - -'-f FILE --file=FILE' - - use a different input file. For stdin, use - (default: - '$LEDGER_FILE' or '$HOME/.hledger.journal') -'--rules-file=RULESFILE' - - Conversion rules file to use when reading CSV (default: FILE.rules) -'--separator=CHAR' - - Field separator to expect when reading CSV (default: ',') -'--alias=OLD=NEW' - - rename accounts named OLD to NEW -'--pivot FIELDNAME' - - use some other field or tag for the account name -'-I --ignore-assertions' - - disable balance assertion checks (note: does not disable balance - assignments) -'-s --strict' - - do extra error checking (check that all posted accounts are - declared) - - -File: hledger-ui.info, Node: General reporting options, Prev: General input options, Up: OPTIONS - -1.3 General reporting options -============================= - -'-b --begin=DATE' - - include postings/txns on or after this date (will be adjusted to - preceding subperiod start when using a report interval) -'-e --end=DATE' - - include postings/txns before this date (will be adjusted to - following subperiod end when using a report interval) -'-D --daily' - - multiperiod/multicolumn report by day -'-W --weekly' - - multiperiod/multicolumn report by week -'-M --monthly' - - multiperiod/multicolumn report by month -'-Q --quarterly' - - multiperiod/multicolumn report by quarter -'-Y --yearly' - - multiperiod/multicolumn report by year -'-p --period=PERIODEXP' - - set start date, end date, and/or reporting interval all at once - using period expressions syntax -'--date2' - - match the secondary date instead (see command help for other - effects) -'--today=DATE' - - override today's date (affects relative smart dates, for - tests/examples) -'-U --unmarked' - - include only unmarked postings/txns (can combine with -P or -C) -'-P --pending' - - include only pending postings/txns -'-C --cleared' - - include only cleared postings/txns -'-R --real' - - include only non-virtual postings -'-NUM --depth=NUM' - - hide/aggregate accounts or postings more than NUM levels deep -'-E --empty' - - show items with zero amount, normally hidden (and vice-versa in - hledger-ui/hledger-web) -'-B --cost' - - convert amounts to their cost/selling amount at transaction time -'-V --market' - - convert amounts to their market value in default valuation - commodities -'-X --exchange=COMM' - - convert amounts to their market value in commodity COMM -'--value' - - convert amounts to cost or market value, more flexibly than - -B/-V/-X -'--infer-equity' - - infer conversion equity postings from costs -'--infer-costs' - - infer costs from conversion equity postings -'--infer-market-prices' - - use costs as additional market prices, as if they were P directives -'--forecast' - - generate transactions from periodic rules, between the latest - recorded txn and 6 months from today, or during the specified - PERIOD (= is required). Auto posting rules will be applied to - these transactions as well. Also, in hledger-ui make future-dated - transactions visible. -'--auto' - - generate extra postings by applying auto posting rules to all txns - (not just forecast txns) -'--verbose-tags' - - add visible tags indicating transactions or postings which have - been generated/modified -'--commodity-style' - - Override the commodity style in the output for the specified - commodity. For example 'EUR1.000,00'. -'--color=WHEN (or --colour=WHEN)' - - Should color-supporting commands use ANSI color codes in text - output. 'auto' (default): whenever stdout seems to be a - color-supporting terminal. 'always' or 'yes': always, useful eg - when piping output into 'less -R'. 'never' or 'no': never. A - NO_COLOR environment variable overrides this. -'--pretty[=WHEN]' - - Show prettier output, e.g. using unicode box-drawing characters. - Accepts 'yes' (the default) or 'no' ('y', 'n', 'always', 'never' - also work). If you provide an argument you must use '=', e.g. - '-pretty=yes'. - - When a reporting option appears more than once in the command line, -the last one takes precedence. - - Some reporting options can also be written as query arguments. +General help flags: + -h --help show command line help + --tldr show command examples with tldr + --info show the hledger manual with info + --man show the hledger manual with man + --version show version information  File: hledger-ui.info, Node: MOUSE, Next: KEYS, Prev: OPTIONS, Up: Top @@ -415,69 +325,69 @@ screen ('--cs', '--bs', '--is', '--all', or '--register=ACCT'). * Menu: -* Menu:: -* Cash accounts:: -* Balance sheet accounts:: -* Income statement accounts:: -* All accounts:: -* Register:: -* Transaction:: -* Error:: +* Menu screen:: +* Cash accounts screen:: +* Balance sheet accounts screen:: +* Income statement accounts screen:: +* All accounts screen:: +* Register screen:: +* Transaction screen:: +* Error screen::  -File: hledger-ui.info, Node: Menu, Next: Cash accounts, Up: SCREENS +File: hledger-ui.info, Node: Menu screen, Next: Cash accounts screen, Up: SCREENS -4.1 Menu -======== +4.1 Menu screen +=============== This is the top-most screen. From here you can navigate to several screens listing accounts of various types. Note some of these may not show anything until you have configured account types.  -File: hledger-ui.info, Node: Cash accounts, Next: Balance sheet accounts, Prev: Menu, Up: SCREENS +File: hledger-ui.info, Node: Cash accounts screen, Next: Balance sheet accounts screen, Prev: Menu screen, Up: SCREENS -4.2 Cash accounts -================= +4.2 Cash accounts screen +======================== This screen shows "cash" (ie, liquid asset) accounts (like 'hledger balancesheet type:c'). It always shows balances (historical ending balances on the date shown in the title line).  -File: hledger-ui.info, Node: Balance sheet accounts, Next: Income statement accounts, Prev: Cash accounts, Up: SCREENS +File: hledger-ui.info, Node: Balance sheet accounts screen, Next: Income statement accounts screen, Prev: Cash accounts screen, Up: SCREENS -4.3 Balance sheet accounts -========================== +4.3 Balance sheet accounts screen +================================= This screen shows asset, liability and equity accounts (like 'hledger balancesheetequity'). It always shows balances.  -File: hledger-ui.info, Node: Income statement accounts, Next: All accounts, Prev: Balance sheet accounts, Up: SCREENS +File: hledger-ui.info, Node: Income statement accounts screen, Next: All accounts screen, Prev: Balance sheet accounts screen, Up: SCREENS -4.4 Income statement accounts -============================= +4.4 Income statement accounts screen +==================================== This screen shows revenue and expense accounts (like 'hledger incomestatement'). It always shows changes (balance changes in the period shown in the title line).  -File: hledger-ui.info, Node: All accounts, Next: Register, Prev: Income statement accounts, Up: SCREENS +File: hledger-ui.info, Node: All accounts screen, Next: Register screen, Prev: Income statement accounts screen, Up: SCREENS -4.5 All accounts -================ +4.5 All accounts screen +======================= This screen shows all accounts in your journal (unless filtered by a query; like 'hledger balance'). It shows balances by default; you can toggle showing changes with the 'H' key.  -File: hledger-ui.info, Node: Register, Next: Transaction, Prev: All accounts, Up: SCREENS +File: hledger-ui.info, Node: Register screen, Next: Transaction screen, Prev: All accounts screen, Up: SCREENS -4.6 Register -============ +4.6 Register screen +=================== This screen shows the transactions affecting a particular account. Each line represents one transaction, and shows: @@ -529,10 +439,10 @@ command-line hledger). Press 'RIGHT' to view the selected transaction in detail.  -File: hledger-ui.info, Node: Transaction, Next: Error, Prev: Register, Up: SCREENS +File: hledger-ui.info, Node: Transaction screen, Next: Error screen, Prev: Register screen, Up: SCREENS -4.7 Transaction -=============== +4.7 Transaction screen +====================== This screen shows a single transaction, as a general journal entry, similar to hledger's print command and journal format @@ -564,10 +474,10 @@ reload the file (or use '-w/--watch' mode) - press 'LEFT' then 'RIGHT' to exit and re-enter the transaction screen.  -File: hledger-ui.info, Node: Error, Prev: Transaction, Up: SCREENS +File: hledger-ui.info, Node: Error screen, Prev: Transaction screen, Up: SCREENS -4.8 Error -========= +4.8 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 @@ -673,44 +583,40 @@ Tag Table: Node: Top221 Node: OPTIONS1830 Ref: #options1928 -Node: General help options2956 -Ref: #general-help-options3105 -Node: General input options3387 -Ref: #general-input-options3572 -Node: General reporting options4229 -Ref: #general-reporting-options4393 -Node: MOUSE7783 -Ref: #mouse7878 -Node: KEYS8115 -Ref: #keys8208 -Node: SCREENS12863 -Ref: #screens12961 -Node: Menu13541 -Ref: #menu13634 -Node: Cash accounts13829 -Ref: #cash-accounts13971 -Node: Balance sheet accounts14155 -Ref: #balance-sheet-accounts14336 -Node: Income statement accounts14456 -Ref: #income-statement-accounts14642 -Node: All accounts14806 -Ref: #all-accounts14952 -Node: Register15134 -Ref: #register15258 -Node: Transaction17542 -Ref: #transaction17665 -Node: Error19082 -Ref: #error19176 -Node: TIPS19420 -Ref: #tips19519 -Node: Watch mode19561 -Ref: #watch-mode19668 -Node: Debug output21127 -Ref: #debug-output21238 -Node: ENVIRONMENT21450 -Ref: #environment21560 -Node: BUGS21751 -Ref: #bugs21834 +Node: General options2895 +Ref: #general-options2999 +Node: MOUSE8226 +Ref: #mouse8321 +Node: KEYS8558 +Ref: #keys8651 +Node: SCREENS13306 +Ref: #screens13404 +Node: Menu screen14040 +Ref: #menu-screen14161 +Node: Cash accounts screen14356 +Ref: #cash-accounts-screen14533 +Node: Balance sheet accounts screen14717 +Ref: #balance-sheet-accounts-screen14933 +Node: Income statement accounts screen15053 +Ref: #income-statement-accounts-screen15274 +Node: All accounts screen15438 +Ref: #all-accounts-screen15619 +Node: Register screen15801 +Ref: #register-screen15960 +Node: Transaction screen18244 +Ref: #transaction-screen18402 +Node: Error screen19819 +Ref: #error-screen19941 +Node: TIPS20185 +Ref: #tips20284 +Node: Watch mode20326 +Ref: #watch-mode20433 +Node: Debug output21892 +Ref: #debug-output22003 +Node: ENVIRONMENT22215 +Ref: #environment22325 +Node: BUGS22516 +Ref: #bugs22599  End Tag Table diff --git a/hledger-ui/hledger-ui.txt b/hledger-ui/hledger-ui.txt index 2242f7ca6..faaf5a44a 100644 --- a/hledger-ui/hledger-ui.txt +++ b/hledger-ui/hledger-ui.txt @@ -73,160 +73,86 @@ OPTIONS hledger-ui also supports many of hledger's general options (and the hledger manual's command line tips also apply here): - General help options - -h --help - show general or COMMAND help + General options + General input/data transformation flags: + -f --file=FILE Read data from FILE, or from stdin if -. Can be + specified more than once. If not specified, reads + from $LEDGER_FILE or $HOME/.hledger.journal. + --rules-file=RULEFILE Use conversion rules from this file for + converting subsequent CSV/SSV/TSV files. If not + specified, uses FILE.rules for each such FILE. + --alias=A=B|/RGX/=RPL transform account names from A to B, or by + replacing regular expression matches + --auto generate extra postings by applying auto posting + rules ("=") to all transactions + --forecast[=PERIOD] Generate extra transactions from periodic rules + ("~"), from after the latest ordinary transaction + until 6 months from now. Or, during the specified + PERIOD (the equals is required). Auto posting rules + will also be applied to these transactions. In + hledger-ui, also make future-dated transactions + visible at startup. + -I --ignore-assertions don't check balance assertions by default + --infer-costs infer conversion equity postings from costs + --infer-equity infer costs from conversion equity postings + --infer-market-prices infer market prices from costs + --pivot=TAGNAME use a different field or tag as account names + -s --strict do extra error checks (and override -I) + --verbose-tags add tags indicating generated/modified data - --man show general or COMMAND user manual with man + General output/reporting flags (supported by some commands): + -b --begin=DATE include postings/transactions on/after this date + -e --end=DATE include postings/transactions before this date + (with a report interval, will be adjusted to + following subperiod end) + -D --daily multiperiod report with 1 day interval + -W --weekly multiperiod report with 1 week interval + -M --monthly multiperiod report with 1 month interval + -Q --quarterly multiperiod report with 1 quarter interval + -Y --yearly multiperiod report with 1 year interval + -p --period=PERIODEXP set begin date, end date, and/or report interval, + with more flexibility + --today=DATE override today's date (affects relative dates) + --date2 match/use secondary dates instead (deprecated) + -U --unmarked include only unmarked postings/transactions + -P --pending include only pending postings/transactions + -C --cleared include only cleared postings/transactions + (-U/-P/-C can be combined) + -R --real include only non-virtual postings + --depth=NUM or -NUM: show only top NUM levels of accounts + -E --empty Show zero items, which are normally hidden. + In hledger-ui & hledger-web, do the opposite. + -B --cost show amounts converted to their cost/sale amount + -V --market Show amounts converted to their value at period + end(s) in their default valuation commodity. + Equivalent to --value=end. + -X --exchange=COMM Show amounts converted to their value at period + end(s) in the specified commodity. + Equivalent to --value=end,COMM. + --value=WHEN[,COMM] show amounts converted to their value on the + specified date(s) in their default valuation + commodity or a specified commodity. WHEN can be: + 'then': value on transaction dates + 'end': value at period end(s) + 'now': value today + YYYY-MM-DD: value on given date + -c --commodity-style=S Override a commodity's display style. + Eg: -c '.' or -c '1.000,00 EUR' + --color=YN --colour Use ANSI color codes in text output? Can be: + 'yes' or 'always', + 'no' or 'never' (a NO_COLOR env var forces this), + 'auto' (the default: when using a color terminal). + --pretty[=YN] Use box-drawing characters in text output? Can be + 'yes' (the default argument for --pretty) or 'no'. + If YN is specified, the equals is required. + --debug=[N] show debug output (levels 1-9, default: 1) - --info show general or COMMAND user manual with info - - --version - show general or ADDONCMD version - - --debug[=N] - show debug output (levels 1-9, default: 1) - - General input options - -f FILE --file=FILE - use a different input file. For stdin, use - (default: - $LEDGER_FILE or $HOME/.hledger.journal) - - --rules-file=RULESFILE - Conversion rules file to use when reading CSV (default: - FILE.rules) - - --separator=CHAR - Field separator to expect when reading CSV (default: ',') - - --alias=OLD=NEW - rename accounts named OLD to NEW - - --pivot FIELDNAME - use some other field or tag for the account name - - -I --ignore-assertions - disable balance assertion checks (note: does not disable balance - assignments) - - -s --strict - do extra error checking (check that all posted accounts are de- - clared) - - General reporting options - -b --begin=DATE - include postings/txns on or after this date (will be adjusted to - preceding subperiod start when using a report interval) - - -e --end=DATE - include postings/txns before this date (will be adjusted to fol- - lowing subperiod end when using a report interval) - - -D --daily - multiperiod/multicolumn report by day - - -W --weekly - multiperiod/multicolumn report by week - - -M --monthly - multiperiod/multicolumn report by month - - -Q --quarterly - multiperiod/multicolumn report by quarter - - -Y --yearly - multiperiod/multicolumn report by year - - -p --period=PERIODEXP - set start date, end date, and/or reporting interval all at once - using period expressions syntax - - --date2 - match the secondary date instead (see command help for other ef- - fects) - - --today=DATE - override today's date (affects relative smart dates, for - tests/examples) - - -U --unmarked - include only unmarked postings/txns (can combine with -P or -C) - - -P --pending - include only pending postings/txns - - -C --cleared - include only cleared postings/txns - - -R --real - include only non-virtual postings - - -NUM --depth=NUM - hide/aggregate accounts or postings more than NUM levels deep - - -E --empty - show items with zero amount, normally hidden (and vice-versa in - hledger-ui/hledger-web) - - -B --cost - convert amounts to their cost/selling amount at transaction time - - -V --market - convert amounts to their market value in default valuation com- - modities - - -X --exchange=COMM - convert amounts to their market value in commodity COMM - - --value - convert amounts to cost or market value, more flexibly than - -B/-V/-X - - --infer-equity - infer conversion equity postings from costs - - --infer-costs - infer costs from conversion equity postings - - --infer-market-prices - use costs as additional market prices, as if they were P direc- - tives - - --forecast - generate transactions from periodic rules, between the latest - recorded txn and 6 months from today, or during the specified - PERIOD (= is required). Auto posting rules will be applied to - these transactions as well. Also, in hledger-ui make fu- - ture-dated transactions visible. - - --auto generate extra postings by applying auto posting rules to all - txns (not just forecast txns) - - --verbose-tags - add visible tags indicating transactions or postings which have - been generated/modified - - --commodity-style - Override the commodity style in the output for the specified - commodity. For example 'EUR1.000,00'. - - --color=WHEN (or --colour=WHEN) - Should color-supporting commands use ANSI color codes in text - output. 'auto' (default): whenever stdout seems to be a - color-supporting terminal. 'always' or 'yes': always, useful eg - when piping output into 'less -R'. 'never' or 'no': never. A - NO_COLOR environment variable overrides this. - - --pretty[=WHEN] - Show prettier output, e.g. using unicode box-drawing charac- - ters. Accepts 'yes' (the default) or 'no' ('y', 'n', 'always', - 'never' also work). If you provide an argument you must use - '=', e.g. '--pretty=yes'. - - When a reporting option appears more than once in the command line, the - last one takes precedence. - - Some reporting options can also be written as query arguments. + General help flags: + -h --help show command line help + --tldr show command examples with tldr + --info show the hledger manual with info + --man show the hledger manual with man + --version show version information MOUSE In most modern terminals, you can navigate through the screens with a @@ -345,31 +271,31 @@ SCREENS You can also use a command line flag to specific a different startup screen (--cs, --bs, --is, --all, or --register=ACCT). - Menu + Menu screen This is the top-most screen. From here you can navigate to several screens listing accounts of various types. Note some of these may not show anything until you have configured account types. - Cash accounts + Cash accounts screen This screen shows "cash" (ie, liquid asset) accounts (like hledger bal- ancesheet type:c). It always shows balances (historical ending bal- ances on the date shown in the title line). - Balance sheet accounts + Balance sheet accounts screen This screen shows asset, liability and equity accounts (like hledger balancesheetequity). It always shows balances. - Income statement accounts + Income statement accounts screen This screen shows revenue and expense accounts (like hledger incomes- tatement). It always shows changes (balance changes in the period shown in the title line). - All accounts + All accounts screen This screen shows all accounts in your journal (unless filtered by a query; like hledger balance). It shows balances by default; you can toggle showing changes with the H key. - Register + Register screen This screen shows the transactions affecting a particular account. Each line represents one transaction, and shows: @@ -418,7 +344,7 @@ SCREENS Press RIGHT to view the selected transaction in detail. - Transaction + Transaction screen This screen shows a single transaction, as a general journal entry, similar to hledger's print command and journal format (hledger_jour- nal(5)). @@ -447,7 +373,7 @@ SCREENS file (or use -w/--watch mode) - press LEFT then RIGHT to exit and re-enter the transaction screen. - Error + 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 again to reload and resume normal operation. (Or, you can press escape @@ -535,4 +461,4 @@ LICENSE SEE ALSO hledger(1), hledger-ui(1), hledger-web(1), ledger(1) -hledger-ui-1.33.99 April 2024 HLEDGER-UI(1) +hledger-ui-1.33.99 May 2024 HLEDGER-UI(1) diff --git a/hledger-web/.date.m4 b/hledger-web/.date.m4 index 1506ce24f..4e27a7647 100644 --- a/hledger-web/.date.m4 +++ b/hledger-web/.date.m4 @@ -1,2 +1,2 @@ m4_dnl Date to show in man pages. Updated by "Shake manuals" -m4_define({{_monthyear_}}, {{April 2024}})m4_dnl +m4_define({{_monthyear_}}, {{May 2024}})m4_dnl diff --git a/hledger-web/hledger-web.1 b/hledger-web/hledger-web.1 index 58d2ddf72..9eb7ec29f 100644 --- a/hledger-web/hledger-web.1 +++ b/hledger-web/hledger-web.1 @@ -1,5 +1,5 @@ -.TH "HLEDGER\-WEB" "1" "April 2024" "hledger-web-1.33.99 " "hledger User Manuals" +.TH "HLEDGER\-WEB" "1" "May 2024" "hledger-web-1.33.99 " "hledger User Manuals" @@ -137,163 +137,89 @@ If you see accounts which appear to have a zero balance, but cannot be hidden with \f[CR]\-E\f[R]: these have a mixed\-cost balance which looks like zero when costs are hidden. Currently hledger\-web does not show costs at all. -.SS General help options -.TP -\f[CR]\-h \-\-help\f[R] -show general or COMMAND help -.TP -\f[CR]\-\-man\f[R] -show general or COMMAND user manual with man -.TP -\f[CR]\-\-info\f[R] -show general or COMMAND user manual with info -.TP -\f[CR]\-\-version\f[R] -show general or ADDONCMD version -.TP -\f[CR]\-\-debug[=N]\f[R] -show debug output (levels 1\-9, default: 1) -.SS General input options -.TP -\f[CR]\-f FILE \-\-file=FILE\f[R] -use a different input file. -For stdin, use \- (default: \f[CR]$LEDGER_FILE\f[R] or -\f[CR]$HOME/.hledger.journal\f[R]) -.TP -\f[CR]\-\-rules\-file=RULESFILE\f[R] -Conversion rules file to use when reading CSV (default: FILE.rules) -.TP -\f[CR]\-\-separator=CHAR\f[R] -Field separator to expect when reading CSV (default: \[aq],\[aq]) -.TP -\f[CR]\-\-alias=OLD=NEW\f[R] -rename accounts named OLD to NEW -.TP -\f[CR]\-\-pivot FIELDNAME\f[R] -use some other field or tag for the account name -.TP -\f[CR]\-I \-\-ignore\-assertions\f[R] -disable balance assertion checks (note: does not disable balance -assignments) -.TP -\f[CR]\-s \-\-strict\f[R] -do extra error checking (check that all posted accounts are declared) -.SS General reporting options -.TP -\f[CR]\-b \-\-begin=DATE\f[R] -include postings/txns on or after this date (will be adjusted to -preceding subperiod start when using a report interval) -.TP -\f[CR]\-e \-\-end=DATE\f[R] -include postings/txns before this date (will be adjusted to following -subperiod end when using a report interval) -.TP -\f[CR]\-D \-\-daily\f[R] -multiperiod/multicolumn report by day -.TP -\f[CR]\-W \-\-weekly\f[R] -multiperiod/multicolumn report by week -.TP -\f[CR]\-M \-\-monthly\f[R] -multiperiod/multicolumn report by month -.TP -\f[CR]\-Q \-\-quarterly\f[R] -multiperiod/multicolumn report by quarter -.TP -\f[CR]\-Y \-\-yearly\f[R] -multiperiod/multicolumn report by year -.TP -\f[CR]\-p \-\-period=PERIODEXP\f[R] -set start date, end date, and/or reporting interval all at once using -period expressions syntax -.TP -\f[CR]\-\-date2\f[R] -match the secondary date instead (see command help for other effects) -.TP -\f[CR]\-\-today=DATE\f[R] -override today\[aq]s date (affects relative smart dates, for -tests/examples) -.TP -\f[CR]\-U \-\-unmarked\f[R] -include only unmarked postings/txns (can combine with \-P or \-C) -.TP -\f[CR]\-P \-\-pending\f[R] -include only pending postings/txns -.TP -\f[CR]\-C \-\-cleared\f[R] -include only cleared postings/txns -.TP -\f[CR]\-R \-\-real\f[R] -include only non\-virtual postings -.TP -\f[CR]\-NUM \-\-depth=NUM\f[R] -hide/aggregate accounts or postings more than NUM levels deep -.TP -\f[CR]\-E \-\-empty\f[R] -show items with zero amount, normally hidden (and vice\-versa in -hledger\-ui/hledger\-web) -.TP -\f[CR]\-B \-\-cost\f[R] -convert amounts to their cost/selling amount at transaction time -.TP -\f[CR]\-V \-\-market\f[R] -convert amounts to their market value in default valuation commodities -.TP -\f[CR]\-X \-\-exchange=COMM\f[R] -convert amounts to their market value in commodity COMM -.TP -\f[CR]\-\-value\f[R] -convert amounts to cost or market value, more flexibly than \-B/\-V/\-X -.TP -\f[CR]\-\-infer\-equity\f[R] -infer conversion equity postings from costs -.TP -\f[CR]\-\-infer\-costs\f[R] -infer costs from conversion equity postings -.TP -\f[CR]\-\-infer\-market\-prices\f[R] -use costs as additional market prices, as if they were P directives -.TP -\f[CR]\-\-forecast\f[R] -generate transactions from periodic rules, -between the latest recorded txn and 6 months from today, -or during the specified PERIOD (= is required). -Auto posting rules will be applied to these transactions as well. -Also, in hledger\-ui make future\-dated transactions visible. -.TP -\f[CR]\-\-auto\f[R] -generate extra postings by applying auto posting rules to all txns (not -just forecast txns) -.TP -\f[CR]\-\-verbose\-tags\f[R] -add visible tags indicating transactions or postings which have been -generated/modified -.TP -\f[CR]\-\-commodity\-style\f[R] -Override the commodity style in the output for the specified commodity. -For example \[aq]EUR1.000,00\[aq]. -.TP -\f[CR]\-\-color=WHEN (or \-\-colour=WHEN)\f[R] -Should color\-supporting commands use ANSI color codes in text output. -\[aq]auto\[aq] (default): whenever stdout seems to be a -color\-supporting terminal. -\[aq]always\[aq] or \[aq]yes\[aq]: always, useful eg when piping output -into \[aq]less \-R\[aq]. -\[aq]never\[aq] or \[aq]no\[aq]: never. -A NO_COLOR environment variable overrides this. -.TP -\f[CR]\-\-pretty[=WHEN]\f[R] -Show prettier output, e.g. -using unicode box\-drawing characters. -Accepts \[aq]yes\[aq] (the default) or \[aq]no\[aq] (\[aq]y\[aq], -\[aq]n\[aq], \[aq]always\[aq], \[aq]never\[aq] also work). -If you provide an argument you must use \[aq]=\[aq], e.g. -\[aq]\-\-pretty=yes\[aq]. -.PP -When a reporting option appears more than once in the command line, the -last one takes precedence. -.PP -Some reporting options can also be written as query arguments. +.SS General options +.IP +.EX +General input/data transformation flags: + \-f \-\-file=FILE Read data from FILE, or from stdin if \-. Can be + specified more than once. If not specified, reads + from $LEDGER_FILE or $HOME/.hledger.journal. + \-\-rules\-file=RULEFILE Use conversion rules from this file for + converting subsequent CSV/SSV/TSV files. If not + specified, uses FILE.rules for each such FILE. + \-\-alias=A=B|/RGX/=RPL transform account names from A to B, or by + replacing regular expression matches + \-\-auto generate extra postings by applying auto posting + rules (\[dq]=\[dq]) to all transactions + \-\-forecast[=PERIOD] Generate extra transactions from periodic rules + (\[dq]\[ti]\[dq]), from after the latest ordinary transaction + until 6 months from now. Or, during the specified + PERIOD (the equals is required). Auto posting rules + will also be applied to these transactions. In + hledger\-ui, also make future\-dated transactions + visible at startup. + \-I \-\-ignore\-assertions don\[aq]t check balance assertions by default + \-\-infer\-costs infer conversion equity postings from costs + \-\-infer\-equity infer costs from conversion equity postings + \-\-infer\-market\-prices infer market prices from costs + \-\-pivot=TAGNAME use a different field or tag as account names + \-s \-\-strict do extra error checks (and override \-I) + \-\-verbose\-tags add tags indicating generated/modified data + +General output/reporting flags (supported by some commands): + \-b \-\-begin=DATE include postings/transactions on/after this date + \-e \-\-end=DATE include postings/transactions before this date + (with a report interval, will be adjusted to + following subperiod end) + \-D \-\-daily multiperiod report with 1 day interval + \-W \-\-weekly multiperiod report with 1 week interval + \-M \-\-monthly multiperiod report with 1 month interval + \-Q \-\-quarterly multiperiod report with 1 quarter interval + \-Y \-\-yearly multiperiod report with 1 year interval + \-p \-\-period=PERIODEXP set begin date, end date, and/or report interval, + with more flexibility + \-\-today=DATE override today\[aq]s date (affects relative dates) + \-\-date2 match/use secondary dates instead (deprecated) + \-U \-\-unmarked include only unmarked postings/transactions + \-P \-\-pending include only pending postings/transactions + \-C \-\-cleared include only cleared postings/transactions + (\-U/\-P/\-C can be combined) + \-R \-\-real include only non\-virtual postings + \-\-depth=NUM or \-NUM: show only top NUM levels of accounts + \-E \-\-empty Show zero items, which are normally hidden. + In hledger\-ui & hledger\-web, do the opposite. + \-B \-\-cost show amounts converted to their cost/sale amount + \-V \-\-market Show amounts converted to their value at period + end(s) in their default valuation commodity. + Equivalent to \-\-value=end. + \-X \-\-exchange=COMM Show amounts converted to their value at period + end(s) in the specified commodity. + Equivalent to \-\-value=end,COMM. + \-\-value=WHEN[,COMM] show amounts converted to their value on the + specified date(s) in their default valuation + commodity or a specified commodity. WHEN can be: + \[aq]then\[aq]: value on transaction dates + \[aq]end\[aq]: value at period end(s) + \[aq]now\[aq]: value today + YYYY\-MM\-DD: value on given date + \-c \-\-commodity\-style=S Override a commodity\[aq]s display style. + Eg: \-c \[aq].\[aq] or \-c \[aq]1.000,00 EUR\[aq] + \-\-color=YN \-\-colour Use ANSI color codes in text output? Can be: + \[aq]yes\[aq] or \[aq]always\[aq], + \[aq]no\[aq] or \[aq]never\[aq] (a NO_COLOR env var forces this), + \[aq]auto\[aq] (the default: when using a color terminal). + \-\-pretty[=YN] Use box\-drawing characters in text output? Can be + \[aq]yes\[aq] (the default argument for \-\-pretty) or \[aq]no\[aq]. + If YN is specified, the equals is required. + \-\-debug=[N] show debug output (levels 1\-9, default: 1) + +General help flags: + \-h \-\-help show command line help + \-\-tldr show command examples with tldr + \-\-info show the hledger manual with info + \-\-man show the hledger manual with man + \-\-version show version information +.EE .SH PERMISSIONS By default, hledger\-web allows anyone who can reach it to view the journal and to add new transactions, but not to change existing data. @@ -468,22 +394,22 @@ corresponds to hledger\[aq]s Transaction and related data types): \[dq]tcomment\[dq]: \[dq]\[dq], \[dq]tpostings\[dq]: [ { - \[dq]pbalanceassertion\[dq]: null, + \[dq]pbalanceassertion\[dq]: \f[B]null\f[R], \[dq]pstatus\[dq]: \[dq]Unmarked\[dq], \[dq]pamount\[dq]: [ { - \[dq]aprice\[dq]: null, + \[dq]aprice\[dq]: \f[B]null\f[R], \[dq]acommodity\[dq]: \[dq]$\[dq], \[dq]aquantity\[dq]: { \[dq]floatingPoint\[dq]: 1, \[dq]decimalPlaces\[dq]: 10, \[dq]decimalMantissa\[dq]: 10000000000 }, - \[dq]aismultiplier\[dq]: false, + \[dq]aismultiplier\[dq]: \f[B]false\f[R], \[dq]astyle\[dq]: { \[dq]ascommodityside\[dq]: \[dq]L\[dq], - \[dq]asdigitgroups\[dq]: null, - \[dq]ascommodityspaced\[dq]: false, + \[dq]asdigitgroups\[dq]: \f[B]null\f[R], + \[dq]ascommodityspaced\[dq]: \f[B]false\f[R], \[dq]asprecision\[dq]: 2, \[dq]asdecimalpoint\[dq]: \[dq].\[dq] } @@ -491,30 +417,30 @@ corresponds to hledger\[aq]s Transaction and related data types): ], \[dq]ptransaction_\[dq]: \[dq]1\[dq], \[dq]paccount\[dq]: \[dq]assets:bank:checking\[dq], - \[dq]pdate\[dq]: null, + \[dq]pdate\[dq]: \f[B]null\f[R], \[dq]ptype\[dq]: \[dq]RegularPosting\[dq], \[dq]pcomment\[dq]: \[dq]\[dq], - \[dq]pdate2\[dq]: null, + \[dq]pdate2\[dq]: \f[B]null\f[R], \[dq]ptags\[dq]: [], - \[dq]poriginal\[dq]: null + \[dq]poriginal\[dq]: \f[B]null\f[R] }, { - \[dq]pbalanceassertion\[dq]: null, + \[dq]pbalanceassertion\[dq]: \f[B]null\f[R], \[dq]pstatus\[dq]: \[dq]Unmarked\[dq], \[dq]pamount\[dq]: [ { - \[dq]aprice\[dq]: null, + \[dq]aprice\[dq]: \f[B]null\f[R], \[dq]acommodity\[dq]: \[dq]$\[dq], \[dq]aquantity\[dq]: { \[dq]floatingPoint\[dq]: \-1, \[dq]decimalPlaces\[dq]: 10, \[dq]decimalMantissa\[dq]: \-10000000000 }, - \[dq]aismultiplier\[dq]: false, + \[dq]aismultiplier\[dq]: \f[B]false\f[R], \[dq]astyle\[dq]: { \[dq]ascommodityside\[dq]: \[dq]L\[dq], - \[dq]asdigitgroups\[dq]: null, - \[dq]ascommodityspaced\[dq]: false, + \[dq]asdigitgroups\[dq]: \f[B]null\f[R], + \[dq]ascommodityspaced\[dq]: \f[B]false\f[R], \[dq]asprecision\[dq]: 2, \[dq]asdecimalpoint\[dq]: \[dq].\[dq] } @@ -522,12 +448,12 @@ corresponds to hledger\[aq]s Transaction and related data types): ], \[dq]ptransaction_\[dq]: \[dq]1\[dq], \[dq]paccount\[dq]: \[dq]income:salary\[dq], - \[dq]pdate\[dq]: null, + \[dq]pdate\[dq]: \f[B]null\f[R], \[dq]ptype\[dq]: \[dq]RegularPosting\[dq], \[dq]pcomment\[dq]: \[dq]\[dq], - \[dq]pdate2\[dq]: null, + \[dq]pdate2\[dq]: \f[B]null\f[R], \[dq]ptags\[dq]: [], - \[dq]poriginal\[dq]: null + \[dq]poriginal\[dq]: \f[B]null\f[R] } ], \[dq]ttags\[dq]: [], @@ -545,7 +471,7 @@ corresponds to hledger\[aq]s Transaction and related data types): \[dq]tcode\[dq]: \[dq]\[dq], \[dq]tindex\[dq]: 1, \[dq]tprecedingcomment\[dq]: \[dq]\[dq], - \[dq]tdate2\[dq]: null, + \[dq]tdate2\[dq]: \f[B]null\f[R], \[dq]tdescription\[dq]: \[dq]income\[dq], \[dq]tstatus\[dq]: \[dq]Unmarked\[dq] } diff --git a/hledger-web/hledger-web.info b/hledger-web/hledger-web.info index f7295975f..4c9ef8353 100644 --- a/hledger-web/hledger-web.info +++ b/hledger-web/hledger-web.info @@ -153,183 +153,93 @@ at all. * Menu: -* General help options:: -* General input options:: -* General reporting options:: +* General options::  -File: hledger-web.info, Node: General help options, Next: General input options, Up: OPTIONS +File: hledger-web.info, Node: General options, Up: OPTIONS -1.1 General help options -======================== +1.1 General options +=================== -'-h --help' +General input/data transformation flags: + -f --file=FILE Read data from FILE, or from stdin if -. Can be + specified more than once. If not specified, reads + from $LEDGER_FILE or $HOME/.hledger.journal. + --rules-file=RULEFILE Use conversion rules from this file for + converting subsequent CSV/SSV/TSV files. If not + specified, uses FILE.rules for each such FILE. + --alias=A=B|/RGX/=RPL transform account names from A to B, or by + replacing regular expression matches + --auto generate extra postings by applying auto posting + rules ("=") to all transactions + --forecast[=PERIOD] Generate extra transactions from periodic rules + ("~"), from after the latest ordinary transaction + until 6 months from now. Or, during the specified + PERIOD (the equals is required). Auto posting rules + will also be applied to these transactions. In + hledger-ui, also make future-dated transactions + visible at startup. + -I --ignore-assertions don't check balance assertions by default + --infer-costs infer conversion equity postings from costs + --infer-equity infer costs from conversion equity postings + --infer-market-prices infer market prices from costs + --pivot=TAGNAME use a different field or tag as account names + -s --strict do extra error checks (and override -I) + --verbose-tags add tags indicating generated/modified data - show general or COMMAND help -'--man' +General output/reporting flags (supported by some commands): + -b --begin=DATE include postings/transactions on/after this date + -e --end=DATE include postings/transactions before this date + (with a report interval, will be adjusted to + following subperiod end) + -D --daily multiperiod report with 1 day interval + -W --weekly multiperiod report with 1 week interval + -M --monthly multiperiod report with 1 month interval + -Q --quarterly multiperiod report with 1 quarter interval + -Y --yearly multiperiod report with 1 year interval + -p --period=PERIODEXP set begin date, end date, and/or report interval, + with more flexibility + --today=DATE override today's date (affects relative dates) + --date2 match/use secondary dates instead (deprecated) + -U --unmarked include only unmarked postings/transactions + -P --pending include only pending postings/transactions + -C --cleared include only cleared postings/transactions + (-U/-P/-C can be combined) + -R --real include only non-virtual postings + --depth=NUM or -NUM: show only top NUM levels of accounts + -E --empty Show zero items, which are normally hidden. + In hledger-ui & hledger-web, do the opposite. + -B --cost show amounts converted to their cost/sale amount + -V --market Show amounts converted to their value at period + end(s) in their default valuation commodity. + Equivalent to --value=end. + -X --exchange=COMM Show amounts converted to their value at period + end(s) in the specified commodity. + Equivalent to --value=end,COMM. + --value=WHEN[,COMM] show amounts converted to their value on the + specified date(s) in their default valuation + commodity or a specified commodity. WHEN can be: + 'then': value on transaction dates + 'end': value at period end(s) + 'now': value today + YYYY-MM-DD: value on given date + -c --commodity-style=S Override a commodity's display style. + Eg: -c '.' or -c '1.000,00 EUR' + --color=YN --colour Use ANSI color codes in text output? Can be: + 'yes' or 'always', + 'no' or 'never' (a NO_COLOR env var forces this), + 'auto' (the default: when using a color terminal). + --pretty[=YN] Use box-drawing characters in text output? Can be + 'yes' (the default argument for --pretty) or 'no'. + If YN is specified, the equals is required. + --debug=[N] show debug output (levels 1-9, default: 1) - show general or COMMAND user manual with man -'--info' - - show general or COMMAND user manual with info -'--version' - - show general or ADDONCMD version -'--debug[=N]' - - show debug output (levels 1-9, default: 1) - - -File: hledger-web.info, Node: General input options, Next: General reporting options, Prev: General help options, Up: OPTIONS - -1.2 General input options -========================= - -'-f FILE --file=FILE' - - use a different input file. For stdin, use - (default: - '$LEDGER_FILE' or '$HOME/.hledger.journal') -'--rules-file=RULESFILE' - - Conversion rules file to use when reading CSV (default: FILE.rules) -'--separator=CHAR' - - Field separator to expect when reading CSV (default: ',') -'--alias=OLD=NEW' - - rename accounts named OLD to NEW -'--pivot FIELDNAME' - - use some other field or tag for the account name -'-I --ignore-assertions' - - disable balance assertion checks (note: does not disable balance - assignments) -'-s --strict' - - do extra error checking (check that all posted accounts are - declared) - - -File: hledger-web.info, Node: General reporting options, Prev: General input options, Up: OPTIONS - -1.3 General reporting options -============================= - -'-b --begin=DATE' - - include postings/txns on or after this date (will be adjusted to - preceding subperiod start when using a report interval) -'-e --end=DATE' - - include postings/txns before this date (will be adjusted to - following subperiod end when using a report interval) -'-D --daily' - - multiperiod/multicolumn report by day -'-W --weekly' - - multiperiod/multicolumn report by week -'-M --monthly' - - multiperiod/multicolumn report by month -'-Q --quarterly' - - multiperiod/multicolumn report by quarter -'-Y --yearly' - - multiperiod/multicolumn report by year -'-p --period=PERIODEXP' - - set start date, end date, and/or reporting interval all at once - using period expressions syntax -'--date2' - - match the secondary date instead (see command help for other - effects) -'--today=DATE' - - override today's date (affects relative smart dates, for - tests/examples) -'-U --unmarked' - - include only unmarked postings/txns (can combine with -P or -C) -'-P --pending' - - include only pending postings/txns -'-C --cleared' - - include only cleared postings/txns -'-R --real' - - include only non-virtual postings -'-NUM --depth=NUM' - - hide/aggregate accounts or postings more than NUM levels deep -'-E --empty' - - show items with zero amount, normally hidden (and vice-versa in - hledger-ui/hledger-web) -'-B --cost' - - convert amounts to their cost/selling amount at transaction time -'-V --market' - - convert amounts to their market value in default valuation - commodities -'-X --exchange=COMM' - - convert amounts to their market value in commodity COMM -'--value' - - convert amounts to cost or market value, more flexibly than - -B/-V/-X -'--infer-equity' - - infer conversion equity postings from costs -'--infer-costs' - - infer costs from conversion equity postings -'--infer-market-prices' - - use costs as additional market prices, as if they were P directives -'--forecast' - - generate transactions from periodic rules, between the latest - recorded txn and 6 months from today, or during the specified - PERIOD (= is required). Auto posting rules will be applied to - these transactions as well. Also, in hledger-ui make future-dated - transactions visible. -'--auto' - - generate extra postings by applying auto posting rules to all txns - (not just forecast txns) -'--verbose-tags' - - add visible tags indicating transactions or postings which have - been generated/modified -'--commodity-style' - - Override the commodity style in the output for the specified - commodity. For example 'EUR1.000,00'. -'--color=WHEN (or --colour=WHEN)' - - Should color-supporting commands use ANSI color codes in text - output. 'auto' (default): whenever stdout seems to be a - color-supporting terminal. 'always' or 'yes': always, useful eg - when piping output into 'less -R'. 'never' or 'no': never. A - NO_COLOR environment variable overrides this. -'--pretty[=WHEN]' - - Show prettier output, e.g. using unicode box-drawing characters. - Accepts 'yes' (the default) or 'no' ('y', 'n', 'always', 'never' - also work). If you provide an argument you must use '=', e.g. - '-pretty=yes'. - - When a reporting option appears more than once in the command line, -the last one takes precedence. - - Some reporting options can also be written as query arguments. +General help flags: + -h --help show command line help + --tldr show command examples with tldr + --info show the hledger manual with info + --man show the hledger manual with man + --version show version information  File: hledger-web.info, Node: PERMISSIONS, Next: EDITING UPLOADING DOWNLOADING, Prev: OPTIONS, Up: Top @@ -640,28 +550,24 @@ Tag Table: Node: Top223 Node: OPTIONS2578 Ref: #options2683 -Node: General help options5648 -Ref: #general-help-options5798 -Node: General input options6080 -Ref: #general-input-options6266 -Node: General reporting options6923 -Ref: #general-reporting-options7088 -Node: PERMISSIONS10478 -Ref: #permissions10617 -Node: EDITING UPLOADING DOWNLOADING11829 -Ref: #editing-uploading-downloading12010 -Node: RELOADING12844 -Ref: #reloading12978 -Node: JSON API13411 -Ref: #json-api13526 -Node: DEBUG OUTPUT19014 -Ref: #debug-output19139 -Node: Debug output19166 -Ref: #debug-output-119267 -Node: ENVIRONMENT19684 -Ref: #environment19803 -Node: BUGS19920 -Ref: #bugs20004 +Node: General options5587 +Ref: #general-options5692 +Node: PERMISSIONS10919 +Ref: #permissions11058 +Node: EDITING UPLOADING DOWNLOADING12270 +Ref: #editing-uploading-downloading12451 +Node: RELOADING13285 +Ref: #reloading13419 +Node: JSON API13852 +Ref: #json-api13967 +Node: DEBUG OUTPUT19455 +Ref: #debug-output19580 +Node: Debug output19607 +Ref: #debug-output-119708 +Node: ENVIRONMENT20125 +Ref: #environment20244 +Node: BUGS20361 +Ref: #bugs20445  End Tag Table diff --git a/hledger-web/hledger-web.txt b/hledger-web/hledger-web.txt index 4ce79c7e3..1a6a3b357 100644 --- a/hledger-web/hledger-web.txt +++ b/hledger-web/hledger-web.txt @@ -122,160 +122,86 @@ OPTIONS when costs are hidden. Currently hledger-web does not show costs at all. - General help options - -h --help - show general or COMMAND help + General options + General input/data transformation flags: + -f --file=FILE Read data from FILE, or from stdin if -. Can be + specified more than once. If not specified, reads + from $LEDGER_FILE or $HOME/.hledger.journal. + --rules-file=RULEFILE Use conversion rules from this file for + converting subsequent CSV/SSV/TSV files. If not + specified, uses FILE.rules for each such FILE. + --alias=A=B|/RGX/=RPL transform account names from A to B, or by + replacing regular expression matches + --auto generate extra postings by applying auto posting + rules ("=") to all transactions + --forecast[=PERIOD] Generate extra transactions from periodic rules + ("~"), from after the latest ordinary transaction + until 6 months from now. Or, during the specified + PERIOD (the equals is required). Auto posting rules + will also be applied to these transactions. In + hledger-ui, also make future-dated transactions + visible at startup. + -I --ignore-assertions don't check balance assertions by default + --infer-costs infer conversion equity postings from costs + --infer-equity infer costs from conversion equity postings + --infer-market-prices infer market prices from costs + --pivot=TAGNAME use a different field or tag as account names + -s --strict do extra error checks (and override -I) + --verbose-tags add tags indicating generated/modified data - --man show general or COMMAND user manual with man + General output/reporting flags (supported by some commands): + -b --begin=DATE include postings/transactions on/after this date + -e --end=DATE include postings/transactions before this date + (with a report interval, will be adjusted to + following subperiod end) + -D --daily multiperiod report with 1 day interval + -W --weekly multiperiod report with 1 week interval + -M --monthly multiperiod report with 1 month interval + -Q --quarterly multiperiod report with 1 quarter interval + -Y --yearly multiperiod report with 1 year interval + -p --period=PERIODEXP set begin date, end date, and/or report interval, + with more flexibility + --today=DATE override today's date (affects relative dates) + --date2 match/use secondary dates instead (deprecated) + -U --unmarked include only unmarked postings/transactions + -P --pending include only pending postings/transactions + -C --cleared include only cleared postings/transactions + (-U/-P/-C can be combined) + -R --real include only non-virtual postings + --depth=NUM or -NUM: show only top NUM levels of accounts + -E --empty Show zero items, which are normally hidden. + In hledger-ui & hledger-web, do the opposite. + -B --cost show amounts converted to their cost/sale amount + -V --market Show amounts converted to their value at period + end(s) in their default valuation commodity. + Equivalent to --value=end. + -X --exchange=COMM Show amounts converted to their value at period + end(s) in the specified commodity. + Equivalent to --value=end,COMM. + --value=WHEN[,COMM] show amounts converted to their value on the + specified date(s) in their default valuation + commodity or a specified commodity. WHEN can be: + 'then': value on transaction dates + 'end': value at period end(s) + 'now': value today + YYYY-MM-DD: value on given date + -c --commodity-style=S Override a commodity's display style. + Eg: -c '.' or -c '1.000,00 EUR' + --color=YN --colour Use ANSI color codes in text output? Can be: + 'yes' or 'always', + 'no' or 'never' (a NO_COLOR env var forces this), + 'auto' (the default: when using a color terminal). + --pretty[=YN] Use box-drawing characters in text output? Can be + 'yes' (the default argument for --pretty) or 'no'. + If YN is specified, the equals is required. + --debug=[N] show debug output (levels 1-9, default: 1) - --info show general or COMMAND user manual with info - - --version - show general or ADDONCMD version - - --debug[=N] - show debug output (levels 1-9, default: 1) - - General input options - -f FILE --file=FILE - use a different input file. For stdin, use - (default: - $LEDGER_FILE or $HOME/.hledger.journal) - - --rules-file=RULESFILE - Conversion rules file to use when reading CSV (default: - FILE.rules) - - --separator=CHAR - Field separator to expect when reading CSV (default: ',') - - --alias=OLD=NEW - rename accounts named OLD to NEW - - --pivot FIELDNAME - use some other field or tag for the account name - - -I --ignore-assertions - disable balance assertion checks (note: does not disable balance - assignments) - - -s --strict - do extra error checking (check that all posted accounts are de- - clared) - - General reporting options - -b --begin=DATE - include postings/txns on or after this date (will be adjusted to - preceding subperiod start when using a report interval) - - -e --end=DATE - include postings/txns before this date (will be adjusted to fol- - lowing subperiod end when using a report interval) - - -D --daily - multiperiod/multicolumn report by day - - -W --weekly - multiperiod/multicolumn report by week - - -M --monthly - multiperiod/multicolumn report by month - - -Q --quarterly - multiperiod/multicolumn report by quarter - - -Y --yearly - multiperiod/multicolumn report by year - - -p --period=PERIODEXP - set start date, end date, and/or reporting interval all at once - using period expressions syntax - - --date2 - match the secondary date instead (see command help for other ef- - fects) - - --today=DATE - override today's date (affects relative smart dates, for - tests/examples) - - -U --unmarked - include only unmarked postings/txns (can combine with -P or -C) - - -P --pending - include only pending postings/txns - - -C --cleared - include only cleared postings/txns - - -R --real - include only non-virtual postings - - -NUM --depth=NUM - hide/aggregate accounts or postings more than NUM levels deep - - -E --empty - show items with zero amount, normally hidden (and vice-versa in - hledger-ui/hledger-web) - - -B --cost - convert amounts to their cost/selling amount at transaction time - - -V --market - convert amounts to their market value in default valuation com- - modities - - -X --exchange=COMM - convert amounts to their market value in commodity COMM - - --value - convert amounts to cost or market value, more flexibly than - -B/-V/-X - - --infer-equity - infer conversion equity postings from costs - - --infer-costs - infer costs from conversion equity postings - - --infer-market-prices - use costs as additional market prices, as if they were P direc- - tives - - --forecast - generate transactions from periodic rules, between the latest - recorded txn and 6 months from today, or during the specified - PERIOD (= is required). Auto posting rules will be applied to - these transactions as well. Also, in hledger-ui make fu- - ture-dated transactions visible. - - --auto generate extra postings by applying auto posting rules to all - txns (not just forecast txns) - - --verbose-tags - add visible tags indicating transactions or postings which have - been generated/modified - - --commodity-style - Override the commodity style in the output for the specified - commodity. For example 'EUR1.000,00'. - - --color=WHEN (or --colour=WHEN) - Should color-supporting commands use ANSI color codes in text - output. 'auto' (default): whenever stdout seems to be a - color-supporting terminal. 'always' or 'yes': always, useful eg - when piping output into 'less -R'. 'never' or 'no': never. A - NO_COLOR environment variable overrides this. - - --pretty[=WHEN] - Show prettier output, e.g. using unicode box-drawing charac- - ters. Accepts 'yes' (the default) or 'no' ('y', 'n', 'always', - 'never' also work). If you provide an argument you must use - '=', e.g. '--pretty=yes'. - - When a reporting option appears more than once in the command line, the - last one takes precedence. - - Some reporting options can also be written as query arguments. + General help flags: + -h --help show command line help + --tldr show command examples with tldr + --info show the hledger manual with info + --man show the hledger manual with man + --version show version information PERMISSIONS By default, hledger-web allows anyone who can reach it to view the @@ -558,4 +484,4 @@ LICENSE SEE ALSO hledger(1), hledger-ui(1), hledger-web(1), ledger(1) -hledger-web-1.33.99 April 2024 HLEDGER-WEB(1) +hledger-web-1.33.99 May 2024 HLEDGER-WEB(1) diff --git a/hledger/.date.m4 b/hledger/.date.m4 index 1506ce24f..4e27a7647 100644 --- a/hledger/.date.m4 +++ b/hledger/.date.m4 @@ -1,2 +1,2 @@ m4_dnl Date to show in man pages. Updated by "Shake manuals" -m4_define({{_monthyear_}}, {{April 2024}})m4_dnl +m4_define({{_monthyear_}}, {{May 2024}})m4_dnl diff --git a/hledger/hledger.1 b/hledger/hledger.1 index af09eed49..7f716a711 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -1,6 +1,6 @@ .\"t -.TH "HLEDGER" "1" "April 2024" "hledger-1.33.99 " "hledger User Manuals" +.TH "HLEDGER" "1" "May 2024" "hledger-1.33.99 " "hledger User Manuals" @@ -330,160 +330,89 @@ without using \f[CR]hledger\f[R]: \f[CR]hledger\-ui \-\-watch\f[R] or .SH Options Run \f[CR]hledger \-h\f[R] to see general command line help, and general options which are common to most hledger commands. -These options can be written anywhere on the command line. -They can be grouped into help, input, and reporting options: -.SS General help options -.TP -\f[CR]\-h \-\-help\f[R] -show general or COMMAND help -.TP -\f[CR]\-\-man\f[R] -show general or COMMAND user manual with man -.TP -\f[CR]\-\-info\f[R] -show general or COMMAND user manual with info -.TP -\f[CR]\-\-version\f[R] -show general or ADDONCMD version -.TP -\f[CR]\-\-debug[=N]\f[R] -show debug output (levels 1\-9, default: 1) -.SS General input options -.TP -\f[CR]\-f FILE \-\-file=FILE\f[R] -use a different input file. -For stdin, use \- (default: \f[CR]$LEDGER_FILE\f[R] or -\f[CR]$HOME/.hledger.journal\f[R]) -.TP -\f[CR]\-\-rules\-file=RULESFILE\f[R] -Conversion rules file to use when reading CSV (default: FILE.rules) -.TP -\f[CR]\-\-separator=CHAR\f[R] -Field separator to expect when reading CSV (default: \[aq],\[aq]) -.TP -\f[CR]\-\-alias=OLD=NEW\f[R] -rename accounts named OLD to NEW -.TP -\f[CR]\-\-pivot FIELDNAME\f[R] -use some other field or tag for the account name -.TP -\f[CR]\-I \-\-ignore\-assertions\f[R] -disable balance assertion checks (note: does not disable balance -assignments) -.TP -\f[CR]\-s \-\-strict\f[R] -do extra error checking (check that all posted accounts are declared) -.SS General reporting options -.TP -\f[CR]\-b \-\-begin=DATE\f[R] -include postings/txns on or after this date (will be adjusted to -preceding subperiod start when using a report interval) -.TP -\f[CR]\-e \-\-end=DATE\f[R] -include postings/txns before this date (will be adjusted to following -subperiod end when using a report interval) -.TP -\f[CR]\-D \-\-daily\f[R] -multiperiod/multicolumn report by day -.TP -\f[CR]\-W \-\-weekly\f[R] -multiperiod/multicolumn report by week -.TP -\f[CR]\-M \-\-monthly\f[R] -multiperiod/multicolumn report by month -.TP -\f[CR]\-Q \-\-quarterly\f[R] -multiperiod/multicolumn report by quarter -.TP -\f[CR]\-Y \-\-yearly\f[R] -multiperiod/multicolumn report by year -.TP -\f[CR]\-p \-\-period=PERIODEXP\f[R] -set start date, end date, and/or reporting interval all at once using -period expressions syntax -.TP -\f[CR]\-\-date2\f[R] -match the secondary date instead (see command help for other effects) -.TP -\f[CR]\-\-today=DATE\f[R] -override today\[aq]s date (affects relative smart dates, for -tests/examples) -.TP -\f[CR]\-U \-\-unmarked\f[R] -include only unmarked postings/txns (can combine with \-P or \-C) -.TP -\f[CR]\-P \-\-pending\f[R] -include only pending postings/txns -.TP -\f[CR]\-C \-\-cleared\f[R] -include only cleared postings/txns -.TP -\f[CR]\-R \-\-real\f[R] -include only non\-virtual postings -.TP -\f[CR]\-NUM \-\-depth=NUM\f[R] -hide/aggregate accounts or postings more than NUM levels deep -.TP -\f[CR]\-E \-\-empty\f[R] -show items with zero amount, normally hidden (and vice\-versa in -hledger\-ui/hledger\-web) -.TP -\f[CR]\-B \-\-cost\f[R] -convert amounts to their cost/selling amount at transaction time -.TP -\f[CR]\-V \-\-market\f[R] -convert amounts to their market value in default valuation commodities -.TP -\f[CR]\-X \-\-exchange=COMM\f[R] -convert amounts to their market value in commodity COMM -.TP -\f[CR]\-\-value\f[R] -convert amounts to cost or market value, more flexibly than \-B/\-V/\-X -.TP -\f[CR]\-\-infer\-equity\f[R] -infer conversion equity postings from costs -.TP -\f[CR]\-\-infer\-costs\f[R] -infer costs from conversion equity postings -.TP -\f[CR]\-\-infer\-market\-prices\f[R] -use costs as additional market prices, as if they were P directives -.TP -\f[CR]\-\-forecast\f[R] -generate transactions from periodic rules, -between the latest recorded txn and 6 months from today, -or during the specified PERIOD (= is required). -Auto posting rules will be applied to these transactions as well. -Also, in hledger\-ui make future\-dated transactions visible. -.TP -\f[CR]\-\-auto\f[R] -generate extra postings by applying auto posting rules to all txns (not -just forecast txns) -.TP -\f[CR]\-\-verbose\-tags\f[R] -add visible tags indicating transactions or postings which have been -generated/modified -.TP -\f[CR]\-\-commodity\-style\f[R] -Override the commodity style in the output for the specified commodity. -For example \[aq]EUR1.000,00\[aq]. -.TP -\f[CR]\-\-color=WHEN (or \-\-colour=WHEN)\f[R] -Should color\-supporting commands use ANSI color codes in text output. -\[aq]auto\[aq] (default): whenever stdout seems to be a -color\-supporting terminal. -\[aq]always\[aq] or \[aq]yes\[aq]: always, useful eg when piping output -into \[aq]less \-R\[aq]. -\[aq]never\[aq] or \[aq]no\[aq]: never. -A NO_COLOR environment variable overrides this. -.TP -\f[CR]\-\-pretty[=WHEN]\f[R] -Show prettier output, e.g. -using unicode box\-drawing characters. -Accepts \[aq]yes\[aq] (the default) or \[aq]no\[aq] (\[aq]y\[aq], -\[aq]n\[aq], \[aq]always\[aq], \[aq]never\[aq] also work). -If you provide an argument you must use \[aq]=\[aq], e.g. -\[aq]\-\-pretty=yes\[aq]. +These options can be written anywhere on the command line: +.IP +.EX +General input/data transformation flags: + \-f \-\-file=FILE Read data from FILE, or from stdin if \-. Can be + specified more than once. If not specified, reads + from $LEDGER_FILE or $HOME/.hledger.journal. + \-\-rules\-file=RULEFILE Use conversion rules from this file for + converting subsequent CSV/SSV/TSV files. If not + specified, uses FILE.rules for each such FILE. + \-\-alias=A=B|/RGX/=RPL transform account names from A to B, or by + replacing regular expression matches + \-\-auto generate extra postings by applying auto posting + rules (\[dq]=\[dq]) to all transactions + \-\-forecast[=PERIOD] Generate extra transactions from periodic rules + (\[dq]\[ti]\[dq]), from after the latest ordinary transaction + until 6 months from now. Or, during the specified + PERIOD (the equals is required). Auto posting rules + will also be applied to these transactions. In + hledger\-ui, also make future\-dated transactions + visible at startup. + \-I \-\-ignore\-assertions don\[aq]t check balance assertions by default + \-\-infer\-costs infer conversion equity postings from costs + \-\-infer\-equity infer costs from conversion equity postings + \-\-infer\-market\-prices infer market prices from costs + \-\-pivot=TAGNAME use a different field or tag as account names + \-s \-\-strict do extra error checks (and override \-I) + \-\-verbose\-tags add tags indicating generated/modified data + +General output/reporting flags (supported by some commands): + \-b \-\-begin=DATE include postings/transactions on/after this date + \-e \-\-end=DATE include postings/transactions before this date + (with a report interval, will be adjusted to + following subperiod end) + \-D \-\-daily multiperiod report with 1 day interval + \-W \-\-weekly multiperiod report with 1 week interval + \-M \-\-monthly multiperiod report with 1 month interval + \-Q \-\-quarterly multiperiod report with 1 quarter interval + \-Y \-\-yearly multiperiod report with 1 year interval + \-p \-\-period=PERIODEXP set begin date, end date, and/or report interval, + with more flexibility + \-\-today=DATE override today\[aq]s date (affects relative dates) + \-\-date2 match/use secondary dates instead (deprecated) + \-U \-\-unmarked include only unmarked postings/transactions + \-P \-\-pending include only pending postings/transactions + \-C \-\-cleared include only cleared postings/transactions + (\-U/\-P/\-C can be combined) + \-R \-\-real include only non\-virtual postings + \-\-depth=NUM or \-NUM: show only top NUM levels of accounts + \-E \-\-empty Show zero items, which are normally hidden. + In hledger\-ui & hledger\-web, do the opposite. + \-B \-\-cost show amounts converted to their cost/sale amount + \-V \-\-market Show amounts converted to their value at period + end(s) in their default valuation commodity. + Equivalent to \-\-value=end. + \-X \-\-exchange=COMM Show amounts converted to their value at period + end(s) in the specified commodity. + Equivalent to \-\-value=end,COMM. + \-\-value=WHEN[,COMM] show amounts converted to their value on the + specified date(s) in their default valuation + commodity or a specified commodity. WHEN can be: + \[aq]then\[aq]: value on transaction dates + \[aq]end\[aq]: value at period end(s) + \[aq]now\[aq]: value today + YYYY\-MM\-DD: value on given date + \-c \-\-commodity\-style=S Override a commodity\[aq]s display style. + Eg: \-c \[aq].\[aq] or \-c \[aq]1.000,00 EUR\[aq] + \-\-color=YN \-\-colour Use ANSI color codes in text output? Can be: + \[aq]yes\[aq] or \[aq]always\[aq], + \[aq]no\[aq] or \[aq]never\[aq] (a NO_COLOR env var forces this), + \[aq]auto\[aq] (the default: when using a color terminal). + \-\-pretty[=YN] Use box\-drawing characters in text output? Can be + \[aq]yes\[aq] (the default argument for \-\-pretty) or \[aq]no\[aq]. + If YN is specified, the equals is required. + \-\-debug=[N] show debug output (levels 1\-9, default: 1) + +General help flags: + \-h \-\-help show command line help + \-\-tldr show command examples with tldr + \-\-info show the hledger manual with info + \-\-man show the hledger manual with man + \-\-version show version information +.EE .PP When a reporting option appears more than once in the command line, the last one takes precedence. @@ -626,16 +555,18 @@ There are some more details in Troubleshooting. This step is essential \- without it, hledger will quit on encountering a non\-ascii character (as with all GHC\-compiled programs). .IP \[bu] 2 -your terminal software (eg Terminal.app, iTerm, CMD.exe, xterm..) -must support unicode +Your terminal software (eg Terminal.app, iTerm, CMD.exe, xterm..) +must support unicode. +On Windows, you may need to use Windows Terminal and/or enable UTF\-8 +support. .IP \[bu] 2 -the terminal must be using a font which includes the required unicode -glyphs +The terminal must be using a font which includes the required unicode +glyphs. .IP \[bu] 2 -the terminal should be configured to display wide characters as double -width (for report alignment) +The terminal should be configured to display wide characters as double +width (for report alignment). .IP \[bu] 2 -on Windows, for best results you should run hledger in the same kind of +On Windows, for best results you should run hledger in the same kind of environment in which it was built. Eg hledger built in the standard CMD.EXE environment (like the binaries on our download page) might show display problems when run in a cygwin @@ -4864,12 +4795,33 @@ Note we used a temporary field name (\f[CR]cur\f[R]) that is not \f[CR]currency\f[R] \- that would trigger the prepending effect, which we don\[aq]t want here. .SS Amount decimal places -Like amounts in a journal file, the amounts generated by CSV rules like -\f[CR]amount1\f[R] influence commodity display styles, such as the -number of decimal places displayed in reports. +When you are reading CSV data, eg with a command like +\f[CR]hledger \-f foo.csv print\f[R], hledger will infer each +commodity\[aq]s decimal precision (and other commodity display styles) +from the amounts \- much as when reading a journal file without +\f[CR]commodity\f[R] directives (see the link). .PP -The original amounts as written in the CSV file do not affect display -style (because we don\[aq]t yet reliably know their commodity). +Note, the commodity styles are not inferred from the numbers in the +original CSV data; rather, they are inferred from the amounts generated +by the CSV rules. +.PP +When you are importing CSV data with the \f[CR]import\f[R] command, eg +\f[CR]hledger import foo.csv\f[R], there\[aq]s another step: +\f[CR]import\f[R] tries to make the new entries conform to the +journal\[aq]s existing styles. +So for each commodity \- let\[aq]s say it\[aq]s EUR \- \f[CR]import\f[R] +will choose: +.IP "1." 3 +the style declared for EUR by a \f[CR]commodity\f[R] directive in the +journal +.IP "2." 3 +otherwise, the style inferred from EUR amounts in the journal +.IP "3." 3 +otherwise, the style inferred from EUR amounts generated by the CSV +rules. +.PP +TLDR: if \f[CR]import\f[R] is not generating the precisions or styles +you want, add a \f[CR]commodity\f[R] directive to specify them. .SS Referencing other fields In field assignments, you can interpolate only CSV fields, not hledger fields. @@ -5529,333 +5481,124 @@ $ hledger \-f a.timedot \-\-alias \[aq]/\[rs]./=:\[aq] bal \-t 4.50 .EE .SH PART 3: REPORTING CONCEPTS -.SH Amount formatting -.SS Commodity display style -For the amounts in each commodity, hledger chooses a consistent display -style (symbol placement, decimal mark and digit group marks, number of -decimal digits) to use in most reports. -This is inferred as follows: -.PP -First, if there\[aq]s a \f[CR]D\f[R] directive declaring a default -commodity, that commodity symbol and amount format is applied to all -no\-symbol amounts in the journal. -.PP -Then each commodity\[aq]s display style is determined from its -\f[CR]commodity\f[R] directive. -We recommend always declaring commodities with \f[CR]commodity\f[R] -directives, since they help ensure consistent display styles and -precisions, and bring other benefits such as error checking for -commodity symbols. -Here\[aq]s an example: -.IP -.EX -# Set display styles (and decimal marks, for parsing, if there is no decimal\-mark directive) -# for the $, EUR, INR and no\-symbol commodities: -commodity $1,000.00 -commodity EUR 1.000,00 -commodity INR 9,99,99,999.00 -commodity 1 000 000.9455 -.EE -.PP -But for convenience, if a \f[CR]commodity\f[R] directive is not present, -hledger infers a commodity\[aq]s display styles from its amounts as they -are written in the journal (excluding cost amounts and amounts in -periodic transaction rules or auto posting rules). -It uses -.IP \[bu] 2 -the symbol placement and decimal mark of the first amount seen -.IP \[bu] 2 -the digit group marks of the first amount with digit group marks -.IP \[bu] 2 -and the maximum number of decimal digits seen across all amounts. -.PP -And as fallback if no applicable amounts are found, it would use a -default style, like \f[CR]$1000.00\f[R] (symbol on the left with no -space, period as decimal mark, and two decimal digits). -.PP -Finally, commodity styles can be overridden by the -\f[CR]\-c/\-\-commodity\-style\f[R] command line option. -.SS Rounding -Amounts are stored internally as decimal numbers with up to 255 decimal -places. -They are displayed with their original journal precisions by print and -print\-like reports, and rounded to their display precision (the number -of decimal digits specified by the commodity display style) by other -reports. -When rounding, hledger uses banker\[aq]s rounding (it rounds to the -nearest even digit). -So eg 0.5 displayed with zero decimal digits appears as \[dq]0\[dq]. -.SS Trailing decimal marks -If you\[aq]re wondering why your \f[CR]print\f[R] report sometimes shows -trailing decimal marks, with no decimal digits; it does this when -showing amounts that have digit group marks but no decimal digits, to -disambiguate them and allow them to be re\-parsed reliably (see Decimal -marks). -Eg: -.IP -.EX -commodity $1,000.00 - -2023\-01\-02 - (a) $1000 -.EE -.IP -.EX -$ hledger print -2023\-01\-02 - (a) $1,000. -.EE -.PP -If this is a problem (eg when exporting to Ledger), you can avoid it by -disabling digit group marks, eg with \-c/\-\-commodity (for each -affected commodity): -.IP -.EX -$ hledger print \-c \[aq]$1000.00\[aq] -2023\-01\-02 - (a) $1000 -.EE -.PP -or by forcing print to always show decimal digits, with \-\-round: -.IP -.EX -$ hledger print \-c \[aq]$1,000.00\[aq] \-\-round=soft -2023\-01\-02 - (a) $1,000.00 -.EE -.SS Amount parseability -More generally, hledger output falls into three rough categories, which -format amounts a little bit differently to suit different consumers: -.PP -\f[B]1. -\[dq]hledger\-readable output\[dq] \- should be readable by hledger (and -by humans)\f[R] -.IP \[bu] 2 -This is produced by reports that show full journal entries: -\f[CR]print\f[R], \f[CR]import\f[R], \f[CR]close\f[R], -\f[CR]rewrite\f[R] etc. -.IP \[bu] 2 -It shows amounts with their original journal precisions, which may not -be consistent. -.IP \[bu] 2 -It adds a trailing decimal mark when needed to avoid showing ambiguous -amounts. -.IP \[bu] 2 -It can be parsed reliably (by hledger and ledger2beancount at least, but -perhaps not by Ledger..) -.PP -\f[B]2. -\[dq]human\-readable output\[dq] \- usually for humans\f[R] -.IP \[bu] 2 -This is produced by all other reports. -.IP \[bu] 2 -It shows amounts with standard display precisions, which will be -consistent within each commodity. -.IP \[bu] 2 -It shows ambiguous amounts unmodified. -.IP \[bu] 2 -It can be parsed reliably in the context of a known report (when you -know decimals are consistently not being shown, you can assume a single -mark is a digit group mark). -.PP -\f[B]3. -\[dq]machine\-readable output\[dq] \- usually for other software\f[R] -.IP \[bu] 2 -This is produced by all reports when an output format like -\f[CR]csv\f[R], \f[CR]tsv\f[R], \f[CR]json\f[R], or \f[CR]sql\f[R] is -selected. -.IP \[bu] 2 -It shows amounts as 1 or 2 do, but without digit group marks. -.IP \[bu] 2 -It can be parsed reliably (if needed, the decimal mark can be changed -with \-c/\-\-commodity\-style). .SH Time periods .SS Report start & end date -By default, most hledger reports will show the full span of time +Most hledger reports will by default show the full time period represented by the journal. The report start date will be the earliest transaction or posting date, and the report end date will be the latest transaction, posting, or market price date. .PP -Often you will want to see a shorter time span, such as the current -month. -You can specify a start and/or end date using \f[CR]\-b/\-\-begin\f[R], -\f[CR]\-e/\-\-end\f[R], \f[CR]\-p/\-\-period\f[R] or a \f[CR]date:\f[R] -query (described below). -All of these accept the smart date syntax (below). +Often you will want to see a shorter period, such as the current month. +You can specify a start and/or end date with the +\f[CR]\-b/\-\-begin\f[R], \f[CR]\-e/\-\-end\f[R], or +\f[CR]\-p/\-\-period\f[R] options, or a \f[CR]date:\f[R] query argument, +described below. +All of these accept the smart date syntax, also described below. .PP -Some notes: -.IP \[bu] 2 -End dates are exclusive, as in Ledger, so you should write the date -\f[I]after\f[R] the last day you want to see in the report. -.IP \[bu] 2 -As noted in reporting options: among start/end dates specified with -\f[I]options\f[R], the last (i.e. -right\-most) option takes precedence. -.IP \[bu] 2 -The effective report start and end dates are the intersection of the -start/end dates from options and that from \f[CR]date:\f[R] queries. -That is, \f[CR]date:2019\-01 date:2019 \-p\[aq]2000 to 2030\[aq]\f[R] -yields January 2019, the smallest common time span. -.IP \[bu] 2 -In some cases a report interval will adjust start/end dates to fall on -interval boundaries (see below). +End dates are exclusive; specify the day after the last day you want to +see in the report. +.PP +When dates are specified by multiple options, the last (right\-most) +option wins. +And when \f[CR]date:\f[R] queries and date options are combined, the +report period will be their intersection. +.PP +Examples: +.TP +\f[CR]\-b 2016/3/17\f[R] +beginning on St. +Patrick\[cq]s day 2016 +.TP +\f[CR]\-e 12/1\f[R] +ending at the start of December 1st in the current year +.TP +\f[CR]\-p \[aq]this month\[aq]\f[R] +during the current month +.TP +\f[CR]\-p thismonth\f[R] +same as above, spaces are optional +.TP +\f[CR]\-b 2023\f[R] +beginning on the first day of 2023 +.TP +\f[CR]date:2023..\f[R] or \f[CR]date:2023\-\f[R] +same as above +.PP +\f[CR]\-b 2024 \-e 2025 \-p \[aq]2000 to 2030\[aq] date:2020\-01 date:2020\f[R] +: +.PD 0 +.P +.PD +during January 2020 (the smallest common period, with the \-p overriding +\-b and \-e) +.SS Smart dates +In hledger\[aq]s user interfaces (though not in the journal file), you +can optionally use \[dq]smart date\[dq] syntax. +Smart dates can be written with english words, can be relative, and can +have parts omitted. +Missing parts are inferred as 1, when needed. +Smart dates can be interpreted as dates or periods depending on context. .PP Examples: .PP -.TS -tab(@); -lw(12.4n) lw(57.6n). -T{ -\f[CR]\-b 2016/3/17\f[R] -T}@T{ -begin on St.\ Patrick\[cq]s day 2016 -T} -T{ -\f[CR]\-e 12/1\f[R] -T}@T{ -end at the start of december 1st of the current year (11/30 will be the -last date included) -T} -T{ -\f[CR]\-b thismonth\f[R] -T}@T{ -all transactions on or after the 1st of the current month -T} -T{ -\f[CR]\-p thismonth\f[R] -T}@T{ -all transactions in the current month -T} -T{ -\f[CR]date:2016/3/17..\f[R] -T}@T{ -the above written as queries instead (\f[CR]..\f[R] can also be replaced -with \f[CR]\-\f[R]) -T} -T{ -\f[CR]date:..12/1\f[R] -T}@T{ -T} -T{ -\f[CR]date:thismonth..\f[R] -T}@T{ -T} -T{ -\f[CR]date:thismonth\f[R] -T}@T{ -T} -.TE -.SS Smart dates -hledger\[aq]s user interfaces accept a \[dq]smart date\[dq] syntax for -added convenience. -Smart dates optionally can be relative to today\[aq]s date, be written -with english words, and have less\-significant parts omitted (missing -parts are inferred as 1). -Some examples: -.PP -.TS -tab(@); -lw(24.2n) lw(45.8n). -T{ -\f[CR]2004/10/1\f[R], \f[CR]2004\-01\-01\f[R], \f[CR]2004.9.1\f[R] -T}@T{ -exact date, several separators allowed. -Year is 4+ digits, month is 1\-12, day is 1\-31 -T} -T{ -\f[CR]2004\f[R] -T}@T{ -start of year -T} -T{ -\f[CR]2004/10\f[R] -T}@T{ +\f[CR]2004\-01\-01\f[R], \f[CR]2004/10/1\f[R], \f[CR]2004.9.1\f[R], +\f[CR]20240504\f[R] : +.PD 0 +.P +.PD +Exact dates. +The year must have at least four digits, the month must be 1\-12, the +day must be 1\-31, the separator can be \f[CR]\-\f[R] or \f[CR]/\f[R] or +\f[CR].\f[R] or nothing. +.TP +\f[CR]2004\-10\f[R] start of month -T} -T{ -\f[CR]10/1\f[R] -T}@T{ -month and day in current year -T} -T{ +.TP +\f[CR]2004\f[R] +start of year +.TP +\f[CR]10/1\f[R] or \f[CR]oct\f[R] or \f[CR]october\f[R] +October 1st in current year +.TP \f[CR]21\f[R] -T}@T{ -day in current month -T} -T{ -\f[CR]october, oct\f[R] -T}@T{ -start of month in current year -T} -T{ +21st day in current month +.TP \f[CR]yesterday, today, tomorrow\f[R] -T}@T{ \-1, 0, 1 days from today -T} -T{ +.TP \f[CR]last/this/next day/week/month/quarter/year\f[R] -T}@T{ \-1, 0, 1 periods from the current period -T} -T{ +.TP \f[CR]in n days/weeks/months/quarters/years\f[R] -T}@T{ n periods from the current period -T} -T{ +.TP \f[CR]n days/weeks/months/quarters/years ahead\f[R] -T}@T{ n periods from the current period -T} -T{ +.TP \f[CR]n days/weeks/months/quarters/years ago\f[R] -T}@T{ \-n periods from the current period -T} -T{ +.TP \f[CR]20181201\f[R] -T}@T{ 8 digit YYYYMMDD with valid year month and day -T} -T{ +.TP \f[CR]201812\f[R] -T}@T{ 6 digit YYYYMM with valid year and month -T} -.TE .PP -Some counterexamples \- malformed digit sequences might give surprising -results: +Dates with no separators are allowed but might give surprising results +if mistyped: +.IP \[bu] 2 +\f[CR]20181301\f[R] (YYYYMMDD with an invalid month) is parsed as an +eight\-digit year +.IP \[bu] 2 +\f[CR]20181232\f[R] (YYYYMMDD with an invalid day) gives a parse error +.IP \[bu] 2 +\f[CR]201801012\f[R] (a valid YYYYMMDD followed by additional digits) +gives a parse error .PP -.TS -tab(@); -lw(11.4n) lw(58.6n). -T{ -\f[CR]201813\f[R] -T}@T{ -6 digits with an invalid month is parsed as start of 6\-digit year -T} -T{ -\f[CR]20181301\f[R] -T}@T{ -8 digits with an invalid month is parsed as start of 8\-digit year -T} -T{ -\f[CR]20181232\f[R] -T}@T{ -8 digits with an invalid day gives an error -T} -T{ -\f[CR]201801012\f[R] -T}@T{ -9+ digits beginning with a valid YYYYMMDD gives an error -T} -.TE -.PP -\[dq]Today\[aq]s date\[dq] can be overridden with the -\f[CR]\-\-today\f[R] option, in case it\[aq]s needed for testing or for -recreating old reports. +The meaning of relative dates depends on today\[aq]s date. +If you need to test or reproduce old reports, you can use the +\f[CR]\-\-today\f[R] option to override that. (Except for periodic transaction rules, which are not affected by \f[CR]\-\-today\f[R].) .SS Report intervals @@ -6059,7 +5802,8 @@ name, case insensitive) .PP Monthly on a custom day: .IP \[bu] 2 -\f[CR]every Nth day [of month]\f[R] +\f[CR]every Nth day [of month]\f[R] (\f[CR]31st day\f[R] will be +adjusted to each month\[aq]s last day) .IP \[bu] 2 \f[CR]every Nth WEEKDAYNAME [of month]\f[R] .PP @@ -6819,6 +6563,146 @@ time, from the same or different periodic transaction rules: \f[CR]hledger bal \-M \-\-budget \-\-forecast ...\f[R] .PP See also: Budgeting and Forecasting. +.SH Amount formatting +.SS Commodity display style +For the amounts in each commodity, hledger chooses a consistent display +style (symbol placement, decimal mark and digit group marks, number of +decimal digits) to use in most reports. +This is inferred as follows: +.PP +First, if there\[aq]s a \f[CR]D\f[R] directive declaring a default +commodity, that commodity symbol and amount format is applied to all +no\-symbol amounts in the journal. +.PP +Then each commodity\[aq]s display style is determined from its +\f[CR]commodity\f[R] directive. +We recommend always declaring commodities with \f[CR]commodity\f[R] +directives, since they help ensure consistent display styles and +precisions, and bring other benefits such as error checking for +commodity symbols. +Here\[aq]s an example: +.IP +.EX +# Set display styles (and decimal marks, for parsing, if there is no decimal\-mark directive) +# for the $, EUR, INR and no\-symbol commodities: +commodity $1,000.00 +commodity EUR 1.000,00 +commodity INR 9,99,99,999.00 +commodity 1 000 000.9455 +.EE +.PP +But for convenience, if a \f[CR]commodity\f[R] directive is not present, +hledger infers a commodity\[aq]s display styles from its amounts as they +are written in the journal (excluding cost amounts and amounts in +periodic transaction rules or auto posting rules). +It uses +.IP \[bu] 2 +the symbol placement and decimal mark of the first amount seen +.IP \[bu] 2 +the digit group marks of the first amount with digit group marks +.IP \[bu] 2 +and the maximum number of decimal digits seen across all amounts. +.PP +And as fallback if no applicable amounts are found, it would use a +default style, like \f[CR]$1000.00\f[R] (symbol on the left with no +space, period as decimal mark, and two decimal digits). +.PP +Finally, commodity styles can be overridden by the +\f[CR]\-c/\-\-commodity\-style\f[R] command line option. +.SS Rounding +Amounts are stored internally as decimal numbers with up to 255 decimal +places. +They are displayed with their original journal precisions by print and +print\-like reports, and rounded to their display precision (the number +of decimal digits specified by the commodity display style) by other +reports. +When rounding, hledger uses banker\[aq]s rounding (it rounds to the +nearest even digit). +So eg 0.5 displayed with zero decimal digits appears as \[dq]0\[dq]. +.SS Trailing decimal marks +If you\[aq]re wondering why your \f[CR]print\f[R] report sometimes shows +trailing decimal marks, with no decimal digits; it does this when +showing amounts that have digit group marks but no decimal digits, to +disambiguate them and allow them to be re\-parsed reliably (see Decimal +marks). +Eg: +.IP +.EX +commodity $1,000.00 + +2023\-01\-02 + (a) $1000 +.EE +.IP +.EX +$ hledger print +2023\-01\-02 + (a) $1,000. +.EE +.PP +If this is a problem (eg when exporting to Ledger), you can avoid it by +disabling digit group marks, eg with \-c/\-\-commodity (for each +affected commodity): +.IP +.EX +$ hledger print \-c \[aq]$1000.00\[aq] +2023\-01\-02 + (a) $1000 +.EE +.PP +or by forcing print to always show decimal digits, with \-\-round: +.IP +.EX +$ hledger print \-c \[aq]$1,000.00\[aq] \-\-round=soft +2023\-01\-02 + (a) $1,000.00 +.EE +.SS Amount parseability +More generally, hledger output falls into three rough categories, which +format amounts a little bit differently to suit different consumers: +.PP +\f[B]1. +\[dq]hledger\-readable output\[dq] \- should be readable by hledger (and +by humans)\f[R] +.IP \[bu] 2 +This is produced by reports that show full journal entries: +\f[CR]print\f[R], \f[CR]import\f[R], \f[CR]close\f[R], +\f[CR]rewrite\f[R] etc. +.IP \[bu] 2 +It shows amounts with their original journal precisions, which may not +be consistent. +.IP \[bu] 2 +It adds a trailing decimal mark when needed to avoid showing ambiguous +amounts. +.IP \[bu] 2 +It can be parsed reliably (by hledger and ledger2beancount at least, but +perhaps not by Ledger..) +.PP +\f[B]2. +\[dq]human\-readable output\[dq] \- usually for humans\f[R] +.IP \[bu] 2 +This is produced by all other reports. +.IP \[bu] 2 +It shows amounts with standard display precisions, which will be +consistent within each commodity. +.IP \[bu] 2 +It shows ambiguous amounts unmodified. +.IP \[bu] 2 +It can be parsed reliably in the context of a known report (when you +know decimals are consistently not being shown, you can assume a single +mark is a digit group mark). +.PP +\f[B]3. +\[dq]machine\-readable output\[dq] \- usually for other software\f[R] +.IP \[bu] 2 +This is produced by all reports when an output format like +\f[CR]csv\f[R], \f[CR]tsv\f[R], \f[CR]json\f[R], or \f[CR]sql\f[R] is +selected. +.IP \[bu] 2 +It shows amounts as 1 or 2 do, but without digit group marks. +.IP \[bu] 2 +It can be parsed reliably (if needed, the decimal mark can be changed +with \-c/\-\-commodity\-style). .SH Cost reporting In some transactions \- for example a currency conversion, or a purchase or sale of stock \- one commodity is exchanged for another. @@ -7795,51 +7679,34 @@ T} \f[CR]\-\-cumulative\f[R] is omitted to save space, it works like \f[CR]\-H\f[R] but with a zero starting balance. .SH PART 4: COMMANDS -.SS Commands overview -Here are the built\-in commands: -.SS DATA ENTRY -These data entry commands are the only ones which can modify your -journal file. +\ +.PP +Here are the standard commands, which you can list by running +\f[CR]hledger\f[R]. +If you have installed more add\-on commands, they also will be listed. +.PP +\f[B]Help commands\f[R] +.IP \[bu] 2 +help \- show the hledger manual with info/man/pager +.IP \[bu] 2 +demo \- show small hledger demos in the terminal +.PP +\f[B]User interface commands\f[R] +.IP \[bu] 2 +ui \- (if installed) run hledger\[aq]s terminal UI +.IP \[bu] 2 +web \- (if installed) run hledger\[aq]s web UI +.PP +\f[B]Data entry commands\f[R] .IP \[bu] 2 add \- add transactions using terminal prompts .IP \[bu] 2 import \- add new transactions from other files, eg CSV files -.SS DATA CREATION -.IP \[bu] 2 -close \- generate balance\-zeroing/restoring transactions -.IP \[bu] 2 -rewrite \- generate auto postings, like print \-\-auto -.SS DATA MANAGEMENT -.IP \[bu] 2 -check \- check for various kinds of error in the data -.IP \[bu] 2 -diff \- compare account transactions in two journal files -.SS REPORTS, FINANCIAL -.IP \[bu] 2 -aregister (areg) \- show transactions in a particular account -.IP \[bu] 2 -balancesheet (bs) \- show assets, liabilities and net worth -.IP \[bu] 2 -balancesheetequity (bse) \- show assets, liabilities and equity -.IP \[bu] 2 -cashflow (cf) \- show changes in liquid assets -.IP \[bu] 2 -incomestatement (is) \- show revenues and expenses -.SS REPORTS, VERSATILE -.IP \[bu] 2 -balance (bal) \- show balance changes, end balances, budgets, gains.. -.IP \[bu] 2 -print \- show transactions or export journal data -.IP \[bu] 2 -register (reg) \- show postings in one or more accounts & running total -.IP \[bu] 2 -roi \- show return on investments -.SS REPORTS, BASIC +.PP +\f[B]Basic report commands\f[R] .IP \[bu] 2 accounts \- show account names .IP \[bu] 2 -activity \- show bar charts of posting counts per period -.IP \[bu] 2 codes \- show transaction codes .IP \[bu] 2 commodities \- show commodity/currency symbols @@ -7857,34 +7724,342 @@ prices \- show market prices stats \- show journal statistics .IP \[bu] 2 tags \- show tag names +.PP +\f[B]Standard report commands\f[R] +.IP \[bu] 2 +print \- show transactions or export journal data +.IP \[bu] 2 +aregister (areg) \- show transactions in a particular account +.IP \[bu] 2 +register (reg) \- show postings in one or more accounts & running total +.IP \[bu] 2 +balancesheet (bs) \- show assets, liabilities and net worth +.IP \[bu] 2 +balancesheetequity (bse) \- show assets, liabilities and equity +.IP \[bu] 2 +cashflow (cf) \- show changes in liquid assets +.IP \[bu] 2 +incomestatement (is) \- show revenues and expenses +.PP +\f[B]Advanced report commands\f[R] +.IP \[bu] 2 +balance (bal) \- show balance changes, end balances, budgets, gains.. +.IP \[bu] 2 +roi \- show return on investments +.PP +\f[B]Chart commands\f[R] +.IP \[bu] 2 +activity \- show bar charts of posting counts per period +.PP +\f[B]Data generation commands\f[R] +.IP \[bu] 2 +close \- generate balance\-zeroing/restoring transactions +.IP \[bu] 2 +rewrite \- generate auto postings, like print \-\-auto +.PP +\f[B]Maintenance commands\f[R] +.IP \[bu] 2 +check \- check for various kinds of error in the data +.IP \[bu] 2 +diff \- compare account transactions in two journal files .IP \[bu] 2 test \- run self tests -.SS HELP -.IP \[bu] 2 -help \- show the hledger manual with info/man/pager -.IP \[bu] 2 -demo \- show small hledger demos in the terminal .PP -\ -.SS ADD\-ONS -And here are some typical add\-on commands. -Some of these are installed by the hledger\-install script. -If installed, they will appear in hledger\[aq]s commands list: -.IP \[bu] 2 -ui \- run hledger\[aq]s terminal UI -.IP \[bu] 2 -web \- run hledger\[aq]s web UI -.IP \[bu] 2 -iadd \- add transactions using a TUI (currently hard to build) -.IP \[bu] 2 -interest \- generate interest transactions -.IP \[bu] 2 -stockquotes \- download market prices from AlphaVantage -.IP \[bu] 2 -Scripts and add\-ons \- check\-fancyassertions, edit, fifo, git, move, -pijul, plot, and more.. +Next, these commands are described in detail. +.SH Help commands +.SS help +Show the hledger user manual with \f[CR]info\f[R], \f[CR]man\f[R], or a +pager. +With a (case insensitive) TOPIC argument, try to open it at that section +heading. .PP -Next, each command is described in detail, in alphabetical order. +This command shows the hledger manual built in to your hledger +executable. +It can be useful when offline, or when you prefer the terminal to a web +browser, or when the appropriate hledger manual or viewers are not +installed properly on your system. +.PP +By default it chooses the best viewer found in $PATH, trying in this +order: \f[CR]info\f[R], \f[CR]man\f[R], \f[CR]$PAGER\f[R], +\f[CR]less\f[R], \f[CR]more\f[R], stdout. +(If a TOPIC is specified, \f[CR]$PAGER\f[R] and \f[CR]more\f[R] are not +tried.) +You can force the use of info, man, or a pager with the \f[CR]\-i\f[R], +\f[CR]\-m\f[R], or \f[CR]\-p\f[R] flags. +If no viewer can be found, or if running non\-interactively, it just +prints the manual to stdout. +.PP +When using \f[CR]info\f[R], TOPIC can match either the full heading or a +prefix. +If your \f[CR]info \-\-version\f[R] is < 6, you\[aq]ll need to upgrade +it, eg with \[aq]\f[CR]brew install texinfo\f[R]\[aq] on mac. +.PP +When using \f[CR]man\f[R] or \f[CR]less\f[R], TOPIC must match the full +heading. +For a prefix match, you can write \[aq]\f[CR]TOPIC.*\f[R]\[aq]. +.PP +Examples +.IP +.EX +$ hledger help \-h # show the help command\[aq]s usage +$ hledger help # show the manual with info, man or $PAGER +$ hledger help \[aq]time periods\[aq] # show the manual\[aq]s \[dq]Time periods\[dq] topic +$ hledger help \[aq]time periods\[aq] \-m # use man, even if info is installed +.EE +.SS demo +Play demos of hledger usage in the terminal, if asciinema is installed. +.PP +Run this command with no argument to list the demos. +To play a demo, write its number or a prefix or substring of its title. +Tips: +.PP +Make your terminal window large enough to see the demo clearly. +.PP +Use the \-s/\-\-speed SPEED option to set your preferred playback speed, +eg \f[CR]\-s4\f[R] to play at 4x original speed or \f[CR]\-s.5\f[R] to +play at half speed. +The default speed is 2x. +.PP +Other asciinema options can be added following a double dash, eg +\f[CR]\-\- \-i.1\f[R] to limit pauses or \f[CR]\-\- \-h\f[R] to list +asciinema\[aq]s other options. +.PP +During playback, several keys are available: SPACE to pause/unpause, . +to step forward (while paused), CTRL\-c quit. +.PP +Examples: +.IP +.EX +$ hledger demo # list available demos +$ hledger demo 1 # play the first demo at default speed (2x) +$ hledger demo install \-s4 # play the \[dq]install\[dq] demo at 4x speed +.EE +.SH User interface commands +.SS ui +Runs hledger\-ui (if installed). +.SS web +Runs hledger\-web (if installed). +.SH Data entry commands +.SS add +Prompt for transactions and add them to the journal. +Any arguments will be used as default inputs for the first N prompts. +.PP +Many hledger users edit their journals directly with a text editor, or +generate them from CSV. +For more interactive data entry, there is the \f[CR]add\f[R] command, +which prompts interactively on the console for new transactions, and +appends them to the main journal file (which should be in journal +format). +Existing transactions are not changed. +This is one of the few hledger commands that writes to the journal file +(see also \f[CR]import\f[R]). +.PP +To use it, just run \f[CR]hledger add\f[R] and follow the prompts. +You can add as many transactions as you like; when you are finished, +enter \f[CR].\f[R] or press control\-d or control\-c to exit. +.PP +Features: +.IP \[bu] 2 +add tries to provide useful defaults, using the most similar (by +description) recent transaction (filtered by the query, if any) as a +template. +.IP \[bu] 2 +You can also set the initial defaults with command line arguments. +.IP \[bu] 2 +Readline\-style edit keys can be used during data entry. +.IP \[bu] 2 +The tab key will auto\-complete whenever possible \- accounts, +payees/descriptions, dates (\f[CR]yesterday\f[R], \f[CR]today\f[R], +\f[CR]tomorrow\f[R]). +If the input area is empty, it will insert the default value. +.IP \[bu] 2 +If the journal defines a default commodity, it will be added to any bare +numbers entered. +.IP \[bu] 2 +A parenthesised transaction code may be entered following a date. +.IP \[bu] 2 +Comments and tags may be entered following a description or amount. +.IP \[bu] 2 +If you make a mistake, enter \f[CR]<\f[R] at any prompt to go one step +backward. +.IP \[bu] 2 +Input prompts are displayed in a different colour when the terminal +supports it. +.PP +Notes: +.IP \[bu] 2 +If you enter a number with no commodity symbol, and you have declared a +default commodity with a \f[CR]D\f[R] directive, you might expect +\f[CR]add\f[R] to add this symbol for you. +It does not do this; we assume that if you are using a \f[CR]D\f[R] +directive you prefer not to see the commodity symbol repeated on amounts +in the journal. +.PP +Examples: +.IP \[bu] 2 +Record new transactions, saving to the default journal file: +.RS 2 +.PP +\f[CR]hledger add\f[R] +.RE +.IP \[bu] 2 +Add transactions to 2024.journal, but also load 2023.journal for +completions: +.RS 2 +.PP +\f[CR]hledger add \-\-file 2024.journal \-\-file 2023.journal\f[R] +.RE +.IP \[bu] 2 +Provide answers for the first four prompts: +.RS 2 +.PP +\f[CR]hledger add today \[aq]best buy\[aq] expenses:supplies \[aq]$20\[aq]\f[R] +.RE +.PP +There is a detailed tutorial at https://hledger.org/add.html. +.SS import +Read new transactions added to each FILE provided as arguments since +last run, and add them to the journal. +Or with \-\-dry\-run, just print the transactions that would be added. +Or with \-\-catchup, just mark all of the FILEs\[aq] current +transactions as imported, without importing them. +.PP +This command may append new transactions to the main journal file (which +should be in journal format). +Existing transactions are not changed. +This is one of the few hledger commands that writes to the journal file +(see also \f[CR]add\f[R]). +.PP +Unlike other hledger commands, with \f[CR]import\f[R] the journal file +is an output 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 +\f[CR]hledger import bank.csv\f[R] or perhaps +\f[CR]hledger import *.csv\f[R]. +.PP +Note you can import from any file format, though CSV files are the most +common import source, and these docs focus on that case. +.SS Date skipping +\f[CR]import\f[R] tries to import only the transactions which are new +since the last import, ignoring any that it has seen in previous runs. +So if your bank\[aq]s CSV includes the last three months of data, you +can download and \f[CR]import\f[R] it every month (or week, or day) and +only the new transactions will be imported each time. +.PP +It works as follows: for each imported \f[CR]FILE\f[R], +.IP \[bu] 2 +It tries to read the latest date previously seen, from +\f[CR].latest.FILE\f[R] in the same directory +.IP \[bu] 2 +Then it processes \f[CR]FILE\f[R], ignoring transactions on or before +that date +.PP +And after a successful import, unless \f[CR]\-\-dry\-run\f[R] was used, +it updates the \f[CR].latest.FILE\f[R](s) for next time. +This is a simple system that works for most real\-world CSV files; it +assumes the following are true, or true enough: +.IP "1." 3 +the name of the input file is stable across successive downloads +.IP "2." 3 +new items always have the newest dates +.IP "3." 3 +item dates are stable across downloads +.IP "4." 3 +the order of same\-date items is stable across downloads. +.PP +Tips: +.IP \[bu] 2 +To help ensure a stable file name, remember you can use a CSV rules file +as an input file. +.IP \[bu] 2 +If you have a bank whose CSV dates or ordering occasionally change, you +can reduce the chance of this happening in new transactions by importing +more often. +(If it happens in old transactions, that\[aq]s harmless.) +.PP +Note this is just one kind of \[dq]deduplication\[dq]: not reprocessing +the same dates across successive runs. +\f[CR]import\f[R] doesn\[aq]t detect other kinds of duplication, such as +the same transaction appearing multiple times within a single run, or a +new transaction that looks identical to a transaction already in the +journal. +(Because these can happen legitimately in real\-world data.) +.PP +Here\[aq]s a situation where you need to run \f[CR]import\f[R] with +care: say you download but forget to import \f[CR]bank.1.csv\f[R], and a +week later you download \f[CR]bank.2.csv\f[R] with some overlapping +data. +You should not process both of these as a single import +(\f[CR]hledger import bank.1.csv bank.2.csv\f[R]), because the +overlapping transactions would not be deduplicated. +Instead, import one file at a time, using the same filename each time: +.IP +.EX +$ mv bank.1.csv bank.csv; hledger import bank.csv +$ mv bank.2.csv bank.csv; hledger import bank.csv +.EE +.PP +Normally you don\[aq]t need to think about \f[CR].latest.*\f[R] files, +but you can create or modify them to catch up to a certain date, or +delete them to mark all transactions as new. +Their format is a single ISO\-format \f[CR]YYYY\-MM\-DD\f[R] date, +optionally repeated on multiple lines, meaning \[dq]I have seen the +transactions before this date, and this many of them on this date\[dq]. +.PP +\f[CR]hledger print \-\-new\f[R] also uses and updates these +\f[CR].latest.*\f[R] files, but it is less often used. +.PP +Related: CSV > Working with CSV > Deduplicating, importing. +.SS Import testing +With \f[CR]\-\-dry\-run\f[R], 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 +categorised: +.IP +.EX +$ hledger import \-\-dry bank.csv | hledger \-f\- \-I print unknown +.EE +.PP +or (live updating): +.IP +.EX +$ ls bank.csv* | entr bash \-c \[aq]echo ====; hledger import \-\-dry bank.csv | hledger \-f\- \-I print unknown\[aq] +.EE +.PP +Note: when importing from multiple files at once, it\[aq]s currently +possible for some .latest files to be updated successfully, while the +actual import fails because of a problem in one of the files, leaving +them out of sync (and causing some transactions to be missed). +To prevent this, do a \-\-dry\-run first and fix any problems before the +real import. +.SS Importing balance assignments +Entries added by import will have their posting amounts made explicit +(like \f[CR]hledger print \-x\f[R]). +This means that any balance assignments in imported files must be +evaluated; but, imported files don\[aq]t get to see the main file\[aq]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 amounts. +To avoid this problem, use print instead of import: +.IP +.EX +$ hledger print IMPORTFILE [\-\-new] >> $LEDGER_FILE +.EE +.PP +(If you think import should leave amounts implicit like print does, +please test it and send a pull request.) +.SS Import and commodity styles +Amounts in entries added by import will be formatted according to the +journal\[aq]s canonical commodity styles, as declared by +\f[CR]commodity\f[R] directives or inferred from the journal\[aq]s +amounts. +.PP +Related: CSV > Amount decimal places. +.SH Basic report commands .SS accounts Show account names. .PP @@ -7948,104 +8123,395 @@ liabilities:debts $ hledger accounts \-\-undeclared \-\-directives >> $LEDGER_FILE $ hledger check accounts .EE -.SS activity -Show an ascii barchart of posting counts per interval. +.SS codes +List the codes seen in transactions, in the order parsed. .PP -The activity command displays an ascii histogram showing transaction -counts by day, week, month or other reporting interval (by day is the -default). -With query arguments, it counts only matched transactions. +This command prints the value of each transaction\[aq]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. +.PP +Transactions aren\[aq]t required to have a code, and missing or empty +codes will not be shown by default. +With the \f[CR]\-E\f[R]/\f[CR]\-\-empty\f[R] flag, they will be printed +as blank lines. +.PP +You can add a query to select a subset of transactions. .PP Examples: .IP .EX -$ hledger activity \-\-quarterly -2008\-01\-01 ** -2008\-04\-01 ******* -2008\-07\-01 -2008\-10\-01 ** +2022/1/1 (123) Supermarket + Food $5.00 + Checking + +2022/1/2 (124) Post Office + Postage $8.32 + Checking + +2022/1/3 Supermarket + Food $11.23 + Checking + +2022/1/4 (126) Post Office + Postage $3.21 + Checking .EE -.SS add -Prompt for transactions and add them to the journal. -Any arguments will be used as default inputs for the first N prompts. -.PP -Many hledger users edit their journals directly with a text editor, or -generate them from CSV. -For more interactive data entry, there is the \f[CR]add\f[R] command, -which prompts interactively on the console for new transactions, and -appends them to the main journal file (which should be in journal -format). -Existing transactions are not changed. -This is one of the few hledger commands that writes to the journal file -(see also \f[CR]import\f[R]). -.PP -To use it, just run \f[CR]hledger add\f[R] and follow the prompts. -You can add as many transactions as you like; when you are finished, -enter \f[CR].\f[R] or press control\-d or control\-c to exit. -.PP -Features: -.IP \[bu] 2 -add tries to provide useful defaults, using the most similar (by -description) recent transaction (filtered by the query, if any) as a -template. -.IP \[bu] 2 -You can also set the initial defaults with command line arguments. -.IP \[bu] 2 -Readline\-style edit keys can be used during data entry. -.IP \[bu] 2 -The tab key will auto\-complete whenever possible \- accounts, -payees/descriptions, dates (\f[CR]yesterday\f[R], \f[CR]today\f[R], -\f[CR]tomorrow\f[R]). -If the input area is empty, it will insert the default value. -.IP \[bu] 2 -If the journal defines a default commodity, it will be added to any bare -numbers entered. -.IP \[bu] 2 -A parenthesised transaction code may be entered following a date. -.IP \[bu] 2 -Comments and tags may be entered following a description or amount. -.IP \[bu] 2 -If you make a mistake, enter \f[CR]<\f[R] at any prompt to go one step -backward. -.IP \[bu] 2 -Input prompts are displayed in a different colour when the terminal -supports it. -.PP -Example (see https://hledger.org/add.html for a detailed tutorial): .IP .EX -$ hledger add -Adding transactions to journal file /src/hledger/examples/sample.journal -Any command line arguments will be used as defaults. -Use tab key to complete, readline keys to edit, enter to accept defaults. -An optional (CODE) may follow transaction dates. -An optional ; COMMENT may follow descriptions or amounts. -If you make a mistake, enter < at any prompt to go one step backward. -To end a transaction, enter . when prompted. -To quit, enter . at a date prompt or press control\-d or control\-c. -Date [2015/05/22]: -Description: supermarket -Account 1: expenses:food -Amount 1: $10 -Account 2: assets:checking -Amount 2 [$\-10.0]: -Account 3 (or . or enter to finish this transaction): . -2015/05/22 supermarket - expenses:food $10 - assets:checking $\-10.0 +$ hledger codes +123 +124 +126 +.EE +.IP +.EX +$ hledger codes \-E +123 +124 -Save this transaction to the journal ? [y]: -Saved. -Starting the next transaction (. or ctrl\-D/ctrl\-C to quit) -Date [2015/05/22]: $ +126 +.EE +.SS commodities +List all commodity/currency symbols used or declared in the journal. +.SS descriptions +List the unique descriptions that appear in transactions. +.PP +This command lists the unique descriptions that appear in transactions, +in alphabetic order. +You can add a query to select a subset of transactions. +.PP +Example: +.IP +.EX +$ hledger descriptions +Store Name +Gas Station | Petrol +Person A +.EE +.SS files +List all files included in the journal. +With a REGEX argument, only file names matching the regular expression +(case sensitive) are shown. +.SS notes +List the unique notes that appear in transactions. +.PP +This command lists the unique notes that appear in transactions, in +alphabetic order. +You can add a query to select a subset of transactions. +The note is the part of the transaction description after a | character +(or if there is no |, the whole description). +.PP +Example: +.IP +.EX +$ hledger notes +Petrol +Snacks +.EE +.SS payees +List the unique payee/payer names that appear in transactions. +.PP +This command lists unique payee/payer names which have been declared +with payee directives (\-\-declared), used in transaction descriptions +(\-\-used), or both (the default). +.PP +The payee/payer is the part of the transaction description before a | +character (or if there is no |, the whole description). +.PP +You can add query arguments to select a subset of transactions. +This implies \-\-used. +.PP +Example: +.IP +.EX +$ hledger payees +Store Name +Gas Station +Person A +.EE +.SS prices +Print the market prices declared with P directives. +With \-\-infer\-market\-prices, also show any additional prices inferred +from costs. +With \-\-show\-reverse, also show additional prices inferred by +reversing known prices. +.PP +Price amounts are always displayed with their full precision, except for +reverse prices which are limited to 8 decimal digits. +.PP +Prices can be filtered by a date:, cur: or amt: query. +.PP +Generally if you run this command with \-\-infer\-market\-prices +\-\-show\-reverse, it will show the same prices used internally to +calculate value reports. +But if in doubt, you can inspect those directly by running the value +report with \-\-debug=2. +.SS stats +Show journal and performance statistics. +.PP +The stats command shows summary information for the whole journal, or a +matched part of it. +With a reporting interval, it shows a report for each report period. +.PP +The default output is fairly impersonal, though it reveals the main file +name. +With \f[CR]\-v/\-\-verbose\f[R], more details are shown, like file +paths, included files, and commodity names. +.PP +It also shows some run time statistics: +.IP \[bu] 2 +elapsed time +.IP \[bu] 2 +throughput: the number of transactions processed per second +.IP \[bu] 2 +live: the peak memory in use by the program to do its work +.IP \[bu] 2 +alloc: the peak memory allocation from the OS as seen by GHC. +Measuring this externally, eg with GNU time, is more accurate; usually +that will be a larger number; sometimes (with swapping?) +smaller. +.PP +The \f[CR]stats\f[R] command\[aq]s run time is similar to that of a +balance report. +.PP +Example: +.IP +.EX +$ hledger stats \-f examples/1ktxns\-1kaccts.journal +Main file : .../1ktxns\-1kaccts.journal +Included files : 0 +Txns span : 2000\-01\-01 to 2002\-09\-27 (1000 days) +Last txn : 2002\-09\-26 (7827 days ago) +Txns : 1000 (1.0 per day) +Txns last 30 days : 0 (0.0 per day) +Txns last 7 days : 0 (0.0 per day) +Payees/descriptions : 1000 +Accounts : 1000 (depth 10) +Commodities : 26 +Market prices : 1000 +Runtime stats : 0.12 s elapsed, 8266 txns/s, 4 MB live, 16 MB alloc .EE .PP -If you enter a number with no commodity symbol, and you have declared a -default commodity with a \f[CR]D\f[R] directive, you might expect -\f[CR]add\f[R] to add this symbol for you. -It does not do this; we assume that if you are using a \f[CR]D\f[R] -directive you prefer not to see the commodity symbol repeated on amounts -in the journal. +This command supports the \-o/\-\-output\-file option (but not +\-O/\-\-output\-format). +.SS tags +List the tags used in the journal, or their values. +.PP +This command lists the tag names used in the journal, whether on +transactions, postings, or account declarations. +.PP +With a TAGREGEX argument, only tag names matching this regular +expression (case insensitive, infix matched) are shown. +.PP +With QUERY arguments, only transactions and accounts matching this query +are considered. +If the query involves transaction fields (date:, desc:, amt:, ...), the +search is restricted to the matched transactions and their accounts. +.PP +With the \-\-values flag, the tags\[aq] unique non\-empty values are +listed instead. +With \-E/\-\-empty, blank/empty values are also shown. +.PP +With \-\-parsed, tags or values are shown in the order they were parsed, +with duplicates included. +(Except, tags from account declarations are always shown first.) +.PP +Tip: remember, accounts also acquire tags from their parents, postings +also acquire tags from their account and transaction, transactions also +acquire tags from their postings. +.SH Standard report commands +.SS print +Show transaction journal entries, sorted by date. +.PP +The print command displays full journal entries (transactions) from the +journal file, sorted by date (or with \f[CR]\-\-date2\f[R], by secondary +date). +.PP +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/regenerate your journal you should take care to also copy +over the directives and inter\-transaction comments. +.PP +Eg: +.IP +.EX +$ hledger print \-f examples/sample.journal date:200806 +2008/06/01 gift + assets:bank:checking $1 + income:gifts $\-1 + +2008/06/02 save + assets:bank:saving $1 + assets:bank:checking $\-1 + +2008/06/03 * eat & shop + expenses:food $1 + expenses:supplies $1 + assets:cash $\-2 +.EE +.SS print explicitness +Normally, whether posting amounts are implicit or explicit is preserved. +For example, when an amount is omitted in the journal, it will not +appear in the output. +Similarly, if a conversion cost is implied but not written, it will not +appear in the output. +.PP +You can use the \f[CR]\-x\f[R]/\f[CR]\-\-explicit\f[R] flag to force +explicit display of all amounts and costs. +This can be useful for troubleshooting or for making your journal more +readable and robust against data entry errors. +\f[CR]\-x\f[R] is also implied by using any of +\f[CR]\-B\f[R],\f[CR]\-V\f[R],\f[CR]\-X\f[R],\f[CR]\-\-value\f[R]. +.PP +The \f[CR]\-x\f[R]/\f[CR]\-\-explicit\f[R] flag will cause any postings +with a multi\-commodity amount (which can arise when a multi\-commodity +transaction has an implicit amount) to be split into multiple +single\-commodity postings, keeping the output parseable. +.SS print amount style +Amounts are shown right\-aligned within each transaction (but not +aligned across all transactions; you can do that with ledger\-mode in +Emacs). +.PP +Amounts will be (mostly) normalised to their commodity display style: +their symbol placement, decimal mark, and digit group marks will be made +consistent. +By default, decimal digits are shown as they are written in the journal. +.PP +With the \f[CR]\-\-round\f[R] (\f[I]Added in 1.32\f[R]) option, +\f[CR]print\f[R] will try increasingly hard to display decimal digits +according to the commodity display styles: +.IP \[bu] 2 +\f[CR]\-\-round=none\f[R] show amounts with original precisions +(default) +.IP \[bu] 2 +\f[CR]\-\-round=soft\f[R] add/remove decimal zeros in amounts (except +costs) +.IP \[bu] 2 +\f[CR]\-\-round=hard\f[R] round amounts (except costs), possibly hiding +significant digits +.IP \[bu] 2 +\f[CR]\-\-round=all\f[R] round all amounts and costs +.PP +\f[CR]soft\f[R] is good for non\-lossy cleanup, formatting amounts more +consistently where it\[aq]s safe to do so. +.PP +\f[CR]hard\f[R] and \f[CR]all\f[R] can cause \f[CR]print\f[R] to show +invalid unbalanced journal entries; they may be useful eg for stronger +cleanup, with manual fixups when needed. +.SS print parseability +print\[aq]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 (though the same can be +achieved with \f[CR]expr:\f[R] queries now): +.IP +.EX +# Show running total of food expenses paid from cash. +# \-f\- reads from stdin. \-I/\-\-ignore\-assertions is sometimes needed. +$ hledger print assets:cash | hledger \-f\- \-I reg expenses:food +.EE +.PP +There are some situations where print\[aq]s output can become +unparseable: +.IP \[bu] 2 +Value reporting affects posting amounts but not balance assertion or +balance assignment amounts, potentially causing those to fail. +.IP \[bu] 2 +Auto postings can generate postings with too many missing amounts. +.IP \[bu] 2 +Account aliases can generate bad account names. +.SS print, other features +With \f[CR]\-B\f[R]/\f[CR]\-\-cost\f[R], amounts with costs are shown +converted to cost. +.PP +With \f[CR]\-\-new\f[R], print shows only transactions it has not seen +on a previous run. +This uses the same deduplication system as the \f[CR]import\f[R] +command. +(See import\[aq]s docs for details.) +.PP +With \f[CR]\-m DESC\f[R]/\f[CR]\-\-match=DESC\f[R], print shows one +recent transaction whose description is most similar to DESC. +DESC should contain at least two characters. +If there is no similar\-enough match, no transaction will be shown and +the program exit code will be non\-zero. +.SS print output format +This command also supports the output destination and output format +options The output formats supported are \f[CR]txt\f[R], +\f[CR]beancount\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]csv\f[R], +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]json\f[R] and +\f[CR]sql\f[R]. +.PP +The \f[CR]beancount\f[R] format tries to produce Beancount\-compatible +output, as follows: +.IP \[bu] 2 +Transaction and postings with unmarked status are converted to cleared +(\f[CR]*\f[R]) status. +.IP \[bu] 2 +Transactions\[aq] payee and note are backslash\-escaped and +double\-quote\-escaped and wrapped in double quotes. +.IP \[bu] 2 +Transaction tags are copied to Beancount #tag format. +.IP \[bu] 2 +Commodity symbols are converted to upper case, and a small number of +currency symbols like \f[CR]$\f[R] are converted to the corresponding +currency names. +.IP \[bu] 2 +Account name parts are capitalised and unsupported characters are +replaced with \f[CR]\-\f[R]. +If an account name part does not begin with a letter, or if the first +part is not Assets, Liabilities, Equity, Income, or Expenses, an error +is raised. +(Use \f[CR]\-\-alias\f[R] options to bring your accounts into +compliance.) +.IP \[bu] 2 +An \f[CR]open\f[R] directive is generated for each account used, on the +earliest transaction date. +.PP +Some limitations: +.IP \[bu] 2 +Balance assertions are removed. +.IP \[bu] 2 +Balance assignments become missing amounts. +.IP \[bu] 2 +Virtual and balanced virtual postings become regular postings. +.IP \[bu] 2 +Directives are not converted. +.PP +Here\[aq]s an example of print\[aq]s CSV output: +.IP +.EX +$ hledger print \-Ocsv +\[dq]txnidx\[dq],\[dq]date\[dq],\[dq]date2\[dq],\[dq]status\[dq],\[dq]code\[dq],\[dq]description\[dq],\[dq]comment\[dq],\[dq]account\[dq],\[dq]amount\[dq],\[dq]commodity\[dq],\[dq]credit\[dq],\[dq]debit\[dq],\[dq]posting\-status\[dq],\[dq]posting\-comment\[dq] +\[dq]1\[dq],\[dq]2008/01/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]income\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] +\[dq]1\[dq],\[dq]2008/01/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]income\[dq],\[dq]\[dq],\[dq]income:salary\[dq],\[dq]\-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq] +\[dq]2\[dq],\[dq]2008/06/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]gift\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] +\[dq]2\[dq],\[dq]2008/06/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]gift\[dq],\[dq]\[dq],\[dq]income:gifts\[dq],\[dq]\-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq] +\[dq]3\[dq],\[dq]2008/06/02\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]save\[dq],\[dq]\[dq],\[dq]assets:bank:saving\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] +\[dq]3\[dq],\[dq]2008/06/02\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]save\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]\-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq] +\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]expenses:food\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] +\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]expenses:supplies\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] +\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]assets:cash\[dq],\[dq]\-2\[dq],\[dq]$\[dq],\[dq]2\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq] +\[dq]5\[dq],\[dq]2008/12/31\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]pay off\[dq],\[dq]\[dq],\[dq]liabilities:debts\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] +\[dq]5\[dq],\[dq]2008/12/31\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]pay off\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]\-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq] +.EE +.IP \[bu] 2 +There is one CSV record per posting, with the parent transaction\[aq]s +fields repeated. +.IP \[bu] 2 +The \[dq]txnidx\[dq] (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 order, etc.) +.IP \[bu] 2 +The amount is separated into \[dq]commodity\[dq] (the symbol) and +\[dq]amount\[dq] (numeric quantity) fields. +.IP \[bu] 2 +The numeric amount is repeated in either the \[dq]credit\[dq] or +\[dq]debit\[dq] column, for convenience. +(Those names are not accurate in the accounting sense; it just puts +negative amounts under credit and zero or greater amounts under debit.) .SS aregister (areg) .PP @@ -8136,6 +8602,373 @@ Use \f[CR]register \-H\f[R] if you need to see the individual postings. There is also a \f[CR]\-\-txn\-dates\f[R] flag, which filters strictly by transaction date, ignoring posting dates. This too can cause an inaccurate running balance. +.SS register +(reg) +.PP +Show postings and their running total. +.PP +The register command displays matched postings, across all accounts, in +date order, with their running total or running historical balance. +(See also the \f[CR]aregister\f[R] command, which shows matched +transactions in a specific account.) +.PP +register normally shows line per posting, but note that multi\-commodity +amounts will occupy multiple lines (one line per commodity). +.PP +It is typically used with a query selecting a particular account, to see +that account\[aq]s activity: +.IP +.EX +$ hledger register checking +2008/01/01 income assets:bank:checking $1 $1 +2008/06/01 gift assets:bank:checking $1 $2 +2008/06/02 save assets:bank:checking $\-1 $1 +2008/12/31 pay off assets:bank:checking $\-1 0 +.EE +.PP +With \f[CR]\-\-date2\f[R], it shows and sorts by secondary date instead. +.PP +For performance reasons, column widths are chosen based on the first +1000 lines; this means unusually wide values in later lines can cause +visual discontinuities as column widths are adjusted. +If you want to ensure perfect alignment, at the cost of more time and +memory, use the \f[CR]\-\-align\-all\f[R] flag. +.PP +The \f[CR]\-\-historical\f[R]/\f[CR]\-H\f[R] flag adds the balance from +any undisplayed prior postings to the running total. +This is useful when you want to see only recent activity, with a +historically accurate running balance: +.IP +.EX +$ hledger register checking \-b 2008/6 \-\-historical +2008/06/01 gift assets:bank:checking $1 $2 +2008/06/02 save assets:bank:checking $\-1 $1 +2008/12/31 pay off assets:bank:checking $\-1 0 +.EE +.PP +The \f[CR]\-\-depth\f[R] option limits the amount of sub\-account detail +displayed. +.PP +The \f[CR]\-\-average\f[R]/\f[CR]\-A\f[R] 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 \f[CR]\-\-empty\f[R] (see below). +It is affected by \f[CR]\-\-historical\f[R]. +It works best when showing just one account and one commodity. +.PP +The \f[CR]\-\-related\f[R]/\f[CR]\-r\f[R] flag shows the \f[I]other\f[R] +postings in the transactions of the postings which would normally be +shown. +.PP +The \f[CR]\-\-invert\f[R] flag negates all amounts. +For example, it can be used on an income account where amounts are +normally displayed as negative numbers. +It\[aq]s also useful to show postings on the checking account together +with the related account: +.IP +.EX +$ hledger register \-\-related \-\-invert assets:checking +.EE +.PP +With a reporting interval, register shows summary postings, one per +interval, aggregating the postings to each account: +.IP +.EX +$ hledger register \-\-monthly income +2008/01 income:salary $\-1 $\-1 +2008/06 income:gifts $\-1 $\-2 +.EE +.PP +Periods with no activity, and summary postings with a zero amount, are +not shown by default; use the \f[CR]\-\-empty\f[R]/\f[CR]\-E\f[R] flag +to see them: +.IP +.EX +$ hledger register \-\-monthly income \-E +2008/01 income:salary $\-1 $\-1 +2008/02 0 $\-1 +2008/03 0 $\-1 +2008/04 0 $\-1 +2008/05 0 $\-1 +2008/06 income:gifts $\-1 $\-2 +2008/07 0 $\-2 +2008/08 0 $\-2 +2008/09 0 $\-2 +2008/10 0 $\-2 +2008/11 0 $\-2 +2008/12 0 $\-2 +.EE +.PP +Often, you\[aq]ll want to see just one line per interval. +The \f[CR]\-\-depth\f[R] option helps with this, causing subaccounts to +be aggregated: +.IP +.EX +$ hledger register \-\-monthly assets \-\-depth 1h +2008/01 assets $1 $1 +2008/06 assets $\-1 0 +2008/12 assets $\-1 $\-1 +.EE +.PP +Note when using report intervals, if you specify start/end dates these +will be adjusted outward if necessary to contain a whole number of +intervals. +This ensures that the first and last intervals are full length and +comparable to the others in the report. +.PP +With \f[CR]\-m DESC\f[R]/\f[CR]\-\-match=DESC\f[R], register does a +fuzzy search for one recent posting whose description is most similar to +DESC. +DESC should contain at least two characters. +If there is no similar\-enough match, no posting will be shown and the +program exit code will be non\-zero. +.SS Custom register output +register uses the full terminal width by default, except on windows. +You can override this by setting the \f[CR]COLUMNS\f[R] environment +variable (not a bash shell variable) or by using the +\f[CR]\-\-width\f[R]/\f[CR]\-w\f[R] option. +.PP +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\[aq]s argument, comma\-separated: \f[CR]\-\-width W,D\f[R] . +Here\[aq]s a diagram (won\[aq]t display correctly in \-\-help): +.IP +.EX +<\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- width (W) \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-> +date (10) description (D) account (W\-41\-D) amount (12) balance (12) +DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA +.EE +.PP +and some examples: +.IP +.EX +$ hledger reg # use terminal width (or 80 on windows) +$ hledger reg \-w 100 # use width 100 +$ COLUMNS=100 hledger reg # set with one\-time environment variable +$ export COLUMNS=100; hledger reg # set till session end (or window resize) +$ hledger reg \-w 100,40 # set overall width 100, description width 40 +$ hledger reg \-w $COLUMNS,40 # use terminal width, & description width 40 +.EE +.PP +This command also supports the output destination and output format +options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), and \f[CR]json\f[R]. +.SS balancesheet +(bs) +.PP +This command displays a balance sheet, showing historical ending +balances of asset and liability accounts. +(To see equity as well, use the balancesheetequity command.) +Amounts are shown with normal positive sign, as in conventional +financial statements. +.PP +This report shows accounts declared with the \f[CR]Asset\f[R], +\f[CR]Cash\f[R] or \f[CR]Liability\f[R] type (see account types). +Or if no such accounts are declared, it shows top\-level accounts named +\f[CR]asset\f[R] or \f[CR]liability\f[R] (case insensitive, plurals +allowed) and their subaccounts. +.PP +Example: +.IP +.EX +$ hledger balancesheet +Balance Sheet 2008\-12\-31 + + || 2008\-12\-31 +====================++============ + Assets || +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- + assets:bank:saving || $1 + assets:cash || $\-2 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- + || $\-1 +====================++============ + Liabilities || +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- + liabilities:debts || $\-1 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- + || $\-1 +====================++============ + Net: || 0 +.EE +.PP +This command is a higher\-level variant of the \f[CR]balance\f[R] +command, and supports many of that command\[aq]s features, such as +multi\-period reports. +It is similar to \f[CR]hledger balance \-H assets liabilities\f[R], but +with smarter account detection, and liabilities displayed with their +sign flipped. +.PP +This command also supports the output destination and output format +options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]html\f[R], and +\f[CR]json\f[R]. +.SS balancesheetequity +(bse) +.PP +This command displays a balance sheet, showing historical ending +balances of asset, liability and equity accounts. +Amounts are shown with normal positive sign, as in conventional +financial statements. +.PP +This report shows accounts declared with the \f[CR]Asset\f[R], +\f[CR]Cash\f[R], \f[CR]Liability\f[R] or \f[CR]Equity\f[R] type (see +account types). +Or if no such accounts are declared, it shows top\-level accounts named +\f[CR]asset\f[R], \f[CR]liability\f[R] or \f[CR]equity\f[R] (case +insensitive, plurals allowed) and their subaccounts. +.PP +Example: +.IP +.EX +$ hledger balancesheetequity +Balance Sheet With Equity 2008\-12\-31 + + || 2008\-12\-31 +====================++============ + Assets || +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- + assets:bank:saving || $1 + assets:cash || $\-2 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- + || $\-1 +====================++============ + Liabilities || +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- + liabilities:debts || $\-1 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- + || $\-1 +====================++============ + Equity || +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- + || 0 +====================++============ + Net: || 0 +.EE +.PP +This command is a higher\-level variant of the \f[CR]balance\f[R] +command, and supports many of that command\[aq]s features, such as +multi\-period reports. +It is similar to +\f[CR]hledger balance \-H assets liabilities equity\f[R], but with +smarter account detection, and liabilities/equity displayed with their +sign flipped. +.PP +This report is the easiest way to see if the accounting equation (A+L+E += 0) is satisfied (after you have done a \f[CR]close \-\-retain\f[R] to +merge revenues and expenses with equity, and perhaps added +\f[CR]\-\-infer\-equity\f[R] to balance your commodity conversions). +.PP +This command also supports the output destination and output format +options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], +\f[CR]tsv\f[R], \f[CR]html\f[R], and \f[CR]json\f[R]. +.SS cashflow +(cf) +.PP +This command displays a (simple) cashflow statement, showing the inflows +and outflows affecting \[dq]cash\[dq] (ie, liquid, easily convertible) +assets. +Amounts are shown with normal positive sign, as in conventional +financial statements. +.PP +This report shows accounts declared with the \f[CR]Cash\f[R] type (see +account types). +Or if no such accounts are declared, it shows accounts +.IP \[bu] 2 +under a top\-level account named \f[CR]asset\f[R] (case insensitive, +plural allowed) +.IP \[bu] 2 +whose name contains some variation of \f[CR]cash\f[R], \f[CR]bank\f[R], +\f[CR]checking\f[R] or \f[CR]saving\f[R]. +.PP +More precisely: all accounts matching this case insensitive regular +expression: +.PP +\f[CR]\[ha]assets?(:.+)?:(cash|bank|che(ck|que?)(ing)?|savings?|currentcash)(:|$)\f[R] +.PP +and their subaccounts. +.PP +An example cashflow report: +.IP +.EX +$ hledger cashflow +Cashflow Statement 2008 + + || 2008 +====================++====== + Cash flows || +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- + assets:bank:saving || $1 + assets:cash || $\-2 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- + || $\-1 +.EE +.PP +This command is a higher\-level variant of the \f[CR]balance\f[R] +command, and supports many of that command\[aq]s features, such as +multi\-period reports. +It is similar to +\f[CR]hledger balance assets not:fixed not:investment not:receivable\f[R], +but with smarter account detection. +.PP +This command also supports the output destination and output format +options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]html\f[R], and +\f[CR]json\f[R]. +.SS incomestatement +(is) +.PP +This command displays an income statement, showing revenues and expenses +during one or more periods. +Amounts are shown with normal positive sign, as in conventional +financial statements. +.PP +This report shows accounts declared with the \f[CR]Revenue\f[R] or +\f[CR]Expense\f[R] type (see account types). +Or if no such accounts are declared, it shows top\-level accounts named +\f[CR]revenue\f[R] or \f[CR]income\f[R] or \f[CR]expense\f[R] (case +insensitive, plurals allowed) and their subaccounts. +.PP +Example: +.IP +.EX +$ hledger incomestatement +Income Statement 2008 + + || 2008 +===================++====== + Revenues || +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- + income:gifts || $1 + income:salary || $1 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- + || $2 +===================++====== + Expenses || +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- + expenses:food || $1 + expenses:supplies || $1 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- + || $2 +===================++====== + Net: || 0 +.EE +.PP +This command is a higher\-level variant of the \f[CR]balance\f[R] +command, and supports many of that command\[aq]s features, such as +multi\-period reports. +It is similar to +\f[CR]hledger balance \[aq](revenues|income)\[aq] expenses\f[R], but +with smarter account detection, and revenues/income displayed with their +sign flipped. +.PP +This command also supports the output destination and output format +options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]html\f[R], and +\f[CR]json\f[R]. +.SH Advanced report commands .SS balance (bal) .PP @@ -8532,6 +9365,10 @@ columns. The \f[CR]\-\-pivot FIELD\f[R] option causes a different transaction field to be used as \[dq]account name\[dq]. See PIVOTING. +.IP \[bu] 2 +The \f[CR]\-\-summary\-only\f[R] flag (\f[CR]\-\-summary\f[R] also +works) hides all but the Total and Average columns (those should be +enabled with \f[CR]\-\-row\-total\f[R] and \f[CR]\-A/\-\-average\f[R]). .PP Multi\-period reports with many periods can be too wide for easy viewing in the terminal. @@ -9227,261 +10064,219 @@ Show monthly change in market value of investment assets. .P .PD Show top gainers [or losers] last week -.SS balancesheet -(bs) +.SS roi +Shows the time\-weighted (TWR) and money\-weighted (IRR) rate of return +on your investments. .PP -This command displays a balance sheet, showing historical ending -balances of asset and liability accounts. -(To see equity as well, use the balancesheetequity command.) -Amounts are shown with normal positive sign, as in conventional -financial statements. +At a minimum, you need to supply a query (which could be just an account +name) to select your investment(s) with \f[CR]\-\-inv\f[R], and another +query to identify your profit and loss transactions with +\f[CR]\-\-pnl\f[R]. .PP -This report shows accounts declared with the \f[CR]Asset\f[R], -\f[CR]Cash\f[R] or \f[CR]Liability\f[R] type (see account types). -Or if no such accounts are declared, it shows top\-level accounts named -\f[CR]asset\f[R] or \f[CR]liability\f[R] (case insensitive, plurals -allowed) and their subaccounts. +If you do not record changes in the value of your investment manually, +or do not require computation of time\-weighted return (TWR), +\f[CR]\-\-pnl\f[R] could be an empty query +(\f[CR]\-\-pnl \[dq]\[dq]\f[R] or \f[CR]\-\-pnl STR\f[R] where +\f[CR]STR\f[R] does not match any of your accounts). .PP +This command will compute and display the internalized rate of return +(IRR, also known as money\-weighted rate of return) and time\-weighted +rate of return (TWR) for your investments for the time period requested. +IRR is always annualized due to the way it is computed, but TWR is +reported both as a rate over the chosen reporting period and as an +annual rate. +.PP +Price directives will be taken into account if you supply appropriate +\f[CR]\-\-cost\f[R] or \f[CR]\-\-value\f[R] flags (see VALUATION). +.PP +Note, in some cases this report can fail, for these reasons: +.IP \[bu] 2 +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. +.IP \[bu] 2 +Error (SearchFailed): Failed to find solution for Internal Rate of +Return (IRR). +Either search does not converge to a solution, or converges too slowly. +.PP +Examples: +.IP \[bu] 2 +Using roi to compute total return of investment in stocks: +https://github.com/simonmichael/hledger/blob/master/examples/investing/roi\-unrealised.ledger +.IP \[bu] 2 +Cookbook > Return on Investment: https://hledger.org/roi.html +.SS Spaces and special characters in \f[CR]\-\-inv\f[R] and \f[CR]\-\-pnl\f[R] +Note that \f[CR]\-\-inv\f[R] and \f[CR]\-\-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 +.EX +$ hledger roi \-\-inv \[aq]term1 term2 term3 ...\[aq] +.EE +.PP +If any query terms contain spaces themselves, you will need an extra +level of nested quoting, eg: +.IP +.EX +$ hledger roi \-\-inv=\[dq]\[aq]Assets:Test 1\[aq]\[dq] \-\-pnl=\[dq]\[aq]Equity:Unrealized Profit and Loss\[aq]\[dq] +.EE +.SS Semantics of \f[CR]\-\-inv\f[R] and \f[CR]\-\-pnl\f[R] +Query supplied to \f[CR]\-\-inv\f[R] has to match all transactions that +are related to your investment. +Transactions not matching \f[CR]\-\-inv\f[R] will be ignored. +.PP +In these transactions, ROI will conside postings that match +\f[CR]\-\-inv\f[R] to be \[dq]investment postings\[dq] and other +postings (not matching \f[CR]\-\-inv\f[R]) will be sorted into two +categories: \[dq]cash flow\[dq] and \[dq]profit and loss\[dq], as ROI +needs to know which part of the investment value is your contributions +and which is due to the return on investment. +.IP \[bu] 2 +\[dq]Cash flow\[dq] is depositing or withdrawing money, buying or +selling assets, or otherwise converting between your investment +commodity and any other commodity. Example: +.RS 2 .IP .EX -$ hledger balancesheet -Balance Sheet 2008\-12\-31 +2019\-01\-01 Investing in Snake Oil + assets:cash \-$100 + investment:snake oil - || 2008\-12\-31 -====================++============ - Assets || -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- - assets:bank:saving || $1 - assets:cash || $\-2 -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- - || $\-1 -====================++============ - Liabilities || -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- - liabilities:debts || $\-1 -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- - || $\-1 -====================++============ - Net: || 0 +2020\-01\-01 Selling my Snake Oil + assets:cash $10 + investment:snake oil = 0 .EE -.PP -This command is a higher\-level variant of the \f[CR]balance\f[R] -command, and supports many of that command\[aq]s features, such as -multi\-period reports. -It is similar to \f[CR]hledger balance \-H assets liabilities\f[R], but -with smarter account detection, and liabilities displayed with their -sign flipped. -.PP -This command also supports the output destination and output format -options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], -\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]html\f[R], and -\f[CR]json\f[R]. -.SS balancesheetequity -(bse) -.PP -This command displays a balance sheet, showing historical ending -balances of asset, liability and equity accounts. -Amounts are shown with normal positive sign, as in conventional -financial statements. -.PP -This report shows accounts declared with the \f[CR]Asset\f[R], -\f[CR]Cash\f[R], \f[CR]Liability\f[R] or \f[CR]Equity\f[R] type (see -account types). -Or if no such accounts are declared, it shows top\-level accounts named -\f[CR]asset\f[R], \f[CR]liability\f[R] or \f[CR]equity\f[R] (case -insensitive, plurals allowed) and their subaccounts. -.PP -Example: +.RE +.IP \[bu] 2 +\[dq]Profit and loss\[dq] is change in the value of your investment: +.RS 2 .IP .EX -$ hledger balancesheetequity -Balance Sheet With Equity 2008\-12\-31 +2019\-06\-01 Snake Oil falls in value + investment:snake oil = $57 + equity:unrealized profit or loss +.EE +.RE +.PP +All non\-investment postings are assumed to be \[dq]cash flow\[dq], +unless they match \f[CR]\-\-pnl\f[R] query. +Changes in value of your investment due to \[dq]profit and loss\[dq] +postings will be considered as part of your investment return. +.PP +Example: if you use \f[CR]\-\-inv snake \-\-pnl equity:unrealized\f[R], +then postings in the example below would be classifed as: +.IP +.EX +2019\-01\-01 Snake Oil #1 + assets:cash \-$100 ; cash flow posting + investment:snake oil ; investment posting - || 2008\-12\-31 -====================++============ - Assets || -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- - assets:bank:saving || $1 - assets:cash || $\-2 -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- - || $\-1 -====================++============ - Liabilities || -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- - liabilities:debts || $\-1 -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- - || $\-1 -====================++============ - Equity || -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\- - || 0 -====================++============ - Net: || 0 -.EE -.PP -This command is a higher\-level variant of the \f[CR]balance\f[R] -command, and supports many of that command\[aq]s features, such as -multi\-period reports. -It is similar to -\f[CR]hledger balance \-H assets liabilities equity\f[R], but with -smarter account detection, and liabilities/equity displayed with their -sign flipped. -.PP -This report is the easiest way to see if the accounting equation (A+L+E -= 0) is satisfied (after you have done a \f[CR]close \-\-retain\f[R] to -merge revenues and expenses with equity, and perhaps added -\f[CR]\-\-infer\-equity\f[R] to balance your commodity conversions). -.PP -This command also supports the output destination and output format -options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], -\f[CR]tsv\f[R], \f[CR]html\f[R], and \f[CR]json\f[R]. -.SS cashflow -(cf) -.PP -This command displays a (simple) cashflow statement, showing the inflows -and outflows affecting \[dq]cash\[dq] (ie, liquid, easily convertible) -assets. -Amounts are shown with normal positive sign, as in conventional -financial statements. -.PP -This report shows accounts declared with the \f[CR]Cash\f[R] type (see -account types). -Or if no such accounts are declared, it shows accounts -.IP \[bu] 2 -under a top\-level account named \f[CR]asset\f[R] (case insensitive, -plural allowed) -.IP \[bu] 2 -whose name contains some variation of \f[CR]cash\f[R], \f[CR]bank\f[R], -\f[CR]checking\f[R] or \f[CR]saving\f[R]. -.PP -More precisely: all accounts matching this case insensitive regular -expression: -.PP -\f[CR]\[ha]assets?(:.+)?:(cash|bank|che(ck|que?)(ing)?|savings?|currentcash)(:|$)\f[R] -.PP -and their subaccounts. -.PP -An example cashflow report: -.IP -.EX -$ hledger cashflow -Cashflow Statement 2008 +2019\-03\-01 Snake Oil #2 + equity:unrealized pnl \-$100 ; profit and loss posting + snake oil ; investment posting - || 2008 -====================++====== - Cash flows || -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- - assets:bank:saving || $1 - assets:cash || $\-2 -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- - || $\-1 +2019\-07\-01 Snake Oil #3 + equity:unrealized pnl ; profit and loss posting + cash \-$100 ; cash flow posting + snake oil $50 ; investment posting .EE +.SS IRR and TWR explained +\[dq]ROI\[dq] stands for \[dq]return on investment\[dq]. +Traditionally this was computed as a difference between current value of +investment and its initial value, expressed in percentage of the initial +value. .PP -This command is a higher\-level variant of the \f[CR]balance\f[R] -command, and supports many of that command\[aq]s features, such as -multi\-period reports. -It is similar to -\f[CR]hledger balance assets not:fixed not:investment not:receivable\f[R], -but with smarter account detection. +However, this approach is only practical in simple cases, where +investments receives no in\-flows or out\-flows of money, and where rate +of growth is fixed over time. +For more complex scenarios you need different ways to compute rate of +return, and this command implements two of them: IRR and TWR. .PP -This command also supports the output destination and output format -options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], -\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]html\f[R], and -\f[CR]json\f[R]. -.SS check -Check for various kinds of errors in your data. +Internal rate of return, or \[dq]IRR\[dq] (also called +\[dq]money\-weighted rate of return\[dq]) takes into account effects of +in\-flows and out\-flows, and the time between them. +Investment at a particular fixed interest rate is going to give you more +interest than the same amount invested at the same interest rate, but +made later in time. +If you are withdrawing from your investment, your future gains would be +smaller (in absolute numbers), and will be a smaller percentage of your +initial investment, so your IRR will be smaller. +And if you are adding to your investment, you will receive bigger +absolute gains, which will be a bigger percentage of your initial +investment, so your IRR will be larger. .PP -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 -\f[CR]check\f[R] 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). +As mentioned before, in\-flows and out\-flows would be any cash that you +personally put in or withdraw, and for the \[dq]roi\[dq] command, these +are the postings that match the query in the\f[CR]\-\-inv\f[R] argument +and NOT match the query in the\f[CR]\-\-pnl\f[R] argument. .PP -Some examples: +If you manually record changes in the value of your investment as +transactions that balance them against \[dq]profit and loss\[dq] (or +\[dq]unrealized gains\[dq]) account or use price directives, then in +order for IRR to compute the precise effect of your in\-flows and +out\-flows on the rate of return, you will need to record the value of +your investement on or close to the days when in\- or out\-flows occur. +.PP +In technical terms, IRR uses the same approach as computation of net +present value, and tries to find a discount rate that makes net present +value of all the cash flows of your investment to add up to zero. +This could be hard to wrap your head around, especially if you +haven\[aq]t done discounted cash flow analysis before. +Implementation of IRR in hledger should produce results that match the +\f[CR]=XIRR\f[R] formula in Excel. +.PP +Second way to compute rate of return that \f[CR]roi\f[R] command +implements is called \[dq]time\-weighted rate of return\[dq] or +\[dq]TWR\[dq]. +Like IRR, it will account for the effect of your in\-flows and +out\-flows, but unlike IRR it will try to compute the true rate of +return of the underlying asset, compensating for the effect that +deposits and withdrawas have on the apparent rate of growth of your +investment. +.PP +TWR represents your investment as an imaginary \[dq]unit fund\[dq] where +in\-flows/ out\-flows lead to buying or selling \[dq]units\[dq] of your +investment and changes in its value change the value of \[dq]investment +unit\[dq]. +Change in \[dq]unit price\[dq] over the reporting period gives you rate +of return of your investment, and make TWR less sensitive than IRR to +the effects of cash in\-flows and out\-flows. +.PP +References: +.IP \[bu] 2 +Explanation of rate of return +.IP \[bu] 2 +Explanation of IRR +.IP \[bu] 2 +Explanation of TWR +.IP \[bu] 2 +IRR vs TWR +.IP \[bu] 2 +Examples of computing IRR and TWR and discussion of the limitations of +both metrics +.SH Chart commands +.SS activity +Show an ascii barchart of posting counts per interval. +.PP +The activity command displays an ascii histogram showing transaction +counts by day, week, month or other reporting interval (by day is the +default). +With query arguments, it counts only matched transactions. +.PP +Examples: .IP .EX -hledger check # basic checks -hledger check \-s # basic + strict checks -hledger check ordereddates payees # basic + two other checks +$ hledger activity \-\-quarterly +2008\-01\-01 ** +2008\-04\-01 ******* +2008\-07\-01 +2008\-10\-01 ** .EE -.PP -If you are an Emacs user, you can also configure flycheck\-hledger to -run these checks, providing instant feedback as you edit the journal. -.PP -Here are the checks currently available: -.SS Default checks -These checks are run automatically by (almost) all hledger commands: -.IP \[bu] 2 -\f[B]parseable\f[R] \- data files are in a supported format, with no -syntax errors and no invalid include directives. -.IP \[bu] 2 -\f[B]autobalanced\f[R] \- all transactions are balanced, after -converting to cost. -Missing amounts and missing costs are inferred automatically where -possible. -.IP \[bu] 2 -\f[B]assertions\f[R] \- all balance assertions in the journal are -passing. -(This check can be disabled with -\f[CR]\-I\f[R]/\f[CR]\-\-ignore\-assertions\f[R].) -.SS Strict checks -These additional checks are run when the -\f[CR]\-s\f[R]/\f[CR]\-\-strict\f[R] (strict mode) flag is used. -Or, they can be run by giving their names as arguments to -\f[CR]check\f[R]: -.IP \[bu] 2 -\f[B]balanced\f[R] \- all transactions are balanced after converting to -cost, without inferring missing costs. -If conversion costs are required, they must be explicit. -.IP \[bu] 2 -\f[B]accounts\f[R] \- all account names used by transactions have been -declared -.IP \[bu] 2 -\f[B]commodities\f[R] \- all commodity symbols used have been declared -.SS Other checks -These checks can be run only by giving their names as arguments to -\f[CR]check\f[R]. -They are more specialised and not desirable for everyone: -.IP \[bu] 2 -\f[B]ordereddates\f[R] \- transactions are ordered by date within each -file -.IP \[bu] 2 -\f[B]payees\f[R] \- all payees used by transactions have been declared -.IP \[bu] 2 -\f[B]recentassertions\f[R] \- all accounts with balance assertions have -a balance assertion within 7 days of their latest posting -.IP \[bu] 2 -\f[B]tags\f[R] \- all tags used by transactions have been declared -.IP \[bu] 2 -\f[B]uniqueleafnames\f[R] \- all account leaf names are unique -.SS Custom checks -A few more checks are are available as separate add\-on commands, in -https://github.com/simonmichael/hledger/tree/master/bin: -.IP \[bu] 2 -\f[B]hledger\-check\-tagfiles\f[R] \- all tag values containing / (a -forward slash) exist as file paths -.IP \[bu] 2 -\f[B]hledger\-check\-fancyassertions\f[R] \- more complex balance -assertions are passing -.PP -You could make similar scripts to perform your own custom checks. -See: Cookbook \-> Scripting. -.SS More about specific checks -\f[CR]hledger check recentassertions\f[R] will complain if any -balance\-asserted account has postings more than 7 days after its latest -balance assertion. -This aims to prevent the situation where you are regularly updating your -journal, but forgetting to check your balances against the real world, -then one day must dig back through months of data to find an error. -It assumes that adding a balance assertion requires/reminds you to check -the real\-world balance. -(That may not be true if you auto\-generate balance assertions from bank -data; in that case, I recommend to import transactions uncleared, and -when you manually review and clear them, also check the latest assertion -against the real\-world balance.) +.SH Data generation commands .SS close (equity) .PP @@ -9702,757 +10497,6 @@ $ hledger bs \-Y \-f 2023.j # unclosed file, no query needed .EE .SS More detailed close examples See examples/multi\-year. -.SS codes -List the codes seen in transactions, in the order parsed. -.PP -This command prints the value of each transaction\[aq]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. -.PP -Transactions aren\[aq]t required to have a code, and missing or empty -codes will not be shown by default. -With the \f[CR]\-E\f[R]/\f[CR]\-\-empty\f[R] flag, they will be printed -as blank lines. -.PP -You can add a query to select a subset of transactions. -.PP -Examples: -.IP -.EX -2022/1/1 (123) Supermarket - Food $5.00 - Checking - -2022/1/2 (124) Post Office - Postage $8.32 - Checking - -2022/1/3 Supermarket - Food $11.23 - Checking - -2022/1/4 (126) Post Office - Postage $3.21 - Checking -.EE -.IP -.EX -$ hledger codes -123 -124 -126 -.EE -.IP -.EX -$ hledger codes \-E -123 -124 - -126 -.EE -.SS commodities -List all commodity/currency symbols used or declared in the journal. -.SS demo -Play demos of hledger usage in the terminal, if asciinema is installed. -.PP -Run this command with no argument to list the demos. -To play a demo, write its number or a prefix or substring of its title. -Tips: -.PP -Make your terminal window large enough to see the demo clearly. -.PP -Use the \-s/\-\-speed SPEED option to set your preferred playback speed, -eg \f[CR]\-s4\f[R] to play at 4x original speed or \f[CR]\-s.5\f[R] to -play at half speed. -The default speed is 2x. -.PP -Other asciinema options can be added following a double dash, eg -\f[CR]\-\- \-i.1\f[R] to limit pauses or \f[CR]\-\- \-h\f[R] to list -asciinema\[aq]s other options. -.PP -During playback, several keys are available: SPACE to pause/unpause, . -to step forward (while paused), CTRL\-c quit. -.PP -Examples: -.IP -.EX -$ hledger demo # list available demos -$ hledger demo 1 # play the first demo at default speed (2x) -$ hledger demo install \-s4 # play the \[dq]install\[dq] demo at 4x speed -.EE -.SS descriptions -List the unique descriptions that appear in transactions. -.PP -This command lists the unique descriptions that appear in transactions, -in alphabetic order. -You can add a query to select a subset of transactions. -.PP -Example: -.IP -.EX -$ hledger descriptions -Store Name -Gas Station | Petrol -Person A -.EE -.SS diff -Compares a particular account\[aq]s transactions in two input files. -It shows any transactions to this account which are in one file but not -in the other. -.PP -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.) -Since postings not transactions are compared, this also works when -multiple bank transactions have been combined into a single journal -entry. -.PP -This is useful eg if you have downloaded an account\[aq]s transactions -from 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. -.PP -Examples: -.IP -.EX -$ hledger diff \-f $LEDGER_FILE \-f bank.csv assets:bank:giro -These transactions are in the first file only: - -2014/01/01 Opening Balances - assets:bank:giro EUR ... - ... - equity:opening balances EUR \-... - -These transactions are in the second file only: -.EE -.SS files -List all files included in the journal. -With a REGEX argument, only file names matching the regular expression -(case sensitive) are shown. -.SS help -Show the hledger user manual in the terminal, with \f[CR]info\f[R], -\f[CR]man\f[R], or a pager. -With a TOPIC argument, open it at that topic if possible. -TOPIC can be any heading in the manual, or a heading prefix, case -insensitive. -Eg: \f[CR]commands\f[R], \f[CR]print\f[R], \f[CR]forecast\f[R], -\f[CR]journal\f[R], \f[CR]amount\f[R], -\f[CR]\[dq]auto postings\[dq]\f[R]. -.PP -This command shows the hledger manual built in to your hledger version. -It can be useful when offline, or when you prefer the terminal to a web -browser, or when the appropriate hledger manual or viewing tools are not -installed on your system. -.PP -By default it chooses the best viewer found in $PATH, trying (in this -order): \f[CR]info\f[R], \f[CR]man\f[R], \f[CR]$PAGER\f[R], -\f[CR]less\f[R], \f[CR]more\f[R]. -You can force the use of info, man, or a pager with the \f[CR]\-i\f[R], -\f[CR]\-m\f[R], or \f[CR]\-p\f[R] flags, If no viewer can be found, or -the command is run non\-interactively, it just prints the manual to -stdout. -.PP -If using \f[CR]info\f[R], note that version 6 or greater is needed for -TOPIC lookup. -If you are on mac you will likely have info 4.8, and should consider -installing a newer version, eg with \f[CR]brew install texinfo\f[R] -(#1770). -.PP -Examples -.IP -.EX -$ hledger help \-\-help # show how the help command works -$ hledger help # show the hledger manual with info, man or $PAGER -$ hledger help journal # show the journal topic in the hledger manual -$ hledger help \-m journal # show it with man, even if info is installed -.EE -.SS import -Read new transactions added to each FILE provided as arguments since -last run, and add them to the journal. -Or with \-\-dry\-run, just print the transactions that would be added. -Or with \-\-catchup, just mark all of the FILEs\[aq] current -transactions as imported, without importing them. -.PP -This command may append new transactions to the main journal file (which -should be in journal format). -Existing transactions are not changed. -This is one of the few hledger commands that writes to the journal file -(see also \f[CR]add\f[R]). -.PP -Unlike other hledger commands, with \f[CR]import\f[R] the journal file -is an output 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 -\f[CR]hledger import bank.csv\f[R] or perhaps -\f[CR]hledger import *.csv\f[R]. -.PP -Note you can import from any file format, though CSV files are the most -common import source, and these docs focus on that case. -.SS Deduplication -\f[CR]import\f[R] tries to import only the transactions which are new -since the last import, ignoring any that it has seen in previous runs. -So if your bank\[aq]s CSV includes the last three months of data, you -can download and \f[CR]import\f[R] it every month (or week, or day) and -only the new transactions will be imported each time. -.PP -It works as follows. -For each imported \f[CR]FILE\f[R] (usually CSV, but they could be any of -hledger\[aq]s input formats): -.IP \[bu] 2 -It tries to recall the latest date seen previously, reading it from a -hidden \f[CR].latest.FILE\f[R] in the same directory. -.IP \[bu] 2 -Then it processes \f[CR]FILE\f[R], ignoring any transactions on or -before the \[dq]latest seen\[dq] date. -.PP -And after a successful import, it updates the \f[CR].latest.FILE\f[R](s) -for next time (unless \f[CR]\-\-dry\-run\f[R] was used). -.PP -This is a limited kind of deduplication, let\[aq]s call it \[dq]date -skipping\[dq]. -Within each input file, it avoids reprocessing the same dates across -successive runs. -This is a simple system that works for most real\-world CSV files; it -assumes these are true, or true enough: -.IP "1." 3 -new items always have the newest dates -.IP "2." 3 -item dates are stable across successive downloads -.IP "3." 3 -the order of same\-date items is stable across downloads -.IP "4." 3 -the name of the input file is stable across downloads -.PP -If you have a bank whose CSV dates or ordering occasionally change, you -can reduce the chance of this happening in new transactions by importing -more often, and in old transactions it doesn\[aq]t matter. -And remember you can use CSV rules files as input, which is one way to -ensure a stable file name. -.PP -\f[CR]import\f[R] doesn\[aq]t detect other kinds of duplication, such as -duplicate transactions within a single run. -(In part, because legitimate duplicate transactions can easily occur in -real\-world data.) -So, say you downloaded but forgot to import \f[CR]bank.1.csv\f[R], and a -week later you downloaded \f[CR]bank.2.csv\f[R] with overlapping data. -Now you should not import both of these at once -(\f[CR]hledger import bank.1.csv bank.2.csv\f[R]); the overlapping -transactions which appear twice would not be deduplicated since this is -considered a single import. -Instead, import these files one at a time, and also use the same -filename each time for a common \[dq]latest seen\[dq] state: -.IP -.EX -$ mv bank.1.csv bank.csv; hledger import bank.csv -$ mv bank.2.csv bank.csv; hledger import bank.csv -.EE -.PP -Normally you can ignore the \f[CR].latest.*\f[R] files, but if needed, -you can delete them (to make all transactions unseen), or -construct/modify them (to catch up to a certain date). -The format is just a single ISO\-format date (\f[CR]YYYY\-MM\-DD\f[R]), -possibly repeated on multiple lines. -It means \[dq]I have seen transactions up to this date, and this many of -them occurring on that date\[dq]. -.PP -\f[CR]hledger print \-\-new\f[R] also uses and updates these -\f[CR].latest.*\f[R] files, but it is less often used. -.PP -Related: CSV > Working with CSV > Deduplicating, importing. -.SS Import testing -With \f[CR]\-\-dry\-run\f[R], 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 -categorised: -.IP -.EX -$ hledger import \-\-dry bank.csv | hledger \-f\- \-I print unknown -.EE -.PP -or (live updating): -.IP -.EX -$ ls bank.csv* | entr bash \-c \[aq]echo ====; hledger import \-\-dry bank.csv | hledger \-f\- \-I print unknown\[aq] -.EE -.PP -Note: when importing from multiple files at once, it\[aq]s currently -possible for some .latest files to be updated successfully, while the -actual import fails because of a problem in one of the files, leaving -them out of sync (and causing some transactions to be missed). -To prevent this, do a \-\-dry\-run first and fix any problems before the -real import. -.SS Importing balance assignments -Entries added by import will have their posting amounts made explicit -(like \f[CR]hledger print \-x\f[R]). -This means that any balance assignments in imported files must be -evaluated; but, imported files don\[aq]t get to see the main file\[aq]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 amounts. -To avoid this problem, use print instead of import: -.IP -.EX -$ hledger print IMPORTFILE [\-\-new] >> $LEDGER_FILE -.EE -.PP -(If you think import should leave amounts implicit like print does, -please test it and send a pull request.) -.SS Commodity display styles -Imported amounts will be formatted according to the canonical commodity -styles (declared or inferred) in the main journal file. -.SS incomestatement -(is) -.PP -This command displays an income statement, showing revenues and expenses -during one or more periods. -Amounts are shown with normal positive sign, as in conventional -financial statements. -.PP -This report shows accounts declared with the \f[CR]Revenue\f[R] or -\f[CR]Expense\f[R] type (see account types). -Or if no such accounts are declared, it shows top\-level accounts named -\f[CR]revenue\f[R] or \f[CR]income\f[R] or \f[CR]expense\f[R] (case -insensitive, plurals allowed) and their subaccounts. -.PP -Example: -.IP -.EX -$ hledger incomestatement -Income Statement 2008 - - || 2008 -===================++====== - Revenues || -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- - income:gifts || $1 - income:salary || $1 -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- - || $2 -===================++====== - Expenses || -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- - expenses:food || $1 - expenses:supplies || $1 -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\- - || $2 -===================++====== - Net: || 0 -.EE -.PP -This command is a higher\-level variant of the \f[CR]balance\f[R] -command, and supports many of that command\[aq]s features, such as -multi\-period reports. -It is similar to -\f[CR]hledger balance \[aq](revenues|income)\[aq] expenses\f[R], but -with smarter account detection, and revenues/income displayed with their -sign flipped. -.PP -This command also supports the output destination and output format -options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], -\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]html\f[R], and -\f[CR]json\f[R]. -.SS notes -List the unique notes that appear in transactions. -.PP -This command lists the unique notes that appear in transactions, in -alphabetic order. -You can add a query to select a subset of transactions. -The note is the part of the transaction description after a | character -(or if there is no |, the whole description). -.PP -Example: -.IP -.EX -$ hledger notes -Petrol -Snacks -.EE -.SS payees -List the unique payee/payer names that appear in transactions. -.PP -This command lists unique payee/payer names which have been declared -with payee directives (\-\-declared), used in transaction descriptions -(\-\-used), or both (the default). -.PP -The payee/payer is the part of the transaction description before a | -character (or if there is no |, the whole description). -.PP -You can add query arguments to select a subset of transactions. -This implies \-\-used. -.PP -Example: -.IP -.EX -$ hledger payees -Store Name -Gas Station -Person A -.EE -.SS prices -Print the market prices declared with P directives. -With \-\-infer\-market\-prices, also show any additional prices inferred -from costs. -With \-\-show\-reverse, also show additional prices inferred by -reversing known prices. -.PP -Price amounts are always displayed with their full precision, except for -reverse prices which are limited to 8 decimal digits. -.PP -Prices can be filtered by a date:, cur: or amt: query. -.PP -Generally if you run this command with \-\-infer\-market\-prices -\-\-show\-reverse, it will show the same prices used internally to -calculate value reports. -But if in doubt, you can inspect those directly by running the value -report with \-\-debug=2. -.SS print -Show transaction journal entries, sorted by date. -.PP -The print command displays full journal entries (transactions) from the -journal file, sorted by date (or with \f[CR]\-\-date2\f[R], by secondary -date). -.PP -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/regenerate your journal you should take care to also copy -over the directives and inter\-transaction comments. -.PP -Eg: -.IP -.EX -$ hledger print \-f examples/sample.journal date:200806 -2008/06/01 gift - assets:bank:checking $1 - income:gifts $\-1 - -2008/06/02 save - assets:bank:saving $1 - assets:bank:checking $\-1 - -2008/06/03 * eat & shop - expenses:food $1 - expenses:supplies $1 - assets:cash $\-2 -.EE -.SS print explicitness -Normally, whether posting amounts are implicit or explicit is preserved. -For example, when an amount is omitted in the journal, it will not -appear in the output. -Similarly, if a conversion cost is implied but not written, it will not -appear in the output. -.PP -You can use the \f[CR]\-x\f[R]/\f[CR]\-\-explicit\f[R] flag to force -explicit display of all amounts and costs. -This can be useful for troubleshooting or for making your journal more -readable and robust against data entry errors. -\f[CR]\-x\f[R] is also implied by using any of -\f[CR]\-B\f[R],\f[CR]\-V\f[R],\f[CR]\-X\f[R],\f[CR]\-\-value\f[R]. -.PP -The \f[CR]\-x\f[R]/\f[CR]\-\-explicit\f[R] flag will cause any postings -with a multi\-commodity amount (which can arise when a multi\-commodity -transaction has an implicit amount) to be split into multiple -single\-commodity postings, keeping the output parseable. -.SS print amount style -Amounts are shown right\-aligned within each transaction (but not -aligned across all transactions; you can do that with ledger\-mode in -Emacs). -.PP -Amounts will be (mostly) normalised to their commodity display style: -their symbol placement, decimal mark, and digit group marks will be made -consistent. -By default, decimal digits are shown as they are written in the journal. -.PP -With the \f[CR]\-\-round\f[R] (\f[I]Added in 1.32\f[R]) option, -\f[CR]print\f[R] will try increasingly hard to display decimal digits -according to the commodity display styles: -.IP \[bu] 2 -\f[CR]\-\-round=none\f[R] show amounts with original precisions -(default) -.IP \[bu] 2 -\f[CR]\-\-round=soft\f[R] add/remove decimal zeros in amounts (except -costs) -.IP \[bu] 2 -\f[CR]\-\-round=hard\f[R] round amounts (except costs), possibly hiding -significant digits -.IP \[bu] 2 -\f[CR]\-\-round=all\f[R] round all amounts and costs -.PP -\f[CR]soft\f[R] is good for non\-lossy cleanup, formatting amounts more -consistently where it\[aq]s safe to do so. -.PP -\f[CR]hard\f[R] and \f[CR]all\f[R] can cause \f[CR]print\f[R] to show -invalid unbalanced journal entries; they may be useful eg for stronger -cleanup, with manual fixups when needed. -.SS print parseability -print\[aq]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 (though the same can be -achieved with \f[CR]expr:\f[R] queries now): -.IP -.EX -# Show running total of food expenses paid from cash. -# \-f\- reads from stdin. \-I/\-\-ignore\-assertions is sometimes needed. -$ hledger print assets:cash | hledger \-f\- \-I reg expenses:food -.EE -.PP -There are some situations where print\[aq]s output can become -unparseable: -.IP \[bu] 2 -Value reporting affects posting amounts but not balance assertion or -balance assignment amounts, potentially causing those to fail. -.IP \[bu] 2 -Auto postings can generate postings with too many missing amounts. -.IP \[bu] 2 -Account aliases can generate bad account names. -.SS print, other features -With \f[CR]\-B\f[R]/\f[CR]\-\-cost\f[R], amounts with costs are shown -converted to cost. -.PP -With \f[CR]\-\-new\f[R], print shows only transactions it has not seen -on a previous run. -This uses the same deduplication system as the \f[CR]import\f[R] -command. -(See import\[aq]s docs for details.) -.PP -With \f[CR]\-m DESC\f[R]/\f[CR]\-\-match=DESC\f[R], print shows one -recent transaction whose description is most similar to DESC. -DESC should contain at least two characters. -If there is no similar\-enough match, no transaction will be shown and -the program exit code will be non\-zero. -.SS print output format -This command also supports the output destination and output format -options The output formats supported are \f[CR]txt\f[R], -\f[CR]beancount\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]csv\f[R], -\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]json\f[R] and -\f[CR]sql\f[R]. -.PP -The \f[CR]beancount\f[R] format tries to produce Beancount\-compatible -output, as follows: -.IP \[bu] 2 -Transaction and postings with unmarked status are converted to cleared -(\f[CR]*\f[R]) status. -.IP \[bu] 2 -Transactions\[aq] payee and note are backslash\-escaped and -double\-quote\-escaped and wrapped in double quotes. -.IP \[bu] 2 -Transaction tags are copied to Beancount #tag format. -.IP \[bu] 2 -Commodity symbols are converted to upper case, and a small number of -currency symbols like \f[CR]$\f[R] are converted to the corresponding -currency names. -.IP \[bu] 2 -Account name parts are capitalised and unsupported characters are -replaced with \f[CR]\-\f[R]. -If an account name part does not begin with a letter, or if the first -part is not Assets, Liabilities, Equity, Income, or Expenses, an error -is raised. -(Use \f[CR]\-\-alias\f[R] options to bring your accounts into -compliance.) -.IP \[bu] 2 -An \f[CR]open\f[R] directive is generated for each account used, on the -earliest transaction date. -.PP -Some limitations: -.IP \[bu] 2 -Balance assertions are removed. -.IP \[bu] 2 -Balance assignments become missing amounts. -.IP \[bu] 2 -Virtual and balanced virtual postings become regular postings. -.IP \[bu] 2 -Directives are not converted. -.PP -Here\[aq]s an example of print\[aq]s CSV output: -.IP -.EX -$ hledger print \-Ocsv -\[dq]txnidx\[dq],\[dq]date\[dq],\[dq]date2\[dq],\[dq]status\[dq],\[dq]code\[dq],\[dq]description\[dq],\[dq]comment\[dq],\[dq]account\[dq],\[dq]amount\[dq],\[dq]commodity\[dq],\[dq]credit\[dq],\[dq]debit\[dq],\[dq]posting\-status\[dq],\[dq]posting\-comment\[dq] -\[dq]1\[dq],\[dq]2008/01/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]income\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] -\[dq]1\[dq],\[dq]2008/01/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]income\[dq],\[dq]\[dq],\[dq]income:salary\[dq],\[dq]\-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq] -\[dq]2\[dq],\[dq]2008/06/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]gift\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] -\[dq]2\[dq],\[dq]2008/06/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]gift\[dq],\[dq]\[dq],\[dq]income:gifts\[dq],\[dq]\-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq] -\[dq]3\[dq],\[dq]2008/06/02\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]save\[dq],\[dq]\[dq],\[dq]assets:bank:saving\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] -\[dq]3\[dq],\[dq]2008/06/02\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]save\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]\-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq] -\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]expenses:food\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] -\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]expenses:supplies\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] -\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]assets:cash\[dq],\[dq]\-2\[dq],\[dq]$\[dq],\[dq]2\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq] -\[dq]5\[dq],\[dq]2008/12/31\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]pay off\[dq],\[dq]\[dq],\[dq]liabilities:debts\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq] -\[dq]5\[dq],\[dq]2008/12/31\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]pay off\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]\-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq] -.EE -.IP \[bu] 2 -There is one CSV record per posting, with the parent transaction\[aq]s -fields repeated. -.IP \[bu] 2 -The \[dq]txnidx\[dq] (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 order, etc.) -.IP \[bu] 2 -The amount is separated into \[dq]commodity\[dq] (the symbol) and -\[dq]amount\[dq] (numeric quantity) fields. -.IP \[bu] 2 -The numeric amount is repeated in either the \[dq]credit\[dq] or -\[dq]debit\[dq] column, for convenience. -(Those names are not accurate in the accounting sense; it just puts -negative amounts under credit and zero or greater amounts under debit.) -.SS register -(reg) -.PP -Show postings and their running total. -.PP -The register command displays matched postings, across all accounts, in -date order, with their running total or running historical balance. -(See also the \f[CR]aregister\f[R] command, which shows matched -transactions in a specific account.) -.PP -register normally shows line per posting, but note that multi\-commodity -amounts will occupy multiple lines (one line per commodity). -.PP -It is typically used with a query selecting a particular account, to see -that account\[aq]s activity: -.IP -.EX -$ hledger register checking -2008/01/01 income assets:bank:checking $1 $1 -2008/06/01 gift assets:bank:checking $1 $2 -2008/06/02 save assets:bank:checking $\-1 $1 -2008/12/31 pay off assets:bank:checking $\-1 0 -.EE -.PP -With \f[CR]\-\-date2\f[R], it shows and sorts by secondary date instead. -.PP -For performance reasons, column widths are chosen based on the first -1000 lines; this means unusually wide values in later lines can cause -visual discontinuities as column widths are adjusted. -If you want to ensure perfect alignment, at the cost of more time and -memory, use the \f[CR]\-\-align\-all\f[R] flag. -.PP -The \f[CR]\-\-historical\f[R]/\f[CR]\-H\f[R] flag adds the balance from -any undisplayed prior postings to the running total. -This is useful when you want to see only recent activity, with a -historically accurate running balance: -.IP -.EX -$ hledger register checking \-b 2008/6 \-\-historical -2008/06/01 gift assets:bank:checking $1 $2 -2008/06/02 save assets:bank:checking $\-1 $1 -2008/12/31 pay off assets:bank:checking $\-1 0 -.EE -.PP -The \f[CR]\-\-depth\f[R] option limits the amount of sub\-account detail -displayed. -.PP -The \f[CR]\-\-average\f[R]/\f[CR]\-A\f[R] 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 \f[CR]\-\-empty\f[R] (see below). -It is affected by \f[CR]\-\-historical\f[R]. -It works best when showing just one account and one commodity. -.PP -The \f[CR]\-\-related\f[R]/\f[CR]\-r\f[R] flag shows the \f[I]other\f[R] -postings in the transactions of the postings which would normally be -shown. -.PP -The \f[CR]\-\-invert\f[R] flag negates all amounts. -For example, it can be used on an income account where amounts are -normally displayed as negative numbers. -It\[aq]s also useful to show postings on the checking account together -with the related account: -.IP -.EX -$ hledger register \-\-related \-\-invert assets:checking -.EE -.PP -With a reporting interval, register shows summary postings, one per -interval, aggregating the postings to each account: -.IP -.EX -$ hledger register \-\-monthly income -2008/01 income:salary $\-1 $\-1 -2008/06 income:gifts $\-1 $\-2 -.EE -.PP -Periods with no activity, and summary postings with a zero amount, are -not shown by default; use the \f[CR]\-\-empty\f[R]/\f[CR]\-E\f[R] flag -to see them: -.IP -.EX -$ hledger register \-\-monthly income \-E -2008/01 income:salary $\-1 $\-1 -2008/02 0 $\-1 -2008/03 0 $\-1 -2008/04 0 $\-1 -2008/05 0 $\-1 -2008/06 income:gifts $\-1 $\-2 -2008/07 0 $\-2 -2008/08 0 $\-2 -2008/09 0 $\-2 -2008/10 0 $\-2 -2008/11 0 $\-2 -2008/12 0 $\-2 -.EE -.PP -Often, you\[aq]ll want to see just one line per interval. -The \f[CR]\-\-depth\f[R] option helps with this, causing subaccounts to -be aggregated: -.IP -.EX -$ hledger register \-\-monthly assets \-\-depth 1h -2008/01 assets $1 $1 -2008/06 assets $\-1 0 -2008/12 assets $\-1 $\-1 -.EE -.PP -Note when using report intervals, if you specify start/end dates these -will be adjusted outward if necessary to contain a whole number of -intervals. -This ensures that the first and last intervals are full length and -comparable to the others in the report. -.PP -With \f[CR]\-m DESC\f[R]/\f[CR]\-\-match=DESC\f[R], register does a -fuzzy search for one recent posting whose description is most similar to -DESC. -DESC should contain at least two characters. -If there is no similar\-enough match, no posting will be shown and the -program exit code will be non\-zero. -.SS Custom register output -register uses the full terminal width by default, except on windows. -You can override this by setting the \f[CR]COLUMNS\f[R] environment -variable (not a bash shell variable) or by using the -\f[CR]\-\-width\f[R]/\f[CR]\-w\f[R] option. -.PP -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\[aq]s argument, comma\-separated: \f[CR]\-\-width W,D\f[R] . -Here\[aq]s a diagram (won\[aq]t display correctly in \-\-help): -.IP -.EX -<\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- width (W) \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-> -date (10) description (D) account (W\-41\-D) amount (12) balance (12) -DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA -.EE -.PP -and some examples: -.IP -.EX -$ hledger reg # use terminal width (or 80 on windows) -$ hledger reg \-w 100 # use width 100 -$ COLUMNS=100 hledger reg # set with one\-time environment variable -$ export COLUMNS=100; hledger reg # set till session end (or window resize) -$ hledger reg \-w 100,40 # set overall width 100, description width 40 -$ hledger reg \-w $COLUMNS,40 # use terminal width, & description width 40 -.EE -.PP -This command also supports the output destination and output format -options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], -\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), and \f[CR]json\f[R]. .SS rewrite Print all transactions, rewriting the postings of matched transactions. For now the only rewrite available is adding new postings, like print @@ -10599,273 +10643,146 @@ print \-\-auto\[aq]s query limits which transactions are printed. .IP \[bu] 2 rewrite applies rules specified on command line or in the journal. print \-\-auto applies rules specified in the journal. -.SS roi -Shows the time\-weighted (TWR) and money\-weighted (IRR) rate of return -on your investments. +.SH Maintenance commands +.SS check +Check for various kinds of errors in your data. .PP -At a minimum, you need to supply a query (which could be just an account -name) to select your investment(s) with \f[CR]\-\-inv\f[R], and another -query to identify your profit and loss transactions with -\f[CR]\-\-pnl\f[R]. +hledger provides a number of built\-in correctness checks to help +validate your data and prevent errors. +Some are run automatically, some when you enable \f[CR]\-\-strict\f[R] +mode; or you can run any of them on demand by providing them as +arguments to the \f[CR]check\f[R] command. +\f[CR]check\f[R] produces no output and a zero exit code if all is well. +Eg: +.IP +.EX +hledger check # run basic checks +hledger check \-s # run basic and strict checks +hledger check ordereddates payees # run basic checks and two others +.EE .PP -If you do not record changes in the value of your investment manually, -or do not require computation of time\-weighted return (TWR), -\f[CR]\-\-pnl\f[R] could be an empty query -(\f[CR]\-\-pnl \[dq]\[dq]\f[R] or \f[CR]\-\-pnl STR\f[R] where -\f[CR]STR\f[R] does not match any of your accounts). +If you are an Emacs user, you can also configure flycheck\-hledger to +run these checks, providing instant feedback as you edit the journal. .PP -This command will compute and display the internalized rate of return -(IRR, also known as money\-weighted rate of return) and time\-weighted -rate of return (TWR) for your investments for the time period requested. -IRR is always annualized due to the way it is computed, but TWR is -reported both as a rate over the chosen reporting period and as an -annual rate. -.PP -Price directives will be taken into account if you supply appropriate -\f[CR]\-\-cost\f[R] or \f[CR]\-\-value\f[R] flags (see VALUATION). -.PP -Note, in some cases this report can fail, for these reasons: +Here are the checks currently available. +Generally, they are performed in the order they are shown here (and only +the first failure is reported). +.SS Basic checks +These important checks are performed by default, by almost all hledger +commands: .IP \[bu] 2 -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. +\f[B]parseable\f[R] \- data files are in a supported format, with no +syntax errors and no invalid include directives. +This ensures that all files exist and are readable. .IP \[bu] 2 -Error (SearchFailed): Failed to find solution for Internal Rate of -Return (IRR). -Either search does not converge to a solution, or converges too slowly. +\f[B]autobalanced\f[R] \- all transactions are balanced, after inferring +missing amounts and conversion costs where possible, and then converting +to cost. +This ensures that each individual transaction is well formed. +.IP \[bu] 2 +\f[B]assertions\f[R] \- all balance assertions in the journal are +passing. +Balance assertions are like canaries in your journal, they catch many +problems. +They can get in the way sometimes; you can disable them temporarily with +\f[CR]\-I\f[R]/\f[CR]\-\-ignore\-assertions\f[R] (unless overridden with +\f[CR]\-s\f[R]/\f[CR]\-\-strict\f[R] or +\f[CR]hledger check assertions\f[R]). +.SS Strict checks +These additional checks are performed by any command when the +\f[CR]\-s\f[R]/\f[CR]\-\-strict\f[R] flag is used (strict mode). +Strict mode always enables the balance assertions check, also. +These provide extra error\-catching power when you are serious about +keeping your data clean and free of typos: +.IP \[bu] 2 +\f[B]balanced\f[R] \- like \f[CR]autobalanced\f[R], but in conversion +transactions, costs must be written explicitly. +This ensures some redundancy in the entry, which helps prevent typos. +.IP \[bu] 2 +\f[B]commodities\f[R] \- all commodity symbols used must be declared. +This guards against mistyping or omitting commodity symbols. +.IP \[bu] 2 +\f[B]accounts\f[R] \- all account names used must be declared. +This prevents the use of mis\-spelled or outdated account names. +.SS Other checks +These other checks are not wanted by everyone, but can be run using the +\f[CR]check\f[R] command: +.IP \[bu] 2 +\f[B]ordereddates\f[R] \- within each file, transactions are ordered by +date. +This is a simple and effective error catcher, and you should use it. +Alas! +not everyone wants it. +If you do, use \f[CR]hledger check \-s ordereddates\f[R]. +When enabled, this check is performed early, before balance assertions +(because copy\-pasted dates are often the root cause of balance +assertion failures). +.IP \[bu] 2 +\f[B]payees\f[R] \- all payees used by transactions must be declared. +This will force you to always use known/declared payee names. +For most people this is a bit too restrictive. +.IP \[bu] 2 +\f[B]tags\f[R] \- all tags used by transactions must be declared. +This prevents mistyped tag names. +.IP \[bu] 2 +\f[B]recentassertions\f[R] \- all accounts with balance assertions must +have a balance assertion within the last 7 days before their latest +posting. +This encourages you to add balance assertions fairly regularly for your +active asset/liability accounts, which in turn should encourage you to +check and reconcile with their real world balances fairly regularly. +\f[CR]close \-\-assert\f[R] can be helpful. +(The older balance assertions become redundant; you can remove them +periodically, or leave them in place, perhaps commented, as +documentation.) +.IP \[bu] 2 +\f[B]uniqueleafnames\f[R] \- no two accounts may have the same leaf +name. +The leaf name is the last colon\-separated part of an account name, eg +\f[CR]checking\f[R] in \f[CR]assets:bank:checking\f[R]. +This encourages you to keep those unique, effectively giving each +account a short name which is easier to remember and to type in +reporting commands. +.SS Custom checks +You can build your own custom checks with add\-on command scripts. +See also Cookbook > Scripting. +Here are some examples from hledger/bin/: +.IP \[bu] 2 +\f[B]hledger\-check\-tagfiles\f[R] \- all tag values containing / (a +forward slash) exist as file paths +.IP \[bu] 2 +\f[B]hledger\-check\-fancyassertions\f[R] \- more complex balance +assertions are passing +.SS diff +Compares a particular account\[aq]s transactions in two input files. +It shows any transactions to this account which are in one file but not +in the other. +.PP +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.) +Since postings not transactions are compared, this also works when +multiple bank transactions have been combined into a single journal +entry. +.PP +This is useful eg if you have downloaded an account\[aq]s transactions +from 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. .PP Examples: -.IP \[bu] 2 -Using roi to compute total return of investment in stocks: -https://github.com/simonmichael/hledger/blob/master/examples/investing/roi\-unrealised.ledger -.IP \[bu] 2 -Cookbook > Return on Investment: https://hledger.org/roi.html -.SS Spaces and special characters in \f[CR]\-\-inv\f[R] and \f[CR]\-\-pnl\f[R] -Note that \f[CR]\-\-inv\f[R] and \f[CR]\-\-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 .EX -$ hledger roi \-\-inv \[aq]term1 term2 term3 ...\[aq] -.EE -.PP -If any query terms contain spaces themselves, you will need an extra -level of nested quoting, eg: -.IP -.EX -$ hledger roi \-\-inv=\[dq]\[aq]Assets:Test 1\[aq]\[dq] \-\-pnl=\[dq]\[aq]Equity:Unrealized Profit and Loss\[aq]\[dq] -.EE -.SS Semantics of \f[CR]\-\-inv\f[R] and \f[CR]\-\-pnl\f[R] -Query supplied to \f[CR]\-\-inv\f[R] has to match all transactions that -are related to your investment. -Transactions not matching \f[CR]\-\-inv\f[R] will be ignored. -.PP -In these transactions, ROI will conside postings that match -\f[CR]\-\-inv\f[R] to be \[dq]investment postings\[dq] and other -postings (not matching \f[CR]\-\-inv\f[R]) will be sorted into two -categories: \[dq]cash flow\[dq] and \[dq]profit and loss\[dq], as ROI -needs to know which part of the investment value is your contributions -and which is due to the return on investment. -.IP \[bu] 2 -\[dq]Cash flow\[dq] is depositing or withdrawing money, buying or -selling assets, or otherwise converting between your investment -commodity and any other commodity. -Example: -.RS 2 -.IP -.EX -2019\-01\-01 Investing in Snake Oil - assets:cash \-$100 - investment:snake oil +$ hledger diff \-f $LEDGER_FILE \-f bank.csv assets:bank:giro +These transactions are in the first file only: -2020\-01\-01 Selling my Snake Oil - assets:cash $10 - investment:snake oil = 0 -.EE -.RE -.IP \[bu] 2 -\[dq]Profit and loss\[dq] is change in the value of your investment: -.RS 2 -.IP -.EX -2019\-06\-01 Snake Oil falls in value - investment:snake oil = $57 - equity:unrealized profit or loss -.EE -.RE -.PP -All non\-investment postings are assumed to be \[dq]cash flow\[dq], -unless they match \f[CR]\-\-pnl\f[R] query. -Changes in value of your investment due to \[dq]profit and loss\[dq] -postings will be considered as part of your investment return. -.PP -Example: if you use \f[CR]\-\-inv snake \-\-pnl equity:unrealized\f[R], -then postings in the example below would be classifed as: -.IP -.EX -2019\-01\-01 Snake Oil #1 - assets:cash \-$100 ; cash flow posting - investment:snake oil ; investment posting +2014/01/01 Opening Balances + assets:bank:giro EUR ... + ... + equity:opening balances EUR \-... -2019\-03\-01 Snake Oil #2 - equity:unrealized pnl \-$100 ; profit and loss posting - snake oil ; investment posting - -2019\-07\-01 Snake Oil #3 - equity:unrealized pnl ; profit and loss posting - cash \-$100 ; cash flow posting - snake oil $50 ; investment posting +These transactions are in the second file only: .EE -.SS IRR and TWR explained -\[dq]ROI\[dq] stands for \[dq]return on investment\[dq]. -Traditionally this was computed as a difference between current value of -investment and its initial value, expressed in percentage of the initial -value. -.PP -However, this approach is only practical in simple cases, where -investments receives no in\-flows or out\-flows of money, and where rate -of growth is fixed over time. -For more complex scenarios you need different ways to compute rate of -return, and this command implements two of them: IRR and TWR. -.PP -Internal rate of return, or \[dq]IRR\[dq] (also called -\[dq]money\-weighted rate of return\[dq]) takes into account effects of -in\-flows and out\-flows, and the time between them. -Investment at a particular fixed interest rate is going to give you more -interest than the same amount invested at the same interest rate, but -made later in time. -If you are withdrawing from your investment, your future gains would be -smaller (in absolute numbers), and will be a smaller percentage of your -initial investment, so your IRR will be smaller. -And if you are adding to your investment, you will receive bigger -absolute gains, which will be a bigger percentage of your initial -investment, so your IRR will be larger. -.PP -As mentioned before, in\-flows and out\-flows would be any cash that you -personally put in or withdraw, and for the \[dq]roi\[dq] command, these -are the postings that match the query in the\f[CR]\-\-inv\f[R] argument -and NOT match the query in the\f[CR]\-\-pnl\f[R] argument. -.PP -If you manually record changes in the value of your investment as -transactions that balance them against \[dq]profit and loss\[dq] (or -\[dq]unrealized gains\[dq]) account or use price directives, then in -order for IRR to compute the precise effect of your in\-flows and -out\-flows on the rate of return, you will need to record the value of -your investement on or close to the days when in\- or out\-flows occur. -.PP -In technical terms, IRR uses the same approach as computation of net -present value, and tries to find a discount rate that makes net present -value of all the cash flows of your investment to add up to zero. -This could be hard to wrap your head around, especially if you -haven\[aq]t done discounted cash flow analysis before. -Implementation of IRR in hledger should produce results that match the -\f[CR]=XIRR\f[R] formula in Excel. -.PP -Second way to compute rate of return that \f[CR]roi\f[R] command -implements is called \[dq]time\-weighted rate of return\[dq] or -\[dq]TWR\[dq]. -Like IRR, it will account for the effect of your in\-flows and -out\-flows, but unlike IRR it will try to compute the true rate of -return of the underlying asset, compensating for the effect that -deposits and withdrawas have on the apparent rate of growth of your -investment. -.PP -TWR represents your investment as an imaginary \[dq]unit fund\[dq] where -in\-flows/ out\-flows lead to buying or selling \[dq]units\[dq] of your -investment and changes in its value change the value of \[dq]investment -unit\[dq]. -Change in \[dq]unit price\[dq] over the reporting period gives you rate -of return of your investment, and make TWR less sensitive than IRR to -the effects of cash in\-flows and out\-flows. -.PP -References: -.IP \[bu] 2 -Explanation of rate of return -.IP \[bu] 2 -Explanation of IRR -.IP \[bu] 2 -Explanation of TWR -.IP \[bu] 2 -IRR vs TWR -.IP \[bu] 2 -Examples of computing IRR and TWR and discussion of the limitations of -both metrics -.SS stats -Show journal and performance statistics. -.PP -The stats command shows summary information for the whole journal, or a -matched part of it. -With a reporting interval, it shows a report for each report period. -.PP -The default output is fairly impersonal, though it reveals the main file -name. -With \f[CR]\-v/\-\-verbose\f[R], more details are shown, like file -paths, included files, and commodity names. -.PP -It also shows some run time statistics: -.IP \[bu] 2 -elapsed time -.IP \[bu] 2 -throughput: the number of transactions processed per second -.IP \[bu] 2 -live: the peak memory in use by the program to do its work -.IP \[bu] 2 -alloc: the peak memory allocation from the OS as seen by GHC. -Measuring this externally, eg with GNU time, is more accurate; usually -that will be a larger number; sometimes (with swapping?) -smaller. -.PP -The \f[CR]stats\f[R] command\[aq]s run time is similar to that of a -balance report. -.PP -Example: -.IP -.EX -$ hledger stats \-f examples/1ktxns\-1kaccts.journal -Main file : .../1ktxns\-1kaccts.journal -Included files : 0 -Txns span : 2000\-01\-01 to 2002\-09\-27 (1000 days) -Last txn : 2002\-09\-26 (7827 days ago) -Txns : 1000 (1.0 per day) -Txns last 30 days : 0 (0.0 per day) -Txns last 7 days : 0 (0.0 per day) -Payees/descriptions : 1000 -Accounts : 1000 (depth 10) -Commodities : 26 -Market prices : 1000 -Runtime stats : 0.12 s elapsed, 8266 txns/s, 4 MB live, 16 MB alloc -.EE -.PP -This command supports the \-o/\-\-output\-file option (but not -\-O/\-\-output\-format). -.SS tags -List the tags used in the journal, or their values. -.PP -This command lists the tag names used in the journal, whether on -transactions, postings, or account declarations. -.PP -With a TAGREGEX argument, only tag names matching this regular -expression (case insensitive, infix matched) are shown. -.PP -With QUERY arguments, only transactions and accounts matching this query -are considered. -If the query involves transaction fields (date:, desc:, amt:, ...), the -search is restricted to the matched transactions and their accounts. -.PP -With the \-\-values flag, the tags\[aq] unique non\-empty values are -listed instead. -With \-E/\-\-empty, blank/empty values are also shown. -.PP -With \-\-parsed, tags or values are shown in the order they were parsed, -with duplicates included. -(Except, tags from account declarations are always shown first.) -.PP -Tip: remember, accounts also acquire tags from their parents, postings -also acquire tags from their account and transaction, transactions also -acquire tags from their postings. .SS test Run built\-in unit tests. .PP @@ -10892,7 +10809,7 @@ For help on these, see https://github.com/feuerbach/tasty#options .PP .SH PART 5: COMMON TASKS Here are some quick examples of how to do some basic tasks with hledger. -.SS Getting help +.SH Getting help Here\[aq]s how to list commands and view options and command docs: .IP .EX @@ -10915,7 +10832,7 @@ To view manuals and introductory docs on the web, visit https://hledger.org. Chat and mail list support and discussion archives can be found at https://hledger.org/support. -.SS Constructing command lines +.SH Constructing command lines hledger has a flexible command line interface. We strive to keep it simple and ergonomic, but if you run into one of the sharp edges described in OPTIONS, here are some tips that might @@ -10934,7 +10851,7 @@ metacharacters from the shell .IP \[bu] 2 to see how a misbehaving command line is being parsed, add \f[CR]\-\-debug=2\f[R]. -.SS Starting a journal file +.SH Starting a journal file hledger looks for your accounting data in a journal file, \f[CR]$HOME/.hledger.journal\f[R] by default: .IP @@ -10972,7 +10889,7 @@ Accounts : 0 (depth 0) Commodities : 0 () Market prices : 0 () .EE -.SS Setting LEDGER_FILE +.SH Setting LEDGER_FILE How to set \f[CR]LEDGER_FILE\f[R] permanently depends on your setup: .PP On unix and mac, running these commands in the terminal will work for @@ -11009,7 +10926,7 @@ persists across a reboot, and if you need to be an Administrator): > MKDIR finance > SETX LEDGER_FILE \[dq]C:\[rs]Users\[rs]USERNAME\[rs]finance\[rs]2023.journal\[dq] .EE -.SS Setting opening balances +.SH Setting opening balances Pick a starting date for which you can look up the balances of some real\-world assets (bank accounts, wallet..) and liabilities (credit cards..). @@ -11098,7 +11015,7 @@ Eg: .EX $ git commit \-m \[aq]initial balances\[aq] 2023.journal .EE -.SS Recording transactions +.SH Recording transactions As you spend or receive money, you can record these transactions using one of the methods above (text editor, hledger add) or by using the hledger\-iadd or hledger\-web add\-ons, or by using the import command @@ -11120,7 +11037,7 @@ hledger.org for more ideas: income:salary assets:bank:checking $1000 .EE -.SS Reconciling +.SH Reconciling Periodically you should reconcile \- compare your hledger\-reported balances against external sources of truth, like bank statements or your bank\[aq]s website \- to be sure that your ledger accurately represents @@ -11181,7 +11098,7 @@ commit: .EX $ git commit \-m \[aq]txns\[aq] 2023.journal .EE -.SS Reporting +.SH Reporting Here are some basic reports. .PP Show all transactions: @@ -11339,7 +11256,7 @@ $ hledger activity \-W 2023\-01\-06 **** 2023\-01\-13 **** .EE -.SS Migrating to a new file +.SH Migrating to a new file At the end of the year, you may want to continue your journal in a new file, so that old transactions don\[aq]t slow down or clutter your reports, and to help ensure the integrity of your accounting history. diff --git a/hledger/hledger.info b/hledger/hledger.info index 421a49981..cb1ecb10e 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -95,7 +95,6 @@ file" and "Setting opening balances" sections in PART 5: COMMON TASKS. * Timeclock:: * Timedot:: * PART 3 REPORTING CONCEPTS:: -* Amount formatting:: * Time periods:: * Depth:: * Queries:: @@ -103,10 +102,29 @@ file" and "Setting opening balances" sections in PART 5: COMMON TASKS. * Generating data:: * Forecasting:: * Budgeting:: +* Amount formatting:: * Cost reporting:: * Value reporting:: * PART 4 COMMANDS:: +* Help commands:: +* User interface commands:: +* Data entry commands:: +* Basic report commands:: +* Standard report commands:: +* Advanced report commands:: +* Chart commands:: +* Data generation commands:: +* Maintenance commands:: * PART 5 COMMON TASKS:: +* Getting help:: +* Constructing command lines:: +* Starting a journal file:: +* Setting LEDGER_FILE:: +* Setting opening balances:: +* Recording transactions:: +* Reconciling:: +* Reporting:: +* Migrating to a new file:: * BUGS::  @@ -337,183 +355,87 @@ File: hledger.info, Node: Options, Next: Command line tips, Prev: Commands, Run 'hledger -h' to see general command line help, and general options which are common to most hledger commands. These options can be written -anywhere on the command line. They can be grouped into help, input, and -reporting options: +anywhere on the command line: -* Menu: +General input/data transformation flags: + -f --file=FILE Read data from FILE, or from stdin if -. Can be + specified more than once. If not specified, reads + from $LEDGER_FILE or $HOME/.hledger.journal. + --rules-file=RULEFILE Use conversion rules from this file for + converting subsequent CSV/SSV/TSV files. If not + specified, uses FILE.rules for each such FILE. + --alias=A=B|/RGX/=RPL transform account names from A to B, or by + replacing regular expression matches + --auto generate extra postings by applying auto posting + rules ("=") to all transactions + --forecast[=PERIOD] Generate extra transactions from periodic rules + ("~"), from after the latest ordinary transaction + until 6 months from now. Or, during the specified + PERIOD (the equals is required). Auto posting rules + will also be applied to these transactions. In + hledger-ui, also make future-dated transactions + visible at startup. + -I --ignore-assertions don't check balance assertions by default + --infer-costs infer conversion equity postings from costs + --infer-equity infer costs from conversion equity postings + --infer-market-prices infer market prices from costs + --pivot=TAGNAME use a different field or tag as account names + -s --strict do extra error checks (and override -I) + --verbose-tags add tags indicating generated/modified data -* General help options:: -* General input options:: -* General reporting options:: +General output/reporting flags (supported by some commands): + -b --begin=DATE include postings/transactions on/after this date + -e --end=DATE include postings/transactions before this date + (with a report interval, will be adjusted to + following subperiod end) + -D --daily multiperiod report with 1 day interval + -W --weekly multiperiod report with 1 week interval + -M --monthly multiperiod report with 1 month interval + -Q --quarterly multiperiod report with 1 quarter interval + -Y --yearly multiperiod report with 1 year interval + -p --period=PERIODEXP set begin date, end date, and/or report interval, + with more flexibility + --today=DATE override today's date (affects relative dates) + --date2 match/use secondary dates instead (deprecated) + -U --unmarked include only unmarked postings/transactions + -P --pending include only pending postings/transactions + -C --cleared include only cleared postings/transactions + (-U/-P/-C can be combined) + -R --real include only non-virtual postings + --depth=NUM or -NUM: show only top NUM levels of accounts + -E --empty Show zero items, which are normally hidden. + In hledger-ui & hledger-web, do the opposite. + -B --cost show amounts converted to their cost/sale amount + -V --market Show amounts converted to their value at period + end(s) in their default valuation commodity. + Equivalent to --value=end. + -X --exchange=COMM Show amounts converted to their value at period + end(s) in the specified commodity. + Equivalent to --value=end,COMM. + --value=WHEN[,COMM] show amounts converted to their value on the + specified date(s) in their default valuation + commodity or a specified commodity. WHEN can be: + 'then': value on transaction dates + 'end': value at period end(s) + 'now': value today + YYYY-MM-DD: value on given date + -c --commodity-style=S Override a commodity's display style. + Eg: -c '.' or -c '1.000,00 EUR' + --color=YN --colour Use ANSI color codes in text output? Can be: + 'yes' or 'always', + 'no' or 'never' (a NO_COLOR env var forces this), + 'auto' (the default: when using a color terminal). + --pretty[=YN] Use box-drawing characters in text output? Can be + 'yes' (the default argument for --pretty) or 'no'. + If YN is specified, the equals is required. + --debug=[N] show debug output (levels 1-9, default: 1) - -File: hledger.info, Node: General help options, Next: General input options, Up: Options - -4.1 General help options -======================== - -'-h --help' - - show general or COMMAND help -'--man' - - show general or COMMAND user manual with man -'--info' - - show general or COMMAND user manual with info -'--version' - - show general or ADDONCMD version -'--debug[=N]' - - show debug output (levels 1-9, default: 1) - - -File: hledger.info, Node: General input options, Next: General reporting options, Prev: General help options, Up: Options - -4.2 General input options -========================= - -'-f FILE --file=FILE' - - use a different input file. For stdin, use - (default: - '$LEDGER_FILE' or '$HOME/.hledger.journal') -'--rules-file=RULESFILE' - - Conversion rules file to use when reading CSV (default: FILE.rules) -'--separator=CHAR' - - Field separator to expect when reading CSV (default: ',') -'--alias=OLD=NEW' - - rename accounts named OLD to NEW -'--pivot FIELDNAME' - - use some other field or tag for the account name -'-I --ignore-assertions' - - disable balance assertion checks (note: does not disable balance - assignments) -'-s --strict' - - do extra error checking (check that all posted accounts are - declared) - - -File: hledger.info, Node: General reporting options, Prev: General input options, Up: Options - -4.3 General reporting options -============================= - -'-b --begin=DATE' - - include postings/txns on or after this date (will be adjusted to - preceding subperiod start when using a report interval) -'-e --end=DATE' - - include postings/txns before this date (will be adjusted to - following subperiod end when using a report interval) -'-D --daily' - - multiperiod/multicolumn report by day -'-W --weekly' - - multiperiod/multicolumn report by week -'-M --monthly' - - multiperiod/multicolumn report by month -'-Q --quarterly' - - multiperiod/multicolumn report by quarter -'-Y --yearly' - - multiperiod/multicolumn report by year -'-p --period=PERIODEXP' - - set start date, end date, and/or reporting interval all at once - using period expressions syntax -'--date2' - - match the secondary date instead (see command help for other - effects) -'--today=DATE' - - override today's date (affects relative smart dates, for - tests/examples) -'-U --unmarked' - - include only unmarked postings/txns (can combine with -P or -C) -'-P --pending' - - include only pending postings/txns -'-C --cleared' - - include only cleared postings/txns -'-R --real' - - include only non-virtual postings -'-NUM --depth=NUM' - - hide/aggregate accounts or postings more than NUM levels deep -'-E --empty' - - show items with zero amount, normally hidden (and vice-versa in - hledger-ui/hledger-web) -'-B --cost' - - convert amounts to their cost/selling amount at transaction time -'-V --market' - - convert amounts to their market value in default valuation - commodities -'-X --exchange=COMM' - - convert amounts to their market value in commodity COMM -'--value' - - convert amounts to cost or market value, more flexibly than - -B/-V/-X -'--infer-equity' - - infer conversion equity postings from costs -'--infer-costs' - - infer costs from conversion equity postings -'--infer-market-prices' - - use costs as additional market prices, as if they were P directives -'--forecast' - - generate transactions from periodic rules, between the latest - recorded txn and 6 months from today, or during the specified - PERIOD (= is required). Auto posting rules will be applied to - these transactions as well. Also, in hledger-ui make future-dated - transactions visible. -'--auto' - - generate extra postings by applying auto posting rules to all txns - (not just forecast txns) -'--verbose-tags' - - add visible tags indicating transactions or postings which have - been generated/modified -'--commodity-style' - - Override the commodity style in the output for the specified - commodity. For example 'EUR1.000,00'. -'--color=WHEN (or --colour=WHEN)' - - Should color-supporting commands use ANSI color codes in text - output. 'auto' (default): whenever stdout seems to be a - color-supporting terminal. 'always' or 'yes': always, useful eg - when piping output into 'less -R'. 'never' or 'no': never. A - NO_COLOR environment variable overrides this. -'--pretty[=WHEN]' - - Show prettier output, e.g. using unicode box-drawing characters. - Accepts 'yes' (the default) or 'no' ('y', 'n', 'always', 'never' - also work). If you provide an argument you must use '=', e.g. - '-pretty=yes'. +General help flags: + -h --help show command line help + --tldr show command examples with tldr + --info show the hledger manual with info + --man show the hledger manual with man + --version show version information When a reporting option appears more than once in the command line, the last one takes precedence. @@ -670,16 +592,17 @@ hledger is expected to handle non-ascii characters correctly: will quit on encountering a non-ascii character (as with all GHC-compiled programs). - * your terminal software (eg Terminal.app, iTerm, CMD.exe, xterm..) - must support unicode + * Your terminal software (eg Terminal.app, iTerm, CMD.exe, xterm..) + must support unicode. On Windows, you may need to use Windows + Terminal and/or enable UTF-8 support. - * the terminal must be using a font which includes the required - unicode glyphs + * The terminal must be using a font which includes the required + unicode glyphs. - * the terminal should be configured to display wide characters as - double width (for report alignment) + * The terminal should be configured to display wide characters as + double width (for report alignment). - * on Windows, for best results you should run hledger in the same + * On Windows, for best results you should run hledger in the same kind of environment in which it was built. Eg hledger built in the standard CMD.EXE environment (like the binaries on our download page) might show display problems when run in a cygwin or msys @@ -4878,12 +4801,28 @@ File: hledger.info, Node: Amount decimal places, Next: Referencing other field 10.18.12 Amount decimal places ------------------------------ -Like amounts in a journal file, the amounts generated by CSV rules like -'amount1' influence commodity display styles, such as the number of -decimal places displayed in reports. +When you are reading CSV data, eg with a command like 'hledger -f +foo.csv print', hledger will infer each commodity's decimal precision +(and other commodity display styles) from the amounts - much as when +reading a journal file without 'commodity' directives (see the link). - The original amounts as written in the CSV file do not affect display -style (because we don't yet reliably know their commodity). + Note, the commodity styles are not inferred from the numbers in the +original CSV data; rather, they are inferred from the amounts generated +by the CSV rules. + + When you are importing CSV data with the 'import' command, eg +'hledger import foo.csv', there's another step: 'import' tries to make +the new entries conform to the journal's existing styles. So for each +commodity - let's say it's EUR - 'import' will choose: + + 1. the style declared for EUR by a 'commodity' directive in the + journal + 2. otherwise, the style inferred from EUR amounts in the journal + 3. otherwise, the style inferred from EUR amounts generated by the CSV + rules. + + TLDR: if 'import' is not generating the precisions or styles you +want, add a 'commodity' directive to specify them.  File: hledger.info, Node: Referencing other fields, Next: How CSV rules are evaluated, Prev: Amount decimal places, Up: Working with CSV @@ -5528,158 +5467,15 @@ $ hledger -f a.timedot --alias '/\./=:' bal -t 4.50  -File: hledger.info, Node: PART 3 REPORTING CONCEPTS, Next: Amount formatting, Prev: Timedot, Up: Top +File: hledger.info, Node: PART 3 REPORTING CONCEPTS, Next: Time periods, Prev: Timedot, Up: Top 13 PART 3: REPORTING CONCEPTS *****************************  -File: hledger.info, Node: Amount formatting, Next: Time periods, Prev: PART 3 REPORTING CONCEPTS, Up: Top +File: hledger.info, Node: Time periods, Next: Depth, Prev: PART 3 REPORTING CONCEPTS, Up: Top -14 Amount formatting -******************** - -* Menu: - -* Commodity display style:: -* Rounding:: -* Trailing decimal marks:: -* Amount parseability:: - - -File: hledger.info, Node: Commodity display style, Next: Rounding, Up: Amount formatting - -14.1 Commodity display style -============================ - -For the amounts in each commodity, hledger chooses a consistent display -style (symbol placement, decimal mark and digit group marks, number of -decimal digits) to use in most reports. This is inferred as follows: - - First, if there's a 'D' directive declaring a default commodity, that -commodity symbol and amount format is applied to all no-symbol amounts -in the journal. - - Then each commodity's display style is determined from its -'commodity' directive. We recommend always declaring commodities with -'commodity' directives, since they help ensure consistent display styles -and precisions, and bring other benefits such as error checking for -commodity symbols. Here's an example: - -# Set display styles (and decimal marks, for parsing, if there is no decimal-mark directive) -# for the $, EUR, INR and no-symbol commodities: -commodity $1,000.00 -commodity EUR 1.000,00 -commodity INR 9,99,99,999.00 -commodity 1 000 000.9455 - - But for convenience, if a 'commodity' directive is not present, -hledger infers a commodity's display styles from its amounts as they are -written in the journal (excluding cost amounts and amounts in periodic -transaction rules or auto posting rules). It uses - - * the symbol placement and decimal mark of the first amount seen - * the digit group marks of the first amount with digit group marks - * and the maximum number of decimal digits seen across all amounts. - - And as fallback if no applicable amounts are found, it would use a -default style, like '$1000.00' (symbol on the left with no space, period -as decimal mark, and two decimal digits). - - Finally, commodity styles can be overridden by the -'-c/--commodity-style' command line option. - - -File: hledger.info, Node: Rounding, Next: Trailing decimal marks, Prev: Commodity display style, Up: Amount formatting - -14.2 Rounding -============= - -Amounts are stored internally as decimal numbers with up to 255 decimal -places. They are displayed with their original journal precisions by -print and print-like reports, and rounded to their display precision -(the number of decimal digits specified by the commodity display style) -by other reports. When rounding, hledger uses banker's rounding (it -rounds to the nearest even digit). So eg 0.5 displayed with zero -decimal digits appears as "0". - - -File: hledger.info, Node: Trailing decimal marks, Next: Amount parseability, Prev: Rounding, Up: Amount formatting - -14.3 Trailing decimal marks -=========================== - -If you're wondering why your 'print' report sometimes shows trailing -decimal marks, with no decimal digits; it does this when showing amounts -that have digit group marks but no decimal digits, to disambiguate them -and allow them to be re-parsed reliably (see Decimal marks). Eg: - -commodity $1,000.00 - -2023-01-02 - (a) $1000 - -$ hledger print -2023-01-02 - (a) $1,000. - - If this is a problem (eg when exporting to Ledger), you can avoid it -by disabling digit group marks, eg with -c/-commodity (for each affected -commodity): - -$ hledger print -c '$1000.00' -2023-01-02 - (a) $1000 - - or by forcing print to always show decimal digits, with -round: - -$ hledger print -c '$1,000.00' --round=soft -2023-01-02 - (a) $1,000.00 - - -File: hledger.info, Node: Amount parseability, Prev: Trailing decimal marks, Up: Amount formatting - -14.4 Amount parseability -======================== - -More generally, hledger output falls into three rough categories, which -format amounts a little bit differently to suit different consumers: - - *1. "hledger-readable output" - should be readable by hledger (and -by humans)* - - * This is produced by reports that show full journal entries: - 'print', 'import', 'close', 'rewrite' etc. - * It shows amounts with their original journal precisions, which may - not be consistent. - * It adds a trailing decimal mark when needed to avoid showing - ambiguous amounts. - * It can be parsed reliably (by hledger and ledger2beancount at - least, but perhaps not by Ledger..) - - *2. "human-readable output" - usually for humans* - - * This is produced by all other reports. - * It shows amounts with standard display precisions, which will be - consistent within each commodity. - * It shows ambiguous amounts unmodified. - * It can be parsed reliably in the context of a known report (when - you know decimals are consistently not being shown, you can assume - a single mark is a digit group mark). - - *3. "machine-readable output" - usually for other software* - - * This is produced by all reports when an output format like 'csv', - 'tsv', 'json', or 'sql' is selected. - * It shows amounts as 1 or 2 do, but without digit group marks. - * It can be parsed reliably (if needed, the decimal mark can be - changed with -c/-commodity-style). - - -File: hledger.info, Node: Time periods, Next: Depth, Prev: Amount formatting, Up: Top - -15 Time periods +14 Time periods *************** * Menu: @@ -5693,101 +5489,123 @@ File: hledger.info, Node: Time periods, Next: Depth, Prev: Amount formatting,  File: hledger.info, Node: Report start & end date, Next: Smart dates, Up: Time periods -15.1 Report start & end date +14.1 Report start & end date ============================ -By default, most hledger reports will show the full span of time +Most hledger reports will by default show the full time period represented by the journal. The report start date will be the earliest transaction or posting date, and the report end date will be the latest transaction, posting, or market price date. - Often you will want to see a shorter time span, such as the current -month. You can specify a start and/or end date using '-b/--begin', -'-e/--end', '-p/--period' or a 'date:' query (described below). All of -these accept the smart date syntax (below). + Often you will want to see a shorter period, such as the current +month. You can specify a start and/or end date with the '-b/--begin', +'-e/--end', or '-p/--period' options, or a 'date:' query argument, +described below. All of these accept the smart date syntax, also +described below. - Some notes: + End dates are exclusive; specify the day after the last day you want +to see in the report. - * End dates are exclusive, as in Ledger, so you should write the date - _after_ the last day you want to see in the report. - * As noted in reporting options: among start/end dates specified with - _options_, the last (i.e. right-most) option takes precedence. - * The effective report start and end dates are the intersection of - the start/end dates from options and that from 'date:' queries. - That is, 'date:2019-01 date:2019 -p'2000 to 2030'' yields January - 2019, the smallest common time span. - * In some cases a report interval will adjust start/end dates to fall - on interval boundaries (see below). + When dates are specified by multiple options, the last (right-most) +option wins. And when 'date:' queries and date options are combined, +the report period will be their intersection. Examples: -'-b begin on St. Patrick's day 2016 -2016/3/17' -'-e 12/1' end at the start of december 1st of the current year - (11/30 will be the last date included) -'-b all transactions on or after the 1st of the current month -thismonth' -'-p all transactions in the current month -thismonth' -'date:2016/3/17..'the above written as queries instead ('..' can also be - replaced with '-') -'date:..12/1' -'date:thismonth..' -'date:thismonth' +'-b 2016/3/17' + + beginning on St. Patrick's day 2016 +'-e 12/1' + + ending at the start of December 1st in the current year +'-p 'this month'' + + during the current month +'-p thismonth' + + same as above, spaces are optional +'-b 2023' + + beginning on the first day of 2023 +'date:2023..' or 'date:2023-' + + same as above + + '-b 2024 -e 2025 -p '2000 to 2030' date:2020-01 date:2020' : +during January 2020 (the smallest common period, with the -p overriding +-b and -e)  File: hledger.info, Node: Smart dates, Next: Report intervals, Prev: Report start & end date, Up: Time periods -15.2 Smart dates +14.2 Smart dates ================ -hledger's user interfaces accept a "smart date" syntax for added -convenience. Smart dates optionally can be relative to today's date, be -written with english words, and have less-significant parts omitted -(missing parts are inferred as 1). Some examples: +In hledger's user interfaces (though not in the journal file), you can +optionally use "smart date" syntax. Smart dates can be written with +english words, can be relative, and can have parts omitted. Missing +parts are inferred as 1, when needed. Smart dates can be interpreted as +dates or periods depending on context. -'2004/10/1', exact date, several separators allowed. Year -'2004-01-01', is 4+ digits, month is 1-12, day is 1-31 -'2004.9.1' -'2004' start of year -'2004/10' start of month -'10/1' month and day in current year -'21' day in current month -'october, oct' start of month in current year -'yesterday, today, -1, 0, 1 days from today -tomorrow' -'last/this/next -1, 0, 1 periods from the current period -day/week/month/quarter/year' -'in n n periods from the current period -days/weeks/months/quarters/years' -'n n periods from the current period -days/weeks/months/quarters/years -ahead' -'n -n periods from the current period -days/weeks/months/quarters/years -ago' -'20181201' 8 digit YYYYMMDD with valid year month and - day -'201812' 6 digit YYYYMM with valid year and month + Examples: - Some counterexamples - malformed digit sequences might give -surprising results: + '2004-01-01', '2004/10/1', '2004.9.1', '20240504' : +Exact dates. The year must have at least four digits, the month must be +1-12, the day must be 1-31, the separator can be '-' or '/' or '.' or +nothing. -'201813' 6 digits with an invalid month is parsed as start of - 6-digit year -'20181301' 8 digits with an invalid month is parsed as start of - 8-digit year -'20181232' 8 digits with an invalid day gives an error -'201801012' 9+ digits beginning with a valid YYYYMMDD gives an error +'2004-10' - "Today's date" can be overridden with the '--today' option, in case -it's needed for testing or for recreating old reports. (Except for -periodic transaction rules, which are not affected by '--today'.) + start of month +'2004' + + start of year +'10/1' or 'oct' or 'october' + + October 1st in current year +'21' + + 21st day in current month +'yesterday, today, tomorrow' + + -1, 0, 1 days from today +'last/this/next day/week/month/quarter/year' + + -1, 0, 1 periods from the current period +'in n days/weeks/months/quarters/years' + + n periods from the current period +'n days/weeks/months/quarters/years ahead' + + n periods from the current period +'n days/weeks/months/quarters/years ago' + + -n periods from the current period +'20181201' + + 8 digit YYYYMMDD with valid year month and day +'201812' + + 6 digit YYYYMM with valid year and month + + Dates with no separators are allowed but might give surprising +results if mistyped: + + * '20181301' (YYYYMMDD with an invalid month) is parsed as an + eight-digit year + * '20181232' (YYYYMMDD with an invalid day) gives a parse error + * '201801012' (a valid YYYYMMDD followed by additional digits) gives + a parse error + + The meaning of relative dates depends on today's date. If you need +to test or reproduce old reports, you can use the '--today' option to +override that. (Except for periodic transaction rules, which are not +affected by '--today'.)  File: hledger.info, Node: Report intervals, Next: Date adjustment, Prev: Smart dates, Up: Time periods -15.3 Report intervals +14.3 Report intervals ===================== A report interval can be specified so that reports like register, @@ -5809,7 +5627,7 @@ described below.  File: hledger.info, Node: Date adjustment, Next: Period expressions, Prev: Report intervals, Up: Time periods -15.4 Date adjustment +14.4 Date adjustment ==================== When there is a report interval (other than daily), report start/end @@ -5833,7 +5651,7 @@ period headings.  File: hledger.info, Node: Period expressions, Prev: Date adjustment, Up: Time periods -15.5 Period expressions +14.5 Period expressions ======================= The '-p/--period' option specifies a period expression, which is a @@ -5893,7 +5711,7 @@ date:  File: hledger.info, Node: Period expressions with a report interval, Next: More complex report intervals, Up: Period expressions -15.5.1 Period expressions with a report interval +14.5.1 Period expressions with a report interval ------------------------------------------------ A period expression can also begin with a report interval, separated @@ -5906,7 +5724,7 @@ from the start/end dates (if any) by a space or the word 'in':  File: hledger.info, Node: More complex report intervals, Next: Multiple weekday intervals, Prev: Period expressions with a report interval, Up: Period expressions -15.5.2 More complex report intervals +14.5.2 More complex report intervals ------------------------------------ Some more complex intervals can be specified within period expressions, @@ -5927,7 +5745,8 @@ such as: Monthly on a custom day: - * 'every Nth day [of month]' + * 'every Nth day [of month]' ('31st day' will be adjusted to each + month's last day) * 'every Nth WEEKDAYNAME [of month]' Yearly on a custom day: @@ -5969,7 +5788,7 @@ $ hledger register checking -p "every 3rd day of week"  File: hledger.info, Node: Multiple weekday intervals, Prev: More complex report intervals, Up: Period expressions -15.5.3 Multiple weekday intervals +14.5.3 Multiple weekday intervals --------------------------------- This special form is also supported: @@ -5997,7 +5816,7 @@ weekendday"'  File: hledger.info, Node: Depth, Next: Queries, Prev: Time periods, Up: Top -16 Depth +15 Depth ******** With the '--depth NUM' option (short form: '-NUM'), reports will show @@ -6009,7 +5828,7 @@ equivalent.  File: hledger.info, Node: Queries, Next: Pivoting, Prev: Depth, Up: Top -17 Queries +16 Queries ********** One of hledger's strengths is being able to quickly report on a precise @@ -6075,7 +5894,7 @@ a more complex query.  File: hledger.info, Node: Query types, Next: Combining query terms, Up: Queries -17.1 Query types +16.1 Query types ================ Here are the types of query term available. Remember these can also be @@ -6167,7 +5986,7 @@ 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 -17.2 Combining query terms +16.2 Combining query terms ========================== When given multiple space-separated query terms, most commands select @@ -6218,7 +6037,7 @@ result sets, with unclear semantics for our reports.  File: hledger.info, Node: Queries and command options, Next: Queries and account aliases, Prev: Combining query terms, Up: Queries -17.3 Queries and command options +16.3 Queries and command options ================================ Some queries can also be expressed as command-line options: 'depth:2' is @@ -6229,7 +6048,7 @@ resulting query is their intersection.  File: hledger.info, Node: Queries and account aliases, Next: Queries and valuation, Prev: Queries and command options, Up: Queries -17.4 Queries and account aliases +16.4 Queries and account aliases ================================ When account names are rewritten with '--alias' or 'alias', 'acct:' will @@ -6238,7 +6057,7 @@ match either the old or the new account name.  File: hledger.info, Node: Queries and valuation, Prev: Queries and account aliases, Up: Queries -17.5 Queries and valuation +16.5 Queries and valuation ========================== When amounts are converted to other commodities in cost or value @@ -6248,7 +6067,7 @@ amount quantity, not the new ones. (Except in hledger 1.22, #1625.)  File: hledger.info, Node: Pivoting, Next: Generating data, Prev: Queries, Up: Top -18 Pivoting +17 Pivoting *********** Normally, hledger groups and sums amounts within each account. The @@ -6309,7 +6128,7 @@ $ hledger balance Income:Dues --pivot kind:member  File: hledger.info, Node: Generating data, Next: Forecasting, Prev: Pivoting, Up: Top -19 Generating data +18 Generating data ****************** hledger has several features for generating data, such as: @@ -6348,7 +6167,7 @@ prefix), so eg you could match generated transactions with  File: hledger.info, Node: Forecasting, Next: Budgeting, Prev: Generating data, Up: Top -20 Forecasting +19 Forecasting ************** Forecasting, or speculative future reporting, can be useful for @@ -6371,7 +6190,7 @@ when you want to see them.  File: hledger.info, Node: --forecast, Next: Inspecting forecast transactions, Up: Forecasting -20.1 -forecast +19.1 -forecast ============== There is another way: with the '--forecast' option, hledger can generate @@ -6395,7 +6214,7 @@ that the '=' is required.  File: hledger.info, Node: Inspecting forecast transactions, Next: Forecast reports, Prev: --forecast, Up: Forecasting -20.2 Inspecting forecast transactions +19.2 Inspecting forecast transactions ===================================== 'print' is the best command for inspecting and troubleshooting forecast @@ -6439,7 +6258,7 @@ reproducible.)  File: hledger.info, Node: Forecast reports, Next: Forecast tags, Prev: Inspecting forecast transactions, Up: Forecasting -20.3 Forecast reports +19.3 Forecast reports ===================== Forecast transactions affect all reports, as you would expect. Eg: @@ -6464,7 +6283,7 @@ Balance changes in 2023-05-01..2023-09-30:  File: hledger.info, Node: Forecast tags, Next: Forecast period in detail, Prev: Forecast reports, Up: Forecasting -20.4 Forecast tags +19.4 Forecast tags ================== Forecast transactions generated by -forecast have a hidden tag, @@ -6480,7 +6299,7 @@ rule was responsible.  File: hledger.info, Node: Forecast period in detail, Next: Forecast troubleshooting, Prev: Forecast tags, Up: Forecasting -20.5 Forecast period, in detail +19.5 Forecast period, in detail =============================== Forecast start/end dates are chosen so as to do something useful by @@ -6511,7 +6330,7 @@ default in almost all situations, while also being flexible. Here are  File: hledger.info, Node: Forecast troubleshooting, Prev: Forecast period in detail, Up: Forecasting -20.6 Forecast troubleshooting +19.6 Forecast troubleshooting ============================= When -forecast is not doing what you expect, one of these tips should @@ -6537,9 +6356,9 @@ help: * Check inside the engine: add '--debug=2' (eg).  -File: hledger.info, Node: Budgeting, Next: Cost reporting, Prev: Forecasting, Up: Top +File: hledger.info, Node: Budgeting, Next: Amount formatting, Prev: Forecasting, Up: Top -21 Budgeting +20 Budgeting ************ With the balance command's '--budget' report, each periodic transaction @@ -6554,7 +6373,150 @@ bal -M --budget --forecast ...' See also: Budgeting and Forecasting.  -File: hledger.info, Node: Cost reporting, Next: Value reporting, Prev: Budgeting, Up: Top +File: hledger.info, Node: Amount formatting, Next: Cost reporting, Prev: Budgeting, Up: Top + +21 Amount formatting +******************** + +* Menu: + +* Commodity display style:: +* Rounding:: +* Trailing decimal marks:: +* Amount parseability:: + + +File: hledger.info, Node: Commodity display style, Next: Rounding, Up: Amount formatting + +21.1 Commodity display style +============================ + +For the amounts in each commodity, hledger chooses a consistent display +style (symbol placement, decimal mark and digit group marks, number of +decimal digits) to use in most reports. This is inferred as follows: + + First, if there's a 'D' directive declaring a default commodity, that +commodity symbol and amount format is applied to all no-symbol amounts +in the journal. + + Then each commodity's display style is determined from its +'commodity' directive. We recommend always declaring commodities with +'commodity' directives, since they help ensure consistent display styles +and precisions, and bring other benefits such as error checking for +commodity symbols. Here's an example: + +# Set display styles (and decimal marks, for parsing, if there is no decimal-mark directive) +# for the $, EUR, INR and no-symbol commodities: +commodity $1,000.00 +commodity EUR 1.000,00 +commodity INR 9,99,99,999.00 +commodity 1 000 000.9455 + + But for convenience, if a 'commodity' directive is not present, +hledger infers a commodity's display styles from its amounts as they are +written in the journal (excluding cost amounts and amounts in periodic +transaction rules or auto posting rules). It uses + + * the symbol placement and decimal mark of the first amount seen + * the digit group marks of the first amount with digit group marks + * and the maximum number of decimal digits seen across all amounts. + + And as fallback if no applicable amounts are found, it would use a +default style, like '$1000.00' (symbol on the left with no space, period +as decimal mark, and two decimal digits). + + Finally, commodity styles can be overridden by the +'-c/--commodity-style' command line option. + + +File: hledger.info, Node: Rounding, Next: Trailing decimal marks, Prev: Commodity display style, Up: Amount formatting + +21.2 Rounding +============= + +Amounts are stored internally as decimal numbers with up to 255 decimal +places. They are displayed with their original journal precisions by +print and print-like reports, and rounded to their display precision +(the number of decimal digits specified by the commodity display style) +by other reports. When rounding, hledger uses banker's rounding (it +rounds to the nearest even digit). So eg 0.5 displayed with zero +decimal digits appears as "0". + + +File: hledger.info, Node: Trailing decimal marks, Next: Amount parseability, Prev: Rounding, Up: Amount formatting + +21.3 Trailing decimal marks +=========================== + +If you're wondering why your 'print' report sometimes shows trailing +decimal marks, with no decimal digits; it does this when showing amounts +that have digit group marks but no decimal digits, to disambiguate them +and allow them to be re-parsed reliably (see Decimal marks). Eg: + +commodity $1,000.00 + +2023-01-02 + (a) $1000 + +$ hledger print +2023-01-02 + (a) $1,000. + + If this is a problem (eg when exporting to Ledger), you can avoid it +by disabling digit group marks, eg with -c/-commodity (for each affected +commodity): + +$ hledger print -c '$1000.00' +2023-01-02 + (a) $1000 + + or by forcing print to always show decimal digits, with -round: + +$ hledger print -c '$1,000.00' --round=soft +2023-01-02 + (a) $1,000.00 + + +File: hledger.info, Node: Amount parseability, Prev: Trailing decimal marks, Up: Amount formatting + +21.4 Amount parseability +======================== + +More generally, hledger output falls into three rough categories, which +format amounts a little bit differently to suit different consumers: + + *1. "hledger-readable output" - should be readable by hledger (and +by humans)* + + * This is produced by reports that show full journal entries: + 'print', 'import', 'close', 'rewrite' etc. + * It shows amounts with their original journal precisions, which may + not be consistent. + * It adds a trailing decimal mark when needed to avoid showing + ambiguous amounts. + * It can be parsed reliably (by hledger and ledger2beancount at + least, but perhaps not by Ledger..) + + *2. "human-readable output" - usually for humans* + + * This is produced by all other reports. + * It shows amounts with standard display precisions, which will be + consistent within each commodity. + * It shows ambiguous amounts unmodified. + * It can be parsed reliably in the context of a known report (when + you know decimals are consistently not being shown, you can assume + a single mark is a digit group mark). + + *3. "machine-readable output" - usually for other software* + + * This is produced by all reports when an output format like 'csv', + 'tsv', 'json', or 'sql' is selected. + * It shows amounts as 1 or 2 do, but without digit group marks. + * It can be parsed reliably (if needed, the decimal mark can be + changed with -c/-commodity-style). + + +File: hledger.info, Node: Cost reporting, Next: Value reporting, Prev: Amount formatting, Up: Top 22 Cost reporting ***************** @@ -7361,126 +7323,32 @@ average totals totals totals column a zero starting balance.  -File: hledger.info, Node: PART 4 COMMANDS, Next: PART 5 COMMON TASKS, Prev: Value reporting, Up: Top +File: hledger.info, Node: PART 4 COMMANDS, Next: Help commands, Prev: Value reporting, Up: Top 24 PART 4: COMMANDS ******************* -* Menu: +Here are the standard commands, which you can list by running 'hledger'. +If you have installed more add-on commands, they also will be listed. -* Commands overview:: -* accounts:: -* activity:: -* add:: -* aregister:: -* balance:: -* balancesheet:: -* balancesheetequity:: -* cashflow:: -* check:: -* close:: -* codes:: -* commodities:: -* demo:: -* descriptions:: -* diff:: -* files:: -* help:: -* import:: -* incomestatement:: -* notes:: -* payees:: -* prices:: -* print:: -* register:: -* rewrite:: -* roi:: -* stats:: -* tags:: -* test:: + *Help commands* - -File: hledger.info, Node: Commands overview, Next: accounts, Up: PART 4 COMMANDS + * help - show the hledger manual with info/man/pager + * demo - show small hledger demos in the terminal -24.1 Commands overview -====================== + *User interface commands* -Here are the built-in commands: + * ui - (if installed) run hledger's terminal UI + * web - (if installed) run hledger's web UI -* Menu: - -* DATA ENTRY:: -* DATA CREATION:: -* DATA MANAGEMENT:: -* REPORTS FINANCIAL:: -* REPORTS VERSATILE:: -* REPORTS BASIC:: -* HELP:: -* ADD-ONS:: - - -File: hledger.info, Node: DATA ENTRY, Next: DATA CREATION, Up: Commands overview - -24.1.1 DATA ENTRY ------------------ - -These data entry commands are the only ones which can modify your -journal file. + *Data entry commands* * add - add transactions using terminal prompts * import - add new transactions from other files, eg CSV files - -File: hledger.info, Node: DATA CREATION, Next: DATA MANAGEMENT, Prev: DATA ENTRY, Up: Commands overview - -24.1.2 DATA CREATION --------------------- - - * close - generate balance-zeroing/restoring transactions - * rewrite - generate auto postings, like print -auto - - -File: hledger.info, Node: DATA MANAGEMENT, Next: REPORTS FINANCIAL, Prev: DATA CREATION, Up: Commands overview - -24.1.3 DATA MANAGEMENT ----------------------- - - * check - check for various kinds of error in the data - * diff - compare account transactions in two journal files - - -File: hledger.info, Node: REPORTS FINANCIAL, Next: REPORTS VERSATILE, Prev: DATA MANAGEMENT, Up: Commands overview - -24.1.4 REPORTS, FINANCIAL -------------------------- - - * aregister (areg) - show transactions in a particular account - * balancesheet (bs) - show assets, liabilities and net worth - * balancesheetequity (bse) - show assets, liabilities and equity - * cashflow (cf) - show changes in liquid assets - * incomestatement (is) - show revenues and expenses - - -File: hledger.info, Node: REPORTS VERSATILE, Next: REPORTS BASIC, Prev: REPORTS FINANCIAL, Up: Commands overview - -24.1.5 REPORTS, VERSATILE -------------------------- - - * balance (bal) - show balance changes, end balances, budgets, - gains.. - * print - show transactions or export journal data - * register (reg) - show postings in one or more accounts & running - total - * roi - show return on investments - - -File: hledger.info, Node: REPORTS BASIC, Next: HELP, Prev: REPORTS VERSATILE, Up: Commands overview - -24.1.6 REPORTS, BASIC ---------------------- + *Basic report commands* * accounts - show account names - * activity - show bar charts of posting counts per period * codes - show transaction codes * commodities - show commodity/currency symbols * descriptions - show transaction descriptions @@ -7490,41 +7358,400 @@ File: hledger.info, Node: REPORTS BASIC, Next: HELP, Prev: REPORTS VERSATILE, * prices - show market prices * stats - show journal statistics * tags - show tag names + + *Standard report commands* + + * print - show transactions or export journal data + * aregister (areg) - show transactions in a particular account + * register (reg) - show postings in one or more accounts & running + total + * balancesheet (bs) - show assets, liabilities and net worth + * balancesheetequity (bse) - show assets, liabilities and equity + * cashflow (cf) - show changes in liquid assets + * incomestatement (is) - show revenues and expenses + + *Advanced report commands* + + * balance (bal) - show balance changes, end balances, budgets, + gains.. + * roi - show return on investments + + *Chart commands* + + * activity - show bar charts of posting counts per period + + *Data generation commands* + + * close - generate balance-zeroing/restoring transactions + * rewrite - generate auto postings, like print -auto + + *Maintenance commands* + + * check - check for various kinds of error in the data + * diff - compare account transactions in two journal files * test - run self tests - -File: hledger.info, Node: HELP, Next: ADD-ONS, Prev: REPORTS BASIC, Up: Commands overview - -24.1.7 HELP ------------ - - * help - show the hledger manual with info/man/pager - * demo - show small hledger demos in the terminal + Next, these commands are described in detail.  -File: hledger.info, Node: ADD-ONS, Prev: HELP, Up: Commands overview +File: hledger.info, Node: Help commands, Next: User interface commands, Prev: PART 4 COMMANDS, Up: Top -24.1.8 ADD-ONS --------------- +25 Help commands +**************** -And here are some typical add-on commands. Some of these are installed -by the hledger-install script. If installed, they will appear in -hledger's commands list: +* Menu: - * ui - run hledger's terminal UI - * web - run hledger's web UI - * iadd - add transactions using a TUI (currently hard to build) - * interest - generate interest transactions - * stockquotes - download market prices from AlphaVantage - * Scripts and add-ons - check-fancyassertions, edit, fifo, git, move, - pijul, plot, and more.. - - Next, each command is described in detail, in alphabetical order. +* help:: +* demo::  -File: hledger.info, Node: accounts, Next: activity, Prev: Commands overview, Up: PART 4 COMMANDS +File: hledger.info, Node: help, Next: demo, Up: Help commands -24.2 accounts +25.1 help +========= + +Show the hledger user manual with 'info', 'man', or a pager. With a +(case insensitive) TOPIC argument, try to open it at that section +heading. + + This command shows the hledger manual built in to your hledger +executable. It can be useful when offline, or when you prefer the +terminal to a web browser, or when the appropriate hledger manual or +viewers are not installed properly on your system. + + By default it chooses the best viewer found in $PATH, trying in this +order: 'info', 'man', '$PAGER', 'less', 'more', stdout. (If a TOPIC is +specified, '$PAGER' and 'more' are not tried.) You can force the use of +info, man, or a pager with the '-i', '-m', or '-p' flags. If no viewer +can be found, or if running non-interactively, it just prints the manual +to stdout. + + When using 'info', TOPIC can match either the full heading or a +prefix. If your 'info --version' is < 6, you'll need to upgrade it, eg +with ''brew install texinfo'' on mac. + + When using 'man' or 'less', TOPIC must match the full heading. For a +prefix match, you can write ''TOPIC.*''. + + Examples + +$ hledger help -h # show the help command's usage +$ hledger help # show the manual with info, man or $PAGER +$ hledger help 'time periods' # show the manual's "Time periods" topic +$ hledger help 'time periods' -m # use man, even if info is installed + + +File: hledger.info, Node: demo, Prev: help, Up: Help commands + +25.2 demo +========= + +Play demos of hledger usage in the terminal, if asciinema is installed. + + Run this command with no argument to list the demos. To play a demo, +write its number or a prefix or substring of its title. Tips: + + Make your terminal window large enough to see the demo clearly. + + Use the -s/-speed SPEED option to set your preferred playback speed, +eg '-s4' to play at 4x original speed or '-s.5' to play at half speed. +The default speed is 2x. + + Other asciinema options can be added following a double dash, eg '-- +-i.1' to limit pauses or '-- -h' to list asciinema's other options. + + During playback, several keys are available: SPACE to pause/unpause, +. to step forward (while paused), CTRL-c quit. + + Examples: + +$ hledger demo # list available demos +$ hledger demo 1 # play the first demo at default speed (2x) +$ hledger demo install -s4 # play the "install" demo at 4x speed + + +File: hledger.info, Node: User interface commands, Next: Data entry commands, Prev: Help commands, Up: Top + +26 User interface commands +************************** + +* Menu: + +* ui:: +* web:: + + +File: hledger.info, Node: ui, Next: web, Up: User interface commands + +26.1 ui +======= + +Runs hledger-ui (if installed). + + +File: hledger.info, Node: web, Prev: ui, Up: User interface commands + +26.2 web +======== + +Runs hledger-web (if installed). + + +File: hledger.info, Node: Data entry commands, Next: Basic report commands, Prev: User interface commands, Up: Top + +27 Data entry commands +********************** + +* Menu: + +* add:: +* import:: + + +File: hledger.info, Node: add, Next: import, Up: Data entry commands + +27.1 add +======== + +Prompt for transactions and add them to the journal. Any arguments will +be used as default inputs for the first N prompts. + + Many hledger users edit their journals directly with a text editor, +or generate them from CSV. For more interactive data entry, there is the +'add' command, which prompts interactively on the console for new +transactions, and appends them to the main journal file (which should be +in journal format). Existing transactions are not changed. This is one +of the few hledger commands that writes to the journal file (see also +'import'). + + To use it, just run 'hledger add' and follow the prompts. You can +add as many transactions as you like; when you are finished, enter '.' +or press control-d or control-c to exit. + + Features: + + * add tries to provide useful defaults, using the most similar (by + description) recent transaction (filtered by the query, if any) as + a template. + * You can also set the initial defaults with command line arguments. + * Readline-style edit keys can be used during data entry. + * The tab key will auto-complete whenever possible - accounts, + payees/descriptions, dates ('yesterday', 'today', 'tomorrow'). If + the input area is empty, it will insert the default value. + * If the journal defines a default commodity, it will be added to any + bare numbers entered. + * A parenthesised transaction code may be entered following a date. + * Comments and tags may be entered following a description or amount. + * If you make a mistake, enter '<' at any prompt to go one step + backward. + * Input prompts are displayed in a different colour when the terminal + supports it. + + Notes: + + * If you enter a number with no commodity symbol, and you have + declared a default commodity with a 'D' directive, you might expect + 'add' to add this symbol for you. It does not do this; we assume + that if you are using a 'D' directive you prefer not to see the + commodity symbol repeated on amounts in the journal. + + Examples: + + * Record new transactions, saving to the default journal file: + + 'hledger add' + + * Add transactions to 2024.journal, but also load 2023.journal for + completions: + + 'hledger add --file 2024.journal --file 2023.journal' + + * Provide answers for the first four prompts: + + 'hledger add today 'best buy' expenses:supplies '$20'' + + There is a detailed tutorial at https://hledger.org/add.html. + + +File: hledger.info, Node: import, Prev: add, Up: Data entry commands + +27.2 import +=========== + +Read new transactions added to each FILE provided as arguments since +last run, and add them to the journal. Or with -dry-run, just print the +transactions that would be added. Or with -catchup, just mark all of +the FILEs' current transactions as imported, without importing them. + + This command may append new transactions to the main journal file +(which should be in journal format). Existing transactions are not +changed. This is one of the few hledger commands that writes to the +journal file (see also 'add'). + + Unlike other hledger commands, with 'import' the journal file is an +output 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 +'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. + +* Menu: + +* Date skipping:: +* Import testing:: +* Importing balance assignments:: +* Import and commodity styles:: + + +File: hledger.info, Node: Date skipping, Next: Import testing, Up: import + +27.2.1 Date skipping +-------------------- + +'import' tries to import only the transactions which are new since the +last import, ignoring any that it has seen in previous runs. So if your +bank's CSV includes the last three months of data, you can download and +'import' it every month (or week, or day) and only the new transactions +will be imported each time. + + It works as follows: for each imported 'FILE', + + * It tries to read the latest date previously seen, from + '.latest.FILE' in the same directory + * Then it processes 'FILE', ignoring transactions on or before that + date + + And after a successful import, unless '--dry-run' was used, it +updates the '.latest.FILE'(s) for next time. This is a simple system +that works for most real-world CSV files; it assumes the following are +true, or true enough: + + 1. the name of the input file is stable across successive downloads + 2. new items always have the newest dates + 3. item dates are stable across downloads + 4. the order of same-date items is stable across downloads. + + Tips: + + * To help ensure a stable file name, remember you can use a CSV rules + file as an input file. + + * If you have a bank whose CSV dates or ordering occasionally change, + you can reduce the chance of this happening in new transactions by + importing more often. (If it happens in old transactions, that's + harmless.) + + Note this is just one kind of "deduplication": not reprocessing the +same dates across successive runs. 'import' doesn't detect other kinds +of duplication, such as the same transaction appearing multiple times +within a single run, or a new transaction that looks identical to a +transaction already in the journal. (Because these can happen +legitimately in real-world data.) + + Here's a situation where you need to run 'import' with care: say you +download but forget to import 'bank.1.csv', and a week later you +download 'bank.2.csv' with some overlapping data. You should not +process both of these as a single import ('hledger import bank.1.csv +bank.2.csv'), because the overlapping transactions would not be +deduplicated. Instead, import one file at a time, using the same +filename each time: + +$ mv bank.1.csv bank.csv; hledger import bank.csv +$ mv bank.2.csv bank.csv; hledger import bank.csv + + Normally you don't need to think about '.latest.*' files, but you can +create or modify them to catch up to a certain date, or delete them to +mark all transactions as new. Their format is a single ISO-format +'YYYY-MM-DD' date, optionally repeated on multiple lines, meaning "I +have seen the transactions before this date, and this many of them on +this date". + + 'hledger print --new' also uses and updates these '.latest.*' files, +but it is less often used. + + Related: CSV > Working with CSV > Deduplicating, importing. + + +File: hledger.info, Node: Import testing, Next: Importing balance assignments, Prev: Date skipping, Up: import + +27.2.2 Import testing +--------------------- + +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 +categorised: + +$ hledger import --dry bank.csv | hledger -f- -I print unknown + + or (live updating): + +$ ls bank.csv* | entr bash -c 'echo ====; hledger import --dry bank.csv | hledger -f- -I print unknown' + + Note: when importing from multiple files at once, it's currently +possible for some .latest files to be updated successfully, while the +actual import fails because of a problem in one of the files, leaving +them out of sync (and causing some transactions to be missed). To +prevent this, do a -dry-run first and fix any problems before the real +import. + + +File: hledger.info, Node: Importing balance assignments, Next: Import and commodity styles, Prev: Import testing, Up: import + +27.2.3 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 +balance assignments (eg from an institution that provides only balances +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, +please test it and send a pull request.) + + +File: hledger.info, Node: Import and commodity styles, Prev: Importing balance assignments, Up: import + +27.2.4 Import and commodity styles +---------------------------------- + +Amounts in entries added by import will be formatted according to the +journal's canonical commodity styles, as declared by 'commodity' +directives or inferred from the journal's amounts. + + Related: CSV > Amount decimal places. + + +File: hledger.info, Node: Basic report commands, Next: Standard report commands, Prev: Data entry commands, Up: Top + +28 Basic report commands +************************ + +* Menu: + +* accounts:: +* codes:: +* commodities:: +* descriptions:: +* files:: +* notes:: +* payees:: +* prices:: +* stats:: +* tags:: + + +File: hledger.info, Node: accounts, Next: codes, Up: Basic report commands + +28.1 accounts ============= Show account names. @@ -7579,102 +7806,449 @@ $ hledger accounts --undeclared --directives >> $LEDGER_FILE $ hledger check accounts  -File: hledger.info, Node: activity, Next: add, Prev: accounts, Up: PART 4 COMMANDS +File: hledger.info, Node: codes, Next: commodities, Prev: accounts, Up: Basic report commands -24.3 activity -============= +28.2 codes +========== -Show an ascii barchart of posting counts per interval. +List the codes seen in transactions, in the order parsed. - The activity command displays an ascii histogram showing transaction -counts by day, week, month or other reporting interval (by day is the -default). With query arguments, it counts only matched transactions. + 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 printed as blank lines. + + You can add a query to select a subset of transactions. Examples: -$ hledger activity --quarterly -2008-01-01 ** -2008-04-01 ******* -2008-07-01 -2008-10-01 ** +2022/1/1 (123) Supermarket + Food $5.00 + Checking + +2022/1/2 (124) Post Office + Postage $8.32 + Checking + +2022/1/3 Supermarket + Food $11.23 + Checking + +2022/1/4 (126) Post Office + Postage $3.21 + Checking + +$ hledger codes +123 +124 +126 + +$ hledger codes -E +123 +124 + +126  -File: hledger.info, Node: add, Next: aregister, Prev: activity, Up: PART 4 COMMANDS +File: hledger.info, Node: commodities, Next: descriptions, Prev: codes, Up: Basic report commands -24.4 add -======== +28.3 commodities +================ -Prompt for transactions and add them to the journal. Any arguments will -be used as default inputs for the first N prompts. - - Many hledger users edit their journals directly with a text editor, -or generate them from CSV. For more interactive data entry, there is the -'add' command, which prompts interactively on the console for new -transactions, and appends them to the main journal file (which should be -in journal format). Existing transactions are not changed. This is one -of the few hledger commands that writes to the journal file (see also -'import'). - - To use it, just run 'hledger add' and follow the prompts. You can -add as many transactions as you like; when you are finished, enter '.' -or press control-d or control-c to exit. - - Features: - - * add tries to provide useful defaults, using the most similar (by - description) recent transaction (filtered by the query, if any) as - a template. - * You can also set the initial defaults with command line arguments. - * Readline-style edit keys can be used during data entry. - * The tab key will auto-complete whenever possible - accounts, - payees/descriptions, dates ('yesterday', 'today', 'tomorrow'). If - the input area is empty, it will insert the default value. - * If the journal defines a default commodity, it will be added to any - bare numbers entered. - * A parenthesised transaction code may be entered following a date. - * Comments and tags may be entered following a description or amount. - * If you make a mistake, enter '<' at any prompt to go one step - backward. - * Input prompts are displayed in a different colour when the terminal - supports it. - - Example (see https://hledger.org/add.html for a detailed tutorial): - -$ hledger add -Adding transactions to journal file /src/hledger/examples/sample.journal -Any command line arguments will be used as defaults. -Use tab key to complete, readline keys to edit, enter to accept defaults. -An optional (CODE) may follow transaction dates. -An optional ; COMMENT may follow descriptions or amounts. -If you make a mistake, enter < at any prompt to go one step backward. -To end a transaction, enter . when prompted. -To quit, enter . at a date prompt or press control-d or control-c. -Date [2015/05/22]: -Description: supermarket -Account 1: expenses:food -Amount 1: $10 -Account 2: assets:checking -Amount 2 [$-10.0]: -Account 3 (or . or enter to finish this transaction): . -2015/05/22 supermarket - expenses:food $10 - assets:checking $-10.0 - -Save this transaction to the journal ? [y]: -Saved. -Starting the next transaction (. or ctrl-D/ctrl-C to quit) -Date [2015/05/22]: $ - - If you enter a number with no commodity symbol, and you have declared -a default commodity with a 'D' directive, you might expect 'add' to add -this symbol for you. It does not do this; we assume that if you are -using a 'D' directive you prefer not to see the commodity symbol -repeated on amounts in the journal. +List all commodity/currency symbols used or declared in the journal.  -File: hledger.info, Node: aregister, Next: balance, Prev: add, Up: PART 4 COMMANDS +File: hledger.info, Node: descriptions, Next: files, Prev: commodities, Up: Basic report commands -24.5 aregister +28.4 descriptions +================= + +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 transactions. + + Example: + +$ hledger descriptions +Store Name +Gas Station | Petrol +Person A + + +File: hledger.info, Node: files, Next: notes, Prev: descriptions, Up: Basic report commands + +28.5 files +========== + +List all files included in the journal. With a REGEX argument, only +file names matching the regular expression (case sensitive) are shown. + + +File: hledger.info, Node: notes, Next: payees, Prev: files, Up: Basic report commands + +28.6 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 +transactions. The note is the part of the transaction description after +a | character (or if there is no |, the whole description). + + Example: + +$ hledger notes +Petrol +Snacks + + +File: hledger.info, Node: payees, Next: prices, Prev: notes, Up: Basic report commands + +28.7 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 +(-used), or both (the default). + + 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 +implies -used. + + Example: + +$ hledger payees +Store Name +Gas Station +Person A + + +File: hledger.info, Node: prices, Next: stats, Prev: payees, Up: Basic report commands + +28.8 prices +=========== + +Print the market prices declared with P directives. With +-infer-market-prices, also show any additional prices inferred from +costs. With -show-reverse, also show additional prices inferred by +reversing known prices. + + Price amounts are always displayed with their full precision, except +for reverse prices which are limited to 8 decimal digits. + + Prices can be filtered by a date:, cur: or amt: query. + + Generally if you run this command with -infer-market-prices +-show-reverse, it will show the same prices used internally to calculate +value reports. But if in doubt, you can inspect those directly by +running the value report with -debug=2. + + +File: hledger.info, Node: stats, Next: tags, Prev: prices, Up: Basic report commands + +28.9 stats +========== + +Show journal and performance statistics. + + The stats command shows summary information for the whole journal, or +a matched part of it. With a reporting interval, it shows a report for +each report period. + + The default output is fairly impersonal, though it reveals the main +file name. With '-v/--verbose', more details are shown, like file +paths, included files, and commodity names. + + It also shows some run time statistics: + + * elapsed time + * throughput: the number of transactions processed per second + * live: the peak memory in use by the program to do its work + * alloc: the peak memory allocation from the OS as seen by GHC. + Measuring this externally, eg with GNU time, is more accurate; + usually that will be a larger number; sometimes (with swapping?) + smaller. + + The 'stats' command's run time is similar to that of a balance +report. + + Example: + +$ hledger stats -f examples/1ktxns-1kaccts.journal +Main file : .../1ktxns-1kaccts.journal +Included files : 0 +Txns span : 2000-01-01 to 2002-09-27 (1000 days) +Last txn : 2002-09-26 (7827 days ago) +Txns : 1000 (1.0 per day) +Txns last 30 days : 0 (0.0 per day) +Txns last 7 days : 0 (0.0 per day) +Payees/descriptions : 1000 +Accounts : 1000 (depth 10) +Commodities : 26 +Market prices : 1000 +Runtime stats : 0.12 s elapsed, 8266 txns/s, 4 MB live, 16 MB alloc + + This command supports the -o/-output-file option (but not +-O/-output-format). + + +File: hledger.info, Node: tags, Prev: stats, Up: Basic report commands + +28.10 tags +========== + +List the tags used in the journal, or their values. + + This command lists the tag names used in the journal, whether on +transactions, postings, or account declarations. + + With a TAGREGEX argument, only tag names matching this regular +expression (case insensitive, infix matched) are shown. + + With QUERY arguments, only transactions and accounts matching this +query are considered. If the query involves transaction fields (date:, +desc:, amt:, ...), the search is restricted to the matched transactions +and their accounts. + + With the -values flag, the tags' unique non-empty values are listed +instead. With -E/-empty, blank/empty values are also shown. + + With -parsed, tags or values are shown in the order they were parsed, +with duplicates included. (Except, tags from account declarations are +always shown first.) + + Tip: remember, accounts also acquire tags from their parents, +postings also acquire tags from their account and transaction, +transactions also acquire tags from their postings. + + +File: hledger.info, Node: Standard report commands, Next: Advanced report commands, Prev: Basic report commands, Up: Top + +29 Standard report commands +*************************** + +* Menu: + +* print:: +* aregister:: +* register:: +* balancesheet:: +* balancesheetequity:: +* cashflow:: +* incomestatement:: + + +File: hledger.info, Node: print, Next: aregister, Up: Standard report commands + +29.1 print +========== + +Show transaction journal entries, sorted by date. + + The print command displays full journal entries (transactions) from +the journal file, sorted by date (or with '--date2', by secondary date). + + 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/regenerate your journal you should take care to also copy +over the directives and inter-transaction comments. + + Eg: + +$ hledger print -f examples/sample.journal date:200806 +2008/06/01 gift + assets:bank:checking $1 + income:gifts $-1 + +2008/06/02 save + assets:bank:saving $1 + assets:bank:checking $-1 + +2008/06/03 * eat & shop + expenses:food $1 + expenses:supplies $1 + assets:cash $-2 + +* Menu: + +* print explicitness:: +* print amount style:: +* print parseability:: +* print other features:: +* print output format:: + + +File: hledger.info, Node: print explicitness, Next: print amount style, Up: print + +29.1.1 print explicitness +------------------------- + +Normally, whether posting amounts are implicit or explicit is preserved. +For example, when an amount is omitted in the journal, it will not +appear in the output. Similarly, if a conversion cost is implied but +not written, it will not appear in the output. + + You can use the '-x'/'--explicit' flag to force explicit display of +all amounts and costs. This 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'. + + The '-x'/'--explicit' flag will cause any postings with a +multi-commodity amount (which can arise when a multi-commodity +transaction has an implicit amount) to be split into multiple +single-commodity postings, keeping the output parseable. + + +File: hledger.info, Node: print amount style, Next: print parseability, Prev: print explicitness, Up: print + +29.1.2 print amount style +------------------------- + +Amounts are shown right-aligned within each transaction (but not aligned +across all transactions; you can do that with ledger-mode in Emacs). + + Amounts will be (mostly) normalised to their commodity display style: +their symbol placement, decimal mark, and digit group marks will be made +consistent. By default, decimal digits are shown as they are written in +the journal. + + With the '--round' (_Added in 1.32_) option, 'print' will try +increasingly hard to display decimal digits according to the commodity +display styles: + + * '--round=none' show amounts with original precisions (default) + * '--round=soft' add/remove decimal zeros in amounts (except costs) + * '--round=hard' round amounts (except costs), possibly hiding + significant digits + * '--round=all' round all amounts and costs + + 'soft' is good for non-lossy cleanup, formatting amounts more +consistently where it's safe to do so. + + 'hard' and 'all' can cause 'print' to show invalid unbalanced journal +entries; they may be useful eg for stronger cleanup, with manual fixups +when needed. + + +File: hledger.info, Node: print parseability, Next: print other features, Prev: print amount style, Up: print + +29.1.3 print parseability +------------------------- + +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 (though the same can be achieved with 'expr:' queries +now): + +# Show running total of food expenses paid from cash. +# -f- reads from stdin. -I/--ignore-assertions is sometimes needed. +$ hledger print assets:cash | hledger -f- -I reg expenses:food + + There are some situations where print's output can become +unparseable: + + * Value reporting affects posting amounts but not balance assertion + or balance assignment amounts, potentially causing those to fail. + * Auto postings can generate postings with too many missing amounts. + * Account aliases can generate bad account names. + + +File: hledger.info, Node: print other features, Next: print output format, Prev: print parseability, Up: print + +29.1.4 print, other features +---------------------------- + +With '-B'/'--cost', amounts with costs are shown converted to cost. + + With '--new', print shows only transactions it has not seen on a +previous run. This uses the same deduplication system as the 'import' +command. (See import's docs for details.) + + With '-m DESC'/'--match=DESC', print shows one recent transaction +whose description is most similar to DESC. DESC should contain at least +two characters. If there is no similar-enough match, no transaction +will be shown and the program exit code will be non-zero. + + +File: hledger.info, Node: print output format, Prev: print other features, Up: print + +29.1.5 print output format +-------------------------- + +This command also supports the output destination and output format +options The output formats supported are 'txt', 'beancount' (_Added in +1.32_), 'csv', 'tsv' (_Added in 1.32_), 'json' and 'sql'. + + The 'beancount' format tries to produce Beancount-compatible output, +as follows: + + * Transaction and postings with unmarked status are converted to + cleared ('*') status. + * Transactions' payee and note are backslash-escaped and + double-quote-escaped and wrapped in double quotes. + * Transaction tags are copied to Beancount #tag format. + * Commodity symbols are converted to upper case, and a small number + of currency symbols like '$' are converted to the corresponding + currency names. + * Account name parts are capitalised and unsupported characters are + replaced with '-'. If an account name part does not begin with a + letter, or if the first part is not Assets, Liabilities, Equity, + Income, or Expenses, an error is raised. (Use '--alias' options to + bring your accounts into compliance.) + * An 'open' directive is generated for each account used, on the + earliest transaction date. + + Some limitations: + + * Balance assertions are removed. + * Balance assignments become missing amounts. + * Virtual and balanced virtual postings become regular postings. + * Directives are not converted. + + Here's an example of print's CSV output: + +$ hledger print -Ocsv +"txnidx","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","posting-status","posting-comment" +"1","2008/01/01","","","","income","","assets:bank:checking","1","$","","1","","" +"1","2008/01/01","","","","income","","income:salary","-1","$","1","","","" +"2","2008/06/01","","","","gift","","assets:bank:checking","1","$","","1","","" +"2","2008/06/01","","","","gift","","income:gifts","-1","$","1","","","" +"3","2008/06/02","","","","save","","assets:bank:saving","1","$","","1","","" +"3","2008/06/02","","","","save","","assets:bank:checking","-1","$","1","","","" +"4","2008/06/03","","*","","eat & shop","","expenses:food","1","$","","1","","" +"4","2008/06/03","","*","","eat & shop","","expenses:supplies","1","$","","1","","" +"4","2008/06/03","","*","","eat & shop","","assets:cash","-2","$","2","","","" +"5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","","" +"5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","","" + + * There is one CSV record per posting, with the parent transaction's + fields repeated. + * 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 order, etc.) + * The amount is separated into "commodity" (the symbol) and "amount" + (numeric quantity) fields. + * The numeric amount is repeated in either the "credit" or "debit" + column, for convenience. (Those names are not accurate in the + accounting sense; it just puts negative amounts under credit and + zero or greater amounts under debit.) + + +File: hledger.info, Node: aregister, Next: register, Prev: print, Up: Standard report commands + +29.2 aregister ============== (areg) @@ -7750,7 +8324,7 @@ in 1.32_), and 'json'.  File: hledger.info, Node: aregister and posting dates, Up: aregister -24.5.1 aregister and posting dates +29.2.1 aregister and posting dates ---------------------------------- aregister always shows one line (and date and amount) per transaction. @@ -7768,2243 +8342,11 @@ transaction date, ignoring posting dates. This too can cause an inaccurate running balance.  -File: hledger.info, Node: balance, Next: balancesheet, Prev: aregister, Up: PART 4 COMMANDS +File: hledger.info, Node: register, Next: balancesheet, Prev: aregister, Up: Standard report commands -24.6 balance -============ - -(bal) - - Show accounts and their balances. - - 'balance' is one of hledger's oldest and most versatile commands, for -listing account balances, balance changes, values, value changes and -more, during one time period or many. Generally it shows a table, with -rows representing accounts, and columns representing periods. - - Note there are some higher-level variants of the 'balance' command -with convenient defaults, which can be simpler to use: 'balancesheet', -'balancesheetequity', 'cashflow' and 'incomestatement'. When you need -more control, then use 'balance'. - -* Menu: - -* balance features:: -* Simple balance report:: -* Balance report line format:: -* Filtered balance report:: -* List or tree mode:: -* Depth limiting:: -* Dropping top-level accounts:: -* Showing declared accounts:: -* Sorting by amount:: -* Percentages:: -* Multi-period balance report:: -* Balance change end balance:: -* Balance report types:: -* Budget report:: -* Balance report layout:: -* Some useful balance reports:: - - -File: hledger.info, Node: balance features, Next: Simple balance report, Up: balance - -24.6.1 balance features ------------------------ - -Here's a quick overview of the 'balance' command's features, followed by -more detailed descriptions and examples. Many of these work with the -higher-level commands as well. - - 'balance' can show.. - - * accounts as a list ('-l') or a tree ('-t') - * optionally depth-limited ('-[1-9]') - * sorted by declaration order and name, or by amount - - ..and their.. - - * balance changes (the default) - * or actual and planned balance changes ('--budget') - * or value of balance changes ('-V') - * or change of balance values ('--valuechange') - * or unrealised capital gain/loss ('--gain') - * or balance changes from sibling postings ('--related'/'-r') - * or postings count ('--count') - - ..in.. - - * one time period (the whole journal period by default) - * or multiple periods ('-D', '-W', '-M', '-Q', '-Y', '-p INTERVAL') - - ..either.. - - * per period (the default) - * or accumulated since report start date ('--cumulative') - * or accumulated since account creation ('--historical/-H') - - ..possibly converted to.. - - * cost ('--value=cost[,COMM]'/'--cost'/'-B') - * or market value, as of transaction dates ('--value=then[,COMM]') - * or at period ends ('--value=end[,COMM]') - * or now ('--value=now') - * or at some other date ('--value=YYYY-MM-DD') - - ..with.. - - * totals ('-T'), averages ('-A'), percentages ('-%'), inverted sign - ('--invert') - * rows and columns swapped ('--transpose') - * another field used as account name ('--pivot') - * custom-formatted line items (single-period reports only) - ('--format') - * commodities displayed on the same line or multiple lines - ('--layout') - - This command supports the output destination and output format -options, with output formats 'txt', 'csv', 'tsv' (_Added in 1.32_), -'json', and (multi-period reports only:) 'html'. In 'txt' output in a -colour-supporting terminal, negative amounts are shown in red. - - -File: hledger.info, Node: Simple balance report, Next: Balance report line format, Prev: balance features, Up: balance - -24.6.2 Simple balance report ----------------------------- - -With no arguments, 'balance' shows a list of all accounts and their -change of balance - ie, the sum of posting amounts, both inflows and -outflows - during the entire period of the journal. ("Simple" here -means just one column of numbers, covering a single period. You can -also have multi-period reports, described later.) - - For real-world accounts, these numbers will normally be their end -balance at the end of the journal period; more on this below. - - Accounts are sorted by declaration order if any, and then -alphabetically by account name. For instance (using -examples/sample.journal): - -$ hledger -f examples/sample.journal bal - $1 assets:bank:saving - $-2 assets:cash - $1 expenses:food - $1 expenses:supplies - $-1 income:gifts - $-1 income:salary - $1 liabilities:debts --------------------- - 0 - - Accounts with a zero balance (and no non-zero subaccounts, in tree -mode - see below) are hidden by default. Use '-E/--empty' to show them -(revealing 'assets:bank:checking' here): - -$ hledger -f examples/sample.journal bal -E - 0 assets:bank:checking - $1 assets:bank:saving - $-2 assets:cash - $1 expenses:food - $1 expenses:supplies - $-1 income:gifts - $-1 income:salary - $1 liabilities:debts --------------------- - 0 - - The total of the amounts displayed is shown as the last line, unless -'-N'/'--no-total' is used. - - -File: hledger.info, Node: Balance report line format, Next: Filtered balance report, Prev: Simple balance report, Up: balance - -24.6.3 Balance report line format ---------------------------------- - -For single-period balance reports displayed in the terminal (only), you -can use '--format FMT' to customise the format and content of each line. -Eg: - -$ hledger -f examples/sample.journal balance --format "%20(account) %12(total)" - assets $-1 - bank:saving $1 - cash $-2 - expenses $2 - food $1 - supplies $1 - income $-2 - gifts $-1 - salary $-1 - liabilities:debts $1 ---------------------------------- - 0 - - The FMT format string specifies the formatting applied to each -account/balance pair. It may contain any suitable text, with data -fields interpolated like so: - - '%[MIN][.MAX](FIELDNAME)' - - * MIN pads with spaces to at least this width (optional) - - * MAX truncates at this width (optional) - - * FIELDNAME must be enclosed in parentheses, and can be one of: - - * 'depth_spacer' - a number of spaces equal to the account's - depth, or if MIN is specified, MIN * depth spaces. - * 'account' - the account's name - * 'total' - the account's balance/posted total, right justified - - Also, FMT can begin with an optional prefix to control how -multi-commodity amounts are rendered: - - * '%_' - render on multiple lines, bottom-aligned (the default) - * '%^' - render on multiple lines, top-aligned - * '%,' - render on one line, comma-separated - - 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: - - * '%(total)' - the account's total - * '%-20.20(account)' - the account's name, left justified, padded to - 20 characters and clipped at 20 characters - * '%,%-50(account) %25(total)' - account name padded to 50 - characters, total padded to 20 characters, with multiple - commodities rendered on one line - * '%20(total) %2(depth_spacer)%-(account)' - the default format for - the single-column balance report - - -File: hledger.info, Node: Filtered balance report, Next: List or tree mode, Prev: Balance report line format, Up: balance - -24.6.4 Filtered balance report ------------------------------- - -You can show fewer accounts, a different time period, totals from -cleared transactions only, etc. by using query arguments or options to -limit the postings being matched. Eg: - -$ hledger -f examples/sample.journal bal --cleared assets date:200806 - $-2 assets:cash --------------------- - $-2 - - -File: hledger.info, Node: List or tree mode, Next: Depth limiting, Prev: Filtered balance report, Up: balance - -24.6.5 List or tree mode ------------------------- - -By default, or with '-l/--flat', accounts are shown as a flat list with -their full names visible, as in the examples above. - - With '-t/--tree', the account hierarchy is shown, with subaccounts' -"leaf" names indented below their parent: - -$ hledger -f examples/sample.journal balance - $-1 assets - $1 bank:saving - $-2 cash - $2 expenses - $1 food - $1 supplies - $-2 income - $-1 gifts - $-1 salary - $1 liabilities:debts --------------------- - 0 - - Notes: - - * "Boring" accounts are combined with their subaccount for more - compact output, unless '--no-elide' is used. Boring accounts have - no balance of their own and just one subaccount (eg 'assets:bank' - and 'liabilities' above). - - * All balances shown are "inclusive", ie including the balances from - all subaccounts. Note this means some repetition in the output, - which requires explanation when sharing reports with - non-plaintextaccounting-users. A tree mode report's final total is - the sum of the top-level balances shown, not of all the balances - shown. - - * Each group of sibling accounts (ie, under a common parent) is - sorted separately. - - -File: hledger.info, Node: Depth limiting, Next: Dropping top-level accounts, Prev: List or tree mode, Up: balance - -24.6.6 Depth limiting ---------------------- - -With a 'depth:NUM' query, or '--depth NUM' option, or just '-NUM' (eg: -'-3') balance reports will show accounts only to the specified depth, -hiding the deeper subaccounts. This can be useful for getting an -overview without too much detail. - - Account balances at the depth limit always include the balances from -any deeper subaccounts (even in list mode). Eg, limiting to depth 1: - -$ hledger -f examples/sample.journal balance -1 - $-1 assets - $2 expenses - $-2 income - $1 liabilities --------------------- - 0 - - -File: hledger.info, Node: Dropping top-level accounts, Next: Showing declared accounts, Prev: Depth limiting, Up: balance - -24.6.7 Dropping top-level accounts ----------------------------------- - -You can also hide one or more top-level account name parts, using -'--drop NUM'. This can be useful for hiding repetitive top-level -account names: - -$ hledger -f examples/sample.journal bal expenses --drop 1 - $1 food - $1 supplies --------------------- - $2 - - -File: hledger.info, Node: Showing declared accounts, Next: Sorting by amount, Prev: Dropping top-level accounts, Up: balance - -24.6.8 Showing declared accounts --------------------------------- - -With '--declared', accounts which have been declared with an account -directive will be included in the balance report, even if they have no -transactions. (Since they will have a zero balance, you will also need -'-E/--empty' to see them.) - - More precisely, _leaf_ declared accounts (with no subaccounts) will -be included, since those are usually the more useful in reports. - - The idea of this is to be able to see a useful "complete" balance -report, even when you don't have transactions in all of your declared -accounts yet. - - -File: hledger.info, Node: Sorting by amount, Next: Percentages, Prev: Showing declared accounts, Up: balance - -24.6.9 Sorting by amount ------------------------- - -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. 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'). - - -File: hledger.info, Node: Percentages, Next: Multi-period balance report, Prev: Sorting by amount, Up: balance - -24.6.10 Percentages -------------------- - -With '-%/--percent', balance reports show each account's value expressed -as a percentage of the (column) total. - - Note it is not useful to calculate percentages if the amounts in a -column 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 report for each commodity: - -$ hledger bal -% cur:\\$ -$ hledger bal -% cur:€ - - -File: hledger.info, Node: Multi-period balance report, Next: Balance change end balance, Prev: Percentages, Up: balance - -24.6.11 Multi-period balance report ------------------------------------ - -With a report interval (set by the '-D/--daily', '-W/--weekly', -'-M/--monthly', '-Q/--quarterly', '-Y/--yearly', or '-p/--period' flag), -'balance' shows a tabular report, with columns representing successive -time periods (and a title): - -$ hledger -f examples/sample.journal bal --quarterly income expenses -E -Balance changes in 2008: - - || 2008q1 2008q2 2008q3 2008q4 -===================++================================= - expenses:food || 0 $1 0 0 - expenses:supplies || 0 $1 0 0 - income:gifts || 0 $-1 0 0 - income:salary || $-1 0 0 0 --------------------++--------------------------------- - || $-1 $1 0 0 - - Notes: - - * The report's start/end dates will be expanded, if necessary, to - fully encompass the displayed subperiods (so that the first and - last subperiods have the same duration as the others). - * Leading and trailing periods (columns) containing all zeroes are - not shown, unless '-E/--empty' is used. - * Accounts (rows) containing all zeroes are not shown, unless - '-E/--empty' is used. - * Amounts with many commodities are shown in abbreviated form, unless - '--no-elide' is used. - * Average and/or total columns can be added with the '-A/--average' - and '-T/--row-total' flags. - * The '--transpose' flag can be used to exchange rows and columns. - * The '--pivot FIELD' option causes a different transaction field to - be used as "account name". See PIVOTING. - - Multi-period reports with many periods can be too wide for easy -viewing in the terminal. Here are some ways to handle that: - - * Hide the totals row with '-N/--no-total' - * Filter to a single currency with 'cur:' - * Convert to a single currency with '-V [--infer-market-price]' - * Use a more compact layout like '--layout=bare' - * Maximize the terminal window - * Reduce the terminal's font size - * View with a pager like less, eg: 'hledger bal -D --color=yes | less - -RS' - * Output as CSV and use a CSV viewer like visidata ('hledger bal -D - -O csv | vd -f csv'), Emacs' csv-mode ('M-x csv-mode, C-c C-a'), or - a spreadsheet ('hledger bal -D -o a.csv && open a.csv') - * Output as HTML and view with a browser: 'hledger bal -D -o a.html - && open a.html' - - -File: hledger.info, Node: Balance change end balance, Next: Balance report types, Prev: Multi-period balance report, Up: balance - -24.6.12 Balance change, end balance ------------------------------------ - -It's important to be clear on the meaning of the numbers shown in -balance reports. Here is some terminology we use: - - 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 your timezone). It is the sum of previous 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 bank statements or bank web UI. (If they are correct!) - - 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 end balances: - - 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' flag. ('-H' causes report start date to be - ignored when summing postings.) - - -File: hledger.info, Node: Balance report types, Next: Budget report, Prev: Balance change end balance, Up: balance - -24.6.13 Balance report types ----------------------------- - -The balance command is quite flexible; here is the full detail on how to -control what it reports. If the following seems complicated, don't -worry - this is for advanced reporting, and it does take time and -experimentation to get familiar with all the report modes. - - There are three important option groups: - - 'hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] -...' - -* Menu: - -* Calculation type:: -* Accumulation type:: -* Valuation type:: -* Combining balance report types:: - - -File: hledger.info, Node: Calculation type, Next: Accumulation type, Up: Balance report types - -24.6.13.1 Calculation type -.......................... - -The basic calculation to perform for each table cell. It is one of: - - * '--sum' : sum the posting amounts (*default*) - * '--budget' : sum the amounts, but also show the budget goal amount - (for each account/period) - * '--valuechange' : show the change in period-end historical balance - values (caused by deposits, withdrawals, and/or market price - fluctuations) - * '--gain' : show the unrealised capital gain/loss, (the current - valued balance minus each amount's original cost) - * '--count' : show the count of postings - - -File: hledger.info, Node: Accumulation type, Next: Valuation type, Prev: Calculation type, Up: Balance report types - -24.6.13.2 Accumulation type -........................... - -How amounts should accumulate across a report's subperiods/columns. -Another way to say it: which time period's postings should contribute to -each cell's calculation. It is one of: - - * '--change' : calculate with postings from column start to column - end, ie "just this column". Typically used to see - revenues/expenses. (*default for balance, cashflow, - incomestatement*) - - * '--cumulative' : calculate with postings from report start to - column end, ie "previous columns plus this column". Typically used - to show changes accumulated since the report's start date. Not - often used. - - * '--historical/-H' : calculate with postings from journal start to - column end, ie "all postings from before report start date until - this column's end". Typically used to see historical end balances - of assets/liabilities/equity. (*default for balancesheet, - balancesheetequity*) - - -File: hledger.info, Node: Valuation type, Next: Combining balance report types, Prev: Accumulation type, Up: Balance report types - -24.6.13.3 Valuation type -........................ - -Which kind of value or cost conversion should be applied, if any, before -displaying the report. It is one of: - - * no valuation type : don't convert to cost or value (*default*) - * '--value=cost[,COMM]' : convert amounts to cost (then optionally to - some other commodity) - * '--value=then[,COMM]' : convert amounts to market value on - transaction dates - * '--value=end[,COMM]' : convert amounts to market value on period - end date(s) - (*default with '--valuechange', '--gain'*) - * '--value=now[,COMM]' : convert amounts to market value on today's - date - * '--value=YYYY-MM-DD[,COMM]' : convert amounts to market value on - another date - - or one of the equivalent simpler flags: - - * '-B/--cost' : like -value=cost (though, note -cost and -value are - independent options which can both be used at once) - * '-V/--market' : like -value=end - * '-X COMM/--exchange COMM' : like -value=end,COMM - - See Cost reporting and Value reporting for more about these. - - -File: hledger.info, Node: Combining balance report types, Prev: Valuation type, Up: Balance report types - -24.6.13.4 Combining balance report types -........................................ - -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: - - * '--valuechange' implies '--value=end' - * '--valuechange' makes '--change' the default when used with the - 'balancesheet'/'balancesheetequity' commands - * '--cumulative' or '--historical' disables '--row-total/-T' - - For reference, here is what the combinations of accumulation and -valuation show: - -Valuation:>no valuation '--value= then' '--value= end' '--value= -Accumulation:v YYYY-MM-DD - /now' ------------------------------------------------------------------------------ -'--change'change in sum of period-end DATE-value - period posting-date value of of change in - market values change in period - in period period -'--cumulative'change from sum of period-end DATE-value - report start to posting-date value of of change - period end market values change from from report - from report report start start to - start to period to period end period end - end -'--historicalchange from sum of period-end DATE-value -/-H' journal start posting-date value of of change - to period end market values change from from journal - (historical end from journal journal start start to - balance) start to period to period end period end - end - - -File: hledger.info, Node: Budget report, Next: Balance report layout, Prev: Balance report types, Up: balance - -24.6.14 Budget report ---------------------- - -The '--budget' report type is like a regular balance report, but with -two main differences: - - * Budget goals and performance percentages are also shown, in - brackets - * Accounts which don't have budget goals are hidden by default. - - This is useful for comparing planned and actual income, expenses, -time usage, etc. - - Periodic transaction rules are used to define budget goals. For -example, here's a periodic rule defining monthly goals for bus travel -and food expenses: - -;; Budget -~ monthly - (expenses:bus) $30 - (expenses:food) $400 - - After recording some actual expenses, - -;; Two months worth of expenses -2017-11-01 - income $-1950 - expenses:bus $35 - expenses:food:groceries $310 - expenses:food:dining $42 - expenses:movies $38 - assets:bank:checking - -2017-12-01 - income $-2100 - expenses:bus $53 - expenses:food:groceries $380 - expenses:food:dining $32 - expenses:gifts $100 - assets:bank:checking - - we can see a budget report like this: - -$ hledger bal -M --budget -Budget performance in 2017-11-01..2017-12-31: - - || Nov Dec -===============++============================================ - || $-425 $-565 - expenses || $425 [ 99% of $430] $565 [131% of $430] - expenses:bus || $35 [117% of $30] $53 [177% of $30] - expenses:food || $352 [ 88% of $400] $412 [103% of $400] ----------------++-------------------------------------------- - || 0 [ 0% of $430] 0 [ 0% of $430] - - This is "goal-based budgeting"; you define goals for accounts and -periods, often recurring, and hledger shows performance relative to the -goals. This contrasts with "envelope budgeting", which is more detailed -and strict - useful when cash is tight, but also quite a bit more work. -https://plaintextaccounting.org/Budgeting has more on this topic. - -* Menu: - -* Using the budget report:: -* Budget date surprises:: -* Selecting budget goals:: -* Budgeting vs forecasting:: - - -File: hledger.info, Node: Using the budget report, Next: Budget date surprises, Up: Budget report - -24.6.14.1 Using the budget report -................................. - -Historically this report has been confusing and fragile. hledger's -version should be relatively robust and intuitive, but you may still -find surprises. Here are more notes to help with learning and -troubleshooting. - - * In the above example, 'expenses:bus' and 'expenses:food' are shown - because they have budget goals during the report period. - - * Their parent 'expenses' is also shown, with budget goals aggregated - from the children. - - * The subaccounts 'expenses:food:groceries' and - 'expenses:food:dining' are not shown since they have no budget goal - of their own, but they contribute to 'expenses:food''s actual - amount. - - * Unbudgeted accounts 'expenses:movies' and 'expenses:gifts' are also - not shown, but they contribute to 'expenses''s actual amount. - - * The other unbudgeted accounts 'income' and 'assets:bank:checking' - are grouped as ''. - - * '--depth' or 'depth:' can be used to limit report depth in the - usual way (but will not reveal unbudgeted subaccounts). - - * Amounts are always inclusive of subaccounts (even in '-l/--list' - mode). - - * Numbers displayed in a -budget report will not always agree with - the totals, because of hidden unbudgeted accounts; this is normal. - '-E/--empty' can be used to reveal the hidden accounts. - - * In the periodic rules used for setting budget goals, unbalanced - postings are convenient. - - * You can filter budget reports with the usual queries, eg to focus - on particular accounts. It's common to restrict them to just - expenses. (The '' account is occasionally hard to - exclude; this is because of date surprises, discussed below.) - - * When you have multiple currencies, you may want to convert them to - one ('-X COMM --infer-market-prices') and/or show just one at a - time ('cur:COMM'). If you do need to show multiple currencies at - once, '--layout bare' can be helpful. - - * You can "roll over" amounts (actual and budgeted) to the next - period with '--cumulative'. - - See also: https://hledger.org/budgeting.html. - - -File: hledger.info, Node: Budget date surprises, Next: Selecting budget goals, Prev: Using the budget report, Up: Budget report - -24.6.14.2 Budget date surprises -............................... - -With small data, or when starting out, some of the generated budget goal -transaction dates might fall outside the report periods. Eg with the -following journal and report, the first period appears to have no -'expenses:food' budget. (Also the '' account should be -excluded by the 'expenses' query, but isn't.): - -~ monthly in 2020 - (expenses:food) $500 - -2020-01-15 - expenses:food $400 - assets:checking - -$ hledger bal --budget expenses -Budget performance in 2020-01-15: - - || 2020-01-15 -===============++==================== - || $400 - expenses:food || 0 [ 0% of $500] ----------------++-------------------- - || $400 [80% of $500] - - In this case, the budget goal transactions are generated on first -days of of month (this can be seen with 'hledger print --forecast -tag:generated expenses'). Whereas the report period defaults to just -the 15th day of january (this can be seen from the report table's column -headings). - - To fix this kind of thing, be more explicit about the report period -(and/or the periodic rules' dates). In this case, adding '-b 2020' does -the trick. - - -File: hledger.info, Node: Selecting budget goals, Next: Budgeting vs forecasting, Prev: Budget date surprises, Up: Budget report - -24.6.14.3 Selecting budget goals -................................ - -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 between period -expression and description), and then select from multiple budgets -defined in your journal. - - -File: hledger.info, Node: Budgeting vs forecasting, Prev: Selecting budget goals, Up: Budget report - -24.6.14.4 Budgeting vs forecasting -.................................. - -'--forecast' and '--budget' both use the periodic transaction rules in -the journal to generate temporary transactions for reporting purposes. -However they are separate features - though you can use both at the same -time if you want. Here are some differences between them: - --forecast -budget --------------------------------------------------------------------------- -is a general option; it enables is a balance command option; -forecasting with all reports it selects the balance - report's budget mode -generates visible transactions which generates invisible -appear in reports transactions which produce - goal amounts -generates forecast transactions from generates budget goal -after the last regular transaction, to transactions throughout the -the end of the report period; or with report period, optionally -an argument '--forecast=PERIODEXPR' restricted by periods -generates them throughout the specified in the periodic -specified period, both optionally transaction rules -restricted by periods specified in the -periodic transaction rules -uses all periodic rules uses all periodic rules; or - with an argument - '--budget=DESCPAT' uses just - the rules matched by DESCPAT - - -File: hledger.info, Node: Balance report layout, Next: Some useful balance reports, Prev: Budget report, Up: balance - -24.6.15 Balance report layout ------------------------------ - -The '--layout' option affects how balance reports show multi-commodity -amounts and commodity symbols, which can improve readability. It can -also normalise the data for easy consumption by other programs. It has -four possible values: - - * '--layout=wide[,WIDTH]': commodities are shown on a single line, - optionally elided to WIDTH - * '--layout=tall': each commodity is shown on a separate line - * '--layout=bare': commodity symbols are in their own column, amounts - are bare numbers - * '--layout=tidy': data is normalised to easily-consumed "tidy" form, - with one row per data value - - Here are the '--layout' modes supported by each output format Only -CSV output supports all of them: - -- txt csv html json sql ---------------------------------------- -wide Y Y Y -tall Y Y Y -bare Y Y Y -tidy Y - - Examples: - -* Menu: - -* Wide layout:: -* Tall layout:: -* Bare layout:: -* Tidy layout:: - - -File: hledger.info, Node: Wide layout, Next: Tall layout, Up: Balance report layout - -24.6.15.1 Wide layout -..................... - -With many commodities, reports can be very wide: - -$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide -Balance changes in 2012-01-01..2014-12-31: - - || 2012 2013 2014 Total -==================++==================================================================================================================================================================================================================== - Assets:US:ETrade || 10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT 70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT -11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT -------------------++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - || 10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT 70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT -11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT - - A width limit reduces the width, but some commodities will be hidden: - -$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide,32 -Balance changes in 2012-01-01..2014-12-31: - - || 2012 2013 2014 Total -==================++=========================================================================================================================== - Assets:US:ETrade || 10.00 ITOT, 337.18 USD, 2 more.. 70.00 GLD, 18.00 ITOT, 3 more.. -11.00 ITOT, 3 more.. 70.00 GLD, 17.00 ITOT, 3 more.. -------------------++--------------------------------------------------------------------------------------------------------------------------- - || 10.00 ITOT, 337.18 USD, 2 more.. 70.00 GLD, 18.00 ITOT, 3 more.. -11.00 ITOT, 3 more.. 70.00 GLD, 17.00 ITOT, 3 more.. - - -File: hledger.info, Node: Tall layout, Next: Bare layout, Prev: Wide layout, Up: Balance report layout - -24.6.15.2 Tall layout -..................... - -Each commodity gets a new line (may be different in each column), and -account names are repeated: - -$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=tall -Balance changes in 2012-01-01..2014-12-31: - - || 2012 2013 2014 Total -==================++================================================== - Assets:US:ETrade || 10.00 ITOT 70.00 GLD -11.00 ITOT 70.00 GLD - Assets:US:ETrade || 337.18 USD 18.00 ITOT 4881.44 USD 17.00 ITOT - Assets:US:ETrade || 12.00 VEA -98.12 USD 14.00 VEA 5120.50 USD - Assets:US:ETrade || 106.00 VHT 10.00 VEA 170.00 VHT 36.00 VEA - Assets:US:ETrade || 18.00 VHT 294.00 VHT -------------------++-------------------------------------------------- - || 10.00 ITOT 70.00 GLD -11.00 ITOT 70.00 GLD - || 337.18 USD 18.00 ITOT 4881.44 USD 17.00 ITOT - || 12.00 VEA -98.12 USD 14.00 VEA 5120.50 USD - || 106.00 VHT 10.00 VEA 170.00 VHT 36.00 VEA - || 18.00 VHT 294.00 VHT - - -File: hledger.info, Node: Bare layout, Next: Tidy layout, Prev: Tall layout, Up: Balance report layout - -24.6.15.3 Bare layout -..................... - -Commodity symbols are kept in one column, each commodity has its own -row, amounts are bare numbers, account names are repeated: - -$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=bare -Balance changes in 2012-01-01..2014-12-31: - - || Commodity 2012 2013 2014 Total -==================++============================================= - Assets:US:ETrade || GLD 0 70.00 0 70.00 - Assets:US:ETrade || ITOT 10.00 18.00 -11.00 17.00 - Assets:US:ETrade || USD 337.18 -98.12 4881.44 5120.50 - Assets:US:ETrade || VEA 12.00 10.00 14.00 36.00 - Assets:US:ETrade || VHT 106.00 18.00 170.00 294.00 -------------------++--------------------------------------------- - || GLD 0 70.00 0 70.00 - || ITOT 10.00 18.00 -11.00 17.00 - || USD 337.18 -98.12 4881.44 5120.50 - || VEA 12.00 10.00 14.00 36.00 - || VHT 106.00 18.00 170.00 294.00 - - Bare layout also affects CSV output, which is useful for producing -data that is easier to consume, eg for making charts: - -$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -O csv --layout=bare -"account","commodity","balance" -"Assets:US:ETrade","GLD","70.00" -"Assets:US:ETrade","ITOT","17.00" -"Assets:US:ETrade","USD","5120.50" -"Assets:US:ETrade","VEA","36.00" -"Assets:US:ETrade","VHT","294.00" -"total","GLD","70.00" -"total","ITOT","17.00" -"total","USD","5120.50" -"total","VEA","36.00" -"total","VHT","294.00" - - Bare layout will sometimes display an extra row for the no-symbol -commodity, because of zero amounts (hledger treats zeroes as -commodity-less, usually). This can break 'hledger-bar' confusingly -(workaround: add a 'cur:' query to exclude the no-symbol row). - - -File: hledger.info, Node: Tidy layout, Prev: Bare layout, Up: Balance report layout - -24.6.15.4 Tidy layout -..................... - -This produces normalised "tidy data" (see -https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html) -where every variable has its own column and each row represents a single -data point. This is the easiest kind of data for other software to -consume: - -$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -Y -O csv --layout=tidy -"account","period","start_date","end_date","commodity","value" -"Assets:US:ETrade","2012","2012-01-01","2012-12-31","GLD","0" -"Assets:US:ETrade","2012","2012-01-01","2012-12-31","ITOT","10.00" -"Assets:US:ETrade","2012","2012-01-01","2012-12-31","USD","337.18" -"Assets:US:ETrade","2012","2012-01-01","2012-12-31","VEA","12.00" -"Assets:US:ETrade","2012","2012-01-01","2012-12-31","VHT","106.00" -"Assets:US:ETrade","2013","2013-01-01","2013-12-31","GLD","70.00" -"Assets:US:ETrade","2013","2013-01-01","2013-12-31","ITOT","18.00" -"Assets:US:ETrade","2013","2013-01-01","2013-12-31","USD","-98.12" -"Assets:US:ETrade","2013","2013-01-01","2013-12-31","VEA","10.00" -"Assets:US:ETrade","2013","2013-01-01","2013-12-31","VHT","18.00" -"Assets:US:ETrade","2014","2014-01-01","2014-12-31","GLD","0" -"Assets:US:ETrade","2014","2014-01-01","2014-12-31","ITOT","-11.00" -"Assets:US:ETrade","2014","2014-01-01","2014-12-31","USD","4881.44" -"Assets:US:ETrade","2014","2014-01-01","2014-12-31","VEA","14.00" -"Assets:US:ETrade","2014","2014-01-01","2014-12-31","VHT","170.00" - - -File: hledger.info, Node: Some useful balance reports, Prev: Balance report layout, Up: balance - -24.6.16 Some useful balance reports ------------------------------------ - -Some frequently used 'balance' options/reports are: - - * 'bal -M revenues expenses' - Show revenues/expenses in each month. Also available as the - 'incomestatement' command. - - * 'bal -M -H assets liabilities' - Show historical asset/liability balances at each month end. Also - available as the 'balancesheet' command. - - * 'bal -M -H assets liabilities equity' - Show historical asset/liability/equity balances at each month end. - Also available as the 'balancesheetequity' command. - - * 'bal -M assets not:receivable' - Show changes to liquid assets in each month. Also available as the - 'cashflow' command. - - Also: - - * 'bal -M expenses -2 -SA' - Show monthly expenses summarised to depth 2 and sorted by average - amount. - - * 'bal -M --budget expenses' - Show monthly expenses and budget goals. - - * 'bal -M --valuechange investments' - Show monthly change in market value of investment assets. - - * 'bal investments --valuechange -D date:lastweek amt:'>1000' -STA - [--invert]' - Show top gainers [or losers] last week - - -File: hledger.info, Node: balancesheet, Next: balancesheetequity, Prev: balance, Up: PART 4 COMMANDS - -24.7 balancesheet -================= - -(bs) - - This command displays a balance sheet, showing historical ending -balances of asset and liability accounts. (To see equity as well, use -the balancesheetequity command.) Amounts are shown with normal positive -sign, as in conventional financial statements. - - This report shows accounts declared with the 'Asset', 'Cash' or -'Liability' type (see account types). Or if no such accounts are -declared, it shows top-level accounts named 'asset' or 'liability' (case -insensitive, plurals allowed) and their subaccounts. - - Example: - -$ hledger balancesheet -Balance Sheet 2008-12-31 - - || 2008-12-31 -====================++============ - Assets || ---------------------++------------ - assets:bank:saving || $1 - assets:cash || $-2 ---------------------++------------ - || $-1 -====================++============ - Liabilities || ---------------------++------------ - liabilities:debts || $-1 ---------------------++------------ - || $-1 -====================++============ - Net: || 0 - - This command is a higher-level variant of the 'balance' command, and -supports 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', 'tsv' (_Added in -1.32_), 'html', and 'json'. - - -File: hledger.info, Node: balancesheetequity, Next: cashflow, Prev: balancesheet, Up: PART 4 COMMANDS - -24.8 balancesheetequity -======================= - -(bse) - - This command displays a balance sheet, showing historical ending -balances of asset, liability and equity accounts. Amounts are shown -with normal positive sign, as in conventional financial statements. - - This report shows accounts declared with the 'Asset', 'Cash', -'Liability' or 'Equity' type (see account types). Or if no such -accounts are declared, it shows top-level accounts named 'asset', -'liability' or 'equity' (case insensitive, plurals allowed) and their -subaccounts. - - Example: - -$ hledger balancesheetequity -Balance Sheet With Equity 2008-12-31 - - || 2008-12-31 -====================++============ - Assets || ---------------------++------------ - assets:bank:saving || $1 - assets:cash || $-2 ---------------------++------------ - || $-1 -====================++============ - Liabilities || ---------------------++------------ - liabilities:debts || $-1 ---------------------++------------ - || $-1 -====================++============ - Equity || ---------------------++------------ ---------------------++------------ - || 0 -====================++============ - Net: || 0 - - This command is a higher-level variant of the 'balance' command, and -supports 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 sign flipped. - - This report is the easiest way to see if the accounting equation -(A+L+E = 0) is satisfied (after you have done a 'close --retain' to -merge revenues and expenses with equity, and perhaps added -'--infer-equity' to balance your commodity conversions). - - This command also supports the output destination and output format -options The output formats supported are 'txt', 'csv', 'tsv', 'html', -and 'json'. - - -File: hledger.info, Node: cashflow, Next: check, Prev: balancesheetequity, Up: PART 4 COMMANDS - -24.9 cashflow +29.3 register ============= -(cf) - - This command displays a (simple) cashflow statement, showing the -inflows and outflows affecting "cash" (ie, liquid, easily convertible) -assets. Amounts are shown with normal positive sign, as in conventional -financial statements. - - This report shows accounts declared with the 'Cash' type (see account -types). Or if no such accounts are declared, it shows accounts - - * under a top-level account named 'asset' (case insensitive, plural - allowed) - * whose name contains some variation of 'cash', 'bank', 'checking' or - 'saving'. - - More precisely: all accounts matching this case insensitive regular -expression: - - '^assets?(:.+)?:(cash|bank|che(ck|que?)(ing)?|savings?|currentcash)(:|$)' - - and their subaccounts. - - An example cashflow report: - -$ hledger cashflow -Cashflow Statement 2008 - - || 2008 -====================++====== - Cash flows || ---------------------++------ - assets:bank:saving || $1 - assets:cash || $-2 ---------------------++------ - || $-1 - - This command is a higher-level variant of the 'balance' command, and -supports 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', 'tsv' (_Added in -1.32_), 'html', and 'json'. - - -File: hledger.info, Node: check, Next: close, Prev: cashflow, Up: PART 4 COMMANDS - -24.10 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 -argument(s). - - Some examples: - -hledger check # basic checks -hledger check -s # basic + strict checks -hledger check ordereddates payees # basic + two other checks - - If you are an Emacs user, you can also configure flycheck-hledger to -run these checks, providing instant feedback as you edit the journal. - - Here are the checks currently available: - -* Menu: - -* Default checks:: -* Strict checks:: -* Other checks:: -* Custom checks:: -* More about specific checks:: - - -File: hledger.info, Node: Default checks, Next: Strict checks, Up: check - -24.10.1 Default checks ----------------------- - -These checks are run automatically by (almost) all hledger commands: - - * *parseable* - data files are in a supported format, with no syntax - errors and no invalid include directives. - - * *autobalanced* - all transactions are balanced, after converting to - cost. Missing amounts and missing costs are inferred automatically - where possible. - - * *assertions* - all balance assertions in the journal are passing. - (This check can be disabled with '-I'/'--ignore-assertions'.) - - -File: hledger.info, Node: Strict checks, Next: Other checks, Prev: Default checks, Up: check - -24.10.2 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 -'check': - - * *balanced* - all transactions are balanced after converting to - cost, without inferring missing costs. If conversion costs are - required, they must be explicit. - - * *accounts* - all account names used by transactions have been - declared - - * *commodities* - all commodity symbols used have been declared - - -File: hledger.info, Node: Other checks, Next: Custom checks, Prev: Strict checks, Up: check - -24.10.3 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: - - * *ordereddates* - transactions are ordered by date within each file - - * *payees* - all payees used by transactions have been declared - - * *recentassertions* - all accounts with balance assertions have a - balance assertion within 7 days of their latest posting - - * *tags* - all tags used by transactions have been declared - - * *uniqueleafnames* - all account leaf names are unique - - -File: hledger.info, Node: Custom checks, Next: More about specific checks, Prev: Other checks, Up: check - -24.10.4 Custom checks ---------------------- - -A few more checks are are available as separate add-on commands, in -https://github.com/simonmichael/hledger/tree/master/bin: - - * *hledger-check-tagfiles* - all tag values containing / (a forward - slash) exist as file paths - - * *hledger-check-fancyassertions* - more complex balance assertions - are passing - - You could make similar scripts to perform your own custom checks. -See: Cookbook -> Scripting. - - -File: hledger.info, Node: More about specific checks, Prev: Custom checks, Up: check - -24.10.5 More about specific checks ----------------------------------- - -'hledger check recentassertions' will complain if any balance-asserted -account has postings more than 7 days after its latest balance -assertion. This aims to prevent the situation where you are regularly -updating your journal, but forgetting to check your balances against the -real world, then one day must dig back through months of data to find an -error. It assumes that adding a balance assertion requires/reminds you -to check the real-world balance. (That may not be true if you -auto-generate balance assertions from bank data; in that case, I -recommend to import transactions uncleared, and when you manually review -and clear them, also check the latest assertion against the real-world -balance.) - - -File: hledger.info, Node: close, Next: codes, Prev: check, Up: PART 4 COMMANDS - -24.11 close -=========== - -(equity) - - 'close' generates several kinds of "closing" and/or "opening" -transactions, useful in certain situations, including migrating balances -to a new journal file, retaining earnings into equity, consolidating -balances, or viewing lots. Like 'print', it prints valid journal -entries. You can append or copy these to your journal file(s) when you -are happy with how they look. - - 'close' currently has six modes, selected by a single mode flag: - -* Menu: - -* close --migrate:: -* close --close:: -* close --open:: -* close --assert:: -* close --assign:: -* close --retain:: -* close customisation:: -* close and balance assertions:: -* close examples:: - - -File: hledger.info, Node: close --migrate, Next: close --close, Up: close - -24.11.1 close -migrate ----------------------- - -This is the most common mode. It prints a "closing balances" -transaction that zeroes out all asset and liability balances (by -default), and an opposite "opening balances" transaction that restores -them again. The balancing account will be 'equity:opening/closing -balances' (or another specified by '--close-acct' or '--open-acct'). - - This is useful when migrating balances to a new journal file at the -start of a new year. Essentially, you run 'hledger close ---migrate=NEWYEAR -e NEWYEAR' and then copy the closing transaction to -the end of the old file and the opening transaction to the start of the -new file. The opening transaction sets correct starting balances in the -new file when it is used alone, and the closing transaction keeps -balances correct when you use both old and new files together, by -cancelling out the following opening transaction and preventing buildup -of duplicated opening balances. Think of the closing/opening pair as -"moving the balances into the next file". - - You can close a different set of accounts by providing a query. Eg -if you want to include equity, you can add 'assets liabilities equity' -or 'type:ALE' arguments. (The balancing account is always excluded.) -Revenues and expenses usually are not migrated to a new file directly; -see '--retain' below. - - The generated transactions will have a 'start:' tag, with its value -set to '--migrate''s 'NEW' argument if any, for easier matching or -exclusion. When 'NEW' is not specified, it will be inferred if possible -by incrementing a number (eg a year number) within the default journal's -main file name. The other modes behave similarly. - - -File: hledger.info, Node: close --close, Next: close --open, Prev: close --migrate, Up: close - -24.11.2 close -close --------------------- - -This prints just the closing balances transaction of '--migrate'. It is -the default behaviour if you specify no mode flag. Using the -customisation options below, you can move balances from any set of -accounts to a different account. - - -File: hledger.info, Node: close --open, Next: close --assert, Prev: close --close, Up: close - -24.11.3 close -open -------------------- - -This prints just the opening balances transaction of '--migrate'. It is -similar to Ledger's equity command. - - -File: hledger.info, Node: close --assert, Next: close --assign, Prev: close --open, Up: close - -24.11.4 close -assert ---------------------- - -This prints a "closing balances" transaction (with 'balances:' tag), -that just declares balance assertions for the current balances without -changing them. It could be useful as documention and to guard against -changes. - - -File: hledger.info, Node: close --assign, Next: close --retain, Prev: close --assert, Up: close - -24.11.5 close -assign ---------------------- - -This prints an "opening balances" transaction that restores the account -balances using balance assignments. Balance assignments work regardless -of any previous balance, so a preceding closing balances transaction is -not needed. - - However, omitting the closing balances transaction would unbalance -equity. This is relatively harmless for personal reports, but it -disturbs the accounting equation, removing a source of error detection. -So '--migrate' is generally the best way to set to set balances in new -files, for now. - - -File: hledger.info, Node: close --retain, Next: close customisation, Prev: close --assign, Up: close - -24.11.6 close -retain ---------------------- - -This is like '--close' with different defaults: it prints a "retain -earnings" transaction (with 'retain:' tag), that transfers revenue and -expense balances to 'equity:retained earnings'. - - This is a different kind of closing, called "retaining earnings" or -"closing the books"; it is traditionally performed by businesses at the -end of each accounting period, to consolidate revenues and expenses into -the main equity balance. ("Revenues" and "expenses" are actually equity -by another name, kept separate temporarily for reporting purposes.) - - In personal accounting you generally don't need to do this, unless -you want the 'balancesheetequity' report to show a zero total, -demonstrating that the accounting equation (A-L=E) is satisfied. - - -File: hledger.info, Node: close customisation, Next: close and balance assertions, Prev: close --retain, Up: close - -24.11.7 close customisation ---------------------------- - -In all modes, the following things can be overridden: - - * the accounts to be closed/opened, with account query arguments - * the balancing account, with '--close-acct=ACCT' and/or - '--open-acct=ACCT' - * the transaction descriptions, with '--close-desc=DESC' and - '--open-desc=DESC' - * the transaction's tag value, with a '--MODE=NEW' option argument - * the closing/opening dates, with '-e OPENDATE' - - By default, the closing date is yesterday, or the journal's end date, -whichever is later; and the opening date is always one day after the -closing date. You can change these by specifying a report end date; the -closing date will be the last day of the report period. Eg '-e 2024' -means "close on 2023-12-31, open on 2024-01-01". - - With '--x/--explicit', the balancing amount will be shown explicitly, -and if it involves multiple commodities, a separate posting will be -generated for each of them (similar to 'print -x'). - - With '--interleaved', each individual transfer is shown with source -and destination postings next to each other (perhaps useful for -troubleshooting). - - With '--show-costs', balances' costs are also shown, with different -costs kept separate. This may generate very large journal entries, if -you have many currency conversions or investment transactions. 'close ---show-costs' is currently the best way to view investment lots with -hledger. (To move or dispose of lots, see the more capable -'hledger-move' script.) - - -File: hledger.info, Node: close and balance assertions, Next: close examples, Prev: close customisation, Up: close - -24.11.8 close and balance assertions ------------------------------------- - -'close' adds balance assertions verifying that the accounts have been -reset to zero in a closing transaction or restored to their previous -balances in an opening transaction. These provide useful error -checking, but you can ignore them temporarily with '-I', or remove them -if you prefer. - - Single-commodity, subaccount-exclusive balance assertions ('=') are -generated by default. This can be changed with '--assertion-type='==*'' -(eg). - - When running 'close' you should probably avoid using '-C', '-R', -'status:' (filtering by status or realness) or '--auto' (generating -postings), since the generated balance assertions would then require -these. - - Transactions with multiple dates (eg posting dates) spanning the file -boundary also can disrupt the balance assertions: - -2023-12-30 a purchase made in december, cleared in january - expenses:food 5 - assets:bank:checking -5 ; date: 2023-01-02 - - To solve this you can transfer the money to and from a temporary -account, splitting the multi-day transaction into two single-day -transactions: - -; in 2022.journal: -2022-12-30 a purchase made in december, cleared in january - expenses:food 5 - equity:pending -5 - -; in 2023.journal: -2023-01-02 last year's transaction cleared - equity:pending 5 = 0 - assets:bank:checking -5 - - -File: hledger.info, Node: close examples, Prev: close and balance assertions, Up: close - -24.11.9 close examples ----------------------- - -* Menu: - -* Retain earnings:: -* Migrate balances to a new file:: -* More detailed close examples:: - - -File: hledger.info, Node: Retain earnings, Next: Migrate balances to a new file, Up: close examples - -24.11.9.1 Retain earnings -......................... - -Record 2022's revenues/expenses as retained earnings on 2022-12-31, -appending the generated transaction to the journal: - -$ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal - - After this, to see 2022's revenues and expenses you must exclude the -retain earnings transaction: - -$ hledger -f 2022.journal is not:desc:'retain earnings' - - -File: hledger.info, Node: Migrate balances to a new file, Next: More detailed close examples, Prev: Retain earnings, Up: close examples - -24.11.9.2 Migrate balances to a new file -........................................ - -Close assets/liabilities on 2022-12-31 and re-open them on 2023-01-01: - -$ hledger close --migrate -f 2022.journal -p 2022 -# copy/paste the closing transaction to the end of 2022.journal -# copy/paste the opening transaction to the start of 2023.journal - - After this, to see 2022's end-of-year balances you must exclude the -closing balances transaction: - -$ hledger -f 2022.journal bs not:desc:'closing balances' - - For more flexibility, it helps to tag closing and opening -transactions with eg 'start:NEWYEAR', then you can ensure correct -balances by excluding all opening/closing transactions except the first, -like so: - -$ hledger bs -Y -f 2021.j -f 2022.j -f 2023.j expr:'tag:start=2021 or not tag:start' -$ hledger bs -Y -f 2021.j -f 2022.j expr:'tag:start=2021 or not tag:start' -$ hledger bs -Y -f 2022.j -f 2023.j expr:'tag:start=2022 or not tag:start' -$ hledger bs -Y -f 2021.j expr:'tag:start=2021 or not tag:start' -$ hledger bs -Y -f 2022.j expr:'tag:start=2022 or not tag:start' -$ hledger bs -Y -f 2023.j # unclosed file, no query needed - - -File: hledger.info, Node: More detailed close examples, Prev: Migrate balances to a new file, Up: close examples - -24.11.9.3 More detailed close examples -...................................... - -See examples/multi-year. - - -File: hledger.info, Node: codes, Next: commodities, Prev: close, Up: PART 4 COMMANDS - -24.12 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 -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 printed as blank lines. - - You can add a query to select a subset of transactions. - - Examples: - -2022/1/1 (123) Supermarket - Food $5.00 - Checking - -2022/1/2 (124) Post Office - Postage $8.32 - Checking - -2022/1/3 Supermarket - Food $11.23 - Checking - -2022/1/4 (126) Post Office - Postage $3.21 - Checking - -$ hledger codes -123 -124 -126 - -$ hledger codes -E -123 -124 - -126 - - -File: hledger.info, Node: commodities, Next: demo, Prev: codes, Up: PART 4 COMMANDS - -24.13 commodities -================= - -List all commodity/currency symbols used or declared in the journal. - - -File: hledger.info, Node: demo, Next: descriptions, Prev: commodities, Up: PART 4 COMMANDS - -24.14 demo -========== - -Play demos of hledger usage in the terminal, if asciinema is installed. - - Run this command with no argument to list the demos. To play a demo, -write its number or a prefix or substring of its title. Tips: - - Make your terminal window large enough to see the demo clearly. - - Use the -s/-speed SPEED option to set your preferred playback speed, -eg '-s4' to play at 4x original speed or '-s.5' to play at half speed. -The default speed is 2x. - - Other asciinema options can be added following a double dash, eg '-- --i.1' to limit pauses or '-- -h' to list asciinema's other options. - - During playback, several keys are available: SPACE to pause/unpause, -. to step forward (while paused), CTRL-c quit. - - Examples: - -$ hledger demo # list available demos -$ hledger demo 1 # play the first demo at default speed (2x) -$ hledger demo install -s4 # play the "install" demo at 4x speed - - -File: hledger.info, Node: descriptions, Next: diff, Prev: demo, Up: PART 4 COMMANDS - -24.15 descriptions -================== - -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 transactions. - - Example: - -$ hledger descriptions -Store Name -Gas Station | Petrol -Person A - - -File: hledger.info, Node: diff, Next: files, Prev: descriptions, Up: PART 4 COMMANDS - -24.16 diff -========== - -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.) -Since postings not transactions are compared, this also works when -multiple 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 the account balance, you can compare the bank data with your -journal to find out the cause. - - Examples: - -$ hledger diff -f $LEDGER_FILE -f bank.csv assets:bank:giro -These transactions are in the first file only: - -2014/01/01 Opening Balances - assets:bank:giro EUR ... - ... - equity:opening balances EUR -... - -These transactions are in the second file only: - - -File: hledger.info, Node: files, Next: help, Prev: diff, Up: PART 4 COMMANDS - -24.17 files -=========== - -List all files included in the journal. With a REGEX argument, only -file names matching the regular expression (case sensitive) are shown. - - -File: hledger.info, Node: help, Next: import, Prev: files, Up: PART 4 COMMANDS - -24.18 help -========== - -Show the hledger user manual in the terminal, with 'info', 'man', or a -pager. With a TOPIC argument, open it at that topic if possible. TOPIC -can be any heading in the manual, or a heading prefix, case insensitive. -Eg: 'commands', 'print', 'forecast', 'journal', 'amount', '"auto -postings"'. - - This command shows the hledger manual built in to your hledger -version. It can be useful when offline, or when you prefer the terminal -to a web browser, or when the appropriate hledger manual or viewing -tools are not installed on your system. - - By default it chooses the best viewer found in $PATH, trying (in this -order): 'info', 'man', '$PAGER', 'less', 'more'. You can force the use -of info, man, or a pager with the '-i', '-m', or '-p' flags, If no -viewer can be found, or the command is run non-interactively, it just -prints the manual to stdout. - - If using 'info', note that version 6 or greater is needed for TOPIC -lookup. If you are on mac you will likely have info 4.8, and should -consider installing a newer version, eg with 'brew install texinfo' -(#1770). - - Examples - -$ hledger help --help # show how the help command works -$ hledger help # show the hledger manual with info, man or $PAGER -$ hledger help journal # show the journal topic in the hledger manual -$ hledger help -m journal # show it with man, even if info is installed - - -File: hledger.info, Node: import, Next: incomestatement, Prev: help, Up: PART 4 COMMANDS - -24.19 import -============ - -Read new transactions added to each FILE provided as arguments since -last run, and add them to the journal. Or with -dry-run, just print the -transactions that would be added. Or with -catchup, just mark all of -the FILEs' current transactions as imported, without importing them. - - This command may append new transactions to the main journal file -(which should be in journal format). Existing transactions are not -changed. This is one of the few hledger commands that writes to the -journal file (see also 'add'). - - Unlike other hledger commands, with 'import' the journal file is an -output 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 -'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. - -* Menu: - -* Deduplication:: -* Import testing:: -* Importing balance assignments:: -* Commodity display styles:: - - -File: hledger.info, Node: Deduplication, Next: Import testing, Up: import - -24.19.1 Deduplication ---------------------- - -'import' tries to import only the transactions which are new since the -last import, ignoring any that it has seen in previous runs. So if your -bank's CSV includes the last three months of data, you can download and -'import' it every month (or week, or day) and only the new transactions -will be imported each time. - - It works as follows. For each imported 'FILE' (usually CSV, but they -could be any of hledger's input formats): - - * It tries to recall the latest date seen previously, reading it from - a hidden '.latest.FILE' in the same directory. - * Then it processes 'FILE', ignoring any transactions on or before - the "latest seen" date. - - And after a successful import, it updates the '.latest.FILE'(s) for -next time (unless '--dry-run' was used). - - This is a limited kind of deduplication, let's call it "date -skipping". Within each input file, it avoids reprocessing the same -dates across successive runs. This is a simple system that works for -most real-world CSV files; it assumes these are true, or true enough: - - 1. new items always have the newest dates - 2. item dates are stable across successive downloads - 3. the order of same-date items is stable across downloads - 4. the name of the input file is stable across downloads - - If you have a bank whose CSV dates or ordering occasionally change, -you can reduce the chance of this happening in new transactions by -importing more often, and in old transactions it doesn't matter. And -remember you can use CSV rules files as input, which is one way to -ensure a stable file name. - - 'import' doesn't detect other kinds of duplication, such as duplicate -transactions within a single run. (In part, because legitimate -duplicate transactions can easily occur in real-world data.) So, say -you downloaded but forgot to import 'bank.1.csv', and a week later you -downloaded 'bank.2.csv' with overlapping data. Now you should not -import both of these at once ('hledger import bank.1.csv bank.2.csv'); -the overlapping transactions which appear twice would not be -deduplicated since this is considered a single import. Instead, import -these files one at a time, and also use the same filename each time for -a common "latest seen" state: - -$ mv bank.1.csv bank.csv; hledger import bank.csv -$ mv bank.2.csv bank.csv; hledger import bank.csv - - Normally you can ignore the '.latest.*' files, but if needed, you can -delete them (to make all transactions unseen), or construct/modify them -(to catch up to a certain date). The format is just a single ISO-format -date ('YYYY-MM-DD'), possibly repeated on multiple lines. It means "I -have seen transactions up to this date, and this many of them occurring -on that date". - - 'hledger print --new' also uses and updates these '.latest.*' files, -but it is less often used. - - Related: CSV > Working with CSV > Deduplicating, importing. - - -File: hledger.info, Node: Import testing, Next: Importing balance assignments, Prev: Deduplication, Up: import - -24.19.2 Import testing ----------------------- - -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 -categorised: - -$ hledger import --dry bank.csv | hledger -f- -I print unknown - - or (live updating): - -$ ls bank.csv* | entr bash -c 'echo ====; hledger import --dry bank.csv | hledger -f- -I print unknown' - - Note: when importing from multiple files at once, it's currently -possible for some .latest files to be updated successfully, while the -actual import fails because of a problem in one of the files, leaving -them out of sync (and causing some transactions to be missed). To -prevent this, do a -dry-run first and fix any problems before the real -import. - - -File: hledger.info, Node: Importing balance assignments, Next: Commodity display styles, Prev: Import testing, Up: import - -24.19.3 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 -balance assignments (eg from an institution that provides only balances -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, -please test it and send a pull request.) - - -File: hledger.info, Node: Commodity display styles, Prev: Importing balance assignments, Up: import - -24.19.4 Commodity display styles --------------------------------- - -Imported amounts will be formatted according to the canonical commodity -styles (declared or inferred) in the main journal file. - - -File: hledger.info, Node: incomestatement, Next: notes, Prev: import, Up: PART 4 COMMANDS - -24.20 incomestatement -===================== - -(is) - - This command displays an income statement, showing revenues and -expenses during one or more periods. Amounts are shown with normal -positive sign, as in conventional financial statements. - - This report shows accounts declared with the 'Revenue' or 'Expense' -type (see account types). Or if no such accounts are declared, it shows -top-level accounts named 'revenue' or 'income' or 'expense' (case -insensitive, plurals allowed) and their subaccounts. - - Example: - -$ hledger incomestatement -Income Statement 2008 - - || 2008 -===================++====== - Revenues || --------------------++------ - income:gifts || $1 - income:salary || $1 --------------------++------ - || $2 -===================++====== - Expenses || --------------------++------ - expenses:food || $1 - expenses:supplies || $1 --------------------++------ - || $2 -===================++====== - Net: || 0 - - This command is a higher-level variant of the 'balance' command, and -supports 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 -sign flipped. - - This command also supports the output destination and output format -options The output formats supported are 'txt', 'csv', 'tsv' (_Added in -1.32_), 'html', and 'json'. - - -File: hledger.info, Node: notes, Next: payees, Prev: incomestatement, Up: PART 4 COMMANDS - -24.21 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 -transactions. The note is the part of the transaction description after -a | character (or if there is no |, the whole description). - - Example: - -$ hledger notes -Petrol -Snacks - - -File: hledger.info, Node: payees, Next: prices, Prev: notes, Up: PART 4 COMMANDS - -24.22 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 -(-used), or both (the default). - - 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 -implies -used. - - Example: - -$ hledger payees -Store Name -Gas Station -Person A - - -File: hledger.info, Node: prices, Next: print, Prev: payees, Up: PART 4 COMMANDS - -24.23 prices -============ - -Print the market prices declared with P directives. With --infer-market-prices, also show any additional prices inferred from -costs. With -show-reverse, also show additional prices inferred by -reversing known prices. - - Price amounts are always displayed with their full precision, except -for reverse prices which are limited to 8 decimal digits. - - Prices can be filtered by a date:, cur: or amt: query. - - Generally if you run this command with -infer-market-prices --show-reverse, it will show the same prices used internally to calculate -value reports. But if in doubt, you can inspect those directly by -running the value report with -debug=2. - - -File: hledger.info, Node: print, Next: register, Prev: prices, Up: PART 4 COMMANDS - -24.24 print -=========== - -Show transaction journal entries, sorted by date. - - The print command displays full journal entries (transactions) from -the journal file, sorted by date (or with '--date2', by secondary date). - - 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/regenerate your journal you should take care to also copy -over the directives and inter-transaction comments. - - Eg: - -$ hledger print -f examples/sample.journal date:200806 -2008/06/01 gift - assets:bank:checking $1 - income:gifts $-1 - -2008/06/02 save - assets:bank:saving $1 - assets:bank:checking $-1 - -2008/06/03 * eat & shop - expenses:food $1 - expenses:supplies $1 - assets:cash $-2 - -* Menu: - -* print explicitness:: -* print amount style:: -* print parseability:: -* print other features:: -* print output format:: - - -File: hledger.info, Node: print explicitness, Next: print amount style, Up: print - -24.24.1 print explicitness --------------------------- - -Normally, whether posting amounts are implicit or explicit is preserved. -For example, when an amount is omitted in the journal, it will not -appear in the output. Similarly, if a conversion cost is implied but -not written, it will not appear in the output. - - You can use the '-x'/'--explicit' flag to force explicit display of -all amounts and costs. This 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'. - - The '-x'/'--explicit' flag will cause any postings with a -multi-commodity amount (which can arise when a multi-commodity -transaction has an implicit amount) to be split into multiple -single-commodity postings, keeping the output parseable. - - -File: hledger.info, Node: print amount style, Next: print parseability, Prev: print explicitness, Up: print - -24.24.2 print amount style --------------------------- - -Amounts are shown right-aligned within each transaction (but not aligned -across all transactions; you can do that with ledger-mode in Emacs). - - Amounts will be (mostly) normalised to their commodity display style: -their symbol placement, decimal mark, and digit group marks will be made -consistent. By default, decimal digits are shown as they are written in -the journal. - - With the '--round' (_Added in 1.32_) option, 'print' will try -increasingly hard to display decimal digits according to the commodity -display styles: - - * '--round=none' show amounts with original precisions (default) - * '--round=soft' add/remove decimal zeros in amounts (except costs) - * '--round=hard' round amounts (except costs), possibly hiding - significant digits - * '--round=all' round all amounts and costs - - 'soft' is good for non-lossy cleanup, formatting amounts more -consistently where it's safe to do so. - - 'hard' and 'all' can cause 'print' to show invalid unbalanced journal -entries; they may be useful eg for stronger cleanup, with manual fixups -when needed. - - -File: hledger.info, Node: print parseability, Next: print other features, Prev: print amount style, Up: print - -24.24.3 print parseability --------------------------- - -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 (though the same can be achieved with 'expr:' queries -now): - -# Show running total of food expenses paid from cash. -# -f- reads from stdin. -I/--ignore-assertions is sometimes needed. -$ hledger print assets:cash | hledger -f- -I reg expenses:food - - There are some situations where print's output can become -unparseable: - - * Value reporting affects posting amounts but not balance assertion - or balance assignment amounts, potentially causing those to fail. - * Auto postings can generate postings with too many missing amounts. - * Account aliases can generate bad account names. - - -File: hledger.info, Node: print other features, Next: print output format, Prev: print parseability, Up: print - -24.24.4 print, other features ------------------------------ - -With '-B'/'--cost', amounts with costs are shown converted to cost. - - With '--new', print shows only transactions it has not seen on a -previous run. This uses the same deduplication system as the 'import' -command. (See import's docs for details.) - - With '-m DESC'/'--match=DESC', print shows one recent transaction -whose description is most similar to DESC. DESC should contain at least -two characters. If there is no similar-enough match, no transaction -will be shown and the program exit code will be non-zero. - - -File: hledger.info, Node: print output format, Prev: print other features, Up: print - -24.24.5 print output format ---------------------------- - -This command also supports the output destination and output format -options The output formats supported are 'txt', 'beancount' (_Added in -1.32_), 'csv', 'tsv' (_Added in 1.32_), 'json' and 'sql'. - - The 'beancount' format tries to produce Beancount-compatible output, -as follows: - - * Transaction and postings with unmarked status are converted to - cleared ('*') status. - * Transactions' payee and note are backslash-escaped and - double-quote-escaped and wrapped in double quotes. - * Transaction tags are copied to Beancount #tag format. - * Commodity symbols are converted to upper case, and a small number - of currency symbols like '$' are converted to the corresponding - currency names. - * Account name parts are capitalised and unsupported characters are - replaced with '-'. If an account name part does not begin with a - letter, or if the first part is not Assets, Liabilities, Equity, - Income, or Expenses, an error is raised. (Use '--alias' options to - bring your accounts into compliance.) - * An 'open' directive is generated for each account used, on the - earliest transaction date. - - Some limitations: - - * Balance assertions are removed. - * Balance assignments become missing amounts. - * Virtual and balanced virtual postings become regular postings. - * Directives are not converted. - - Here's an example of print's CSV output: - -$ hledger print -Ocsv -"txnidx","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","posting-status","posting-comment" -"1","2008/01/01","","","","income","","assets:bank:checking","1","$","","1","","" -"1","2008/01/01","","","","income","","income:salary","-1","$","1","","","" -"2","2008/06/01","","","","gift","","assets:bank:checking","1","$","","1","","" -"2","2008/06/01","","","","gift","","income:gifts","-1","$","1","","","" -"3","2008/06/02","","","","save","","assets:bank:saving","1","$","","1","","" -"3","2008/06/02","","","","save","","assets:bank:checking","-1","$","1","","","" -"4","2008/06/03","","*","","eat & shop","","expenses:food","1","$","","1","","" -"4","2008/06/03","","*","","eat & shop","","expenses:supplies","1","$","","1","","" -"4","2008/06/03","","*","","eat & shop","","assets:cash","-2","$","2","","","" -"5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","","" -"5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","","" - - * There is one CSV record per posting, with the parent transaction's - fields repeated. - * 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 order, etc.) - * The amount is separated into "commodity" (the symbol) and "amount" - (numeric quantity) fields. - * The numeric amount is repeated in either the "credit" or "debit" - column, for convenience. (Those names are not accurate in the - accounting sense; it just puts negative amounts under credit and - zero or greater amounts under debit.) - - -File: hledger.info, Node: register, Next: rewrite, Prev: print, Up: PART 4 COMMANDS - -24.25 register -============== - (reg) Show postings and their running total. @@ -10112,8 +8454,8 @@ no posting will be shown and the program exit code will be non-zero.  File: hledger.info, Node: Custom register output, Up: register -24.25.1 Custom register output ------------------------------- +29.3.1 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 @@ -10142,162 +8484,1260 @@ options The output formats supported are 'txt', 'csv', 'tsv' (_Added in 1.32_), and 'json'.  -File: hledger.info, Node: rewrite, Next: roi, Prev: register, Up: PART 4 COMMANDS +File: hledger.info, Node: balancesheet, Next: balancesheetequity, Prev: register, Up: Standard report commands -24.26 rewrite +29.4 balancesheet +================= + +(bs) + + This command displays a balance sheet, showing historical ending +balances of asset and liability accounts. (To see equity as well, use +the balancesheetequity command.) Amounts are shown with normal positive +sign, as in conventional financial statements. + + This report shows accounts declared with the 'Asset', 'Cash' or +'Liability' type (see account types). Or if no such accounts are +declared, it shows top-level accounts named 'asset' or 'liability' (case +insensitive, plurals allowed) and their subaccounts. + + Example: + +$ hledger balancesheet +Balance Sheet 2008-12-31 + + || 2008-12-31 +====================++============ + Assets || +--------------------++------------ + assets:bank:saving || $1 + assets:cash || $-2 +--------------------++------------ + || $-1 +====================++============ + Liabilities || +--------------------++------------ + liabilities:debts || $-1 +--------------------++------------ + || $-1 +====================++============ + Net: || 0 + + This command is a higher-level variant of the 'balance' command, and +supports 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', 'tsv' (_Added in +1.32_), 'html', and 'json'. + + +File: hledger.info, Node: balancesheetequity, Next: cashflow, Prev: balancesheet, Up: Standard report commands + +29.5 balancesheetequity +======================= + +(bse) + + This command displays a balance sheet, showing historical ending +balances of asset, liability and equity accounts. Amounts are shown +with normal positive sign, as in conventional financial statements. + + This report shows accounts declared with the 'Asset', 'Cash', +'Liability' or 'Equity' type (see account types). Or if no such +accounts are declared, it shows top-level accounts named 'asset', +'liability' or 'equity' (case insensitive, plurals allowed) and their +subaccounts. + + Example: + +$ hledger balancesheetequity +Balance Sheet With Equity 2008-12-31 + + || 2008-12-31 +====================++============ + Assets || +--------------------++------------ + assets:bank:saving || $1 + assets:cash || $-2 +--------------------++------------ + || $-1 +====================++============ + Liabilities || +--------------------++------------ + liabilities:debts || $-1 +--------------------++------------ + || $-1 +====================++============ + Equity || +--------------------++------------ +--------------------++------------ + || 0 +====================++============ + Net: || 0 + + This command is a higher-level variant of the 'balance' command, and +supports 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 sign flipped. + + This report is the easiest way to see if the accounting equation +(A+L+E = 0) is satisfied (after you have done a 'close --retain' to +merge revenues and expenses with equity, and perhaps added +'--infer-equity' to balance your commodity conversions). + + This command also supports the output destination and output format +options The output formats supported are 'txt', 'csv', 'tsv', 'html', +and 'json'. + + +File: hledger.info, Node: cashflow, Next: incomestatement, Prev: balancesheetequity, Up: Standard report commands + +29.6 cashflow ============= -Print all transactions, rewriting the postings of matched transactions. -For now the only rewrite available is adding new postings, like print --auto. +(cf) - This is a start at a generic rewriter of transaction entries. It -reads 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 -transaction's first posting amount. + This command displays a (simple) cashflow statement, showing the +inflows and outflows affecting "cash" (ie, liquid, easily convertible) +assets. Amounts are shown with normal positive sign, as in conventional +financial statements. - Examples: + This report shows accounts declared with the 'Cash' type (see account +types). Or if no such accounts are declared, it shows accounts -$ hledger-rewrite.hs ^income --add-posting '(liabilities:tax) *.33 ; income tax' --add-posting '(reserve:gifts) $100' -$ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts) *-1"' -$ hledger-rewrite.hs -f rewrites.hledger + * under a top-level account named 'asset' (case insensitive, plural + allowed) + * whose name contains some variation of 'cash', 'bank', 'checking' or + 'saving'. - rewrites.hledger may consist of entries like: + More precisely: all accounts matching this case insensitive regular +expression: -= ^income amt:<0 date:2017 - (liabilities:tax) *0.33 ; tax on income - (reserve:grocery) *0.25 ; reserve 25% for grocery - (reserve:) *0.25 ; reserve 25% for grocery + '^assets?(:.+)?:(cash|bank|che(ck|que?)(ing)?|savings?|currentcash)(:|$)' - Note the single quotes to protect the dollar sign from bash, and the -two spaces between account and amount. + and their subaccounts. - More: + An example cashflow report: -$ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ... -$ hledger rewrite -- ^income --add-posting '(liabilities:tax) *.33' -$ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"' -$ hledger rewrite -- ^income --add-posting '(budget:foreign currency) *0.25 JPY; diversify' +$ hledger cashflow +Cashflow Statement 2008 - 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 -commodity. + || 2008 +====================++====== + Cash flows || +--------------------++------ + assets:bank:saving || $1 + assets:cash || $-2 +--------------------++------ + || $-1 + + This command is a higher-level variant of the 'balance' command, and +supports 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', 'tsv' (_Added in +1.32_), 'html', and 'json'. + + +File: hledger.info, Node: incomestatement, Prev: cashflow, Up: Standard report commands + +29.7 incomestatement +==================== + +(is) + + This command displays an income statement, showing revenues and +expenses during one or more periods. Amounts are shown with normal +positive sign, as in conventional financial statements. + + This report shows accounts declared with the 'Revenue' or 'Expense' +type (see account types). Or if no such accounts are declared, it shows +top-level accounts named 'revenue' or 'income' or 'expense' (case +insensitive, plurals allowed) and their subaccounts. + + Example: + +$ hledger incomestatement +Income Statement 2008 + + || 2008 +===================++====== + Revenues || +-------------------++------ + income:gifts || $1 + income:salary || $1 +-------------------++------ + || $2 +===================++====== + Expenses || +-------------------++------ + expenses:food || $1 + expenses:supplies || $1 +-------------------++------ + || $2 +===================++====== + Net: || 0 + + This command is a higher-level variant of the 'balance' command, and +supports 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 +sign flipped. + + This command also supports the output destination and output format +options The output formats supported are 'txt', 'csv', 'tsv' (_Added in +1.32_), 'html', and 'json'. + + +File: hledger.info, Node: Advanced report commands, Next: Chart commands, Prev: Standard report commands, Up: Top + +30 Advanced report commands +*************************** * Menu: -* Re-write rules in a file:: -* Diff output format:: -* rewrite vs print --auto:: +* balance:: +* roi::  -File: hledger.info, Node: Re-write rules in a file, Next: Diff output format, Up: rewrite +File: hledger.info, Node: balance, Next: roi, Up: Advanced report commands -24.26.1 Re-write rules in a file +30.1 balance +============ + +(bal) + + Show accounts and their balances. + + 'balance' is one of hledger's oldest and most versatile commands, for +listing account balances, balance changes, values, value changes and +more, during one time period or many. Generally it shows a table, with +rows representing accounts, and columns representing periods. + + Note there are some higher-level variants of the 'balance' command +with convenient defaults, which can be simpler to use: 'balancesheet', +'balancesheetequity', 'cashflow' and 'incomestatement'. When you need +more control, then use 'balance'. + +* Menu: + +* balance features:: +* Simple balance report:: +* Balance report line format:: +* Filtered balance report:: +* List or tree mode:: +* Depth limiting:: +* Dropping top-level accounts:: +* Showing declared accounts:: +* Sorting by amount:: +* Percentages:: +* Multi-period balance report:: +* Balance change end balance:: +* Balance report types:: +* Budget report:: +* Balance report layout:: +* Some useful balance reports:: + + +File: hledger.info, Node: balance features, Next: Simple balance report, Up: balance + +30.1.1 balance features +----------------------- + +Here's a quick overview of the 'balance' command's features, followed by +more detailed descriptions and examples. Many of these work with the +higher-level commands as well. + + 'balance' can show.. + + * accounts as a list ('-l') or a tree ('-t') + * optionally depth-limited ('-[1-9]') + * sorted by declaration order and name, or by amount + + ..and their.. + + * balance changes (the default) + * or actual and planned balance changes ('--budget') + * or value of balance changes ('-V') + * or change of balance values ('--valuechange') + * or unrealised capital gain/loss ('--gain') + * or balance changes from sibling postings ('--related'/'-r') + * or postings count ('--count') + + ..in.. + + * one time period (the whole journal period by default) + * or multiple periods ('-D', '-W', '-M', '-Q', '-Y', '-p INTERVAL') + + ..either.. + + * per period (the default) + * or accumulated since report start date ('--cumulative') + * or accumulated since account creation ('--historical/-H') + + ..possibly converted to.. + + * cost ('--value=cost[,COMM]'/'--cost'/'-B') + * or market value, as of transaction dates ('--value=then[,COMM]') + * or at period ends ('--value=end[,COMM]') + * or now ('--value=now') + * or at some other date ('--value=YYYY-MM-DD') + + ..with.. + + * totals ('-T'), averages ('-A'), percentages ('-%'), inverted sign + ('--invert') + * rows and columns swapped ('--transpose') + * another field used as account name ('--pivot') + * custom-formatted line items (single-period reports only) + ('--format') + * commodities displayed on the same line or multiple lines + ('--layout') + + This command supports the output destination and output format +options, with output formats 'txt', 'csv', 'tsv' (_Added in 1.32_), +'json', and (multi-period reports only:) 'html'. In 'txt' output in a +colour-supporting terminal, negative amounts are shown in red. + + +File: hledger.info, Node: Simple balance report, Next: Balance report line format, Prev: balance features, Up: balance + +30.1.2 Simple balance report +---------------------------- + +With no arguments, 'balance' shows a list of all accounts and their +change of balance - ie, the sum of posting amounts, both inflows and +outflows - during the entire period of the journal. ("Simple" here +means just one column of numbers, covering a single period. You can +also have multi-period reports, described later.) + + For real-world accounts, these numbers will normally be their end +balance at the end of the journal period; more on this below. + + Accounts are sorted by declaration order if any, and then +alphabetically by account name. For instance (using +examples/sample.journal): + +$ hledger -f examples/sample.journal bal + $1 assets:bank:saving + $-2 assets:cash + $1 expenses:food + $1 expenses:supplies + $-1 income:gifts + $-1 income:salary + $1 liabilities:debts +-------------------- + 0 + + Accounts with a zero balance (and no non-zero subaccounts, in tree +mode - see below) are hidden by default. Use '-E/--empty' to show them +(revealing 'assets:bank:checking' here): + +$ hledger -f examples/sample.journal bal -E + 0 assets:bank:checking + $1 assets:bank:saving + $-2 assets:cash + $1 expenses:food + $1 expenses:supplies + $-1 income:gifts + $-1 income:salary + $1 liabilities:debts +-------------------- + 0 + + The total of the amounts displayed is shown as the last line, unless +'-N'/'--no-total' is used. + + +File: hledger.info, Node: Balance report line format, Next: Filtered balance report, Prev: Simple balance report, Up: balance + +30.1.3 Balance report line format +--------------------------------- + +For single-period balance reports displayed in the terminal (only), you +can use '--format FMT' to customise the format and content of each line. +Eg: + +$ hledger -f examples/sample.journal balance --format "%20(account) %12(total)" + assets $-1 + bank:saving $1 + cash $-2 + expenses $2 + food $1 + supplies $1 + income $-2 + gifts $-1 + salary $-1 + liabilities:debts $1 +--------------------------------- + 0 + + The FMT format string specifies the formatting applied to each +account/balance pair. It may contain any suitable text, with data +fields interpolated like so: + + '%[MIN][.MAX](FIELDNAME)' + + * MIN pads with spaces to at least this width (optional) + + * MAX truncates at this width (optional) + + * FIELDNAME must be enclosed in parentheses, and can be one of: + + * 'depth_spacer' - a number of spaces equal to the account's + depth, or if MIN is specified, MIN * depth spaces. + * 'account' - the account's name + * 'total' - the account's balance/posted total, right justified + + Also, FMT can begin with an optional prefix to control how +multi-commodity amounts are rendered: + + * '%_' - render on multiple lines, bottom-aligned (the default) + * '%^' - render on multiple lines, top-aligned + * '%,' - render on one line, comma-separated + + 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: + + * '%(total)' - the account's total + * '%-20.20(account)' - the account's name, left justified, padded to + 20 characters and clipped at 20 characters + * '%,%-50(account) %25(total)' - account name padded to 50 + characters, total padded to 20 characters, with multiple + commodities rendered on one line + * '%20(total) %2(depth_spacer)%-(account)' - the default format for + the single-column balance report + + +File: hledger.info, Node: Filtered balance report, Next: List or tree mode, Prev: Balance report line format, Up: balance + +30.1.4 Filtered balance report +------------------------------ + +You can show fewer accounts, a different time period, totals from +cleared transactions only, etc. by using query arguments or options to +limit the postings being matched. Eg: + +$ hledger -f examples/sample.journal bal --cleared assets date:200806 + $-2 assets:cash +-------------------- + $-2 + + +File: hledger.info, Node: List or tree mode, Next: Depth limiting, Prev: Filtered balance report, Up: balance + +30.1.5 List or tree mode +------------------------ + +By default, or with '-l/--flat', accounts are shown as a flat list with +their full names visible, as in the examples above. + + With '-t/--tree', the account hierarchy is shown, with subaccounts' +"leaf" names indented below their parent: + +$ hledger -f examples/sample.journal balance + $-1 assets + $1 bank:saving + $-2 cash + $2 expenses + $1 food + $1 supplies + $-2 income + $-1 gifts + $-1 salary + $1 liabilities:debts +-------------------- + 0 + + Notes: + + * "Boring" accounts are combined with their subaccount for more + compact output, unless '--no-elide' is used. Boring accounts have + no balance of their own and just one subaccount (eg 'assets:bank' + and 'liabilities' above). + + * All balances shown are "inclusive", ie including the balances from + all subaccounts. Note this means some repetition in the output, + which requires explanation when sharing reports with + non-plaintextaccounting-users. A tree mode report's final total is + the sum of the top-level balances shown, not of all the balances + shown. + + * Each group of sibling accounts (ie, under a common parent) is + sorted separately. + + +File: hledger.info, Node: Depth limiting, Next: Dropping top-level accounts, Prev: List or tree mode, Up: balance + +30.1.6 Depth limiting +--------------------- + +With a 'depth:NUM' query, or '--depth NUM' option, or just '-NUM' (eg: +'-3') balance reports will show accounts only to the specified depth, +hiding the deeper subaccounts. This can be useful for getting an +overview without too much detail. + + Account balances at the depth limit always include the balances from +any deeper subaccounts (even in list mode). Eg, limiting to depth 1: + +$ hledger -f examples/sample.journal balance -1 + $-1 assets + $2 expenses + $-2 income + $1 liabilities +-------------------- + 0 + + +File: hledger.info, Node: Dropping top-level accounts, Next: Showing declared accounts, Prev: Depth limiting, Up: balance + +30.1.7 Dropping top-level accounts +---------------------------------- + +You can also hide one or more top-level account name parts, using +'--drop NUM'. This can be useful for hiding repetitive top-level +account names: + +$ hledger -f examples/sample.journal bal expenses --drop 1 + $1 food + $1 supplies +-------------------- + $2 + + +File: hledger.info, Node: Showing declared accounts, Next: Sorting by amount, Prev: Dropping top-level accounts, Up: balance + +30.1.8 Showing declared accounts -------------------------------- -During the run this tool will execute so called "Automated Transactions" -found in any journal it process. I.e instead of specifying this -operations in command line you can put them in a journal file. +With '--declared', accounts which have been declared with an account +directive will be included in the balance report, even if they have no +transactions. (Since they will have a zero balance, you will also need +'-E/--empty' to see them.) -$ rewrite-rules.journal + More precisely, _leaf_ declared accounts (with no subaccounts) will +be included, since those are usually the more useful in reports. - Make contents look like this: - -= ^income - (liabilities:tax) *.33 - -= expenses:gifts - budget:gifts *-1 - assets:budget *1 - - Note that ''='' (equality symbol) that is used instead of date in -transactions you usually write. It indicates the query by which you -want to match the posting to add new ones. - -$ hledger rewrite -- -f input.journal -f rewrite-rules.journal > rewritten-tidy-output.journal - - This is something similar to the commands pipeline: - -$ hledger rewrite -- -f input.journal '^income' --add-posting '(liabilities:tax) *.33' \ - | hledger rewrite -- -f - expenses:gifts --add-posting 'budget:gifts *-1' \ - --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 -postings. + The idea of this is to be able to see a useful "complete" balance +report, even when you don't have transactions in all of your declared +accounts yet.  -File: hledger.info, Node: Diff output format, Next: rewrite vs print --auto, Prev: Re-write rules in a file, Up: rewrite +File: hledger.info, Node: Sorting by amount, Next: Percentages, Prev: Showing declared accounts, Up: balance -24.26.2 Diff output format --------------------------- +30.1.9 Sorting by amount +------------------------ -To use this tool for batch modification of your journal files you may -find useful output in form of unified diff. +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. 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). -$ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax) *.33' - - Output might look like: - ---- /tmp/examples/sample.journal -+++ /tmp/examples/sample.journal -@@ -18,3 +18,4 @@ - 2008/01/01 income -- assets:bank:checking $1 -+ assets:bank:checking $1 - income:salary -+ (liabilities:tax) 0 -@@ -22,3 +23,4 @@ - 2008/06/01 gift -- assets:bank:checking $1 -+ assets:bank:checking $1 - income:gifts -+ (liabilities:tax) 0 - - If you'll pass this through 'patch' tool you'll get transactions -containing the posting that matches your query be updated. Note that -multiple 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 from 'hledger print'. - - See also: - - https://github.com/simonmichael/hledger/issues/99 + 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').  -File: hledger.info, Node: rewrite vs print --auto, Prev: Diff output format, Up: rewrite +File: hledger.info, Node: Percentages, Next: Multi-period balance report, Prev: Sorting by amount, Up: balance -24.26.3 rewrite vs. print -auto -------------------------------- +30.1.10 Percentages +------------------- -This command predates print -auto, and currently does much the same -thing, but with these differences: +With '-%/--percent', balance reports show each account's value expressed +as a percentage of the (column) total. - * with multiple files, rewrite lets rules in any file affect all - other files. print -auto uses standard directive scoping; rules - affect only child files. + Note it is not useful to calculate percentages if the amounts in a +column have mixed signs. In this case, make a separate report for each +sign, eg: - * rewrite's query limits which transactions can be rewritten; all are - printed. print -auto's query limits which transactions are - printed. +$ hledger bal -% amt:`>0` +$ hledger bal -% amt:`<0` - * rewrite applies rules specified on command line or in the journal. - print -auto applies rules specified in the journal. + 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:€  -File: hledger.info, Node: roi, Next: stats, Prev: rewrite, Up: PART 4 COMMANDS +File: hledger.info, Node: Multi-period balance report, Next: Balance change end balance, Prev: Percentages, Up: balance -24.27 roi -========= +30.1.11 Multi-period balance report +----------------------------------- + +With a report interval (set by the '-D/--daily', '-W/--weekly', +'-M/--monthly', '-Q/--quarterly', '-Y/--yearly', or '-p/--period' flag), +'balance' shows a tabular report, with columns representing successive +time periods (and a title): + +$ hledger -f examples/sample.journal bal --quarterly income expenses -E +Balance changes in 2008: + + || 2008q1 2008q2 2008q3 2008q4 +===================++================================= + expenses:food || 0 $1 0 0 + expenses:supplies || 0 $1 0 0 + income:gifts || 0 $-1 0 0 + income:salary || $-1 0 0 0 +-------------------++--------------------------------- + || $-1 $1 0 0 + + Notes: + + * The report's start/end dates will be expanded, if necessary, to + fully encompass the displayed subperiods (so that the first and + last subperiods have the same duration as the others). + * Leading and trailing periods (columns) containing all zeroes are + not shown, unless '-E/--empty' is used. + * Accounts (rows) containing all zeroes are not shown, unless + '-E/--empty' is used. + * Amounts with many commodities are shown in abbreviated form, unless + '--no-elide' is used. + * Average and/or total columns can be added with the '-A/--average' + and '-T/--row-total' flags. + * The '--transpose' flag can be used to exchange rows and columns. + * The '--pivot FIELD' option causes a different transaction field to + be used as "account name". See PIVOTING. + * The '--summary-only' flag ('--summary' also works) hides all but + the Total and Average columns (those should be enabled with + '--row-total' and '-A/--average'). + + Multi-period reports with many periods can be too wide for easy +viewing in the terminal. Here are some ways to handle that: + + * Hide the totals row with '-N/--no-total' + * Filter to a single currency with 'cur:' + * Convert to a single currency with '-V [--infer-market-price]' + * Use a more compact layout like '--layout=bare' + * Maximize the terminal window + * Reduce the terminal's font size + * View with a pager like less, eg: 'hledger bal -D --color=yes | less + -RS' + * Output as CSV and use a CSV viewer like visidata ('hledger bal -D + -O csv | vd -f csv'), Emacs' csv-mode ('M-x csv-mode, C-c C-a'), or + a spreadsheet ('hledger bal -D -o a.csv && open a.csv') + * Output as HTML and view with a browser: 'hledger bal -D -o a.html + && open a.html' + + +File: hledger.info, Node: Balance change end balance, Next: Balance report types, Prev: Multi-period balance report, Up: balance + +30.1.12 Balance change, end balance +----------------------------------- + +It's important to be clear on the meaning of the numbers shown in +balance reports. Here is some terminology we use: + + 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 your timezone). It is the sum of previous 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 bank statements or bank web UI. (If they are correct!) + + 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 end balances: + + 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' flag. ('-H' causes report start date to be + ignored when summing postings.) + + +File: hledger.info, Node: Balance report types, Next: Budget report, Prev: Balance change end balance, Up: balance + +30.1.13 Balance report types +---------------------------- + +The balance command is quite flexible; here is the full detail on how to +control what it reports. If the following seems complicated, don't +worry - this is for advanced reporting, and it does take time and +experimentation to get familiar with all the report modes. + + There are three important option groups: + + 'hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] +...' + +* Menu: + +* Calculation type:: +* Accumulation type:: +* Valuation type:: +* Combining balance report types:: + + +File: hledger.info, Node: Calculation type, Next: Accumulation type, Up: Balance report types + +30.1.13.1 Calculation type +.......................... + +The basic calculation to perform for each table cell. It is one of: + + * '--sum' : sum the posting amounts (*default*) + * '--budget' : sum the amounts, but also show the budget goal amount + (for each account/period) + * '--valuechange' : show the change in period-end historical balance + values (caused by deposits, withdrawals, and/or market price + fluctuations) + * '--gain' : show the unrealised capital gain/loss, (the current + valued balance minus each amount's original cost) + * '--count' : show the count of postings + + +File: hledger.info, Node: Accumulation type, Next: Valuation type, Prev: Calculation type, Up: Balance report types + +30.1.13.2 Accumulation type +........................... + +How amounts should accumulate across a report's subperiods/columns. +Another way to say it: which time period's postings should contribute to +each cell's calculation. It is one of: + + * '--change' : calculate with postings from column start to column + end, ie "just this column". Typically used to see + revenues/expenses. (*default for balance, cashflow, + incomestatement*) + + * '--cumulative' : calculate with postings from report start to + column end, ie "previous columns plus this column". Typically used + to show changes accumulated since the report's start date. Not + often used. + + * '--historical/-H' : calculate with postings from journal start to + column end, ie "all postings from before report start date until + this column's end". Typically used to see historical end balances + of assets/liabilities/equity. (*default for balancesheet, + balancesheetequity*) + + +File: hledger.info, Node: Valuation type, Next: Combining balance report types, Prev: Accumulation type, Up: Balance report types + +30.1.13.3 Valuation type +........................ + +Which kind of value or cost conversion should be applied, if any, before +displaying the report. It is one of: + + * no valuation type : don't convert to cost or value (*default*) + * '--value=cost[,COMM]' : convert amounts to cost (then optionally to + some other commodity) + * '--value=then[,COMM]' : convert amounts to market value on + transaction dates + * '--value=end[,COMM]' : convert amounts to market value on period + end date(s) + (*default with '--valuechange', '--gain'*) + * '--value=now[,COMM]' : convert amounts to market value on today's + date + * '--value=YYYY-MM-DD[,COMM]' : convert amounts to market value on + another date + + or one of the equivalent simpler flags: + + * '-B/--cost' : like -value=cost (though, note -cost and -value are + independent options which can both be used at once) + * '-V/--market' : like -value=end + * '-X COMM/--exchange COMM' : like -value=end,COMM + + See Cost reporting and Value reporting for more about these. + + +File: hledger.info, Node: Combining balance report types, Prev: Valuation type, Up: Balance report types + +30.1.13.4 Combining balance report types +........................................ + +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: + + * '--valuechange' implies '--value=end' + * '--valuechange' makes '--change' the default when used with the + 'balancesheet'/'balancesheetequity' commands + * '--cumulative' or '--historical' disables '--row-total/-T' + + For reference, here is what the combinations of accumulation and +valuation show: + +Valuation:>no valuation '--value= then' '--value= end' '--value= +Accumulation:v YYYY-MM-DD + /now' +----------------------------------------------------------------------------- +'--change'change in sum of period-end DATE-value + period posting-date value of of change in + market values change in period + in period period +'--cumulative'change from sum of period-end DATE-value + report start to posting-date value of of change + period end market values change from from report + from report report start start to + start to period to period end period end + end +'--historicalchange from sum of period-end DATE-value +/-H' journal start posting-date value of of change + to period end market values change from from journal + (historical end from journal journal start start to + balance) start to period to period end period end + end + + +File: hledger.info, Node: Budget report, Next: Balance report layout, Prev: Balance report types, Up: balance + +30.1.14 Budget report +--------------------- + +The '--budget' report type is like a regular balance report, but with +two main differences: + + * Budget goals and performance percentages are also shown, in + brackets + * Accounts which don't have budget goals are hidden by default. + + This is useful for comparing planned and actual income, expenses, +time usage, etc. + + Periodic transaction rules are used to define budget goals. For +example, here's a periodic rule defining monthly goals for bus travel +and food expenses: + +;; Budget +~ monthly + (expenses:bus) $30 + (expenses:food) $400 + + After recording some actual expenses, + +;; Two months worth of expenses +2017-11-01 + income $-1950 + expenses:bus $35 + expenses:food:groceries $310 + expenses:food:dining $42 + expenses:movies $38 + assets:bank:checking + +2017-12-01 + income $-2100 + expenses:bus $53 + expenses:food:groceries $380 + expenses:food:dining $32 + expenses:gifts $100 + assets:bank:checking + + we can see a budget report like this: + +$ hledger bal -M --budget +Budget performance in 2017-11-01..2017-12-31: + + || Nov Dec +===============++============================================ + || $-425 $-565 + expenses || $425 [ 99% of $430] $565 [131% of $430] + expenses:bus || $35 [117% of $30] $53 [177% of $30] + expenses:food || $352 [ 88% of $400] $412 [103% of $400] +---------------++-------------------------------------------- + || 0 [ 0% of $430] 0 [ 0% of $430] + + This is "goal-based budgeting"; you define goals for accounts and +periods, often recurring, and hledger shows performance relative to the +goals. This contrasts with "envelope budgeting", which is more detailed +and strict - useful when cash is tight, but also quite a bit more work. +https://plaintextaccounting.org/Budgeting has more on this topic. + +* Menu: + +* Using the budget report:: +* Budget date surprises:: +* Selecting budget goals:: +* Budgeting vs forecasting:: + + +File: hledger.info, Node: Using the budget report, Next: Budget date surprises, Up: Budget report + +30.1.14.1 Using the budget report +................................. + +Historically this report has been confusing and fragile. hledger's +version should be relatively robust and intuitive, but you may still +find surprises. Here are more notes to help with learning and +troubleshooting. + + * In the above example, 'expenses:bus' and 'expenses:food' are shown + because they have budget goals during the report period. + + * Their parent 'expenses' is also shown, with budget goals aggregated + from the children. + + * The subaccounts 'expenses:food:groceries' and + 'expenses:food:dining' are not shown since they have no budget goal + of their own, but they contribute to 'expenses:food''s actual + amount. + + * Unbudgeted accounts 'expenses:movies' and 'expenses:gifts' are also + not shown, but they contribute to 'expenses''s actual amount. + + * The other unbudgeted accounts 'income' and 'assets:bank:checking' + are grouped as ''. + + * '--depth' or 'depth:' can be used to limit report depth in the + usual way (but will not reveal unbudgeted subaccounts). + + * Amounts are always inclusive of subaccounts (even in '-l/--list' + mode). + + * Numbers displayed in a -budget report will not always agree with + the totals, because of hidden unbudgeted accounts; this is normal. + '-E/--empty' can be used to reveal the hidden accounts. + + * In the periodic rules used for setting budget goals, unbalanced + postings are convenient. + + * You can filter budget reports with the usual queries, eg to focus + on particular accounts. It's common to restrict them to just + expenses. (The '' account is occasionally hard to + exclude; this is because of date surprises, discussed below.) + + * When you have multiple currencies, you may want to convert them to + one ('-X COMM --infer-market-prices') and/or show just one at a + time ('cur:COMM'). If you do need to show multiple currencies at + once, '--layout bare' can be helpful. + + * You can "roll over" amounts (actual and budgeted) to the next + period with '--cumulative'. + + See also: https://hledger.org/budgeting.html. + + +File: hledger.info, Node: Budget date surprises, Next: Selecting budget goals, Prev: Using the budget report, Up: Budget report + +30.1.14.2 Budget date surprises +............................... + +With small data, or when starting out, some of the generated budget goal +transaction dates might fall outside the report periods. Eg with the +following journal and report, the first period appears to have no +'expenses:food' budget. (Also the '' account should be +excluded by the 'expenses' query, but isn't.): + +~ monthly in 2020 + (expenses:food) $500 + +2020-01-15 + expenses:food $400 + assets:checking + +$ hledger bal --budget expenses +Budget performance in 2020-01-15: + + || 2020-01-15 +===============++==================== + || $400 + expenses:food || 0 [ 0% of $500] +---------------++-------------------- + || $400 [80% of $500] + + In this case, the budget goal transactions are generated on first +days of of month (this can be seen with 'hledger print --forecast +tag:generated expenses'). Whereas the report period defaults to just +the 15th day of january (this can be seen from the report table's column +headings). + + To fix this kind of thing, be more explicit about the report period +(and/or the periodic rules' dates). In this case, adding '-b 2020' does +the trick. + + +File: hledger.info, Node: Selecting budget goals, Next: Budgeting vs forecasting, Prev: Budget date surprises, Up: Budget report + +30.1.14.3 Selecting budget goals +................................ + +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 between period +expression and description), and then select from multiple budgets +defined in your journal. + + +File: hledger.info, Node: Budgeting vs forecasting, Prev: Selecting budget goals, Up: Budget report + +30.1.14.4 Budgeting vs forecasting +.................................. + +'--forecast' and '--budget' both use the periodic transaction rules in +the journal to generate temporary transactions for reporting purposes. +However they are separate features - though you can use both at the same +time if you want. Here are some differences between them: + +-forecast -budget +-------------------------------------------------------------------------- +is a general option; it enables is a balance command option; +forecasting with all reports it selects the balance + report's budget mode +generates visible transactions which generates invisible +appear in reports transactions which produce + goal amounts +generates forecast transactions from generates budget goal +after the last regular transaction, to transactions throughout the +the end of the report period; or with report period, optionally +an argument '--forecast=PERIODEXPR' restricted by periods +generates them throughout the specified in the periodic +specified period, both optionally transaction rules +restricted by periods specified in the +periodic transaction rules +uses all periodic rules uses all periodic rules; or + with an argument + '--budget=DESCPAT' uses just + the rules matched by DESCPAT + + +File: hledger.info, Node: Balance report layout, Next: Some useful balance reports, Prev: Budget report, Up: balance + +30.1.15 Balance report layout +----------------------------- + +The '--layout' option affects how balance reports show multi-commodity +amounts and commodity symbols, which can improve readability. It can +also normalise the data for easy consumption by other programs. It has +four possible values: + + * '--layout=wide[,WIDTH]': commodities are shown on a single line, + optionally elided to WIDTH + * '--layout=tall': each commodity is shown on a separate line + * '--layout=bare': commodity symbols are in their own column, amounts + are bare numbers + * '--layout=tidy': data is normalised to easily-consumed "tidy" form, + with one row per data value + + Here are the '--layout' modes supported by each output format Only +CSV output supports all of them: + +- txt csv html json sql +--------------------------------------- +wide Y Y Y +tall Y Y Y +bare Y Y Y +tidy Y + + Examples: + +* Menu: + +* Wide layout:: +* Tall layout:: +* Bare layout:: +* Tidy layout:: + + +File: hledger.info, Node: Wide layout, Next: Tall layout, Up: Balance report layout + +30.1.15.1 Wide layout +..................... + +With many commodities, reports can be very wide: + +$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide +Balance changes in 2012-01-01..2014-12-31: + + || 2012 2013 2014 Total +==================++==================================================================================================================================================================================================================== + Assets:US:ETrade || 10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT 70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT -11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT +------------------++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + || 10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT 70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT -11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT + + A width limit reduces the width, but some commodities will be hidden: + +$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide,32 +Balance changes in 2012-01-01..2014-12-31: + + || 2012 2013 2014 Total +==================++=========================================================================================================================== + Assets:US:ETrade || 10.00 ITOT, 337.18 USD, 2 more.. 70.00 GLD, 18.00 ITOT, 3 more.. -11.00 ITOT, 3 more.. 70.00 GLD, 17.00 ITOT, 3 more.. +------------------++--------------------------------------------------------------------------------------------------------------------------- + || 10.00 ITOT, 337.18 USD, 2 more.. 70.00 GLD, 18.00 ITOT, 3 more.. -11.00 ITOT, 3 more.. 70.00 GLD, 17.00 ITOT, 3 more.. + + +File: hledger.info, Node: Tall layout, Next: Bare layout, Prev: Wide layout, Up: Balance report layout + +30.1.15.2 Tall layout +..................... + +Each commodity gets a new line (may be different in each column), and +account names are repeated: + +$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=tall +Balance changes in 2012-01-01..2014-12-31: + + || 2012 2013 2014 Total +==================++================================================== + Assets:US:ETrade || 10.00 ITOT 70.00 GLD -11.00 ITOT 70.00 GLD + Assets:US:ETrade || 337.18 USD 18.00 ITOT 4881.44 USD 17.00 ITOT + Assets:US:ETrade || 12.00 VEA -98.12 USD 14.00 VEA 5120.50 USD + Assets:US:ETrade || 106.00 VHT 10.00 VEA 170.00 VHT 36.00 VEA + Assets:US:ETrade || 18.00 VHT 294.00 VHT +------------------++-------------------------------------------------- + || 10.00 ITOT 70.00 GLD -11.00 ITOT 70.00 GLD + || 337.18 USD 18.00 ITOT 4881.44 USD 17.00 ITOT + || 12.00 VEA -98.12 USD 14.00 VEA 5120.50 USD + || 106.00 VHT 10.00 VEA 170.00 VHT 36.00 VEA + || 18.00 VHT 294.00 VHT + + +File: hledger.info, Node: Bare layout, Next: Tidy layout, Prev: Tall layout, Up: Balance report layout + +30.1.15.3 Bare layout +..................... + +Commodity symbols are kept in one column, each commodity has its own +row, amounts are bare numbers, account names are repeated: + +$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=bare +Balance changes in 2012-01-01..2014-12-31: + + || Commodity 2012 2013 2014 Total +==================++============================================= + Assets:US:ETrade || GLD 0 70.00 0 70.00 + Assets:US:ETrade || ITOT 10.00 18.00 -11.00 17.00 + Assets:US:ETrade || USD 337.18 -98.12 4881.44 5120.50 + Assets:US:ETrade || VEA 12.00 10.00 14.00 36.00 + Assets:US:ETrade || VHT 106.00 18.00 170.00 294.00 +------------------++--------------------------------------------- + || GLD 0 70.00 0 70.00 + || ITOT 10.00 18.00 -11.00 17.00 + || USD 337.18 -98.12 4881.44 5120.50 + || VEA 12.00 10.00 14.00 36.00 + || VHT 106.00 18.00 170.00 294.00 + + Bare layout also affects CSV output, which is useful for producing +data that is easier to consume, eg for making charts: + +$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -O csv --layout=bare +"account","commodity","balance" +"Assets:US:ETrade","GLD","70.00" +"Assets:US:ETrade","ITOT","17.00" +"Assets:US:ETrade","USD","5120.50" +"Assets:US:ETrade","VEA","36.00" +"Assets:US:ETrade","VHT","294.00" +"total","GLD","70.00" +"total","ITOT","17.00" +"total","USD","5120.50" +"total","VEA","36.00" +"total","VHT","294.00" + + Bare layout will sometimes display an extra row for the no-symbol +commodity, because of zero amounts (hledger treats zeroes as +commodity-less, usually). This can break 'hledger-bar' confusingly +(workaround: add a 'cur:' query to exclude the no-symbol row). + + +File: hledger.info, Node: Tidy layout, Prev: Bare layout, Up: Balance report layout + +30.1.15.4 Tidy layout +..................... + +This produces normalised "tidy data" (see +https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html) +where every variable has its own column and each row represents a single +data point. This is the easiest kind of data for other software to +consume: + +$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -Y -O csv --layout=tidy +"account","period","start_date","end_date","commodity","value" +"Assets:US:ETrade","2012","2012-01-01","2012-12-31","GLD","0" +"Assets:US:ETrade","2012","2012-01-01","2012-12-31","ITOT","10.00" +"Assets:US:ETrade","2012","2012-01-01","2012-12-31","USD","337.18" +"Assets:US:ETrade","2012","2012-01-01","2012-12-31","VEA","12.00" +"Assets:US:ETrade","2012","2012-01-01","2012-12-31","VHT","106.00" +"Assets:US:ETrade","2013","2013-01-01","2013-12-31","GLD","70.00" +"Assets:US:ETrade","2013","2013-01-01","2013-12-31","ITOT","18.00" +"Assets:US:ETrade","2013","2013-01-01","2013-12-31","USD","-98.12" +"Assets:US:ETrade","2013","2013-01-01","2013-12-31","VEA","10.00" +"Assets:US:ETrade","2013","2013-01-01","2013-12-31","VHT","18.00" +"Assets:US:ETrade","2014","2014-01-01","2014-12-31","GLD","0" +"Assets:US:ETrade","2014","2014-01-01","2014-12-31","ITOT","-11.00" +"Assets:US:ETrade","2014","2014-01-01","2014-12-31","USD","4881.44" +"Assets:US:ETrade","2014","2014-01-01","2014-12-31","VEA","14.00" +"Assets:US:ETrade","2014","2014-01-01","2014-12-31","VHT","170.00" + + +File: hledger.info, Node: Some useful balance reports, Prev: Balance report layout, Up: balance + +30.1.16 Some useful balance reports +----------------------------------- + +Some frequently used 'balance' options/reports are: + + * 'bal -M revenues expenses' + Show revenues/expenses in each month. Also available as the + 'incomestatement' command. + + * 'bal -M -H assets liabilities' + Show historical asset/liability balances at each month end. Also + available as the 'balancesheet' command. + + * 'bal -M -H assets liabilities equity' + Show historical asset/liability/equity balances at each month end. + Also available as the 'balancesheetequity' command. + + * 'bal -M assets not:receivable' + Show changes to liquid assets in each month. Also available as the + 'cashflow' command. + + Also: + + * 'bal -M expenses -2 -SA' + Show monthly expenses summarised to depth 2 and sorted by average + amount. + + * 'bal -M --budget expenses' + Show monthly expenses and budget goals. + + * 'bal -M --valuechange investments' + Show monthly change in market value of investment assets. + + * 'bal investments --valuechange -D date:lastweek amt:'>1000' -STA + [--invert]' + Show top gainers [or losers] last week + + +File: hledger.info, Node: roi, Prev: balance, Up: Advanced report commands + +30.2 roi +======== Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on your investments. @@ -10346,8 +9786,8 @@ annual rate.  File: hledger.info, Node: Spaces and special characters in --inv and --pnl, Next: Semantics of --inv and --pnl, Up: roi -24.27.1 Spaces and special characters in '--inv' and ----------------------------------------------------- +30.2.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). @@ -10365,8 +9805,8 @@ $ 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 -24.27.2 Semantics of '--inv' and '--pnl' ----------------------------------------- +30.2.2 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. @@ -10419,8 +9859,8 @@ 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 -24.27.3 IRR and TWR explained ------------------------------ +30.2.3 IRR and TWR explained +---------------------------- "ROI" stands for "return on investment". Traditionally this was computed as a difference between current value of investment and its @@ -10486,89 +9926,658 @@ cash in-flows and out-flows. of both metrics  -File: hledger.info, Node: stats, Next: tags, Prev: roi, Up: PART 4 COMMANDS +File: hledger.info, Node: Chart commands, Next: Data generation commands, Prev: Advanced report commands, Up: Top -24.28 stats -=========== +31 Chart commands +***************** -Show journal and performance statistics. +* Menu: - The stats command shows summary information for the whole journal, or -a matched part of it. With a reporting interval, it shows a report for -each report period. - - The default output is fairly impersonal, though it reveals the main -file name. With '-v/--verbose', more details are shown, like file -paths, included files, and commodity names. - - It also shows some run time statistics: - - * elapsed time - * throughput: the number of transactions processed per second - * live: the peak memory in use by the program to do its work - * alloc: the peak memory allocation from the OS as seen by GHC. - Measuring this externally, eg with GNU time, is more accurate; - usually that will be a larger number; sometimes (with swapping?) - smaller. - - The 'stats' command's run time is similar to that of a balance -report. - - Example: - -$ hledger stats -f examples/1ktxns-1kaccts.journal -Main file : .../1ktxns-1kaccts.journal -Included files : 0 -Txns span : 2000-01-01 to 2002-09-27 (1000 days) -Last txn : 2002-09-26 (7827 days ago) -Txns : 1000 (1.0 per day) -Txns last 30 days : 0 (0.0 per day) -Txns last 7 days : 0 (0.0 per day) -Payees/descriptions : 1000 -Accounts : 1000 (depth 10) -Commodities : 26 -Market prices : 1000 -Runtime stats : 0.12 s elapsed, 8266 txns/s, 4 MB live, 16 MB alloc - - This command supports the -o/-output-file option (but not --O/-output-format). +* activity::  -File: hledger.info, Node: tags, Next: test, Prev: stats, Up: PART 4 COMMANDS +File: hledger.info, Node: activity, Up: Chart commands -24.29 tags -========== +31.1 activity +============= -List the tags used in the journal, or their values. +Show an ascii barchart of posting counts per interval. - This command lists the tag names used in the journal, whether on -transactions, postings, or account declarations. + The activity command displays an ascii histogram showing transaction +counts by day, week, month or other reporting interval (by day is the +default). With query arguments, it counts only matched transactions. - With a TAGREGEX argument, only tag names matching this regular -expression (case insensitive, infix matched) are shown. + Examples: - With QUERY arguments, only transactions and accounts matching this -query are considered. If the query involves transaction fields (date:, -desc:, amt:, ...), the search is restricted to the matched transactions -and their accounts. - - With the -values flag, the tags' unique non-empty values are listed -instead. With -E/-empty, blank/empty values are also shown. - - With -parsed, tags or values are shown in the order they were parsed, -with duplicates included. (Except, tags from account declarations are -always shown first.) - - Tip: remember, accounts also acquire tags from their parents, -postings also acquire tags from their account and transaction, -transactions also acquire tags from their postings. +$ hledger activity --quarterly +2008-01-01 ** +2008-04-01 ******* +2008-07-01 +2008-10-01 **  -File: hledger.info, Node: test, Prev: tags, Up: PART 4 COMMANDS +File: hledger.info, Node: Data generation commands, Next: Maintenance commands, Prev: Chart commands, Up: Top -24.30 test +32 Data generation commands +*************************** + +* Menu: + +* close:: +* rewrite:: + + +File: hledger.info, Node: close, Next: rewrite, Up: Data generation commands + +32.1 close ========== +(equity) + + 'close' generates several kinds of "closing" and/or "opening" +transactions, useful in certain situations, including migrating balances +to a new journal file, retaining earnings into equity, consolidating +balances, or viewing lots. Like 'print', it prints valid journal +entries. You can append or copy these to your journal file(s) when you +are happy with how they look. + + 'close' currently has six modes, selected by a single mode flag: + +* Menu: + +* close --migrate:: +* close --close:: +* close --open:: +* close --assert:: +* close --assign:: +* close --retain:: +* close customisation:: +* close and balance assertions:: +* close examples:: + + +File: hledger.info, Node: close --migrate, Next: close --close, Up: close + +32.1.1 close -migrate +--------------------- + +This is the most common mode. It prints a "closing balances" +transaction that zeroes out all asset and liability balances (by +default), and an opposite "opening balances" transaction that restores +them again. The balancing account will be 'equity:opening/closing +balances' (or another specified by '--close-acct' or '--open-acct'). + + This is useful when migrating balances to a new journal file at the +start of a new year. Essentially, you run 'hledger close +--migrate=NEWYEAR -e NEWYEAR' and then copy the closing transaction to +the end of the old file and the opening transaction to the start of the +new file. The opening transaction sets correct starting balances in the +new file when it is used alone, and the closing transaction keeps +balances correct when you use both old and new files together, by +cancelling out the following opening transaction and preventing buildup +of duplicated opening balances. Think of the closing/opening pair as +"moving the balances into the next file". + + You can close a different set of accounts by providing a query. Eg +if you want to include equity, you can add 'assets liabilities equity' +or 'type:ALE' arguments. (The balancing account is always excluded.) +Revenues and expenses usually are not migrated to a new file directly; +see '--retain' below. + + The generated transactions will have a 'start:' tag, with its value +set to '--migrate''s 'NEW' argument if any, for easier matching or +exclusion. When 'NEW' is not specified, it will be inferred if possible +by incrementing a number (eg a year number) within the default journal's +main file name. The other modes behave similarly. + + +File: hledger.info, Node: close --close, Next: close --open, Prev: close --migrate, Up: close + +32.1.2 close -close +------------------- + +This prints just the closing balances transaction of '--migrate'. It is +the default behaviour if you specify no mode flag. Using the +customisation options below, you can move balances from any set of +accounts to a different account. + + +File: hledger.info, Node: close --open, Next: close --assert, Prev: close --close, Up: close + +32.1.3 close -open +------------------ + +This prints just the opening balances transaction of '--migrate'. It is +similar to Ledger's equity command. + + +File: hledger.info, Node: close --assert, Next: close --assign, Prev: close --open, Up: close + +32.1.4 close -assert +-------------------- + +This prints a "closing balances" transaction (with 'balances:' tag), +that just declares balance assertions for the current balances without +changing them. It could be useful as documention and to guard against +changes. + + +File: hledger.info, Node: close --assign, Next: close --retain, Prev: close --assert, Up: close + +32.1.5 close -assign +-------------------- + +This prints an "opening balances" transaction that restores the account +balances using balance assignments. Balance assignments work regardless +of any previous balance, so a preceding closing balances transaction is +not needed. + + However, omitting the closing balances transaction would unbalance +equity. This is relatively harmless for personal reports, but it +disturbs the accounting equation, removing a source of error detection. +So '--migrate' is generally the best way to set to set balances in new +files, for now. + + +File: hledger.info, Node: close --retain, Next: close customisation, Prev: close --assign, Up: close + +32.1.6 close -retain +-------------------- + +This is like '--close' with different defaults: it prints a "retain +earnings" transaction (with 'retain:' tag), that transfers revenue and +expense balances to 'equity:retained earnings'. + + This is a different kind of closing, called "retaining earnings" or +"closing the books"; it is traditionally performed by businesses at the +end of each accounting period, to consolidate revenues and expenses into +the main equity balance. ("Revenues" and "expenses" are actually equity +by another name, kept separate temporarily for reporting purposes.) + + In personal accounting you generally don't need to do this, unless +you want the 'balancesheetequity' report to show a zero total, +demonstrating that the accounting equation (A-L=E) is satisfied. + + +File: hledger.info, Node: close customisation, Next: close and balance assertions, Prev: close --retain, Up: close + +32.1.7 close customisation +-------------------------- + +In all modes, the following things can be overridden: + + * the accounts to be closed/opened, with account query arguments + * the balancing account, with '--close-acct=ACCT' and/or + '--open-acct=ACCT' + * the transaction descriptions, with '--close-desc=DESC' and + '--open-desc=DESC' + * the transaction's tag value, with a '--MODE=NEW' option argument + * the closing/opening dates, with '-e OPENDATE' + + By default, the closing date is yesterday, or the journal's end date, +whichever is later; and the opening date is always one day after the +closing date. You can change these by specifying a report end date; the +closing date will be the last day of the report period. Eg '-e 2024' +means "close on 2023-12-31, open on 2024-01-01". + + With '--x/--explicit', the balancing amount will be shown explicitly, +and if it involves multiple commodities, a separate posting will be +generated for each of them (similar to 'print -x'). + + With '--interleaved', each individual transfer is shown with source +and destination postings next to each other (perhaps useful for +troubleshooting). + + With '--show-costs', balances' costs are also shown, with different +costs kept separate. This may generate very large journal entries, if +you have many currency conversions or investment transactions. 'close +--show-costs' is currently the best way to view investment lots with +hledger. (To move or dispose of lots, see the more capable +'hledger-move' script.) + + +File: hledger.info, Node: close and balance assertions, Next: close examples, Prev: close customisation, Up: close + +32.1.8 close and balance assertions +----------------------------------- + +'close' adds balance assertions verifying that the accounts have been +reset to zero in a closing transaction or restored to their previous +balances in an opening transaction. These provide useful error +checking, but you can ignore them temporarily with '-I', or remove them +if you prefer. + + Single-commodity, subaccount-exclusive balance assertions ('=') are +generated by default. This can be changed with '--assertion-type='==*'' +(eg). + + When running 'close' you should probably avoid using '-C', '-R', +'status:' (filtering by status or realness) or '--auto' (generating +postings), since the generated balance assertions would then require +these. + + Transactions with multiple dates (eg posting dates) spanning the file +boundary also can disrupt the balance assertions: + +2023-12-30 a purchase made in december, cleared in january + expenses:food 5 + assets:bank:checking -5 ; date: 2023-01-02 + + To solve this you can transfer the money to and from a temporary +account, splitting the multi-day transaction into two single-day +transactions: + +; in 2022.journal: +2022-12-30 a purchase made in december, cleared in january + expenses:food 5 + equity:pending -5 + +; in 2023.journal: +2023-01-02 last year's transaction cleared + equity:pending 5 = 0 + assets:bank:checking -5 + + +File: hledger.info, Node: close examples, Prev: close and balance assertions, Up: close + +32.1.9 close examples +--------------------- + +* Menu: + +* Retain earnings:: +* Migrate balances to a new file:: +* More detailed close examples:: + + +File: hledger.info, Node: Retain earnings, Next: Migrate balances to a new file, Up: close examples + +32.1.9.1 Retain earnings +........................ + +Record 2022's revenues/expenses as retained earnings on 2022-12-31, +appending the generated transaction to the journal: + +$ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal + + After this, to see 2022's revenues and expenses you must exclude the +retain earnings transaction: + +$ hledger -f 2022.journal is not:desc:'retain earnings' + + +File: hledger.info, Node: Migrate balances to a new file, Next: More detailed close examples, Prev: Retain earnings, Up: close examples + +32.1.9.2 Migrate balances to a new file +....................................... + +Close assets/liabilities on 2022-12-31 and re-open them on 2023-01-01: + +$ hledger close --migrate -f 2022.journal -p 2022 +# copy/paste the closing transaction to the end of 2022.journal +# copy/paste the opening transaction to the start of 2023.journal + + After this, to see 2022's end-of-year balances you must exclude the +closing balances transaction: + +$ hledger -f 2022.journal bs not:desc:'closing balances' + + For more flexibility, it helps to tag closing and opening +transactions with eg 'start:NEWYEAR', then you can ensure correct +balances by excluding all opening/closing transactions except the first, +like so: + +$ hledger bs -Y -f 2021.j -f 2022.j -f 2023.j expr:'tag:start=2021 or not tag:start' +$ hledger bs -Y -f 2021.j -f 2022.j expr:'tag:start=2021 or not tag:start' +$ hledger bs -Y -f 2022.j -f 2023.j expr:'tag:start=2022 or not tag:start' +$ hledger bs -Y -f 2021.j expr:'tag:start=2021 or not tag:start' +$ hledger bs -Y -f 2022.j expr:'tag:start=2022 or not tag:start' +$ hledger bs -Y -f 2023.j # unclosed file, no query needed + + +File: hledger.info, Node: More detailed close examples, Prev: Migrate balances to a new file, Up: close examples + +32.1.9.3 More detailed close examples +..................................... + +See examples/multi-year. + + +File: hledger.info, Node: rewrite, Prev: close, Up: Data generation commands + +32.2 rewrite +============ + +Print all transactions, rewriting the postings of matched transactions. +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 one or more specified postings to any transactions matching QUERY. +The posting amounts can be fixed, or a multiplier of the existing +transaction's first posting amount. + + Examples: + +$ hledger-rewrite.hs ^income --add-posting '(liabilities:tax) *.33 ; income tax' --add-posting '(reserve:gifts) $100' +$ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts) *-1"' +$ hledger-rewrite.hs -f rewrites.hledger + + rewrites.hledger may consist of entries like: + += ^income amt:<0 date:2017 + (liabilities:tax) *0.33 ; tax on income + (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 +two spaces between account and amount. + + More: + +$ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ... +$ hledger rewrite -- ^income --add-posting '(liabilities:tax) *.33' +$ 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 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 +commodity. + +* Menu: + +* Re-write rules in a file:: +* Diff output format:: +* rewrite vs print --auto:: + + +File: hledger.info, Node: Re-write rules in a file, Next: Diff output format, Up: rewrite + +32.2.1 Re-write rules in a file +------------------------------- + +During the run this tool will execute so called "Automated Transactions" +found in any journal it process. I.e instead of specifying this +operations in command line you can put them in a journal file. + +$ rewrite-rules.journal + + Make contents look like this: + += ^income + (liabilities:tax) *.33 + += expenses:gifts + budget:gifts *-1 + assets:budget *1 + + Note that ''='' (equality symbol) that is used instead of date in +transactions you usually write. It indicates the query by which you +want to match the posting to add new ones. + +$ hledger rewrite -- -f input.journal -f rewrite-rules.journal > rewritten-tidy-output.journal + + This is something similar to the commands pipeline: + +$ hledger rewrite -- -f input.journal '^income' --add-posting '(liabilities:tax) *.33' \ + | hledger rewrite -- -f - expenses:gifts --add-posting 'budget:gifts *-1' \ + --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 +postings. + + +File: hledger.info, Node: Diff output format, Next: rewrite vs print --auto, Prev: Re-write rules in a file, Up: rewrite + +32.2.2 Diff output format +------------------------- + +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' + + Output might look like: + +--- /tmp/examples/sample.journal ++++ /tmp/examples/sample.journal +@@ -18,3 +18,4 @@ + 2008/01/01 income +- assets:bank:checking $1 ++ assets:bank:checking $1 + income:salary ++ (liabilities:tax) 0 +@@ -22,3 +23,4 @@ + 2008/06/01 gift +- assets:bank:checking $1 ++ assets:bank:checking $1 + income:gifts ++ (liabilities:tax) 0 + + If you'll pass this through 'patch' tool you'll get transactions +containing the posting that matches your query be updated. Note that +multiple 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 from 'hledger print'. + + See also: + + https://github.com/simonmichael/hledger/issues/99 + + +File: hledger.info, Node: rewrite vs print --auto, Prev: Diff output format, Up: rewrite + +32.2.3 rewrite vs. print -auto +------------------------------ + +This command predates print -auto, and currently does much the same +thing, but with these differences: + + * with multiple files, rewrite lets rules in any file affect all + other files. print -auto uses standard directive scoping; rules + affect only child files. + + * rewrite's query limits which transactions can be rewritten; all are + printed. print -auto's query limits which transactions are + printed. + + * rewrite applies rules specified on command line or in the journal. + print -auto applies rules specified in the journal. + + +File: hledger.info, Node: Maintenance commands, Next: PART 5 COMMON TASKS, Prev: Data generation commands, Up: Top + +33 Maintenance commands +*********************** + +* Menu: + +* check:: +* diff:: +* test:: + + +File: hledger.info, Node: check, Next: diff, Up: Maintenance commands + +33.1 check +========== + +Check for various kinds of errors in your data. + + hledger provides a number of built-in correctness checks to help +validate your data and prevent errors. Some are run automatically, some +when you enable '--strict' mode; or you can run any of them on demand by +providing them as arguments to the 'check' command. 'check' produces no +output and a zero exit code if all is well. Eg: + +hledger check # run basic checks +hledger check -s # run basic and strict checks +hledger check ordereddates payees # run basic checks and two others + + If you are an Emacs user, you can also configure flycheck-hledger to +run these checks, providing instant feedback as you edit the journal. + + Here are the checks currently available. Generally, they are +performed in the order they are shown here (and only the first failure +is reported). + +* Menu: + +* Basic checks:: +* Strict checks:: +* Other checks:: +* Custom checks:: + + +File: hledger.info, Node: Basic checks, Next: Strict checks, Up: check + +33.1.1 Basic checks +------------------- + +These important checks are performed by default, by almost all hledger +commands: + + * *parseable* - data files are in a supported format, with no syntax + errors and no invalid include directives. This ensures that all + files exist and are readable. + + * *autobalanced* - all transactions are balanced, after inferring + missing amounts and conversion costs where possible, and then + converting to cost. This ensures that each individual transaction + is well formed. + + * *assertions* - all balance assertions in the journal are passing. + Balance assertions are like canaries in your journal, they catch + many problems. They can get in the way sometimes; you can disable + them temporarily with '-I'/'--ignore-assertions' (unless overridden + with '-s'/'--strict' or 'hledger check assertions'). + + +File: hledger.info, Node: Strict checks, Next: Other checks, Prev: Basic checks, Up: check + +33.1.2 Strict checks +-------------------- + +These additional checks are performed by any command when the +'-s'/'--strict' flag is used (strict mode). Strict mode always enables +the balance assertions check, also. These provide extra error-catching +power when you are serious about keeping your data clean and free of +typos: + + * *balanced* - like 'autobalanced', but in conversion transactions, + costs must be written explicitly. This ensures some redundancy in + the entry, which helps prevent typos. + + * *commodities* - all commodity symbols used must be declared. This + guards against mistyping or omitting commodity symbols. + + * *accounts* - all account names used must be declared. This + prevents the use of mis-spelled or outdated account names. + + +File: hledger.info, Node: Other checks, Next: Custom checks, Prev: Strict checks, Up: check + +33.1.3 Other checks +------------------- + +These other checks are not wanted by everyone, but can be run using the +'check' command: + + * *ordereddates* - within each file, transactions are ordered by + date. This is a simple and effective error catcher, and you should + use it. Alas! not everyone wants it. If you do, use 'hledger + check -s ordereddates'. When enabled, this check is performed + early, before balance assertions (because copy-pasted dates are + often the root cause of balance assertion failures). + + * *payees* - all payees used by transactions must be declared. This + will force you to always use known/declared payee names. For most + people this is a bit too restrictive. + + * *tags* - all tags used by transactions must be declared. This + prevents mistyped tag names. + + * *recentassertions* - all accounts with balance assertions must have + a balance assertion within the last 7 days before their latest + posting. This encourages you to add balance assertions fairly + regularly for your active asset/liability accounts, which in turn + should encourage you to check and reconcile with their real world + balances fairly regularly. 'close --assert' can be helpful. (The + older balance assertions become redundant; you can remove them + periodically, or leave them in place, perhaps commented, as + documentation.) + + * *uniqueleafnames* - no two accounts may have the same leaf name. + The leaf name is the last colon-separated part of an account name, + eg 'checking' in 'assets:bank:checking'. This encourages you to + keep those unique, effectively giving each account a short name + which is easier to remember and to type in reporting commands. + + +File: hledger.info, Node: Custom checks, Prev: Other checks, Up: check + +33.1.4 Custom checks +-------------------- + +You can build your own custom checks with add-on command scripts. See +also Cookbook > Scripting. Here are some examples from hledger/bin/: + + * *hledger-check-tagfiles* - all tag values containing / (a forward + slash) exist as file paths + + * *hledger-check-fancyassertions* - more complex balance assertions + are passing + + +File: hledger.info, Node: diff, Next: test, Prev: check, Up: Maintenance commands + +33.2 diff +========= + +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.) +Since postings not transactions are compared, this also works when +multiple 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 the account balance, you can compare the bank data with your +journal to find out the cause. + + Examples: + +$ hledger diff -f $LEDGER_FILE -f bank.csv assets:bank:giro +These transactions are in the first file only: + +2014/01/01 Opening Balances + assets:bank:giro EUR ... + ... + equity:opening balances EUR -... + +These transactions are in the second file only: + + +File: hledger.info, Node: test, Prev: diff, Up: Maintenance commands + +33.3 test +========= + Run built-in unit tests. This command runs the unit tests built in to hledger and hledger-lib, @@ -10590,30 +10599,18 @@ $ hledger test -- -pData.Amount --color=never ('-- --help' currently doesn't show them).  -File: hledger.info, Node: PART 5 COMMON TASKS, Next: BUGS, Prev: PART 4 COMMANDS, Up: Top +File: hledger.info, Node: PART 5 COMMON TASKS, Next: Getting help, Prev: Maintenance commands, Up: Top -25 PART 5: COMMON TASKS +34 PART 5: COMMON TASKS *********************** Here are some quick examples of how to do some basic tasks with hledger. -* Menu: - -* Getting help:: -* Constructing command lines:: -* Starting a journal file:: -* Setting LEDGER_FILE:: -* Setting opening balances:: -* Recording transactions:: -* Reconciling:: -* Reporting:: -* Migrating to a new file:: -  -File: hledger.info, Node: Getting help, Next: Constructing command lines, Up: PART 5 COMMON TASKS +File: hledger.info, Node: Getting help, Next: Constructing command lines, Prev: PART 5 COMMON TASKS, Up: Top -25.1 Getting help -================= +35 Getting help +*************** Here's how to list commands and view options and command docs: @@ -10633,10 +10630,10 @@ https://hledger.org. Chat and mail list support and discussion archives can be found at https://hledger.org/support.  -File: hledger.info, Node: Constructing command lines, Next: Starting a journal file, Prev: Getting help, Up: PART 5 COMMON TASKS +File: hledger.info, Node: Constructing command lines, Next: Starting a journal file, Prev: Getting help, Up: Top -25.2 Constructing command lines -=============================== +36 Constructing command lines +***************************** hledger has a flexible command line interface. We strive to keep it simple and ergonomic, but if you run into one of the sharp edges @@ -10653,10 +10650,10 @@ described in OPTIONS, here are some tips that might help: '--debug=2'.  -File: hledger.info, Node: Starting a journal file, Next: Setting LEDGER_FILE, Prev: Constructing command lines, Up: PART 5 COMMON TASKS +File: hledger.info, Node: Starting a journal file, Next: Setting LEDGER_FILE, Prev: Constructing command lines, Up: Top -25.3 Starting a journal file -============================ +37 Starting a journal file +************************** hledger looks for your accounting data in a journal file, '$HOME/.hledger.journal' by default: @@ -10692,10 +10689,10 @@ Commodities : 0 () Market prices : 0 ()  -File: hledger.info, Node: Setting LEDGER_FILE, Next: Setting opening balances, Prev: Starting a journal file, Up: PART 5 COMMON TASKS +File: hledger.info, Node: Setting LEDGER_FILE, Next: Setting opening balances, Prev: Starting a journal file, Up: Top -25.4 Setting LEDGER_FILE -======================== +38 Setting LEDGER_FILE +********************** How to set 'LEDGER_FILE' permanently depends on your setup: @@ -10728,10 +10725,10 @@ persists across a reboot, and if you need to be an Administrator): > SETX LEDGER_FILE "C:\Users\USERNAME\finance\2023.journal"  -File: hledger.info, Node: Setting opening balances, Next: Recording transactions, Prev: Setting LEDGER_FILE, Up: PART 5 COMMON TASKS +File: hledger.info, Node: Setting opening balances, Next: Recording transactions, Prev: Setting LEDGER_FILE, Up: Top -25.5 Setting opening balances -============================= +39 Setting opening balances +*************************** Pick a starting date for which you can look up the balances of some real-world assets (bank accounts, wallet..) and liabilities (credit @@ -10811,10 +10808,10 @@ the journal. Eg: $ git commit -m 'initial balances' 2023.journal  -File: hledger.info, Node: Recording transactions, Next: Reconciling, Prev: Setting opening balances, Up: PART 5 COMMON TASKS +File: hledger.info, Node: Recording transactions, Next: Reconciling, Prev: Setting opening balances, Up: Top -25.6 Recording transactions -=========================== +40 Recording transactions +************************* As you spend or receive money, you can record these transactions using one of the methods above (text editor, hledger add) or by using the @@ -10837,10 +10834,10 @@ and hledger.org for more ideas: assets:bank:checking $1000  -File: hledger.info, Node: Reconciling, Next: Reporting, Prev: Recording transactions, Up: PART 5 COMMON TASKS +File: hledger.info, Node: Reconciling, Next: Reporting, Prev: Recording transactions, Up: Top -25.7 Reconciling -================ +41 Reconciling +************** Periodically you should reconcile - compare your hledger-reported balances against external sources of truth, like bank statements or your @@ -10892,10 +10889,10 @@ commit: $ git commit -m 'txns' 2023.journal  -File: hledger.info, Node: Reporting, Next: Migrating to a new file, Prev: Reconciling, Up: PART 5 COMMON TASKS +File: hledger.info, Node: Reporting, Next: Migrating to a new file, Prev: Reconciling, Up: Top -25.8 Reporting -============== +42 Reporting +************ Here are some basic reports. @@ -11040,10 +11037,10 @@ $ hledger activity -W 2023-01-13 ****  -File: hledger.info, Node: Migrating to a new file, Prev: Reporting, Up: PART 5 COMMON TASKS +File: hledger.info, Node: Migrating to a new file, Next: BUGS, Prev: Reporting, Up: Top -25.9 Migrating to a new file -============================ +43 Migrating to a new file +************************** At the end of the year, you may want to continue your journal in a new file, so that old transactions don't slow down or clutter your reports, @@ -11053,9 +11050,9 @@ close command. If using version control, don't forget to 'git add' the new file.  -File: hledger.info, Node: BUGS, Prev: PART 5 COMMON TASKS, Up: Top +File: hledger.info, Node: BUGS, Prev: Migrating to a new file, Up: Top -26 BUGS +44 BUGS ******* We welcome bug reports in the hledger issue tracker (shortcut: @@ -11087,7 +11084,7 @@ Ledger.  File: hledger.info, Node: Troubleshooting, Up: BUGS -26.1 Troubleshooting +44.1 Troubleshooting ==================== Here are some common issues you might encounter when you run hledger, @@ -11144,690 +11141,686 @@ See hledger and Ledger for full details.  Tag Table: Node: Top208 -Node: PART 1 USER INTERFACE3812 -Ref: #part-1-user-interface3951 -Node: Input3951 -Ref: #input4061 -Node: Text encoding5028 -Ref: #text-encoding5142 -Node: Data formats5708 -Ref: #data-formats5843 -Node: Standard input7432 -Ref: #standard-input7572 -Node: Multiple files7799 -Ref: #multiple-files7938 -Node: Strict mode8536 -Ref: #strict-mode8646 -Node: Commands9370 -Ref: #commands9472 -Node: Add-on commands10539 -Ref: #add-on-commands10641 -Node: Options11757 -Ref: #options11869 -Node: General help options12197 -Ref: #general-help-options12343 -Node: General input options12625 -Ref: #general-input-options12807 -Node: General reporting options13464 -Ref: #general-reporting-options13625 -Node: Command line tips17015 -Ref: #command-line-tips17145 -Node: Option repetition17404 -Ref: #option-repetition17548 -Node: Special characters17652 -Ref: #special-characters17825 -Node: Single escaping shell metacharacters17988 -Ref: #single-escaping-shell-metacharacters18229 -Node: Double escaping regular expression metacharacters18832 -Ref: #double-escaping-regular-expression-metacharacters19143 -Node: Triple escaping for add-on commands19669 -Ref: #triple-escaping-for-add-on-commands19929 -Node: Less escaping20573 -Ref: #less-escaping20727 -Node: Unicode characters21051 -Ref: #unicode-characters21226 -Node: Regular expressions22638 -Ref: #regular-expressions22811 -Node: hledger's regular expressions25907 -Ref: #hledgers-regular-expressions26066 -Node: Argument files27452 -Ref: #argument-files27588 -Node: Output28085 -Ref: #output28197 -Node: Output destination28324 -Ref: #output-destination28455 -Node: Output format28880 -Ref: #output-format29026 -Node: CSV output30623 -Ref: #csv-output30739 -Node: HTML output30842 -Ref: #html-output30980 -Node: JSON output31074 -Ref: #json-output31212 -Node: SQL output32134 -Ref: #sql-output32250 -Node: Commodity styles32985 -Ref: #commodity-styles33125 -Node: Colour33863 -Ref: #colour33981 -Node: Box-drawing34385 -Ref: #box-drawing34503 -Node: Paging34793 -Ref: #paging34907 -Node: Debug output35860 -Ref: #debug-output35966 -Node: Environment36629 -Ref: #environment36753 -Node: PART 2 DATA FORMATS37297 -Ref: #part-2-data-formats37440 -Node: Journal37440 -Ref: #journal37549 -Node: Journal cheatsheet39917 -Ref: #journal-cheatsheet40044 -Node: Comments46131 -Ref: #comments46259 -Node: Transactions47075 -Ref: #transactions47198 -Node: Dates48212 -Ref: #dates48319 -Node: Simple dates48364 -Ref: #simple-dates48480 -Node: Posting dates48980 -Ref: #posting-dates49098 -Node: Status50067 -Ref: #status50168 -Node: Code51833 -Ref: #code51936 -Node: Description52168 -Ref: #description52299 -Node: Payee and note52855 -Ref: #payee-and-note52961 -Node: Transaction comments53946 -Ref: #transaction-comments54099 -Node: Postings54462 -Ref: #postings54593 -Node: Debits and credits55625 -Ref: #debits-and-credits55772 -Node: The two space delimiter56235 -Ref: #the-two-space-delimiter56392 -Node: Account names56800 -Ref: #account-names56930 -Node: Amounts58604 -Ref: #amounts58732 -Node: Decimal marks59633 -Ref: #decimal-marks59760 -Node: Digit group marks60737 -Ref: #digit-group-marks60890 -Node: Commodity61372 -Ref: #commodity61501 -Node: Costs62489 -Ref: #costs62584 -Node: Balance assertions64741 -Ref: #balance-assertions64894 -Node: Assertions and ordering65978 -Ref: #assertions-and-ordering66167 -Node: Assertions and multiple included files66706 -Ref: #assertions-and-multiple-included-files66966 -Node: Assertions and multiple -f files67466 -Ref: #assertions-and-multiple--f-files67711 -Node: Assertions and costs68108 -Ref: #assertions-and-costs68317 -Node: Assertions and commodities68758 -Ref: #assertions-and-commodities68973 -Node: Assertions and subaccounts70417 -Ref: #assertions-and-subaccounts70643 -Node: Assertions and virtual postings71087 -Ref: #assertions-and-virtual-postings71325 -Node: Assertions and auto postings71457 -Ref: #assertions-and-auto-postings71687 -Node: Assertions and precision72332 -Ref: #assertions-and-precision72514 -Node: Posting comments72781 -Ref: #posting-comments72944 -Node: Transaction balancing73321 -Ref: #transaction-balancing73480 -Node: Tags75323 -Ref: #tags75442 -Node: Tag names76785 -Ref: #tag-names76892 -Node: Special tags77280 -Ref: #special-tags77412 -Node: Tag values78925 -Ref: #tag-values79035 -Node: Directives79907 -Ref: #directives80034 -Node: Directives and multiple files81364 -Ref: #directives-and-multiple-files81542 -Node: Directive effects82309 -Ref: #directive-effects82463 -Node: account directive85465 -Ref: #account-directive85621 -Node: Account comments86915 -Ref: #account-comments87066 -Node: Account error checking87574 -Ref: #account-error-checking87767 -Node: Account display order88956 -Ref: #account-display-order89144 -Node: Account types90154 -Ref: #account-types90295 -Node: alias directive93928 -Ref: #alias-directive94089 -Node: Basic aliases95139 -Ref: #basic-aliases95270 -Node: Regex aliases96014 -Ref: #regex-aliases96171 -Node: Combining aliases97061 -Ref: #combining-aliases97239 -Node: Aliases and multiple files98515 -Ref: #aliases-and-multiple-files98719 -Node: end aliases directive99298 -Ref: #end-aliases-directive99517 -Node: Aliases can generate bad account names99666 -Ref: #aliases-can-generate-bad-account-names99914 -Node: Aliases and account types100499 -Ref: #aliases-and-account-types100691 -Node: commodity directive101387 -Ref: #commodity-directive101561 -Node: Commodity directive syntax102974 -Ref: #commodity-directive-syntax103159 -Node: Commodity error checking104610 -Ref: #commodity-error-checking104791 -Node: decimal-mark directive105085 -Ref: #decimal-mark-directive105267 -Node: include directive105664 -Ref: #include-directive105828 -Node: P directive106740 -Ref: #p-directive106885 -Node: payee directive107774 -Ref: #payee-directive107923 -Node: tag directive108396 -Ref: #tag-directive108551 -Node: Periodic transactions109008 -Ref: #periodic-transactions109173 -Node: Periodic rule syntax111162 -Ref: #periodic-rule-syntax111340 -Node: Periodic rules and relative dates111985 -Ref: #periodic-rules-and-relative-dates112251 -Node: Two spaces between period expression and description!112762 -Ref: #two-spaces-between-period-expression-and-description113039 -Node: Auto postings113723 -Ref: #auto-postings113871 -Node: Auto postings and multiple files116701 -Ref: #auto-postings-and-multiple-files116865 -Node: Auto postings and dates117266 -Ref: #auto-postings-and-dates117514 -Node: Auto postings and transaction balancing / inferred amounts / balance assertions117689 -Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions118045 -Node: Auto posting tags118548 -Ref: #auto-posting-tags118830 -Node: Auto postings on forecast transactions only119466 -Ref: #auto-postings-on-forecast-transactions-only119712 -Node: Other syntax119959 -Ref: #other-syntax120075 -Node: Balance assignments120731 -Ref: #balance-assignments120887 -Node: Balance assignments and costs122259 -Ref: #balance-assignments-and-costs122471 -Node: Balance assignments and multiple files122681 -Ref: #balance-assignments-and-multiple-files122911 -Node: Bracketed posting dates123104 -Ref: #bracketed-posting-dates123288 -Node: D directive123802 -Ref: #d-directive123970 -Node: apply account directive125575 -Ref: #apply-account-directive125755 -Node: Y directive126442 -Ref: #y-directive126602 -Node: Secondary dates127430 -Ref: #secondary-dates127584 -Node: Star comments128398 -Ref: #star-comments128558 -Node: Valuation expressions129090 -Ref: #valuation-expressions129267 -Node: Virtual postings129389 -Ref: #virtual-postings129566 -Node: Other Ledger directives131013 -Ref: #other-ledger-directives131209 -Node: Other cost/lot notations131775 -Ref: #other-costlot-notations131948 -Node: CSV134537 -Ref: #csv134630 -Node: CSV rules cheatsheet136627 -Ref: #csv-rules-cheatsheet136756 -Node: source138554 -Ref: #source138677 -Node: separator139557 -Ref: #separator139670 -Node: skip140210 -Ref: #skip140318 -Node: date-format140862 -Ref: #date-format140983 -Node: timezone141707 -Ref: #timezone141830 -Node: newest-first142835 -Ref: #newest-first142973 -Node: intra-day-reversed143550 -Ref: #intra-day-reversed143704 -Node: decimal-mark144152 -Ref: #decimal-mark144293 -Node: fields list144632 -Ref: #fields-list144771 -Node: Field assignment146442 -Ref: #field-assignment146586 -Node: Field names147663 -Ref: #field-names147794 -Node: date field148997 -Ref: #date-field149115 -Node: date2 field149163 -Ref: #date2-field149304 -Node: status field149360 -Ref: #status-field149503 -Node: code field149552 -Ref: #code-field149697 -Node: description field149742 -Ref: #description-field149902 -Node: comment field149961 -Ref: #comment-field150116 -Node: account field150409 -Ref: #account-field150559 -Node: amount field151129 -Ref: #amount-field151278 -Node: currency field153970 -Ref: #currency-field154123 -Node: balance field154380 -Ref: #balance-field154512 -Node: if block154905 -Ref: #if-block155026 -Node: Matchers156434 -Ref: #matchers156548 -Node: What matchers match157345 -Ref: #what-matchers-match157494 -Node: Combining matchers157934 -Ref: #combining-matchers158102 -Node: Match groups158639 -Ref: #match-groups158767 -Node: if table159535 -Ref: #if-table159657 -Node: balance-type161538 -Ref: #balance-type161667 -Node: include162367 -Ref: #include162494 -Node: Working with CSV162938 -Ref: #working-with-csv163085 -Node: Rapid feedback163492 -Ref: #rapid-feedback163625 -Node: Valid CSV164077 -Ref: #valid-csv164223 -Node: File Extension164955 -Ref: #file-extension165128 -Node: Reading CSV from standard input165692 -Ref: #reading-csv-from-standard-input165916 -Node: Reading multiple CSV files166080 -Ref: #reading-multiple-csv-files166311 -Node: Reading files specified by rule166552 -Ref: #reading-files-specified-by-rule166780 -Node: Valid transactions167951 -Ref: #valid-transactions168150 -Node: Deduplicating importing168778 -Ref: #deduplicating-importing168973 -Node: Setting amounts170009 -Ref: #setting-amounts170180 -Node: Amount signs172538 -Ref: #amount-signs172708 -Node: Setting currency/commodity173605 -Ref: #setting-currencycommodity173809 -Node: Amount decimal places174983 -Ref: #amount-decimal-places175189 -Node: Referencing other fields175501 -Ref: #referencing-other-fields175714 -Node: How CSV rules are evaluated176611 -Ref: #how-csv-rules-are-evaluated176828 -Node: Well factored rules178281 -Ref: #well-factored-rules178449 -Node: CSV rules examples178773 -Ref: #csv-rules-examples178908 -Node: Bank of Ireland178973 -Ref: #bank-of-ireland179110 -Node: Coinbase180572 -Ref: #coinbase180710 -Node: Amazon181757 -Ref: #amazon181882 -Node: Paypal183601 -Ref: #paypal183709 -Node: Timeclock191353 -Ref: #timeclock191458 -Node: Timedot193634 -Ref: #timedot193757 -Node: Timedot examples196878 -Ref: #timedot-examples196984 -Node: PART 3 REPORTING CONCEPTS199155 -Ref: #part-3-reporting-concepts199324 -Node: Amount formatting199324 -Ref: #amount-formatting199480 -Node: Commodity display style199582 -Ref: #commodity-display-style199736 -Node: Rounding201423 -Ref: #rounding201578 -Node: Trailing decimal marks202028 -Ref: #trailing-decimal-marks202207 -Node: Amount parseability202961 -Ref: #amount-parseability203117 -Node: Time periods204542 -Ref: #time-periods204668 -Node: Report start & end date204786 -Ref: #report-start-end-date204938 -Node: Smart dates206597 -Ref: #smart-dates206750 -Node: Report intervals208618 -Ref: #report-intervals208773 -Node: Date adjustment209191 -Ref: #date-adjustment209351 -Node: Period expressions210202 -Ref: #period-expressions210343 -Node: Period expressions with a report interval212107 -Ref: #period-expressions-with-a-report-interval212341 -Node: More complex report intervals212555 -Ref: #more-complex-report-intervals212800 -Node: Multiple weekday intervals214601 -Ref: #multiple-weekday-intervals214790 -Node: Depth215612 -Ref: #depth215714 -Node: Queries216010 -Ref: #queries216112 -Node: Query types217708 -Ref: #query-types217829 -Node: Combining query terms221063 -Ref: #combining-query-terms221240 -Node: Queries and command options222803 -Ref: #queries-and-command-options223008 -Node: Queries and account aliases223257 -Ref: #queries-and-account-aliases223462 -Node: Queries and valuation223582 -Ref: #queries-and-valuation223739 -Node: Pivoting223944 -Ref: #pivoting224058 -Node: Generating data225835 -Ref: #generating-data225967 -Node: Forecasting227550 -Ref: #forecasting227675 -Node: --forecast228206 -Ref: #forecast228337 -Node: Inspecting forecast transactions229307 -Ref: #inspecting-forecast-transactions229509 -Node: Forecast reports230639 -Ref: #forecast-reports230812 -Node: Forecast tags231748 -Ref: #forecast-tags231908 -Node: Forecast period in detail232368 -Ref: #forecast-period-in-detail232562 -Node: Forecast troubleshooting233456 -Ref: #forecast-troubleshooting233624 -Node: Budgeting234527 -Ref: #budgeting234647 -Node: Cost reporting235084 -Ref: #cost-reporting235218 -Node: Recording costs235879 -Ref: #recording-costs236015 -Node: Reporting at cost237606 -Ref: #reporting-at-cost237781 -Node: Equity conversion postings238371 -Ref: #equity-conversion-postings238585 -Node: Inferring equity conversion postings241016 -Ref: #inferring-equity-conversion-postings241279 -Node: Combining costs and equity conversion postings242031 -Ref: #combining-costs-and-equity-conversion-postings242341 -Node: Requirements for detecting equity conversion postings243256 -Ref: #requirements-for-detecting-equity-conversion-postings243578 -Node: Infer cost and equity by default ?244778 -Ref: #infer-cost-and-equity-by-default245007 -Node: Value reporting245215 -Ref: #value-reporting245357 -Node: -V Value246096 -Ref: #v-value246228 -Node: -X Value in specified commodity246423 -Ref: #x-value-in-specified-commodity246624 -Node: Valuation date246773 -Ref: #valuation-date246950 -Node: Finding market price247733 -Ref: #finding-market-price247944 -Node: --infer-market-prices market prices from transactions249113 -Ref: #infer-market-prices-market-prices-from-transactions249395 -Node: Valuation commodity252157 -Ref: #valuation-commodity252377 -Node: --value Flexible valuation253590 -Ref: #value-flexible-valuation253789 -Node: Valuation examples255433 -Ref: #valuation-examples255633 -Node: Interaction of valuation and queries257565 -Ref: #interaction-of-valuation-and-queries257805 -Node: Effect of valuation on reports258282 -Ref: #effect-of-valuation-on-reports258485 -Node: PART 4 COMMANDS266180 -Ref: #part-4-commands266329 -Node: Commands overview266708 -Ref: #commands-overview266842 -Node: DATA ENTRY267021 -Ref: #data-entry267145 -Node: DATA CREATION267344 -Ref: #data-creation267498 -Node: DATA MANAGEMENT267616 -Ref: #data-management267781 -Node: REPORTS FINANCIAL267902 -Ref: #reports-financial268077 -Node: REPORTS VERSATILE268382 -Ref: #reports-versatile268555 -Node: REPORTS BASIC268808 -Ref: #reports-basic268960 -Node: HELP269469 -Ref: #help269591 -Node: ADD-ONS269701 -Ref: #add-ons269807 -Node: accounts270386 -Ref: #accounts270519 -Node: activity272406 -Ref: #activity272525 -Node: add272899 -Ref: #add273009 -Node: aregister275995 -Ref: #aregister276116 -Node: aregister and posting dates279022 -Ref: #aregister-and-posting-dates279167 -Node: balance279923 -Ref: #balance280049 -Node: balance features281039 -Ref: #balance-features281179 -Node: Simple balance report283089 -Ref: #simple-balance-report283274 -Node: Balance report line format284899 -Ref: #balance-report-line-format285101 -Node: Filtered balance report287259 -Ref: #filtered-balance-report287451 -Node: List or tree mode287778 -Ref: #list-or-tree-mode287946 -Node: Depth limiting289291 -Ref: #depth-limiting289457 -Node: Dropping top-level accounts290058 -Ref: #dropping-top-level-accounts290258 -Node: Showing declared accounts290568 -Ref: #showing-declared-accounts290767 -Node: Sorting by amount291298 -Ref: #sorting-by-amount291465 -Node: Percentages292135 -Ref: #percentages292294 -Node: Multi-period balance report292842 -Ref: #multi-period-balance-report293042 -Node: Balance change end balance295419 -Ref: #balance-change-end-balance295628 -Node: Balance report types297056 -Ref: #balance-report-types297237 -Node: Calculation type297735 -Ref: #calculation-type297890 -Node: Accumulation type298439 -Ref: #accumulation-type298619 -Node: Valuation type299540 -Ref: #valuation-type299728 -Node: Combining balance report types300729 -Ref: #combining-balance-report-types300923 -Node: Budget report302761 -Ref: #budget-report302923 -Node: Using the budget report305066 -Ref: #using-the-budget-report305239 -Node: Budget date surprises307342 -Ref: #budget-date-surprises307542 -Node: Selecting budget goals308706 -Ref: #selecting-budget-goals308909 -Node: Budgeting vs forecasting309654 -Ref: #budgeting-vs-forecasting309831 -Node: Balance report layout311331 -Ref: #balance-report-layout311516 -Node: Wide layout312469 -Ref: #wide-layout312604 -Node: Tall layout314874 -Ref: #tall-layout315029 -Node: Bare layout316180 -Ref: #bare-layout316335 -Node: Tidy layout318239 -Ref: #tidy-layout318374 -Node: Some useful balance reports319783 -Ref: #some-useful-balance-reports319958 -Node: balancesheet321043 -Ref: #balancesheet321188 -Node: balancesheetequity322799 -Ref: #balancesheetequity322957 -Node: cashflow324977 -Ref: #cashflow325108 -Node: check326595 -Ref: #check326709 -Node: Default checks327513 -Ref: #default-checks327639 -Node: Strict checks328136 -Ref: #strict-checks328281 -Node: Other checks328761 -Ref: #other-checks328903 -Node: Custom checks329436 -Ref: #custom-checks329593 -Node: More about specific checks330010 -Ref: #more-about-specific-checks330172 -Node: close330878 -Ref: #close330989 -Node: close --migrate331642 -Ref: #close---migrate331769 -Node: close --close333408 -Ref: #close---close333552 -Node: close --open333788 -Ref: #close---open333929 -Node: close --assert334039 -Ref: #close---assert334185 -Node: close --assign334406 -Ref: #close---assign334554 -Node: close --retain335080 -Ref: #close---retain335233 -Node: close customisation335978 -Ref: #close-customisation336157 -Node: close and balance assertions337624 -Ref: #close-and-balance-assertions337821 -Node: close examples339148 -Ref: #close-examples339289 -Node: Retain earnings339387 -Ref: #retain-earnings339546 -Node: Migrate balances to a new file339892 -Ref: #migrate-balances-to-a-new-file340118 -Node: More detailed close examples341246 -Ref: #more-detailed-close-examples341444 -Node: codes341470 -Ref: #codes341587 -Node: commodities342451 -Ref: #commodities342579 -Node: demo342649 -Ref: #demo342770 -Node: descriptions343686 -Ref: #descriptions343816 -Node: diff344107 -Ref: #diff344222 -Node: files345264 -Ref: #files345373 -Node: help345514 -Ref: #help-1345623 -Node: import346996 -Ref: #import347119 -Node: Deduplication348227 -Ref: #deduplication348352 -Node: Import testing351213 -Ref: #import-testing351378 -Node: Importing balance assignments352221 -Ref: #importing-balance-assignments352427 -Node: Commodity display styles353076 -Ref: #commodity-display-styles353249 -Node: incomestatement353378 -Ref: #incomestatement353520 -Node: notes354994 -Ref: #notes355116 -Node: payees355478 -Ref: #payees355593 -Node: prices356112 -Ref: #prices356227 -Node: print356880 -Ref: #print356995 -Node: print explicitness357971 -Ref: #print-explicitness358114 -Node: print amount style358893 -Ref: #print-amount-style359063 -Node: print parseability360133 -Ref: #print-parseability360305 -Node: print other features361054 -Ref: #print-other-features361233 -Node: print output format361754 -Ref: #print-output-format361902 -Node: register365041 -Ref: #register365163 -Node: Custom register output370194 -Ref: #custom-register-output370325 -Node: rewrite371672 -Ref: #rewrite371790 -Node: Re-write rules in a file373688 -Ref: #re-write-rules-in-a-file373851 -Node: Diff output format375000 -Ref: #diff-output-format375183 -Node: rewrite vs print --auto376275 -Ref: #rewrite-vs.-print---auto376435 -Node: roi376991 -Ref: #roi377098 -Node: Spaces and special characters in --inv and --pnl378910 -Ref: #spaces-and-special-characters-in---inv-and---pnl379150 -Node: Semantics of --inv and --pnl379638 -Ref: #semantics-of---inv-and---pnl379877 -Node: IRR and TWR explained381727 -Ref: #irr-and-twr-explained381887 -Node: stats385140 -Ref: #stats385248 -Node: tags386762 -Ref: #tags-1386869 -Node: test387878 -Ref: #test387971 -Node: PART 5 COMMON TASKS388713 -Ref: #part-5-common-tasks388859 -Node: Getting help389157 -Ref: #getting-help389298 -Node: Constructing command lines390058 -Ref: #constructing-command-lines390259 -Node: Starting a journal file390916 -Ref: #starting-a-journal-file391118 -Node: Setting LEDGER_FILE392320 -Ref: #setting-ledger_file392512 -Node: Setting opening balances393469 -Ref: #setting-opening-balances393670 -Node: Recording transactions396811 -Ref: #recording-transactions397000 -Node: Reconciling397556 -Ref: #reconciling397708 -Node: Reporting399965 -Ref: #reporting400114 -Node: Migrating to a new file404099 -Ref: #migrating-to-a-new-file404256 -Node: BUGS404555 -Ref: #bugs404645 -Node: Troubleshooting405524 -Ref: #troubleshooting405624 +Node: PART 1 USER INTERFACE4253 +Ref: #part-1-user-interface4392 +Node: Input4392 +Ref: #input4502 +Node: Text encoding5469 +Ref: #text-encoding5583 +Node: Data formats6149 +Ref: #data-formats6284 +Node: Standard input7873 +Ref: #standard-input8013 +Node: Multiple files8240 +Ref: #multiple-files8379 +Node: Strict mode8977 +Ref: #strict-mode9087 +Node: Commands9811 +Ref: #commands9913 +Node: Add-on commands10980 +Ref: #add-on-commands11082 +Node: Options12198 +Ref: #options12310 +Node: Command line tips17882 +Ref: #command-line-tips18012 +Node: Option repetition18271 +Ref: #option-repetition18415 +Node: Special characters18519 +Ref: #special-characters18692 +Node: Single escaping shell metacharacters18855 +Ref: #single-escaping-shell-metacharacters19096 +Node: Double escaping regular expression metacharacters19699 +Ref: #double-escaping-regular-expression-metacharacters20010 +Node: Triple escaping for add-on commands20536 +Ref: #triple-escaping-for-add-on-commands20796 +Node: Less escaping21440 +Ref: #less-escaping21594 +Node: Unicode characters21918 +Ref: #unicode-characters22093 +Node: Regular expressions23592 +Ref: #regular-expressions23765 +Node: hledger's regular expressions26861 +Ref: #hledgers-regular-expressions27020 +Node: Argument files28406 +Ref: #argument-files28542 +Node: Output29039 +Ref: #output29151 +Node: Output destination29278 +Ref: #output-destination29409 +Node: Output format29834 +Ref: #output-format29980 +Node: CSV output31577 +Ref: #csv-output31693 +Node: HTML output31796 +Ref: #html-output31934 +Node: JSON output32028 +Ref: #json-output32166 +Node: SQL output33088 +Ref: #sql-output33204 +Node: Commodity styles33939 +Ref: #commodity-styles34079 +Node: Colour34817 +Ref: #colour34935 +Node: Box-drawing35339 +Ref: #box-drawing35457 +Node: Paging35747 +Ref: #paging35861 +Node: Debug output36814 +Ref: #debug-output36920 +Node: Environment37583 +Ref: #environment37707 +Node: PART 2 DATA FORMATS38251 +Ref: #part-2-data-formats38394 +Node: Journal38394 +Ref: #journal38503 +Node: Journal cheatsheet40871 +Ref: #journal-cheatsheet40998 +Node: Comments47085 +Ref: #comments47213 +Node: Transactions48029 +Ref: #transactions48152 +Node: Dates49166 +Ref: #dates49273 +Node: Simple dates49318 +Ref: #simple-dates49434 +Node: Posting dates49934 +Ref: #posting-dates50052 +Node: Status51021 +Ref: #status51122 +Node: Code52787 +Ref: #code52890 +Node: Description53122 +Ref: #description53253 +Node: Payee and note53809 +Ref: #payee-and-note53915 +Node: Transaction comments54900 +Ref: #transaction-comments55053 +Node: Postings55416 +Ref: #postings55547 +Node: Debits and credits56579 +Ref: #debits-and-credits56726 +Node: The two space delimiter57189 +Ref: #the-two-space-delimiter57346 +Node: Account names57754 +Ref: #account-names57884 +Node: Amounts59558 +Ref: #amounts59686 +Node: Decimal marks60587 +Ref: #decimal-marks60714 +Node: Digit group marks61691 +Ref: #digit-group-marks61844 +Node: Commodity62326 +Ref: #commodity62455 +Node: Costs63443 +Ref: #costs63538 +Node: Balance assertions65695 +Ref: #balance-assertions65848 +Node: Assertions and ordering66932 +Ref: #assertions-and-ordering67121 +Node: Assertions and multiple included files67660 +Ref: #assertions-and-multiple-included-files67920 +Node: Assertions and multiple -f files68420 +Ref: #assertions-and-multiple--f-files68665 +Node: Assertions and costs69062 +Ref: #assertions-and-costs69271 +Node: Assertions and commodities69712 +Ref: #assertions-and-commodities69927 +Node: Assertions and subaccounts71371 +Ref: #assertions-and-subaccounts71597 +Node: Assertions and virtual postings72041 +Ref: #assertions-and-virtual-postings72279 +Node: Assertions and auto postings72411 +Ref: #assertions-and-auto-postings72641 +Node: Assertions and precision73286 +Ref: #assertions-and-precision73468 +Node: Posting comments73735 +Ref: #posting-comments73898 +Node: Transaction balancing74275 +Ref: #transaction-balancing74434 +Node: Tags76277 +Ref: #tags76396 +Node: Tag names77739 +Ref: #tag-names77846 +Node: Special tags78234 +Ref: #special-tags78366 +Node: Tag values79879 +Ref: #tag-values79989 +Node: Directives80861 +Ref: #directives80988 +Node: Directives and multiple files82318 +Ref: #directives-and-multiple-files82496 +Node: Directive effects83263 +Ref: #directive-effects83417 +Node: account directive86419 +Ref: #account-directive86575 +Node: Account comments87869 +Ref: #account-comments88020 +Node: Account error checking88528 +Ref: #account-error-checking88721 +Node: Account display order89910 +Ref: #account-display-order90098 +Node: Account types91108 +Ref: #account-types91249 +Node: alias directive94882 +Ref: #alias-directive95043 +Node: Basic aliases96093 +Ref: #basic-aliases96224 +Node: Regex aliases96968 +Ref: #regex-aliases97125 +Node: Combining aliases98015 +Ref: #combining-aliases98193 +Node: Aliases and multiple files99469 +Ref: #aliases-and-multiple-files99673 +Node: end aliases directive100252 +Ref: #end-aliases-directive100471 +Node: Aliases can generate bad account names100620 +Ref: #aliases-can-generate-bad-account-names100868 +Node: Aliases and account types101453 +Ref: #aliases-and-account-types101645 +Node: commodity directive102341 +Ref: #commodity-directive102515 +Node: Commodity directive syntax103928 +Ref: #commodity-directive-syntax104113 +Node: Commodity error checking105564 +Ref: #commodity-error-checking105745 +Node: decimal-mark directive106039 +Ref: #decimal-mark-directive106221 +Node: include directive106618 +Ref: #include-directive106782 +Node: P directive107694 +Ref: #p-directive107839 +Node: payee directive108728 +Ref: #payee-directive108877 +Node: tag directive109350 +Ref: #tag-directive109505 +Node: Periodic transactions109962 +Ref: #periodic-transactions110127 +Node: Periodic rule syntax112116 +Ref: #periodic-rule-syntax112294 +Node: Periodic rules and relative dates112939 +Ref: #periodic-rules-and-relative-dates113205 +Node: Two spaces between period expression and description!113716 +Ref: #two-spaces-between-period-expression-and-description113993 +Node: Auto postings114677 +Ref: #auto-postings114825 +Node: Auto postings and multiple files117655 +Ref: #auto-postings-and-multiple-files117819 +Node: Auto postings and dates118220 +Ref: #auto-postings-and-dates118468 +Node: Auto postings and transaction balancing / inferred amounts / balance assertions118643 +Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions118999 +Node: Auto posting tags119502 +Ref: #auto-posting-tags119784 +Node: Auto postings on forecast transactions only120420 +Ref: #auto-postings-on-forecast-transactions-only120666 +Node: Other syntax120913 +Ref: #other-syntax121029 +Node: Balance assignments121685 +Ref: #balance-assignments121841 +Node: Balance assignments and costs123213 +Ref: #balance-assignments-and-costs123425 +Node: Balance assignments and multiple files123635 +Ref: #balance-assignments-and-multiple-files123865 +Node: Bracketed posting dates124058 +Ref: #bracketed-posting-dates124242 +Node: D directive124756 +Ref: #d-directive124924 +Node: apply account directive126529 +Ref: #apply-account-directive126709 +Node: Y directive127396 +Ref: #y-directive127556 +Node: Secondary dates128384 +Ref: #secondary-dates128538 +Node: Star comments129352 +Ref: #star-comments129512 +Node: Valuation expressions130044 +Ref: #valuation-expressions130221 +Node: Virtual postings130343 +Ref: #virtual-postings130520 +Node: Other Ledger directives131967 +Ref: #other-ledger-directives132163 +Node: Other cost/lot notations132729 +Ref: #other-costlot-notations132902 +Node: CSV135491 +Ref: #csv135584 +Node: CSV rules cheatsheet137581 +Ref: #csv-rules-cheatsheet137710 +Node: source139508 +Ref: #source139631 +Node: separator140511 +Ref: #separator140624 +Node: skip141164 +Ref: #skip141272 +Node: date-format141816 +Ref: #date-format141937 +Node: timezone142661 +Ref: #timezone142784 +Node: newest-first143789 +Ref: #newest-first143927 +Node: intra-day-reversed144504 +Ref: #intra-day-reversed144658 +Node: decimal-mark145106 +Ref: #decimal-mark145247 +Node: fields list145586 +Ref: #fields-list145725 +Node: Field assignment147396 +Ref: #field-assignment147540 +Node: Field names148617 +Ref: #field-names148748 +Node: date field149951 +Ref: #date-field150069 +Node: date2 field150117 +Ref: #date2-field150258 +Node: status field150314 +Ref: #status-field150457 +Node: code field150506 +Ref: #code-field150651 +Node: description field150696 +Ref: #description-field150856 +Node: comment field150915 +Ref: #comment-field151070 +Node: account field151363 +Ref: #account-field151513 +Node: amount field152083 +Ref: #amount-field152232 +Node: currency field154924 +Ref: #currency-field155077 +Node: balance field155334 +Ref: #balance-field155466 +Node: if block155859 +Ref: #if-block155980 +Node: Matchers157388 +Ref: #matchers157502 +Node: What matchers match158299 +Ref: #what-matchers-match158448 +Node: Combining matchers158888 +Ref: #combining-matchers159056 +Node: Match groups159593 +Ref: #match-groups159721 +Node: if table160489 +Ref: #if-table160611 +Node: balance-type162492 +Ref: #balance-type162621 +Node: include163321 +Ref: #include163448 +Node: Working with CSV163892 +Ref: #working-with-csv164039 +Node: Rapid feedback164446 +Ref: #rapid-feedback164579 +Node: Valid CSV165031 +Ref: #valid-csv165177 +Node: File Extension165909 +Ref: #file-extension166082 +Node: Reading CSV from standard input166646 +Ref: #reading-csv-from-standard-input166870 +Node: Reading multiple CSV files167034 +Ref: #reading-multiple-csv-files167265 +Node: Reading files specified by rule167506 +Ref: #reading-files-specified-by-rule167734 +Node: Valid transactions168905 +Ref: #valid-transactions169104 +Node: Deduplicating importing169732 +Ref: #deduplicating-importing169927 +Node: Setting amounts170963 +Ref: #setting-amounts171134 +Node: Amount signs173492 +Ref: #amount-signs173662 +Node: Setting currency/commodity174559 +Ref: #setting-currencycommodity174763 +Node: Amount decimal places175937 +Ref: #amount-decimal-places176143 +Node: Referencing other fields177196 +Ref: #referencing-other-fields177409 +Node: How CSV rules are evaluated178306 +Ref: #how-csv-rules-are-evaluated178523 +Node: Well factored rules179976 +Ref: #well-factored-rules180144 +Node: CSV rules examples180468 +Ref: #csv-rules-examples180603 +Node: Bank of Ireland180668 +Ref: #bank-of-ireland180805 +Node: Coinbase182267 +Ref: #coinbase182405 +Node: Amazon183452 +Ref: #amazon183577 +Node: Paypal185296 +Ref: #paypal185404 +Node: Timeclock193048 +Ref: #timeclock193153 +Node: Timedot195329 +Ref: #timedot195452 +Node: Timedot examples198573 +Ref: #timedot-examples198679 +Node: PART 3 REPORTING CONCEPTS200850 +Ref: #part-3-reporting-concepts201014 +Node: Time periods201014 +Ref: #time-periods201148 +Node: Report start & end date201266 +Ref: #report-start-end-date201418 +Node: Smart dates202742 +Ref: #smart-dates202895 +Node: Report intervals204685 +Ref: #report-intervals204840 +Node: Date adjustment205258 +Ref: #date-adjustment205418 +Node: Period expressions206269 +Ref: #period-expressions206410 +Node: Period expressions with a report interval208174 +Ref: #period-expressions-with-a-report-interval208408 +Node: More complex report intervals208622 +Ref: #more-complex-report-intervals208867 +Node: Multiple weekday intervals210728 +Ref: #multiple-weekday-intervals210917 +Node: Depth211739 +Ref: #depth211841 +Node: Queries212137 +Ref: #queries212239 +Node: Query types213835 +Ref: #query-types213956 +Node: Combining query terms217190 +Ref: #combining-query-terms217367 +Node: Queries and command options218930 +Ref: #queries-and-command-options219135 +Node: Queries and account aliases219384 +Ref: #queries-and-account-aliases219589 +Node: Queries and valuation219709 +Ref: #queries-and-valuation219866 +Node: Pivoting220071 +Ref: #pivoting220185 +Node: Generating data221962 +Ref: #generating-data222094 +Node: Forecasting223677 +Ref: #forecasting223802 +Node: --forecast224333 +Ref: #forecast224464 +Node: Inspecting forecast transactions225434 +Ref: #inspecting-forecast-transactions225636 +Node: Forecast reports226766 +Ref: #forecast-reports226939 +Node: Forecast tags227875 +Ref: #forecast-tags228035 +Node: Forecast period in detail228495 +Ref: #forecast-period-in-detail228689 +Node: Forecast troubleshooting229583 +Ref: #forecast-troubleshooting229751 +Node: Budgeting230654 +Ref: #budgeting230777 +Node: Amount formatting231214 +Ref: #amount-formatting231356 +Node: Commodity display style231458 +Ref: #commodity-display-style231612 +Node: Rounding233299 +Ref: #rounding233454 +Node: Trailing decimal marks233904 +Ref: #trailing-decimal-marks234083 +Node: Amount parseability234837 +Ref: #amount-parseability234993 +Node: Cost reporting236418 +Ref: #cost-reporting236560 +Node: Recording costs237221 +Ref: #recording-costs237357 +Node: Reporting at cost238948 +Ref: #reporting-at-cost239123 +Node: Equity conversion postings239713 +Ref: #equity-conversion-postings239927 +Node: Inferring equity conversion postings242358 +Ref: #inferring-equity-conversion-postings242621 +Node: Combining costs and equity conversion postings243373 +Ref: #combining-costs-and-equity-conversion-postings243683 +Node: Requirements for detecting equity conversion postings244598 +Ref: #requirements-for-detecting-equity-conversion-postings244920 +Node: Infer cost and equity by default ?246120 +Ref: #infer-cost-and-equity-by-default246349 +Node: Value reporting246557 +Ref: #value-reporting246699 +Node: -V Value247438 +Ref: #v-value247570 +Node: -X Value in specified commodity247765 +Ref: #x-value-in-specified-commodity247966 +Node: Valuation date248115 +Ref: #valuation-date248292 +Node: Finding market price249075 +Ref: #finding-market-price249286 +Node: --infer-market-prices market prices from transactions250455 +Ref: #infer-market-prices-market-prices-from-transactions250737 +Node: Valuation commodity253499 +Ref: #valuation-commodity253719 +Node: --value Flexible valuation254932 +Ref: #value-flexible-valuation255131 +Node: Valuation examples256775 +Ref: #valuation-examples256975 +Node: Interaction of valuation and queries258907 +Ref: #interaction-of-valuation-and-queries259147 +Node: Effect of valuation on reports259624 +Ref: #effect-of-valuation-on-reports259827 +Node: PART 4 COMMANDS267522 +Ref: #part-4-commands267665 +Node: Help commands269738 +Ref: #help-commands269883 +Node: help269911 +Ref: #help270000 +Node: demo271369 +Ref: #demo271458 +Node: User interface commands272374 +Ref: #user-interface-commands272543 +Node: ui272568 +Ref: #ui272660 +Node: web272693 +Ref: #web272787 +Node: Data entry commands272821 +Ref: #data-entry-commands272990 +Node: add273019 +Ref: #add273113 +Node: import275561 +Ref: #import275661 +Node: Date skipping276772 +Ref: #date-skipping276895 +Node: Import testing279673 +Ref: #import-testing279836 +Node: Importing balance assignments280679 +Ref: #importing-balance-assignments280886 +Node: Import and commodity styles281535 +Ref: #import-and-commodity-styles281715 +Node: Basic report commands281944 +Ref: #basic-report-commands282118 +Node: accounts282245 +Ref: #accounts282355 +Node: codes284242 +Ref: #codes284366 +Node: commodities285230 +Ref: #commodities285370 +Node: descriptions285440 +Ref: #descriptions285582 +Node: files285873 +Ref: #files285995 +Node: notes286136 +Ref: #notes286252 +Node: payees286614 +Ref: #payees286733 +Node: prices287252 +Ref: #prices287371 +Node: stats288024 +Ref: #stats288139 +Node: tags289653 +Ref: #tags-1289753 +Node: Standard report commands290762 +Ref: #standard-report-commands290947 +Node: print291067 +Ref: #print291175 +Node: print explicitness292151 +Ref: #print-explicitness292292 +Node: print amount style293071 +Ref: #print-amount-style293239 +Node: print parseability294309 +Ref: #print-parseability294479 +Node: print other features295228 +Ref: #print-other-features295405 +Node: print output format295926 +Ref: #print-output-format296072 +Node: aregister299211 +Ref: #aregister299344 +Node: aregister and posting dates302250 +Ref: #aregister-and-posting-dates302395 +Node: register303151 +Ref: #register303289 +Node: Custom register output308320 +Ref: #custom-register-output308449 +Node: balancesheet309796 +Ref: #balancesheet309951 +Node: balancesheetequity311562 +Ref: #balancesheetequity311729 +Node: cashflow313749 +Ref: #cashflow313899 +Node: incomestatement315386 +Ref: #incomestatement315523 +Node: Advanced report commands316997 +Ref: #advanced-report-commands317175 +Node: balance317205 +Ref: #balance317313 +Node: balance features318303 +Ref: #balance-features318443 +Node: Simple balance report320353 +Ref: #simple-balance-report320538 +Node: Balance report line format322163 +Ref: #balance-report-line-format322365 +Node: Filtered balance report324523 +Ref: #filtered-balance-report324715 +Node: List or tree mode325042 +Ref: #list-or-tree-mode325210 +Node: Depth limiting326555 +Ref: #depth-limiting326721 +Node: Dropping top-level accounts327322 +Ref: #dropping-top-level-accounts327522 +Node: Showing declared accounts327832 +Ref: #showing-declared-accounts328031 +Node: Sorting by amount328562 +Ref: #sorting-by-amount328729 +Node: Percentages329399 +Ref: #percentages329558 +Node: Multi-period balance report330106 +Ref: #multi-period-balance-report330306 +Node: Balance change end balance332858 +Ref: #balance-change-end-balance333067 +Node: Balance report types334495 +Ref: #balance-report-types334676 +Node: Calculation type335174 +Ref: #calculation-type335329 +Node: Accumulation type335878 +Ref: #accumulation-type336058 +Node: Valuation type336979 +Ref: #valuation-type337167 +Node: Combining balance report types338168 +Ref: #combining-balance-report-types338362 +Node: Budget report340200 +Ref: #budget-report340362 +Node: Using the budget report342505 +Ref: #using-the-budget-report342678 +Node: Budget date surprises344781 +Ref: #budget-date-surprises344981 +Node: Selecting budget goals346145 +Ref: #selecting-budget-goals346348 +Node: Budgeting vs forecasting347093 +Ref: #budgeting-vs-forecasting347270 +Node: Balance report layout348770 +Ref: #balance-report-layout348955 +Node: Wide layout349908 +Ref: #wide-layout350043 +Node: Tall layout352313 +Ref: #tall-layout352468 +Node: Bare layout353619 +Ref: #bare-layout353774 +Node: Tidy layout355678 +Ref: #tidy-layout355813 +Node: Some useful balance reports357222 +Ref: #some-useful-balance-reports357397 +Node: roi358482 +Ref: #roi358582 +Node: Spaces and special characters in --inv and --pnl360394 +Ref: #spaces-and-special-characters-in---inv-and---pnl360632 +Node: Semantics of --inv and --pnl361120 +Ref: #semantics-of---inv-and---pnl361357 +Node: IRR and TWR explained363207 +Ref: #irr-and-twr-explained363365 +Node: Chart commands366618 +Ref: #chart-commands366776 +Node: activity366799 +Ref: #activity366888 +Node: Data generation commands367262 +Ref: #data-generation-commands367436 +Node: close367468 +Ref: #close367574 +Node: close --migrate368227 +Ref: #close---migrate368352 +Node: close --close369991 +Ref: #close---close370133 +Node: close --open370369 +Ref: #close---open370508 +Node: close --assert370618 +Ref: #close---assert370762 +Node: close --assign370983 +Ref: #close---assign371129 +Node: close --retain371655 +Ref: #close---retain371806 +Node: close customisation372551 +Ref: #close-customisation372728 +Node: close and balance assertions374195 +Ref: #close-and-balance-assertions374390 +Node: close examples375717 +Ref: #close-examples375856 +Node: Retain earnings375954 +Ref: #retain-earnings376111 +Node: Migrate balances to a new file376457 +Ref: #migrate-balances-to-a-new-file376681 +Node: More detailed close examples377809 +Ref: #more-detailed-close-examples378005 +Node: rewrite378031 +Ref: #rewrite378141 +Node: Re-write rules in a file380039 +Ref: #re-write-rules-in-a-file380200 +Node: Diff output format381349 +Ref: #diff-output-format381530 +Node: rewrite vs print --auto382622 +Ref: #rewrite-vs.-print---auto382780 +Node: Maintenance commands383336 +Ref: #maintenance-commands383507 +Node: check383545 +Ref: #check383644 +Node: Basic checks384593 +Ref: #basic-checks384711 +Node: Strict checks385546 +Ref: #strict-checks385687 +Node: Other checks386421 +Ref: #other-checks386561 +Node: Custom checks388276 +Ref: #custom-checks388396 +Node: diff388731 +Ref: #diff388841 +Node: test389883 +Ref: #test389979 +Node: PART 5 COMMON TASKS390721 +Ref: #part-5-common-tasks390880 +Node: Getting help390954 +Ref: #getting-help391103 +Node: Constructing command lines391863 +Ref: #constructing-command-lines392044 +Node: Starting a journal file392701 +Ref: #starting-a-journal-file392883 +Node: Setting LEDGER_FILE394085 +Ref: #setting-ledger_file394257 +Node: Setting opening balances395214 +Ref: #setting-opening-balances395395 +Node: Recording transactions398536 +Ref: #recording-transactions398705 +Node: Reconciling399261 +Ref: #reconciling399393 +Node: Reporting401650 +Ref: #reporting401779 +Node: Migrating to a new file405764 +Ref: #migrating-to-a-new-file405914 +Node: BUGS406213 +Ref: #bugs406307 +Node: Troubleshooting407186 +Ref: #troubleshooting407286  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index 0badc730b..88e02e574 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -240,158 +240,87 @@ Commands Options Run hledger -h to see general command line help, and general options which are common to most hledger commands. These options can be writ- - ten anywhere on the command line. They can be grouped into help, in- - put, and reporting options: + ten anywhere on the command line: - General help options - -h --help - show general or COMMAND help + General input/data transformation flags: + -f --file=FILE Read data from FILE, or from stdin if -. Can be + specified more than once. If not specified, reads + from $LEDGER_FILE or $HOME/.hledger.journal. + --rules-file=RULEFILE Use conversion rules from this file for + converting subsequent CSV/SSV/TSV files. If not + specified, uses FILE.rules for each such FILE. + --alias=A=B|/RGX/=RPL transform account names from A to B, or by + replacing regular expression matches + --auto generate extra postings by applying auto posting + rules ("=") to all transactions + --forecast[=PERIOD] Generate extra transactions from periodic rules + ("~"), from after the latest ordinary transaction + until 6 months from now. Or, during the specified + PERIOD (the equals is required). Auto posting rules + will also be applied to these transactions. In + hledger-ui, also make future-dated transactions + visible at startup. + -I --ignore-assertions don't check balance assertions by default + --infer-costs infer conversion equity postings from costs + --infer-equity infer costs from conversion equity postings + --infer-market-prices infer market prices from costs + --pivot=TAGNAME use a different field or tag as account names + -s --strict do extra error checks (and override -I) + --verbose-tags add tags indicating generated/modified data - --man show general or COMMAND user manual with man + General output/reporting flags (supported by some commands): + -b --begin=DATE include postings/transactions on/after this date + -e --end=DATE include postings/transactions before this date + (with a report interval, will be adjusted to + following subperiod end) + -D --daily multiperiod report with 1 day interval + -W --weekly multiperiod report with 1 week interval + -M --monthly multiperiod report with 1 month interval + -Q --quarterly multiperiod report with 1 quarter interval + -Y --yearly multiperiod report with 1 year interval + -p --period=PERIODEXP set begin date, end date, and/or report interval, + with more flexibility + --today=DATE override today's date (affects relative dates) + --date2 match/use secondary dates instead (deprecated) + -U --unmarked include only unmarked postings/transactions + -P --pending include only pending postings/transactions + -C --cleared include only cleared postings/transactions + (-U/-P/-C can be combined) + -R --real include only non-virtual postings + --depth=NUM or -NUM: show only top NUM levels of accounts + -E --empty Show zero items, which are normally hidden. + In hledger-ui & hledger-web, do the opposite. + -B --cost show amounts converted to their cost/sale amount + -V --market Show amounts converted to their value at period + end(s) in their default valuation commodity. + Equivalent to --value=end. + -X --exchange=COMM Show amounts converted to their value at period + end(s) in the specified commodity. + Equivalent to --value=end,COMM. + --value=WHEN[,COMM] show amounts converted to their value on the + specified date(s) in their default valuation + commodity or a specified commodity. WHEN can be: + 'then': value on transaction dates + 'end': value at period end(s) + 'now': value today + YYYY-MM-DD: value on given date + -c --commodity-style=S Override a commodity's display style. + Eg: -c '.' or -c '1.000,00 EUR' + --color=YN --colour Use ANSI color codes in text output? Can be: + 'yes' or 'always', + 'no' or 'never' (a NO_COLOR env var forces this), + 'auto' (the default: when using a color terminal). + --pretty[=YN] Use box-drawing characters in text output? Can be + 'yes' (the default argument for --pretty) or 'no'. + If YN is specified, the equals is required. + --debug=[N] show debug output (levels 1-9, default: 1) - --info show general or COMMAND user manual with info - - --version - show general or ADDONCMD version - - --debug[=N] - show debug output (levels 1-9, default: 1) - - General input options - -f FILE --file=FILE - use a different input file. For stdin, use - (default: - $LEDGER_FILE or $HOME/.hledger.journal) - - --rules-file=RULESFILE - Conversion rules file to use when reading CSV (default: - FILE.rules) - - --separator=CHAR - Field separator to expect when reading CSV (default: ',') - - --alias=OLD=NEW - rename accounts named OLD to NEW - - --pivot FIELDNAME - use some other field or tag for the account name - - -I --ignore-assertions - disable balance assertion checks (note: does not disable balance - assignments) - - -s --strict - do extra error checking (check that all posted accounts are de- - clared) - - General reporting options - -b --begin=DATE - include postings/txns on or after this date (will be adjusted to - preceding subperiod start when using a report interval) - - -e --end=DATE - include postings/txns before this date (will be adjusted to fol- - lowing subperiod end when using a report interval) - - -D --daily - multiperiod/multicolumn report by day - - -W --weekly - multiperiod/multicolumn report by week - - -M --monthly - multiperiod/multicolumn report by month - - -Q --quarterly - multiperiod/multicolumn report by quarter - - -Y --yearly - multiperiod/multicolumn report by year - - -p --period=PERIODEXP - set start date, end date, and/or reporting interval all at once - using period expressions syntax - - --date2 - match the secondary date instead (see command help for other ef- - fects) - - --today=DATE - override today's date (affects relative smart dates, for - tests/examples) - - -U --unmarked - include only unmarked postings/txns (can combine with -P or -C) - - -P --pending - include only pending postings/txns - - -C --cleared - include only cleared postings/txns - - -R --real - include only non-virtual postings - - -NUM --depth=NUM - hide/aggregate accounts or postings more than NUM levels deep - - -E --empty - show items with zero amount, normally hidden (and vice-versa in - hledger-ui/hledger-web) - - -B --cost - convert amounts to their cost/selling amount at transaction time - - -V --market - convert amounts to their market value in default valuation com- - modities - - -X --exchange=COMM - convert amounts to their market value in commodity COMM - - --value - convert amounts to cost or market value, more flexibly than - -B/-V/-X - - --infer-equity - infer conversion equity postings from costs - - --infer-costs - infer costs from conversion equity postings - - --infer-market-prices - use costs as additional market prices, as if they were P direc- - tives - - --forecast - generate transactions from periodic rules, between the latest - recorded txn and 6 months from today, or during the specified - PERIOD (= is required). Auto posting rules will be applied to - these transactions as well. Also, in hledger-ui make fu- - ture-dated transactions visible. - - --auto generate extra postings by applying auto posting rules to all - txns (not just forecast txns) - - --verbose-tags - add visible tags indicating transactions or postings which have - been generated/modified - - --commodity-style - Override the commodity style in the output for the specified - commodity. For example 'EUR1.000,00'. - - --color=WHEN (or --colour=WHEN) - Should color-supporting commands use ANSI color codes in text - output. 'auto' (default): whenever stdout seems to be a - color-supporting terminal. 'always' or 'yes': always, useful eg - when piping output into 'less -R'. 'never' or 'no': never. A - NO_COLOR environment variable overrides this. - - --pretty[=WHEN] - Show prettier output, e.g. using unicode box-drawing charac- - ters. Accepts 'yes' (the default) or 'no' ('y', 'n', 'always', - 'never' also work). If you provide an argument you must use - '=', e.g. '--pretty=yes'. + General help flags: + -h --help show command line help + --tldr show command examples with tldr + --info show the hledger manual with info + --man show the hledger manual with man + --version show version information When a reporting option appears more than once in the command line, the last one takes precedence. @@ -399,19 +328,19 @@ Options Some reporting options can also be written as query arguments. Command line tips - Here are some details useful to know about for hledger command lines + Here are some details useful to know about for hledger command lines (and elsewhere). Feel free to skip this section until you need it. Option repetition - If options are repeated in a command line, hledger will generally use + If options are repeated in a command line, hledger will generally use the last (right-most) occurence. Special characters Single escaping (shell metacharacters) - In shell command lines, characters significant to your shell - such as - spaces, <, >, (, ), |, $ and \ - should be "shell-escaped" if you want - hledger to see them. This is done by enclosing them in single or dou- - ble quotes, or by writing a backslash before them. Eg to match an ac- + In shell command lines, characters significant to your shell - such as + spaces, <, >, (, ), |, $ and \ - should be "shell-escaped" if you want + hledger to see them. This is done by enclosing them in single or dou- + ble quotes, or by writing a backslash before them. Eg to match an ac- count name containing a space: $ hledger register 'credit card' @@ -420,17 +349,17 @@ Command line tips $ 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. + 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 - you don't want them to be interpreted by hledger's regular expression - engine. This is done by writing backslashes before them, but since - backslash is typically also a shell metacharacter, both shell-escaping - and regex-escaping will be needed. Eg to match a literal $ sign while + Characters significant in regular expressions (described below) - such + as ., ^, $, [, ], (, ), |, and \ - may need to be "regex-escaped" if + you don't want them to be interpreted by hledger's regular expression + engine. This is done by writing backslashes before them, but since + backslash is typically also a shell metacharacter, both shell-escaping + and regex-escaping will be needed. Eg to match a literal $ sign while using the bash shell: $ hledger balance cur:'\$' @@ -440,10 +369,10 @@ Command line tips $ hledger balance cur:\\$ Triple escaping (for add-on commands) - When you use hledger to run an external add-on command (described be- + When you use hledger to run an external add-on command (described be- low), one level of shell-escaping is lost from any options or arguments - intended for by the add-on command, so those need an extra level of - shell-escaping. Eg to match a literal $ sign while using the bash + intended for by the add-on command, so those need an extra level of + shell-escaping. Eg to match a literal $ sign while using the bash shell and running an add-on command (ui): $ hledger ui cur:'\\$' @@ -459,14 +388,14 @@ Command line tips double-escaped: \\$ triple-escaped: \\\\$ - Or, you can avoid the extra escaping by running the add-on executable + Or, you can avoid the extra escaping by running the add-on executable directly: $ hledger-ui cur:\\$ Less escaping Options and arguments are sometimes used in places other than the shell - command line, where shell-escaping is not needed, so there you should + command line, where shell-escaping is not needed, so there you should use one less level of escaping. Those places include: o an @argumentfile @@ -480,8 +409,8 @@ Command line tips Unicode characters hledger is expected to handle non-ascii characters correctly: - o they should be parsed correctly in input files and on the command - line, by all hledger tools (add, iadd, hledger-web's search/add/edit + o they should be parsed correctly in input files and on the command + line, by all hledger tools (add, iadd, hledger-web's search/add/edit forms, etc.) o they should be displayed correctly by all hledger tools, and @@ -489,39 +418,40 @@ Command line tips This requires a well-configured environment. Here are some tips: - o A system locale must be configured, and it must be one that can de- - code the characters being used. In bash, you can set a locale like - this: export LANG=en_US.UTF-8. There are some more details in Trou- - bleshooting. This step is essential - without it, hledger will quit - on encountering a non-ascii character (as with all GHC-compiled pro- + o A system locale must be configured, and it must be one that can de- + code the characters being used. In bash, you can set a locale like + this: export LANG=en_US.UTF-8. There are some more details in Trou- + bleshooting. This step is essential - without it, hledger will quit + on encountering a non-ascii character (as with all GHC-compiled pro- grams). - o your terminal software (eg Terminal.app, iTerm, CMD.exe, xterm..) - must support unicode + o Your terminal software (eg Terminal.app, iTerm, CMD.exe, xterm..) + must support unicode. On Windows, you may need to use Windows Termi- + nal and/or enable UTF-8 support. - o the terminal must be using a font which includes the required unicode - glyphs + o The terminal must be using a font which includes the required unicode + glyphs. - o the terminal should be configured to display wide characters as dou- - ble width (for report alignment) + o The terminal should be configured to display wide characters as dou- + ble width (for report alignment). - o on Windows, for best results you should run hledger in the same kind - of environment in which it was built. Eg hledger built in the stan- - dard CMD.EXE environment (like the binaries on our download page) - might show display problems when run in a cygwin or msys terminal, + o On Windows, for best results you should run hledger in the same kind + of environment in which it was built. Eg hledger built in the stan- + dard CMD.EXE environment (like the binaries on our download page) + might show display problems when run in a cygwin or msys terminal, and vice versa. (See eg #961). Regular expressions - A regular expression (regexp) is a small piece of text where certain - characters (like ., ^, $, +, *, (), |, [], \) have special meanings, - forming a tiny language for matching text precisely - very useful in - hledger and elsewhere. To learn all about them, visit regular-expres- + A regular expression (regexp) is a small piece of text where certain + characters (like ., ^, $, +, *, (), |, [], \) have special meanings, + forming a tiny language for matching text precisely - very useful in + hledger and elsewhere. To learn all about them, visit regular-expres- sions.info. - hledger supports regexps whenever you are entering a pattern to match - something, eg in query arguments, account aliases, CSV if rules, + hledger supports regexps whenever you are entering a pattern to match + something, eg in query arguments, account aliases, CSV if rules, hledger-web's search form, hledger-ui's / search, etc. You may need to - wrap them in quotes, especially at the command line (see Special char- + wrap them in quotes, especially at the command line (see Special char- acters above). Here are some examples: Account name queries (quoted for command line use): @@ -577,49 +507,49 @@ Command line tips & %date (29|30|31|01|02|03)$ hledger's regular expressions - hledger's regular expressions come from the regex-tdfa library. If - they're not doing what you expect, it's important to know exactly what + hledger's regular expressions come from the regex-tdfa library. If + they're not doing what you expect, it's important to know exactly what they support: 1. they are case insensitive - 2. they are infix matching (they do not need to match the entire thing + 2. they are infix matching (they do not need to match the entire thing being matched) 3. they are POSIX ERE (extended regular expressions) 4. they also support GNU word boundaries (\b, \B, \<, \>) - 5. backreferences are supported when doing text replacement in account - aliases or CSV rules, where backreferences can be used in the re- + 5. backreferences are supported when doing text replacement in account + aliases or CSV rules, where backreferences can be used in the re- placement string to reference capturing groups in the search regexp. Otherwise, if you write \1, it will match the digit 1. - 6. they do not support mode modifiers ((?s)), character classes (\w, + 6. they do not support mode modifiers ((?s)), character classes (\w, \d), or anything else not mentioned above. Some things to note: - o In the alias directive and --alias option, regular expressions must - be enclosed in forward slashes (/REGEX/). Elsewhere in hledger, + o In the alias directive and --alias option, regular expressions must + be enclosed in forward slashes (/REGEX/). Elsewhere in hledger, these are not required. - o In queries, to match a regular expression metacharacter like $ as a - literal character, prepend a backslash. Eg to search for amounts + o In queries, to match a regular expression metacharacter like $ as a + literal character, prepend a backslash. Eg to search for amounts with the dollar sign in hledger-web, write cur:\$. - o On the command line, some metacharacters like $ have a special mean- + o On the command line, some metacharacters like $ have a special mean- ing to the shell and so must be escaped at least once more. See Spe- cial characters. Argument files You can save a set of command line options and arguments in a file, and - then reuse them by writing @FILENAME as a command line argument. Eg: + then reuse them by writing @FILENAME as a command line argument. Eg: hledger bal @foo.args. - Inside the argument file, each line should contain just one option or - argument. Don't use spaces except inside quotes (or you'll see a con- - fusing error); write = (or nothing) between a flag and its argument. + Inside the argument file, each line should contain just one option or + argument. Don't use spaces except inside quotes (or you'll see a con- + fusing error); write = (or nothing) between a flag and its argument. For the special characters mentioned above, use one less level of quot- ing than you would at the command prompt. @@ -630,15 +560,15 @@ Output $ hledger print > foo.txt - Some commands (print, register, stats, the balance commands) also pro- - vide the -o/--output-file option, which does the same thing without + Some commands (print, register, stats, the balance commands) also pro- + vide the -o/--output-file option, which does the same thing without needing the shell. Eg: $ hledger print -o foo.txt $ hledger print -o - # write to stdout (the default) Output format - Some commands offer other kinds of output, not just text on the termi- + Some commands offer other kinds of output, not just text on the termi- nal. Here are those commands and the formats currently supported: - txt csv/tsv html json sql @@ -655,19 +585,19 @@ Output o 1 Also affected by the balance commands' --layout option. - o 2 balance does not support html output without a report interval or + o 2 balance does not support html output without a report interval or with --budget. The output format is selected by the -O/--output-format=FMT option: $ hledger print -O csv # print CSV on stdout - or by the filename extension of an output file specified with the + or by the filename extension of an output file specified with the -o/--output-file=FILE.FMT option: $ hledger balancesheet -o foo.csv # write CSV to foo.csv - The -O option can be combined with -o to override the file extension, + The -O option can be combined with -o to override the file extension, if needed: $ hledger balancesheet -o foo.txt -O csv # write CSV to foo.txt @@ -675,7 +605,7 @@ Output Some notes about the various output formats: CSV output - o In CSV output, digit group marks (such as thousands separators) are + o In CSV output, digit group marks (such as thousands separators) are disabled automatically. HTML output @@ -685,82 +615,82 @@ Output JSON output o This is not yet much used; real-world feedback is welcome. - o Our JSON is rather large and verbose, since it is a faithful repre- - sentation of hledger's internal data types. To understand the JSON, - read the Haskell type definitions, which are mostly in + o Our JSON is rather large and verbose, since it is a faithful repre- + sentation of hledger's internal data types. To understand the JSON, + read the Haskell type definitions, which are mostly in https://github.com/simonmichael/hledger/blob/mas- ter/hledger-lib/Hledger/Data/Types.hs. - o hledger represents quantities as Decimal values storing up to 255 - significant digits, eg for repeating decimals. Such numbers can + o hledger represents quantities as Decimal values storing up to 255 + significant digits, eg for repeating decimals. Such numbers can arise in practice (from automatically-calculated transaction prices), - and would break most JSON consumers. So in JSON, we show quantities + and would break most JSON consumers. So in JSON, we show quantities as simple Numbers with at most 10 decimal places. We don't limit the - number of integer digits, but that part is under your control. We - hope this approach will not cause problems in practice; if you find + number of integer digits, but that part is under your control. We + hope this approach will not cause problems in practice; if you find otherwise, please let us know. (Cf #1195) SQL output o This is not yet much used; real-world feedback is welcome. - o SQL output is expected to work at least with SQLite, MySQL and Post- + o SQL output is expected to work at least with SQLite, MySQL and Post- gres. - o For SQLite, it will be more useful if you modify the generated id + o For SQLite, it will be more useful if you modify the generated id field to be a PRIMARY KEY. Eg: $ hledger print -O sql | sed 's/id serial/id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL/g' | ... - o SQL output is structured with the expectations that statements will - be executed in the empty database. If you already have tables cre- - ated via SQL output of hledger, you would probably want to either + o SQL output is structured with the expectations that statements will + be executed in the empty database. If you already have tables cre- + ated via SQL output of hledger, you would probably want to either clear tables of existing data (via delete or truncate SQL statements) or drop tables completely as otherwise your postings will be duped. Commodity styles - When displaying amounts, hledger infers a standard display style for + When displaying amounts, hledger infers a standard display style for each commodity/currency, as described below in Commodity display style. If needed, this can be overridden by a -c/--commodity-style option (ex- cept for cost amounts and amounts displayed by the print command, which - are always displayed with all decimal digits). For example, the fol- + are always displayed with all decimal digits). For example, the fol- lowing will force dollar amounts to be displayed as shown: $ hledger print -c '$1.000,0' This option can repeated to set the display style for multiple commodi- - ties/currencies. Its argument is as described in the commodity direc- + ties/currencies. Its argument is as described in the commodity direc- tive. - In some cases hledger will adjust number formatting to improve their + In some cases hledger will adjust number formatting to improve their parseability (such as adding trailing decimal marks when needed). Colour - In terminal output, some commands can produce colour when the terminal + In terminal output, some commands can produce colour when the terminal supports it: - o if the --color/--colour option is given a value of yes or always (or + o if the --color/--colour option is given a value of yes or always (or no or never), colour will (or will not) be used; - o otherwise, if the NO_COLOR environment variable is set, colour will + o otherwise, if the NO_COLOR environment variable is set, colour will not be used; - o otherwise, colour will be used if the output (terminal or file) sup- + o otherwise, colour will be used if the output (terminal or file) sup- ports it. Box-drawing - In terminal output, you can enable unicode box-drawing characters to + In terminal output, you can enable unicode box-drawing characters to render prettier tables: - o if the --pretty option is given a value of yes or always (or no or + o if the --pretty option is given a value of yes or always (or no or never), unicode characters will (or will not) be used; o otherwise, unicode characters will not be used. Paging - When showing long output in the terminal, hledger will try to use the - pager specified by the PAGER environment variable, or less, or more. - (A pager is a helper program that shows one page at a time rather than + When showing long output in the terminal, hledger will try to use the + pager specified by the PAGER environment variable, or less, or more. + (A pager is a helper program that shows one page at a time rather than scrolling everything off screen). Currently it does this only for help output, not for reports; specifically, @@ -770,23 +700,23 @@ Output o when viewing manuals with hledger help or hledger --man. - Note the pager is expected to handle ANSI codes, which hledger uses eg + Note the pager is expected to handle ANSI codes, which hledger uses eg for bold emphasis. For the common pager less (and its more compatibil- - ity mode), we add R to the LESS and MORE environment variables to make - this work. If you use a different pager, you might need to configure + ity mode), we add R to the LESS and MORE environment variables to make + this work. If you use a different pager, you might need to configure it similarly, to avoid seeing junk on screen (let us know). Otherwise, - you can set the NO_COLOR environment variable to 1 to disable all ANSI + you can set the NO_COLOR environment variable to 1 to disable all ANSI output (see Colour). Debug output We intend hledger to be relatively easy to troubleshoot, introspect and - develop. You can add --debug[=N] to any hledger command line to see - additional debug output. N ranges from 1 (least output, the default) - to 9 (maximum output). Typically you would start with 1 and increase - until you are seeing enough. Debug output goes to stderr, and is not + develop. You can add --debug[=N] to any hledger command line to see + additional debug output. N ranges from 1 (least output, the default) + to 9 (maximum output). Typically you would start with 1 and increase + until you are seeing enough. Debug output goes to stderr, and is not affected by -o/--output-file (unless you redirect stderr to stdout, eg: - 2>&1). It will be interleaved with normal output, which can help re- - veal when parts of the code are evaluated. To capture debug output in + 2>&1). It will be interleaved with normal output, which can help re- + veal when parts of the code are evaluated. To capture debug output in a log file instead, you can usually redirect stderr, eg: hledger bal --debug=3 2>hledger.log @@ -794,52 +724,52 @@ Output Environment These environment variables affect hledger: - COLUMNS This is normally set by your terminal; some hledger commands - (register) will format their output to this width. If not set, they + COLUMNS This is normally set by your terminal; some hledger commands + (register) will format their output to this width. If not set, they will try to use the available terminal width. - LEDGER_FILE The main journal file to use when not specified with + LEDGER_FILE The main journal file to use when not specified with -f/--file. Default: $HOME/.hledger.journal. - NO_COLOR If this environment variable is set (with any value), hledger - will not use ANSI color codes in terminal output, unless overridden by + NO_COLOR If this environment variable is set (with any value), hledger + will not use ANSI color codes in terminal output, unless overridden by an explicit --color/--colour option. PART 2: DATA FORMATS Journal hledger's usual data source is a plain text file containing journal en- - tries in hledger journal format. If you're looking for a quick refer- - ence, jump ahead to the journal cheatsheet (or use the table of con- + tries in hledger journal format. If you're looking for a quick refer- + ence, jump ahead to the journal cheatsheet (or use the table of con- tents at https://hledger.org/hledger.html). - This file represents an accounting General Journal. The .journal file - extension is most often used, though not strictly required. The jour- - nal file contains a number of transaction entries, each describing a - transfer of money (or any commodity) between two or more named ac- + This file represents an accounting General Journal. The .journal file + extension is most often used, though not strictly required. The jour- + nal file contains a number of transaction entries, each describing a + transfer of money (or any commodity) between two or more named ac- counts, in a simple format readable by both hledger and humans. - hledger's journal format is compatible with most of Ledger's journal + hledger's journal format is compatible with most of Ledger's journal format, but not all of it. The differences and interoperation tips are - described at hledger and Ledger. With some care, and by avoiding in- - compatible features, you can keep your hledger journal readable by - Ledger and vice versa. This can useful eg for comparing the behaviour + described at hledger and Ledger. With some care, and by avoiding in- + compatible features, you can keep your hledger journal readable by + Ledger and vice versa. This can useful eg for comparing the behaviour of one app against the other. You can use hledger without learning any more about this file; just use the add or web or import commands to create and update it. Many users, though, edit the journal file with a text editor, and track - changes with a version control system such as git. Editor addons such - as ledger-mode or hledger-mode for Emacs, vim-ledger for Vim, and + changes with a version control system such as git. Editor addons such + as ledger-mode or hledger-mode for Emacs, vim-ledger for Vim, and hledger-vscode for Visual Studio Code, make this easier, adding colour, formatting, tab completion, and useful commands. See Editor configura- tion at hledger.org for the full list. A hledger journal file can contain three kinds of thing: comment lines, - transactions, and/or directives (including periodic transaction rules - and auto posting rules). Understanding the journal file format will - also give you a good understanding of hledger's data model. Here's a - quick cheatsheet/overview, followed by detailed descriptions of each + transactions, and/or directives (including periodic transaction rules + and auto posting rules). Understanding the journal file format will + also give you a good understanding of hledger's data model. Here's a + quick cheatsheet/overview, followed by detailed descriptions of each part. Journal cheatsheet @@ -973,7 +903,7 @@ Journal Comments Lines in the journal will be ignored if they begin with a hash (#) or a - semicolon (;). (See also Other syntax.) hledger will also ignore re- + semicolon (;). (See also Other syntax.) hledger will also ignore re- gions beginning with a comment line and ending with an end comment line (or file end). Here's a suggestion for choosing between them: @@ -995,15 +925,15 @@ Journal end comment Some hledger entries can have same-line comments attached to them, from - ; (semicolon) to end of line. See Transaction comments, Posting com- + ; (semicolon) to end of line. See Transaction comments, Posting com- ments, and Account comments below. Transactions - Transactions are the main unit of information in a journal file. They - represent events, typically a movement of some quantity of commodities + Transactions are the main unit of information in a journal file. They + represent events, typically a movement of some quantity of commodities between two or more named accounts. - Each transaction is recorded as a journal entry, beginning with a sim- + Each transaction is recorded as a journal entry, beginning with a sim- ple date in column 0. This can be followed by any of the following op- tional fields, separated by spaces: @@ -1013,11 +943,11 @@ Journal o a description (any remaining text until end of line or a semicolon) - o a comment (any remaining text following a semicolon until end of + o a comment (any remaining text following a semicolon until end of line, and any following indented lines beginning with a semicolon) o 0 or more indented posting lines, describing what was transferred and - the accounts involved (indented comment lines are also allowed, but + the accounts involved (indented comment lines are also allowed, but not blank lines or non-indented lines). Here's a simple journal file containing one transaction: @@ -1028,22 +958,22 @@ Journal Dates Simple dates - Dates in the journal file use simple dates format: YYYY-MM-DD or + Dates in the journal file use simple dates format: YYYY-MM-DD or YYYY/MM/DD or YYYY.MM.DD, with leading zeros optional. The year may be - omitted, in which case it will be inferred from the context: the cur- - rent transaction, the default year set with a Y directive, or the cur- + omitted, in which case it will be inferred from the context: the cur- + rent transaction, the default year set with a Y directive, or the cur- rent date when the command is run. Some examples: 2010-01-31, 2010/01/31, 2010.1.31, 1/31. - (The UI also accepts simple dates, as well as the more flexible smart + (The UI also accepts simple dates, as well as the more flexible smart dates documented in the hledger manual.) Posting dates - You can give individual postings a different date from their parent - transaction, by adding a posting comment containing a tag (see below) + You can give individual postings a different date from their parent + transaction, by adding a posting comment containing a tag (see below) like date:DATE. This is probably the best way to control posting dates - precisely. Eg in this example the expense should appear in May re- - ports, and the deduction from checking should be reported on 6/1 for + precisely. Eg in this example the expense should appear in May re- + ports, and the deduction from checking should be reported on 6/1 for easy bank reconciliation: 2015/5/30 @@ -1056,15 +986,15 @@ Journal $ hledger -f t.j register checking 2015-06-01 assets:checking $-10 $-10 - DATE should be a simple date; if the year is not specified it will use + DATE should be a simple date; if the year is not specified it will use the year of the transaction's date. - The date: tag must have a valid simple date value if it is present, eg + The date: tag must have a valid simple date value if it is present, eg a date: tag with no value is not allowed. Status - Transactions (or individual postings within a transaction) can have a - status mark, which is a single character before the transaction de- - scription (or posting account name), separated from it by a space, in- + Transactions (or individual postings within a transaction) can have a + status mark, which is a single character before the transaction de- + scription (or posting account name), separated from it by a space, in- dicating one of three statuses: mark status @@ -1073,20 +1003,20 @@ Journal ! pending * cleared - When reporting, you can filter by status with the -U/--unmarked, + When reporting, you can filter by status with the -U/--unmarked, -P/--pending, and -C/--cleared flags (and you can combine these, eg -UP - to match all except cleared things). Or you can use the status:, sta- + to match all except cleared things). Or you can use the status:, sta- tus:!, and status:* queries, or the U, P, C keys in hledger-ui. (Note: in Ledger the "unmarked" state is called "uncleared"; in hledger we renamed it to "unmarked" for semantic clarity.) - Status marks are optional, but can be helpful eg for reconciling with + Status marks are optional, but can be helpful eg for reconciling with real-world accounts. Some editor modes provide highlighting and short- - cuts for working with status. Eg in Emacs ledger-mode, you can toggle + cuts for working with status. Eg in Emacs ledger-mode, you can toggle transaction status with C-c C-e, or posting status with C-c C-c. - What "uncleared", "pending", and "cleared" actually mean is up to you. + What "uncleared", "pending", and "cleared" actually mean is up to you. Here's one suggestion: status meaning @@ -1097,55 +1027,55 @@ Journal cleared complete, reconciled as far as possible, and considered cor- rect - With this scheme, you would use -PC to see the current balance at your + With this scheme, you would use -PC to see the current balance at your bank, -U to see things which will probably hit your bank soon (like un- - cashed checks), and no flags to see the most up-to-date state of your + cashed checks), and no flags to see the most up-to-date state of your finances. Code - After the status mark, but before the description, you can optionally - write a transaction "code", enclosed in parentheses. This is a good - place to record a check number, or some other important transaction id + After the status mark, but before the description, you can optionally + write a transaction "code", enclosed in parentheses. This is a good + place to record a check number, or some other important transaction id or reference number. Description - After the date, status mark and/or code fields, the rest of the line - (or until a comment is begun with ;) is the transaction's description. + After the date, status mark and/or code fields, the rest of the line + (or until a comment is begun with ;) is the transaction's description. Here you can describe the transaction (called the "narration" in tradi- - tional bookkeeping), or you can record a payee/payer name, or you can + tional bookkeeping), or you can record a payee/payer name, or you can leave it empty. - Transaction descriptions show up in print output and in register re- + Transaction descriptions show up in print output and in register re- ports, and can be listed with the descriptions command. - You can query by description with desc:DESCREGEX, or pivot on descrip- + You can query by description with desc:DESCREGEX, or pivot on descrip- tion with --pivot desc. Payee and note Sometimes people want a dedicated payee/payer field that can be queried - and checked more strictly. If you want that, you can write a | (pipe) - character in the description. This divides it into a "payee" field on + and checked more strictly. If you want that, you can write a | (pipe) + character in the description. This divides it into a "payee" field on the left, and a "note" field on the right. (Either can be empty.) - You can query these with payee:PAYEEREGEX and note:NOTEREGEX, list - their values with the payees and notes commands, or pivot on payee or + You can query these with payee:PAYEEREGEX and note:NOTEREGEX, list + their values with the payees and notes commands, or pivot on payee or note. Note: in transactions with no | character, description, payee, and note all have the same value. Once a | is added, they become distinct. (If - you'd like to change this behaviour, please propose it on the mail + you'd like to change this behaviour, please propose it on the mail list.) If you want more strict error checking, you can declare the valid payee - names with payee directives, and then enforce these with hledger check - payees. (Note: because of the above, for this you'll need to ensure - every transaction description contains a | and therefore a checkable + names with payee directives, and then enforce these with hledger check + payees. (Note: because of the above, for this you'll need to ensure + every transaction description contains a | and therefore a checkable payee name, even if it's empty.) Transaction comments - Text following ;, after a transaction description, and/or on indented - lines immediately below it, form comments for that transaction. They - are reproduced by print but otherwise ignored, except they may contain + Text following ;, after a transaction description, and/or on indented + lines immediately below it, form comments for that transaction. They + are reproduced by print but otherwise ignored, except they may contain tags, which are not ignored. 2012-01-01 something ; a transaction comment @@ -1154,63 +1084,63 @@ Journal assets Postings - A posting is an addition of some amount to, or removal of some amount - from, an account. Each posting line begins with at least one space or + A posting is an addition of some amount to, or removal of some amount + from, an account. Each posting line begins with at least one space or tab (2 or 4 spaces is common), followed by: o (optional) a status character (empty, !, or *), followed by a space - o (required) an account name (any text, optionally containing single + o (required) an account name (any text, optionally containing single spaces, until end of line or a double space) o (optional) two or more spaces (or tabs) followed by an amount. - If the amount is positive, it is being added to the account; if nega- + If the amount is positive, it is being added to the account; if nega- tive, it is being removed from the account. - The posting amounts in a transaction must sum up to zero, indicating - that the inflows and outflows are equal. We call this a balanced + The posting amounts in a transaction must sum up to zero, indicating + that the inflows and outflows are equal. We call this a balanced transaction. (You can read more about the nitty-gritty details of "sum up to zero" in Transaction balancing below.) - As a convenience, you can optionally leave one amount blank; hledger + As a convenience, you can optionally leave one amount blank; hledger will infer what it should be so as to balance the transaction. Debits and credits The traditional accounting concepts of debit and credit of course exist - in hledger, but we represent them with numeric sign, as described - above. Positive and negative posting amounts represent debits and + in hledger, but we represent them with numeric sign, as described + above. Positive and negative posting amounts represent debits and credits respectively. - You don't need to remember that, but if you would like to - eg for - helping newcomers or for talking with your accountant - here's a handy + You don't need to remember that, but if you would like to - eg for + helping newcomers or for talking with your accountant - here's a handy mnemonic: debit / plus / left / short words credit / minus / right / longer words The two space delimiter - Be sure to notice the unusual separator between the account name and + Be sure to notice the unusual separator between the account name and the following amount. Because hledger allows account names with spaces - in them, you must separate the account name and amount (if any) by two - or more spaces (or tabs). It's easy to forget at first. If you ever - see the amount being treated as part of the account name, you'll know + in them, you must separate the account name and amount (if any) by two + or more spaces (or tabs). It's easy to forget at first. If you ever + see the amount being treated as part of the account name, you'll know you probably need to add another space between them. Account names - Accounts are the main way of categorising things in hledger. As in - Double Entry Bookkeeping, they can represent real world accounts (such + Accounts are the main way of categorising things in hledger. As in + Double Entry Bookkeeping, they can represent real world accounts (such as a bank account), or more abstract categories such as "money borrowed from Frank" or "money spent on electricity". - You can use any account names you like, but we usually start with the + You can use any account names you like, but we usually start with the traditional accounting categories, which in english are assets, liabil- ities, equity, revenues, expenses. (You might see these referred to as A, L, E, R, X for short.) - For more precise reporting, we usually divide the top level accounts + For more precise reporting, we usually divide the top level accounts into more detailed subaccounts, by writing a full colon between account - name parts. For example, from the account names assets:bank:checking + name parts. For example, from the account names assets:bank:checking and expenses:food, hledger will infer this hierarchy of five accounts: assets @@ -1228,33 +1158,33 @@ Journal food hledger reports can summarise the account tree to any depth, so you can - go as deep as you like with subcategories, but keeping your account + go as deep as you like with subcategories, but keeping your account names relatively simple may be best when starting out. Account names may be capitalised or not; they may contain letters, num- - bers, symbols, or single spaces. Note, when an account name and an - amount are written on the same line, they must be separated by two or + bers, symbols, or single spaces. Note, when an account name and an + amount are written on the same line, they must be separated by two or more spaces (or tabs). - Parentheses or brackets enclosing the full account name indicate vir- - tual postings, described below. Parentheses or brackets internal to + Parentheses or brackets enclosing the full account name indicate vir- + tual postings, described below. Parentheses or brackets internal to the account name have no special meaning. - Account names can be altered temporarily or permanently by account + Account names can be altered temporarily or permanently by account aliases. Amounts After the account name, there is usually an amount. (Remember: between account name and amount, there must be two or more spaces.) - hledger's amount format is flexible, supporting several international - formats. Here are some examples. Amounts have a number (the "quan- + hledger's amount format is flexible, supporting several international + formats. Here are some examples. Amounts have a number (the "quan- tity"): 1 ..and usually a currency symbol or commodity name (more on this below), - to the left or right of the quantity, with or without a separating + to the left or right of the quantity, with or without a separating space: $1 @@ -1262,13 +1192,13 @@ Journal 3 "green apples" Amounts can be preceded by a minus sign (or a plus sign, though plus is - the default), The sign can be written before or after a left-side com- + the default), The sign can be written before or after a left-side com- modity symbol: -$1 $-1 - One or more spaces between the sign and the number are acceptable when + One or more spaces between the sign and the number are acceptable when parsing (but they won't be displayed in output): + $1 @@ -1286,31 +1216,31 @@ Journal 1,23 Both of these are common in international number formats, so hledger is - not biased towards one or the other. Because hledger also supports - digit group marks (eg thousands separators), this means that a number - like 1,000 or 1.000 containing just one period or comma is ambiguous. - In such cases, hledger by default assumes it is a decimal mark, and + not biased towards one or the other. Because hledger also supports + digit group marks (eg thousands separators), this means that a number + like 1,000 or 1.000 containing just one period or comma is ambiguous. + In such cases, hledger by default assumes it is a decimal mark, and will parse both of those as 1. - To help hledger parse such ambiguous numbers more accurately, if you - use digit group marks, we recommend declaring the decimal mark explic- - itly. The best way is to add a decimal-mark directive at the top of + To help hledger parse such ambiguous numbers more accurately, if you + use digit group marks, we recommend declaring the decimal mark explic- + itly. The best way is to add a decimal-mark directive at the top of each data file, like this: decimal-mark . - Or you can declare it per commodity with commodity directives, de- + Or you can declare it per commodity with commodity directives, de- scribed below. - hledger also accepts numbers like 10. with no digits after the decimal - mark (and will sometimes display numbers that way to disambiguate them + hledger also accepts numbers like 10. with no digits after the decimal + mark (and will sometimes display numbers that way to disambiguate them - see Trailing decimal marks). Digit group marks - In the integer part of the amount quantity (left of the decimal mark), - groups of digits can optionally be separated by a digit group mark - a - comma or period (whichever is not used as decimal mark), or a space - (several Unicode space variants, like no-break space, are also ac- + In the integer part of the amount quantity (left of the decimal mark), + groups of digits can optionally be separated by a digit group mark - a + comma or period (whichever is not used as decimal mark), or a space + (several Unicode space variants, like no-break space, are also ac- cepted). So these are all valid amounts in a journal file: $1,000,000.00 @@ -1320,46 +1250,46 @@ Journal 1 000 000.00 ; <- no-break space Commodity - Amounts in hledger have both a "quantity", which is a signed decimal + Amounts in hledger have both a "quantity", which is a signed decimal number, and a "commodity", which is a currency symbol, stock ticker, or any word or phrase describing something you are tracking. If the commodity name contains non-letters (spaces, numbers, or punctu- - ation), you must always write it inside double quotes ("green apples", + ation), you must always write it inside double quotes ("green apples", "ABC123"). - If you write just a bare number, that too will have a commodity, with + If you write just a bare number, that too will have a commodity, with name ""; we call that the "no-symbol commodity". - Actually, hledger combines these single-commodity amounts into more - powerful multi-commodity amounts, which are what it works with most of - the time. A multi-commodity amount could be, eg: 1 USD, 2 EUR, 3.456 - TSLA. In practice, you will only see multi-commodity amounts in + Actually, hledger combines these single-commodity amounts into more + powerful multi-commodity amounts, which are what it works with most of + the time. A multi-commodity amount could be, eg: 1 USD, 2 EUR, 3.456 + TSLA. In practice, you will only see multi-commodity amounts in hledger's output; you can't write them directly in the journal file. By default, the format of amounts in the journal influences how hledger - displays them in output. This is explained in Commodity display style + displays them in output. This is explained in Commodity display style below. Costs - After a posting amount, you can note its cost (when buying) or selling - price (when selling) in another commodity, by writing either @ UNIT- - PRICE or @@ TOTALPRICE after it. This indicates a conversion transac- + After a posting amount, you can note its cost (when buying) or selling + price (when selling) in another commodity, by writing either @ UNIT- + PRICE or @@ TOTALPRICE after it. This indicates a conversion transac- tion, where one commodity is exchanged for another. - (You might also see this called "transaction price" in hledger docs, - discussions, or code; that term was directionally neutral and reminded - that it is a price specific to a transaction, but we now just call it + (You might also see this called "transaction price" in hledger docs, + discussions, or code; that term was directionally neutral and reminded + that it is a price specific to a transaction, but we now just call it "cost", with the understanding that the transaction could be a purchase or a sale.) - Costs are usually written explicitly with @ or @@, but can also be in- + Costs are usually written explicitly with @ or @@, but can also be in- ferred automatically for simple multi-commodity transactions. Note, if - costs are inferred, the order of postings is significant; the first + costs are inferred, the order of postings is significant; the first posting will have a cost attached, in the commodity of the second. - As an example, here are several ways to record purchases of a foreign - currency in hledger, using the cost notation either explicitly or im- + As an example, here are several ways to record purchases of a foreign + currency in hledger, using the cost notation either explicitly or im- plicitly: 1. Write the price per unit, as @ UNITPRICE after the amount: @@ -1383,17 +1313,17 @@ Journal assets:euros 100 ; one hundred euros purchased assets:dollars $-135 ; for $135 - Amounts can be converted to cost at report time using the -B/--cost + Amounts can be converted to cost at report time using the -B/--cost flag; this is discussed more in the Cost reporting section. - Note that the cost normally should be a positive amount, though it's - not required to be. This can be a little confusing, see discussion at + Note that the cost normally should be a positive amount, though it's + not required to be. This can be a little confusing, see discussion at --infer-market-prices: market prices from transactions. Balance assertions - hledger supports Ledger-style balance assertions in journal files. - These look like, for example, = EXPECTEDBALANCE following a posting's - amount. Eg here we assert the expected dollar balance in accounts a + hledger supports Ledger-style balance assertions in journal files. + These look like, for example, = EXPECTEDBALANCE following a posting's + amount. Eg here we assert the expected dollar balance in accounts a and b after each posting: 2013/1/1 @@ -1405,42 +1335,42 @@ Journal b $-1 = $-2 After reading a journal file, hledger will check all balance assertions - and report an error if any of them fail. Balance assertions can pro- - tect you from, eg, inadvertently disrupting reconciled balances while - cleaning up old entries. You can disable them temporarily with the + and report an error if any of them fail. Balance assertions can pro- + tect you from, eg, inadvertently disrupting reconciled balances while + cleaning up old entries. You can disable them temporarily with the -I/--ignore-assertions flag, which can be useful for troubleshooting or - for reading Ledger files. (Note: this flag currently does not disable + for reading Ledger files. (Note: this flag currently does not disable balance assignments, described below). Assertions and ordering - hledger calculates and checks an account's balance assertions in date + hledger calculates and checks an account's balance assertions in date order (and when there are multiple assertions on the same day, in parse - order). Note this is different from Ledger, which checks assertions + order). Note this is different from Ledger, which checks assertions always in parse order, ignoring dates. This means in hledger you can freely reorder transactions, postings, or files, and balance assertions will usually keep working. The exception - is when you reorder multiple postings on the same day, to the same ac- + is when you reorder multiple postings on the same day, to the same ac- count, which have balance assertions; those will likely need updating. Assertions and multiple included files - Multiple files included with the include directive are processed as if - concatenated into one file, preserving their order and the posting or- - der within each file. It means that balance assertions in later files + Multiple files included with the include directive are processed as if + concatenated into one file, preserving their order and the posting or- + der within each file. It means that balance assertions in later files will see balance from earlier files. - And if you have multiple postings to an account on the same day, split - across multiple files, and you want to assert the account's balance on + And if you have multiple postings to an account on the same day, split + across multiple files, and you want to assert the account's balance on that day, you'll need to put the assertion in the right file - the last one in the sequence, probably. Assertions and multiple -f files - Unlike include, when multiple files are specified on the command line - with multiple -f/--file options, balance assertions will not see bal- + Unlike include, when multiple files are specified on the command line + with multiple -f/--file options, balance assertions will not see bal- ance from earlier files. This can be useful when you do not want prob- lems in earlier files to disrupt valid assertions in later files. - If you do want assertions to see balance from earlier files, use in- + If you do want assertions to see balance from earlier files, use in- clude, or concatenate the files temporarily. Assertions and costs @@ -1450,20 +1380,20 @@ Journal 2019/1/1 (a) $1 @ 1 = $1 - We do allow costs to be written in balance assertion amounts, however, - and print shows them, but they don't affect whether the assertion - passes or fails. This is for backward compatibility (hledger's close - command used to generate balance assertions with costs), and because + We do allow costs to be written in balance assertion amounts, however, + and print shows them, but they don't affect whether the assertion + passes or fails. This is for backward compatibility (hledger's close + command used to generate balance assertions with costs), and because balance assignments do use costs (see below). Assertions and commodities - The balance assertions described so far are "single commodity balance + The balance assertions described so far are "single commodity balance assertions": they assert and check the balance in one commodity, ignor- - ing any others that may be present. This is how balance assertions + ing any others that may be present. This is how balance assertions work in Ledger also. - If an account contains multiple commodities, you can assert their bal- - ances by writing multiple postings with balance assertions, one for + If an account contains multiple commodities, you can assert their bal- + ances by writing multiple postings with balance assertions, one for each commodity: 2013/1/1 @@ -1475,8 +1405,8 @@ Journal both 0 = $1 both 0 = 1 - In hledger you can make a stronger "sole commodity balance assertion" - by writing two equals signs (== EXPECTEDBALANCE). This also asserts + In hledger you can make a stronger "sole commodity balance assertion" + by writing two equals signs (== EXPECTEDBALANCE). This also asserts that there are no other commodities in the account besides the asserted one (or at least, that their current balance is zero): @@ -1486,12 +1416,12 @@ Journal both ;== $1 ; this one would fail because 'both' contains $ and It's less easy to make a "sole commodities balance assertion" (note the - plural) - ie, asserting that an account contains two or more specified + plural) - ie, asserting that an account contains two or more specified commodities and no others. It can be done by 1. isolating each commodity in a subaccount, and asserting those - 2. and also asserting there are no commodities in the parent account + 2. and also asserting there are no commodities in the parent account itself: 2013/1/1 @@ -1503,10 +1433,10 @@ Journal Assertions and subaccounts All of the balance assertions above (both = and ==) are "subaccount-ex- - clusive balance assertions"; they ignore any balances that exist in + clusive balance assertions"; they ignore any balances that exist in deeper subaccounts. - In hledger you can make "subaccount-inclusive balance assertions" by + In hledger you can make "subaccount-inclusive balance assertions" by adding a star after the equals (=* or ==*): 2019/1/1 @@ -1520,10 +1450,10 @@ Journal are not affected by the --real/-R flag or real: query. Assertions and auto postings - Balance assertions are affected by the --auto flag, which generates + Balance assertions are affected by the --auto flag, which generates auto postings, which can alter account balances. Because auto postings are optional in hledger, accounts affected by them effectively have two - balances. But balance assertions can only test one or the other of + balances. But balance assertions can only test one or the other of these. So to avoid making fragile assertions, either: o assert the balance calculated with --auto, and always use --auto with @@ -1536,15 +1466,15 @@ Journal avoid auto postings entirely). Assertions and precision - Balance assertions compare the exactly calculated amounts, which are - not always what is shown by reports. Eg a commodity directive may - limit the display precision, but this will not affect balance asser- + Balance assertions compare the exactly calculated amounts, which are + not always what is shown by reports. Eg a commodity directive may + limit the display precision, but this will not affect balance asser- tions. Balance assertion failure messages show exact amounts. Posting comments - Text following ;, at the end of a posting line, and/or on indented - lines immediately below it, form comments for that posting. They are - reproduced by print but otherwise ignored, except they may contain + Text following ;, at the end of a posting line, and/or on indented + lines immediately below it, form comments for that posting. They are + reproduced by print but otherwise ignored, except they may contain tags, which are not ignored. 2012-01-01 @@ -1554,55 +1484,55 @@ Journal ; a second comment line for posting 2 Transaction balancing - How exactly does hledger decide when a transaction is balanced ? The + How exactly does hledger decide when a transaction is balanced ? The general goal is that if you look at the journal entry and calculate the amounts' sum perfectly with pencil and paper, hledger should agree with you. - Real world transactions, especially for investments or cryptocurren- - cies, often involve imprecise costs, complex decimals, and/or infi- - nitely-recurring decimals, which are difficult or inconvenient to han- + Real world transactions, especially for investments or cryptocurren- + cies, often involve imprecise costs, complex decimals, and/or infi- + nitely-recurring decimals, which are difficult or inconvenient to han- dle on a computer. So to be a practical accounting system, hledger al- - lows some imprecision when checking transaction balancedness. The + lows some imprecision when checking transaction balancedness. The question is, how much imprecision should be allowed ? - hledger currently decides it based on the commodity display styles: if + hledger currently decides it based on the commodity display styles: if the postings' sum would appear to be zero when displayed with the stan- dard display precisions, the transaction is considered balanced. Or equivalently: if the journal entry is displayed with amounts rounded - to the standard display precisions (with hledger print --round=hard), - and a human with pencil and paper would agree that those displayed + to the standard display precisions (with hledger print --round=hard), + and a human with pencil and paper would agree that those displayed amounts add up to zero, the transaction is considered balanced. - This has some advantages: it is fairly intuitive, general not - hard-coded, yet configurable when needed. On the downside it means - that transaction balancedness is related to commodity display preci- - sions, so eg when using -c/--commodity-style to display things with - more than usual precision, you might need to fix some of your journal + This has some advantages: it is fairly intuitive, general not + hard-coded, yet configurable when needed. On the downside it means + that transaction balancedness is related to commodity display preci- + sions, so eg when using -c/--commodity-style to display things with + more than usual precision, you might need to fix some of your journal entries (ie, add decimal digits to make them balance more precisely). Other PTA tools (Ledger, Beancount..) have their own ways of doing it. Possible improvements are discussed at #1964. - Note: if you have multiple journal files, and are relying on commodity - directives to make imprecise journal entries balance, the directives' + Note: if you have multiple journal files, and are relying on commodity + directives to make imprecise journal entries balance, the directives' placement might be important - see commodity directive. Tags - Tags are a way to add extra labels or data fields to transactions, + Tags are a way to add extra labels or data fields to transactions, postings, or accounts, which you can then search or pivot on. - A tag is a word, optionally hyphenated, immediately followed by a full + A tag is a word, optionally hyphenated, immediately followed by a full colon, in the comment of a transaction, a posting, or an account direc- - tive. Eg: 2024-01-01 a transaction ; foo: Note this is an exception + tive. Eg: 2024-01-01 a transaction ; foo: Note this is an exception to the usual rule that things in comments are ignored. - You can write multiple tags on one line, separated by comma. Or you - can write each tag on its own comment line (no comma needed in this + You can write multiple tags on one line, separated by comma. Or you + can write each tag on its own comment line (no comma needed in this case). - For example, here are five different tags: one on the assets:checking + For example, here are five different tags: one on the assets:checking account, two on the transaction, and two on the expenses:food posting: account assets:checking ; accounttag: @@ -1612,15 +1542,15 @@ Journal assets:checking $-1 expenses:food $1 ; postingtag:, another-posting-tag: - Postings also inherit tags from their transaction and their account. - And transactions also acquire tags from their postings (and postings' - accounts). So in the example above, the expenses posting effectively + Postings also inherit tags from their transaction and their account. + And transactions also acquire tags from their postings (and postings' + accounts). So in the example above, the expenses posting effectively has all five tags (by inheriting from the account and transaction), and - the transaction also has all five tags (by acquiring from the expenses + the transaction also has all five tags (by acquiring from the expenses posting). Tag names - Most non-whitespace characters are allowed in tag names. Eg : is a + Most non-whitespace characters are allowed in tag names. Eg : is a valid tag. You can list the tag names used in your journal with the tags command: @@ -1629,13 +1559,13 @@ Journal In commands which use a query, you can match by tag name. Eg: hledger print tag:NAMEREGEX - You can declare valid tag names with the tag directive and then check + You can declare valid tag names with the tag directive and then check them with the check command. Special tags - Some tag names have special significance to hledger. There's not much - harm in using them yourself, but some could produce an error message, - particularly the date: and type: tags. They are explained elsewhere, + Some tag names have special significance to hledger. There's not much + harm in using them yourself, but some could produce an error message, + particularly the date: and type: tags. They are explained elsewhere, but here is a quick list for reference: Tags you can set to influence hledger's behaviour: @@ -1663,34 +1593,34 @@ Journal _conversion-matched -- exists on postings which have been matched with a nearby @/@@ cost annotation Tag values - Tags can have a value, which is any text after the colon up until a - comma or end of line, with surrounding whitespace removed. Ending at + Tags can have a value, which is any text after the colon up until a + comma or end of line, with surrounding whitespace removed. Ending at comma allows us to write multiple tags on one line, but also means that tag values can not contain commas. - Eg in the following posting, the three tags' values are "value 1", + Eg in the following posting, the three tags' values are "value 1", "value 2", and "" (empty) respectively: expenses:food $10 ; foo, tag1: value 1 , tag2:value 2, bar tag3: , baz - Multiple tags with the same name are additive rather than overriding: - when the same tag name is seen again with a new value, the new + Multiple tags with the same name are additive rather than overriding: + when the same tag name is seen again with a new value, the new name:value pair is added to the tags. It is not possible to override a previous tag's value or remove a tag. - You can list all the values used for a particular tag in the journal + You can list all the values used for a particular tag in the journal with hledger tags TAGNAME --values You can match on tag values with a query like tag:NAMEREGEX=VALUEREGEX Directives - Besides transactions, there is something else you can put in a journal - file: directives. These are declarations, beginning with a keyword, - that modify hledger's behaviour. Some directives can have more spe- - cific subdirectives, indented below them. hledger's directives are + Besides transactions, there is something else you can put in a journal + file: directives. These are declarations, beginning with a keyword, + that modify hledger's behaviour. Some directives can have more spe- + cific subdirectives, indented below them. hledger's directives are similar to Ledger's in many cases, but there are also many differences. - Directives are not required, but can be useful. Here are the main di- + Directives are not required, but can be useful. Here are the main di- rectives: purpose directive @@ -1698,16 +1628,16 @@ Journal READING DATA: Rewrite account names alias Comment out sections of the file comment - Declare file's decimal mark, to help decimal-mark + Declare file's decimal mark, to help decimal-mark parse amounts accurately Include other data files include GENERATING DATA: - Generate recurring transactions or bud- ~ + Generate recurring transactions or bud- ~ get goals - Generate extra postings on existing = + Generate extra postings on existing = transactions CHECKING FOR ERRORS: - Define valid entities to provide more account, commodity, payee, tag + Define valid entities to provide more account, commodity, payee, tag error checking REPORTING: Declare accounts' type and display order account @@ -1715,23 +1645,23 @@ Journal Declare market prices P Directives and multiple files - Directives vary in their scope, ie which journal entries and which in- + Directives vary in their scope, ie which journal entries and which in- put files they affect. Most often, a directive will affect the follow- - ing entries and included files if any, until the end of the current + ing entries and included files if any, until the end of the current file - and no further. You might find this inconvenient! For example, - alias directives do not affect parent or sibling files. But there are + alias directives do not affect parent or sibling files. But there are usually workarounds; for example, put alias directives in your top-most file, before including other files. - The restriction, though it may be annoying at first, is in a good + The restriction, though it may be annoying at first, is in a good cause; it allows reports to be stable and deterministic, independent of - the order of input. Without it, reports could show different numbers - depending on the order of -f options, or the positions of include di- + the order of input. Without it, reports could show different numbers + depending on the order of -f options, or the positions of include di- rectives in your files. Directive effects - Here are all hledger's directives, with their effects and scope sum- - marised - nine main directives, plus four others which we consider + Here are all hledger's directives, with their effects and scope sum- + marised - nine main directives, plus four others which we consider non-essential: di- what it does ends @@ -1739,53 +1669,53 @@ Journal tive file end? -------------------------------------------------------------------------------------- - ac- Declares an account, for checking all entries in all files; and N + ac- Declares an account, for checking all entries in all files; and N count its display order and type. Subdirectives: any text, ignored. - alias Rewrites account names, in following entries until end of cur- Y + alias Rewrites account names, in following entries until end of cur- Y rent file or end aliases. Command line equivalent: --alias - com- Ignores part of the journal file, until end of current file or Y + com- Ignores part of the journal file, until end of current file or Y ment end comment. com- Declares up to four things: 1. a commodity symbol, for checking N,N,Y,Y - mod- all amounts in all files 2. the display style for all amounts - ity of this commodity 3. the decimal mark for parsing amounts of - this commodity, in the rest of this file and its children, if - there is no decimal-mark directive 4. the precision to use for - balanced-transaction checking in this commodity, in this file - and its children. Takes precedence over D. Subdirectives: + mod- all amounts in all files 2. the display style for all amounts + ity of this commodity 3. the decimal mark for parsing amounts of + this commodity, in the rest of this file and its children, if + there is no decimal-mark directive 4. the precision to use for + balanced-transaction checking in this commodity, in this file + and its children. Takes precedence over D. Subdirectives: format (ignored). Command line equivalent: -c/--commodity-style - deci- Declares the decimal mark, for parsing amounts of all commodi- Y + deci- Declares the decimal mark, for parsing amounts of all commodi- Y mal-mark ties in following entries until next decimal-mark or end of cur- - rent file. Included files can override. Takes precedence over + rent file. Included files can override. Takes precedence over commodity and D. - include Includes entries and directives from another file, as if they N - were written inline. Command line alternative: multiple + include Includes entries and directives from another file, as if they N + were written inline. Command line alternative: multiple -f/--file payee Declares a payee name, for checking all entries in all files. N P Declares the market price of a commodity on some date, for value N reports. - ~ Declares a periodic transaction rule that generates future N - (tilde) transactions with --forecast and budget goals with balance + ~ Declares a periodic transaction rule that generates future N + (tilde) transactions with --forecast and budget goals with balance --budget. Other syntax: - apply Prepends a common parent account to all account names, in fol- Y + apply Prepends a common parent account to all account names, in fol- Y account lowing entries until end of current file or end apply account. - D Sets a default commodity to use for no-symbol amounts;and, if Y,Y,N,N - there is no commodity directive for this commodity: its decimal + D Sets a default commodity to use for no-symbol amounts;and, if Y,Y,N,N + there is no commodity directive for this commodity: its decimal mark, balancing precision, and display style, as above. - Y Sets a default year to use for any yearless dates, in following Y + Y Sets a default year to use for any yearless dates, in following Y entries until end of current file. - = Declares an auto posting rule that generates extra postings on partly - (equals) matched transactions with --auto, in current, parent, and child + = Declares an auto posting rule that generates extra postings on partly + (equals) matched transactions with --auto, in current, parent, and child files (but not sibling files, see #1212). - Other Other directives from Ledger's file format are accepted but ig- + Other Other directives from Ledger's file format are accepted but ig- Ledger nored. direc- tives account directive account directives can be used to declare accounts (ie, the places that - amounts are transferred from and to). Though not required, these dec- + amounts are transferred from and to). Though not required, these dec- larations can provide several benefits: o They can document your intended chart of accounts, providing a refer- @@ -1797,17 +1727,17 @@ Journal o They can restrict which accounts may be posted to by transactions, eg in strict mode, which helps prevent errors. - o They influence account display order in reports, allowing non-alpha- + o They influence account display order in reports, allowing non-alpha- betic sorting (eg Revenues to appear above Expenses). - o They can help hledger know your accounts' types (asset, liability, + o They can help hledger know your accounts' types (asset, liability, equity, revenue, expense), enabling reports like balancesheet and in- comestatement. - o They help with account name completion (in hledger add, hledger-web, + o They help with account name completion (in hledger add, hledger-web, hledger-iadd, ledger-mode, etc.) - They are written as the word account followed by a hledger-style ac- + They are written as the word account followed by a hledger-style ac- count name. Eg: account assets:bank:checking @@ -1819,11 +1749,11 @@ Journal Account comments Text following two or more spaces and ; at the end of an account direc- - tive line, and/or following ; on indented lines immediately below it, - form comments for that account. They are ignored except they may con- + tive line, and/or following ; on indented lines immediately below it, + form comments for that account. They are ignored except they may con- tain tags, which are not ignored. - The two-space requirement for same-line account comments is because ; + The two-space requirement for same-line account comments is because ; is allowed in account names. account assets:bank:checking ; same-line comment, at least 2 spaces before the semicolon @@ -1831,34 +1761,34 @@ Journal ; some tags - type:A, acctnum:12345 Account error checking - By default, accounts need not be declared; they come into existence - when a posting references them. This is convenient, but it means - hledger can't warn you when you mis-spell an account name in the jour- + By default, accounts need not be declared; they come into existence + when a posting references them. This is convenient, but it means + hledger can't warn you when you mis-spell an account name in the jour- nal. Usually you'll find that error later, as an extra account in bal- ance reports, or an incorrect balance when reconciling. - In strict mode, enabled with the -s/--strict flag, hledger will report - an error if any transaction uses an account name that has not been de- + In strict mode, enabled with the -s/--strict flag, hledger will report + an error if any transaction uses an account name that has not been de- clared by an account directive. Some notes: - o The declaration is case-sensitive; transactions must use the correct + o The declaration is case-sensitive; transactions must use the correct account name capitalisation. - o The account directive's scope is "whole file and below" (see direc- + o The account directive's scope is "whole file and below" (see direc- tives). This means it affects all of the current file, and any files - it includes, but not parent or sibling files. The position of ac- - count directives within the file does not matter, though it's usual + it includes, but not parent or sibling files. The position of ac- + count directives within the file does not matter, though it's usual to put them at the top. - o Accounts can only be declared in journal files, but will affect in- + o Accounts can only be declared in journal files, but will affect in- cluded files of all types. - o It's currently not possible to declare "all possible subaccounts" + o It's currently not possible to declare "all possible subaccounts" with a wildcard; every account posted to must be declared. Account display order Account directives also cause hledger to display accounts in a particu- - lar order, not just alphabetically. Eg, here is a conventional order- + lar order, not just alphabetically. Eg, here is a conventional order- ing for the top-level accounts: account assets @@ -1876,42 +1806,42 @@ Journal revenues expenses - If there are undeclared accounts, those will be displayed last, in al- + If there are undeclared accounts, those will be displayed last, in al- phabetical order. Sorting is done within each group of sibling accounts, at each level of - the account tree. Eg, a declaration like account parent:child influ- + the account tree. Eg, a declaration like account parent:child influ- ences child's position among its siblings. - Note, it does not affect parent's position; for that, you need an ac- + Note, it does not affect parent's position; for that, you need an ac- count parent declaration. - Sibling accounts are always displayed together; hledger won't display + Sibling accounts are always displayed together; hledger won't display x:y in between a:b and a:c. - An account directive both declares an account as a valid posting tar- - get, and declares its display order; you can't easily do one without + An account directive both declares an account as a valid posting tar- + get, and declares its display order; you can't easily do one without the other. Account types hledger knows that accounts come in several types: assets, liabilities, - expenses and so on. This enables easy reports like balancesheet and + expenses and so on. This enables easy reports like balancesheet and incomestatement, and filtering by account type with the type: query. As a convenience, hledger will detect these account types automatically - if you are using common english-language top-level account names (de- - scribed below). But it's more robust to declare accounts' types ex- - plicitly, by adding type: tags to their account directives. The tag's + if you are using common english-language top-level account names (de- + scribed below). But it's more robust to declare accounts' types ex- + plicitly, by adding type: tags to their account directives. The tag's value should be one of the five main account types: o A or Asset (things you own) o L or Liability (things you owe) - o E or Equity (investment/ownership; balanced counterpart of assets & + o E or Equity (investment/ownership; balanced counterpart of assets & liabilities) - o R or Revenue (what you received money from, AKA income; technically + o R or Revenue (what you received money from, AKA income; technically part of Equity) o X or Expense (what you spend money on; technically part of Equity) @@ -1921,7 +1851,7 @@ Journal o C or Cash (a subtype of Asset, indicating liquid assets for the cash- flow report) - o V or Conversion (a subtype of Equity, for conversions (see Cost re- + o V or Conversion (a subtype of Equity, for conversions (see Cost re- porting).) Subaccounts inherit their parent's type, or they can override it. Here @@ -1940,7 +1870,7 @@ Journal Here are some tips for working with account types. - o The rules for inferring types from account names are as follows. + o The rules for inferring types from account names are as follows. These are just a convenience that sometimes help new users get going; if they don't work for you, just ignore them and declare your account types. See also Regular expressions. @@ -1955,25 +1885,25 @@ Journal ^(income|revenue)s?(:|$) | Revenue ^expenses?(:|$) | Expense - o If you declare any account types, it's a good idea to declare an ac- + o If you declare any account types, it's a good idea to declare an ac- count for all of the account types, because a mixture of declared and name-inferred types can disrupt certain reports. - o Certain uses of account aliases can disrupt account types. See + o Certain uses of account aliases can disrupt account types. See Rewriting accounts > Aliases and account types. o As mentioned above, subaccounts will inherit a type from their parent - account. More precisely, an account's type is decided by the first + account. More precisely, an account's type is decided by the first of these that exists: 1. A type: declaration for this account. - 2. A type: declaration in the parent accounts above it, preferring + 2. A type: declaration in the parent accounts above it, preferring the nearest. 3. An account type inferred from this account's name. - 4. An account type inferred from a parent account's name, preferring + 4. An account type inferred from a parent account's name, preferring the nearest parent. 5. Otherwise, it will have no type. @@ -1999,7 +1929,7 @@ Journal o customising reports Account aliases also rewrite account names in account directives. They - do not affect account names being entered via hledger add or + do not affect account names being entered via hledger add or hledger-web. Account aliases are very powerful. They are generally easy to use cor- @@ -2009,9 +1939,9 @@ Journal See also Rewrite account names. Basic aliases - To set an account alias, use the alias directive in your journal file. - This affects all subsequent journal entries in the current file or its - included files (but note: not sibling or parent files). The spaces + To set an account alias, use the alias directive in your journal file. + This affects all subsequent journal entries in the current file or its + included files (but note: not sibling or parent files). The spaces around the = are optional: alias OLD = NEW @@ -2019,17 +1949,17 @@ Journal Or, you can use the --alias 'OLD=NEW' option on the command line. This affects all entries. It's useful for trying out aliases interactively. - OLD and NEW are case sensitive full account names. hledger will re- - place any occurrence of the old account name with the new one. Subac- + OLD and NEW are case sensitive full account names. hledger will re- + place any occurrence of the old account name with the new one. Subac- counts are also affected. Eg: alias checking = assets:bank:wells fargo:checking ; rewrites "checking" to "assets:bank:wells fargo:checking", or "checking:a" to "assets:bank:wells fargo:checking:a" Regex aliases - There is also a more powerful variant that uses a regular expression, - indicated by wrapping the pattern in forward slashes. (This is the - only place where hledger requires forward slashes around a regular ex- + There is also a more powerful variant that uses a regular expression, + indicated by wrapping the pattern in forward slashes. (This is the + only place where hledger requires forward slashes around a regular ex- pression.) Eg: @@ -2040,13 +1970,13 @@ Journal $ hledger --alias '/REGEX/=REPLACEMENT' ... - Any part of an account name matched by REGEX will be replaced by RE- + Any part of an account name matched by REGEX will be replaced by RE- PLACEMENT. REGEX is case-insensitive as usual. - If you need to match a forward slash, escape it with a backslash, eg + If you need to match a forward slash, escape it with a backslash, eg /\/=:. - If REGEX contains parenthesised match groups, these can be referenced + If REGEX contains parenthesised match groups, these can be referenced by the usual backslash and number in REPLACEMENT: alias /^(.+):bank:([^:]+):(.*)/ = \1:\2 \3 @@ -2056,21 +1986,21 @@ Journal option argument), so it can contain trailing whitespace. Combining aliases - You can define as many aliases as you like, using journal directives + You can define as many aliases as you like, using journal directives and/or command line options. - Recursive aliases - where an account name is rewritten by one alias, - then by another alias, and so on - are allowed. Each alias sees the + Recursive aliases - where an account name is rewritten by one alias, + then by another alias, and so on - are allowed. Each alias sees the effect of previously applied aliases. - In such cases it can be important to understand which aliases will be - applied and in which order. For (each account name in) each journal + In such cases it can be important to understand which aliases will be + applied and in which order. For (each account name in) each journal entry, we apply: - 1. alias directives preceding the journal entry, most recently parsed + 1. alias directives preceding the journal entry, most recently parsed first (ie, reading upward from the journal entry, bottom to top) - 2. --alias options, in the order they appeared on the command line + 2. --alias options, in the order they appeared on the command line (left to right). In other words, for (an account name in) a given journal entry: @@ -2081,20 +2011,20 @@ Journal o aliases defined after/below the entry do not affect it. - This gives nearby aliases precedence over distant ones, and helps pro- - vide semantic stability - aliases will keep working the same way inde- + This gives nearby aliases precedence over distant ones, and helps pro- + vide semantic stability - aliases will keep working the same way inde- pendent of which files are being read and in which order. - In case of trouble, adding --debug=6 to the command line will show + In case of trouble, adding --debug=6 to the command line will show which aliases are being applied when. Aliases and multiple files - As explained at Directives and multiple files, alias directives do not + As explained at Directives and multiple files, alias directives do not affect parent or sibling files. Eg in this command, hledger -f a.aliases -f b.journal - account aliases defined in a.aliases will not affect b.journal. In- + account aliases defined in a.aliases will not affect b.journal. In- cluding the aliases doesn't work either: include a.aliases @@ -2122,7 +2052,7 @@ Journal end aliases Aliases can generate bad account names - Be aware that account aliases can produce malformed account names, + Be aware that account aliases can produce malformed account names, which could cause confusing reports or invalid print output. For exam- ple, you could erase all account names: @@ -2134,8 +2064,8 @@ Journal 2021-01-01 1 - The above print output is not a valid journal. Or you could insert an - illegal double space, causing print output that would give a different + The above print output is not a valid journal. Or you could insert an + illegal double space, causing print output that would give a different journal when reparsed: 2021-01-01 @@ -2152,15 +2082,15 @@ Journal types) is renamed by an alias, normally the account type remains in ef- fect. - However, renaming in a way that reshapes the account tree (eg renaming - parent accounts but not their children, or vice versa) could prevent + However, renaming in a way that reshapes the account tree (eg renaming + parent accounts but not their children, or vice versa) could prevent child accounts from inheriting the account type of their parents. - Secondly, if an account's type is being inferred from its name, renam- + Secondly, if an account's type is being inferred from its name, renam- ing it by an alias could prevent or alter that. - If you are using account aliases and the type: query is not matching - accounts as you expect, try troubleshooting with the accounts command, + If you are using account aliases and the type: query is not matching + accounts as you expect, try troubleshooting with the accounts command, eg something like: $ hledger accounts --alias assets=bassetts type:a @@ -2168,37 +2098,37 @@ Journal commodity directive The commodity directive performs several functions: - 1. It declares which commodity symbols may be used in the journal, en- - abling useful error checking with strict mode or the check command. + 1. It declares which commodity symbols may be used in the journal, en- + abling useful error checking with strict mode or the check command. See Commodity error checking below. - 2. It declares how all amounts in this commodity should be displayed, + 2. It declares how all amounts in this commodity should be displayed, eg how many decimals to show. See Commodity display style above. - 3. (If no decimal-mark directive is in effect:) It sets the decimal - mark to expect (period or comma) when parsing amounts in this com- + 3. (If no decimal-mark directive is in effect:) It sets the decimal + mark to expect (period or comma) when parsing amounts in this com- modity, in this file and files it includes, from the directive until end of current file. See Decimal marks above. 4. It declares the precision with which this commodity's amounts should - be compared when checking for balanced transactions, anywhere in + be compared when checking for balanced transactions, anywhere in this file and files it includes, until end of current file. - Declaring commodities solves several common parsing/display problems, + Declaring commodities solves several common parsing/display problems, so we recommend it. Note that effects 3 and 4 above end at the end of the directive's file, - and will not affect sibling or parent files. So if you are relying on - them (especially 4) and using multiple files, placing your commodity - directives in a top-level parent file might be important. Or, keep - your decimal marks unambiguous and your entries well balanced and pre- + and will not affect sibling or parent files. So if you are relying on + them (especially 4) and using multiple files, placing your commodity + directives in a top-level parent file might be important. Or, keep + your decimal marks unambiguous and your entries well balanced and pre- cise. (Related: #793) Commodity directive syntax A commodity directive is normally the word commodity followed by a sam- - ple amount (and optionally a comment). Only the amount's symbol and + ple amount (and optionally a comment). Only the amount's symbol and format is significant. Eg: commodity $1000.00 @@ -2207,19 +2137,19 @@ Journal Commodities do not have tags (tags in the comment will be ignored). - A commodity directive's sample amount must always include a period or - comma decimal mark (this rule helps disambiguate decimal marks and - digit group marks). If you don't want to show any decimal digits, + A commodity directive's sample amount must always include a period or + comma decimal mark (this rule helps disambiguate decimal marks and + digit group marks). If you don't want to show any decimal digits, write the decimal mark at the end: commodity 1000. AAAA ; show AAAA with no decimals - Commodity symbols containing spaces, numbers, or punctuation must be + Commodity symbols containing spaces, numbers, or punctuation must be enclosed in double quotes, as usual: commodity 1.0000 "AAAA 2023" - Commodity directives normally include a sample amount, but can declare + Commodity directives normally include a sample amount, but can declare only a symbol (ie, just function 1 above): commodity $ @@ -2228,7 +2158,7 @@ Journal commodity "" ; the no-symbol commodity Commodity directives may also be written with an indented format subdi- - rective, as in Ledger. The symbol is repeated and must be the same in + rective, as in Ledger. The symbol is repeated and must be the same in both places. Other subdirectives are currently ignored: ; display indian rupees with currency name on the left, @@ -2239,10 +2169,10 @@ Journal an unsupported subdirective ; ignored by hledger Commodity error checking - In strict mode (-s/--strict) (or when you run hledger check commodi- - ties), hledger will report an error if an undeclared commodity symbol - is used. (With one exception: zero amounts are always allowed to have - no commodity symbol.) It works like account error checking (described + In strict mode (-s/--strict) (or when you run hledger check commodi- + ties), hledger will report an error if an undeclared commodity symbol + is used. (With one exception: zero amounts are always allowed to have + no commodity symbol.) It works like account error checking (described above). decimal-mark directive @@ -2256,20 +2186,20 @@ Journal decimal-mark , - This prevents any ambiguity when parsing numbers in the file, so we - recommend it, especially if the file contains digit group marks (eg + This prevents any ambiguity when parsing numbers in the file, so we + recommend it, especially if the file contains digit group marks (eg thousands separators). include directive - You can pull in the content of additional files by writing an include + You can pull in the content of additional files by writing an include directive, like this: include FILEPATH - Only journal files can include, and only journal, timeclock or timedot + Only journal files can include, and only journal, timeclock or timedot files can be included (not CSV files, currently). - If the file path does not begin with a slash, it is relative to the + If the file path does not begin with a slash, it is relative to the current file's folder. A tilde means home directory, eg: include ~/main.journal. @@ -2278,27 +2208,27 @@ Journal *.journal. There is limited support for recursive wildcards: **/ (the slash is re- - quired) matches 0 or more subdirectories. It's not super convenient - since you have to avoid include cycles and including directories, but + quired) matches 0 or more subdirectories. It's not super convenient + since you have to avoid include cycles and including directories, but this can be done, eg: include */**/*.journal. The path may also be prefixed to force a specific file format, overrid- - ing the file extension (as described in Data formats): include time- + ing the file extension (as described in Data formats): include time- dot:~/notes/2023*.md. P directive The P directive declares a market price, which is a conversion rate be- - tween two commodities on a certain date. This allows value reports to + tween two commodities on a certain date. This allows value reports to convert amounts of one commodity to their value in another, on or after - that date. These prices are often obtained from a stock exchange, + that date. These prices are often obtained from a stock exchange, cryptocurrency exchange, the or foreign exchange market. The format is: P DATE COMMODITY1SYMBOL COMMODITY2AMOUNT - DATE is a simple date, COMMODITY1SYMBOL is the symbol of the commodity - being priced, and COMMODITY2AMOUNT is the amount (symbol and quantity) + DATE is a simple date, COMMODITY1SYMBOL is the symbol of the commodity + being priced, and COMMODITY2AMOUNT is the amount (symbol and quantity) of commodity 2 that one unit of commodity 1 is worth on this date. Ex- amples: @@ -2308,15 +2238,15 @@ Journal # and $1.40 from 2010-01-01 onward: P 2010-01-01 $1.40 - The -V, -X and --value flags use these market prices to show amount + The -V, -X and --value flags use these market prices to show amount values in another commodity. See Value reporting. payee directive payee PAYEE NAME This directive can be used to declare a limited set of payees which may - appear in transaction descriptions. The "payees" check will report an - error if any transaction refers to a payee that has not been declared. + appear in transaction descriptions. The "payees" check will report an + error if any transaction refers to a payee that has not been declared. Eg: payee Whole Foods ; a comment @@ -2332,58 +2262,58 @@ Journal tag directive tag TAGNAME - This directive can be used to declare a limited set of tag names al- + This directive can be used to declare a limited set of tag names al- lowed in tags. TAGNAME should be a valid tag name (no spaces). Eg: tag item-id Any indented subdirectives are currently ignored. - The "tags" check will report an error if any undeclared tag name is + The "tags" check will report an error if any undeclared tag name is used. It is quite easy to accidentally create a tag through normal use of colons in comments; if you want to prevent this, you can declare and check your tags . Periodic transactions - The ~ directive declares a "periodic rule" which generates temporary + The ~ directive declares a "periodic rule" which generates temporary extra transactions, usually recurring at some interval, when hledger is run with the --forecast flag. These "forecast transactions" are useful - for forecasting future activity. They exist only for the duration of + for forecasting future activity. They exist only for the duration of the report, and only when --forecast is used; they are not saved in the journal file by hledger. - Periodic rules also have a second use: with the --budget flag they set + Periodic rules also have a second use: with the --budget flag they set budget goals for budgeting. - Periodic rules can be a little tricky, so before you use them, read + Periodic rules can be a little tricky, so before you use them, read this whole section, or at least the following tips: - 1. Two spaces accidentally added or omitted will cause you trouble - + 1. Two spaces accidentally added or omitted will cause you trouble - read about this below. - 2. For troubleshooting, show the generated transactions with hledger - print --forecast tag:generated or hledger register --forecast + 2. For troubleshooting, show the generated transactions with hledger + print --forecast tag:generated or hledger register --forecast tag:generated. - 3. Forecasted transactions will begin only after the last non-fore- + 3. Forecasted transactions will begin only after the last non-fore- casted transaction's date. - 4. Forecasted transactions will end 6 months from today, by default. + 4. Forecasted transactions will end 6 months from today, by default. See below for the exact start/end rules. - 5. period expressions can be tricky. Their documentation needs im- + 5. period expressions can be tricky. Their documentation needs im- provement, but is worth studying. - 6. Some period expressions with a repeating interval must begin on a - natural boundary of that interval. Eg in weekly from DATE, DATE - must be a monday. ~ weekly from 2019/10/1 (a tuesday) will give an + 6. Some period expressions with a repeating interval must begin on a + natural boundary of that interval. Eg in weekly from DATE, DATE + must be a monday. ~ weekly from 2019/10/1 (a tuesday) will give an error. 7. Other period expressions with an interval are automatically expanded - to cover a whole number of that interval. (This is done to improve + to cover a whole number of that interval. (This is done to improve reports, but it also affects periodic transactions. Yes, it's a bit - inconsistent with the above.) Eg: ~ every 10th day of month from - 2023/01, which is equivalent to ~ every 10th day of month from + inconsistent with the above.) Eg: ~ every 10th day of month from + 2023/01, which is equivalent to ~ every 10th day of month from 2023/01/01, will be adjusted to start on 2019/12/10. Periodic rule syntax @@ -2401,14 +2331,14 @@ Journal expenses:utilities $400 assets:bank:checking - The period expression is the same syntax used for specifying multi-pe- - riod reports, just interpreted differently; there, it specifies report + The period expression is the same syntax used for specifying multi-pe- + riod reports, just interpreted differently; there, it specifies report periods; here it specifies recurrence dates (the periods' start dates). Periodic rules and relative dates - Partial or relative dates (like 12/31, 25, tomorrow, last week, next - quarter) are usually not recommended in periodic rules, since the re- - sults will change as time passes. If used, they will be interpreted + Partial or relative dates (like 12/31, 25, tomorrow, last week, next + quarter) are usually not recommended in periodic rules, since the re- + sults will change as time passes. If used, they will be interpreted relative to, in order of preference: 1. the first day of the default year specified by a recent Y directive @@ -2417,11 +2347,11 @@ Journal 3. or the date on which you are running the report. - They will not be affected at all by report period or forecast period + They will not be affected at all by report period or forecast period dates. Two spaces between period expression and description! - If the period expression is followed by a transaction description, + If the period expression is followed by a transaction description, these must be separated by two or more spaces. This helps hledger know where the period expression ends, so that descriptions can not acciden- tally alter their meaning, as in this example: @@ -2435,51 +2365,51 @@ Journal So, - o Do write two spaces between your period expression and your transac- + o Do write two spaces between your period expression and your transac- tion description, if any. - o Don't accidentally write two spaces in the middle of your period ex- + o Don't accidentally write two spaces in the middle of your period ex- pression. Auto postings The = directive declares an "auto posting rule", which adds extra post- - ings to existing transactions. (Remember, postings are the account + ings to existing transactions. (Remember, postings are the account name & amount lines below a transaction's date & description.) - In the journal, an auto posting rule looks quite like a transaction, - but instead of date and description it has = (mnemonic: "match") and a + In the journal, an auto posting rule looks quite like a transaction, + but instead of date and description it has = (mnemonic: "match") and a query, like this: = QUERY ACCOUNT AMOUNT ... - Queries are just like command line queries; an account name substring - is most common. Query terms containing spaces should be enclosed in + Queries are just like command line queries; an account name substring + is most common. Query terms containing spaces should be enclosed in single or double quotes. - Each = rule works like this: when hledger is run with the --auto flag, - wherever the QUERY matches a posting in the journal, the rule's post- + Each = rule works like this: when hledger is run with the --auto flag, + wherever the QUERY matches a posting in the journal, the rule's post- ings are added to that transaction, immediately below the matched post- - ing. Note these generated postings are temporary, existing only for - the duration of the report, and only when --auto is used; they are not + ing. Note these generated postings are temporary, existing only for + the duration of the report, and only when --auto is used; they are not saved in the journal file by hledger. Generated postings' amounts can depend on the matched posting's amount. - So auto postings can be useful for, eg, adding tax postings with a + So auto postings can be useful for, eg, adding tax postings with a standard percentage. AMOUNT can be: - o a number with no commodity symbol, like 2. The matched posting's + o a number with no commodity symbol, like 2. The matched posting's commodity symbol will be added to this. - o a normal amount with a commodity symbol, like $2. This will be used + o a normal amount with a commodity symbol, like $2. This will be used as-is. - o an asterisk followed by a number, like *2. This will multiply the + o an asterisk followed by a number, like *2. This will multiply the matched posting's amount (and total price, if any) by the number. - o an asterisk followed by an amount with commodity symbol, like *$2. - This multiplies and also replaces the commodity symbol with this new + o an asterisk followed by an amount with commodity symbol, like *$2. + This multiplies and also replaces the commodity symbol with this new one. Some examples: @@ -2514,38 +2444,38 @@ Journal assets:checking $20 Note that depending fully on generated data such as this has some draw- - backs - it's less portable, less future-proof, less auditable by oth- + backs - it's less portable, less future-proof, less auditable by oth- ers, and less robust (eg your balance assertions will depend on whether - you use or don't use --auto). An alternative is to use auto postings + you use or don't use --auto). An alternative is to use auto postings in "one time" fashion - use them to help build a complex journal entry, - view it with hledger print --auto, and then copy that output into the + view it with hledger print --auto, and then copy that output into the journal file to make it permanent. Auto postings and multiple files An auto posting rule can affect any transaction in the current file, or - in any parent file or child file. Note, currently it will not affect + in any parent file or child file. Note, currently it will not affect sibling files (when multiple -f/--file are used - see #1212). Auto postings and dates - A posting date (or secondary date) in the matched posting, or (taking - precedence) a posting date in the auto posting rule itself, will also + A posting date (or secondary date) in the matched posting, or (taking + precedence) a posting date in the auto posting rule itself, will also be used in the generated posting. Auto postings and transaction balancing / inferred amounts / balance asser- tions Currently, auto postings are added: - o after missing amounts are inferred, and transactions are checked for + o after missing amounts are inferred, and transactions are checked for balancedness, o but before balance assertions are checked. - Note this means that journal entries must be balanced both before and + Note this means that journal entries must be balanced both before and after auto postings are added. This changed in hledger 1.12+; see #893 for background. - This also means that you cannot have more than one auto-posting with a - missing amount applied to a given transaction, as it will be unable to + This also means that you cannot have more than one auto-posting with a + missing amount applied to a given transaction, as it will be unable to infer amounts. Auto posting tags @@ -2554,11 +2484,11 @@ Journal o generated-posting:= QUERY - shows this was generated by an auto post- ing rule, and the query - o _generated-posting:= QUERY - a hidden tag, which does not appear in + o _generated-posting:= QUERY - a hidden tag, which does not appear in hledger's output. This can be used to match postings generated "just now", rather than generated in the past and saved to the journal. - Also, any transaction that has been changed by auto posting rules will + Also, any transaction that has been changed by auto posting rules will have these tags added: o modified: - this transaction was modified @@ -2567,24 +2497,24 @@ Journal tion was modified "just now". Auto postings on forecast transactions only - Tip: you can can make auto postings that will apply to forecast trans- - actions but not recorded transactions, by adding tag:_generated-trans- - action to their QUERY. This can be useful when generating new journal + Tip: you can can make auto postings that will apply to forecast trans- + actions but not recorded transactions, by adding tag:_generated-trans- + action to their QUERY. This can be useful when generating new journal entries to be saved in the journal. Other syntax - hledger journal format supports quite a few other features, mainly to - make interoperating with or converting from Ledger easier. Note some - of the features below are powerful and can be useful in special cases, - but in general, features in this section are considered less important - or even not recommended for most users. Downsides are mentioned to + hledger journal format supports quite a few other features, mainly to + make interoperating with or converting from Ledger easier. Note some + of the features below are powerful and can be useful in special cases, + but in general, features in this section are considered less important + or even not recommended for most users. Downsides are mentioned to help you decide if you want to use them. Balance assignments - Ledger-style balance assignments are also supported. These are like - balance assertions, but with no posting amount on the left side of the - equals sign; instead it is calculated automatically so as to satisfy - the assertion. This can be a convenience during data entry, eg when + Ledger-style balance assignments are also supported. These are like + balance assertions, but with no posting amount on the left side of the + equals sign; instead it is calculated automatically so as to satisfy + the assertion. This can be a convenience during data entry, eg when setting opening balances: ; starting a new journal, set asset account balances @@ -2602,15 +2532,15 @@ Journal expenses:misc The calculated amount depends on the account's balance in the commodity - at that point (which depends on the previously-dated postings of the - commodity to that account since the last balance assertion or assign- + at that point (which depends on the previously-dated postings of the + commodity to that account since the last balance assertion or assign- ment). - Downsides: using balance assignments makes your journal less explicit; + Downsides: using balance assignments makes your journal less explicit; to know the exact amount posted, you have to run hledger or do the cal- - culations yourself, instead of just reading it. Also balance assign- + culations yourself, instead of just reading it. Also balance assign- ments' forcing of balances can hide errors. These things make your fi- - nancial data less portable, less future-proof, and less trustworthy in + nancial data less portable, less future-proof, and less trustworthy in an audit. Balance assignments and costs @@ -2625,31 +2555,31 @@ Journal (a) $1 @ 2 = $1 @ 2 Balance assignments and multiple files - Balance assignments handle multiple files like balance assertions. - They see balance from other files previously included from the current + Balance assignments handle multiple files like balance assertions. + They see balance from other files previously included from the current file, but not from previous sibling or parent files. Bracketed posting dates - For setting posting dates and secondary posting dates, Ledger's brack- + For setting posting dates and secondary posting dates, Ledger's brack- eted date syntax is also supported: [DATE], [DATE=DATE2] or [=DATE2] in - posting comments. hledger will attempt to parse any square-bracketed - sequence of the 0123456789/-.= characters in this way. With this syn- - tax, DATE infers its year from the transaction and DATE2 infers its + posting comments. hledger will attempt to parse any square-bracketed + sequence of the 0123456789/-.= characters in this way. With this syn- + tax, DATE infers its year from the transaction and DATE2 infers its year from DATE. - Downsides: another syntax to learn, redundant with hledger's + Downsides: another syntax to learn, redundant with hledger's date:/date2: tags, and confusingly similar to Ledger's lot date syntax. D directive D AMOUNT - This directive sets a default commodity, to be used for any subsequent - commodityless amounts (ie, plain numbers) seen while parsing the jour- - nal. This effect lasts until the next D directive, or the end of the + This directive sets a default commodity, to be used for any subsequent + commodityless amounts (ie, plain numbers) seen while parsing the jour- + nal. This effect lasts until the next D directive, or the end of the current file. - For compatibility/historical reasons, D also acts like a commodity di- - rective (setting the commodity's decimal mark for parsing and display + For compatibility/historical reasons, D also acts like a commodity di- + rective (setting the commodity's decimal mark for parsing and display style for output). So its argument is not just a commodity symbol, but a full amount demonstrating the style. The amount must include a deci- mal mark (either period or comma). Eg: @@ -2664,23 +2594,23 @@ Journal Interactions with other directives: - For setting a commodity's display style, a commodity directive has + For setting a commodity's display style, a commodity directive has highest priority, then a D directive. - For detecting a commodity's decimal mark during parsing, decimal-mark + For detecting a commodity's decimal mark during parsing, decimal-mark has highest priority, then commodity, then D. - For checking commodity symbols with the check command, a commodity di- + For checking commodity symbols with the check command, a commodity di- rective is required (hledger check commodities ignores D directives). - Downsides: omitting commodity symbols makes your financial data less - explicit, less portable, and less trustworthy in an audit. It is usu- - ally an unsustainable shortcut; sooner or later you will want to track - multiple commodities. D is overloaded with functions redundant with + Downsides: omitting commodity symbols makes your financial data less + explicit, less portable, and less trustworthy in an audit. It is usu- + ally an unsustainable shortcut; sooner or later you will want to track + multiple commodities. D is overloaded with functions redundant with commodity and decimal-mark. And it works differently from Ledger's D. apply account directive - This directive sets a default parent account, which will be prepended + This directive sets a default parent account, which will be prepended to all accounts in following entries, until an end apply account direc- tive or end of current file. Eg: @@ -2702,10 +2632,10 @@ Journal Account names entered via hledger add or hledger-web are not affected. - Account aliases, if any, are applied after the parent account is + Account aliases, if any, are applied after the parent account is prepended. - Downsides: this can make your financial data less explicit, less + Downsides: this can make your financial data less explicit, less portable, and less trustworthy in an audit. Y directive @@ -2715,7 +2645,7 @@ Journal year YEAR apply year YEAR - The space is optional. This sets a default year to be used for subse- + The space is optional. This sets a default year to be used for subse- quent dates which don't specify a year. Eg: Y2009 ; set default year to 2009 @@ -2736,57 +2666,57 @@ Journal Downsides: omitting the year (from primary transaction dates, at least) makes your financial data less explicit, less portable, and less trust- - worthy in an audit. Such dates can get separated from their corre- - sponding Y directive, eg when evaluating a region of the journal in - your editor. A missing Y directive makes reports dependent on today's + worthy in an audit. Such dates can get separated from their corre- + sponding Y directive, eg when evaluating a region of the journal in + your editor. A missing Y directive makes reports dependent on today's date. Secondary dates A secondary date is written after the primary date, following an equals - sign. If the year is omitted, the primary date's year is assumed. - When running reports, the primary (left) date is used by default, but - with the --date2 flag (or --aux-date or --effective), the secondary + sign. If the year is omitted, the primary date's year is assumed. + When running reports, the primary (left) date is used by default, but + with the --date2 flag (or --aux-date or --effective), the secondary (right) date will be used instead. - The meaning of secondary dates is up to you, but it's best to follow a - consistent rule. Eg "primary = the bank's clearing date, secondary = + The meaning of secondary dates is up to you, but it's best to follow a + consistent rule. Eg "primary = the bank's clearing date, secondary = date the transaction was initiated, if different". - Downsides: makes your financial data more complicated, less portable, + Downsides: makes your financial data more complicated, less portable, and less trustworthy in an audit. Keeping the meaning of the two dates - consistent requires discipline, and you have to remember which report- - ing mode is appropriate for a given report. Posting dates are simpler + consistent requires discipline, and you have to remember which report- + ing mode is appropriate for a given report. Posting dates are simpler and better. Star comments - Lines beginning with * (star/asterisk) are also comment lines. This + Lines beginning with * (star/asterisk) are also comment lines. This feature allows Emacs users to insert org headings in their journal, al- lowing them to fold/unfold/navigate it like an outline when viewed with org mode. - Downsides: another, unconventional comment syntax to learn. Decreases - your journal's portability. And switching to Emacs org mode just for - folding/unfolding meant losing the benefits of ledger mode; nowadays - you can add outshine mode to ledger mode to get folding without losing + Downsides: another, unconventional comment syntax to learn. Decreases + your journal's portability. And switching to Emacs org mode just for + folding/unfolding meant losing the benefits of ledger mode; nowadays + you can add outshine mode to ledger mode to get folding without losing ledger mode's features. Valuation expressions - Ledger allows a valuation function or value to be written in double + Ledger allows a valuation function or value to be written in double parentheses after an amount. hledger ignores these. Virtual postings A posting with parentheses around the account name, like (some:account) - 10, is called an unbalanced virtual posting. These postings do not - participate in transaction balancing. (And if you write them without - an amount, a zero amount is always inferred.) These can occasionally - be convenient for special circumstances, but they violate double entry - bookkeeping and make your data less portable across applications, so + 10, is called an unbalanced virtual posting. These postings do not + participate in transaction balancing. (And if you write them without + an amount, a zero amount is always inferred.) These can occasionally + be convenient for special circumstances, but they violate double entry + bookkeeping and make your data less portable across applications, so many people avoid using them at all. - A posting with brackets around the account name ([some:account]) is - called a balanced virtual posting. The balanced virtual postings in a + A posting with brackets around the account name ([some:account]) is + called a balanced virtual posting. The balanced virtual postings in a transaction must add up to zero, just like ordinary postings, but sepa- - rately from them. These are not part of double entry bookkeeping ei- + rately from them. These are not part of double entry bookkeeping ei- ther, but they are at least balanced. An example: 2022-01-01 buy food with cash, update budget envelope subaccounts, & something else @@ -2797,13 +2727,13 @@ Journal [assets:checking:available] $10 ; <- (something:else) $5 ; <- this is not required to balance - Ordinary postings, whose account names are neither parenthesised nor - bracketed, are called real postings. You can exclude virtual postings + Ordinary postings, whose account names are neither parenthesised nor + bracketed, are called real postings. You can exclude virtual postings from reports with the -R/--real flag or a real:1 query. Other Ledger directives These other Ledger directives are currently accepted but ignored. This - allows hledger to read more Ledger files, but be aware that hledger's + allows hledger to read more Ledger files, but be aware that hledger's reports may differ from Ledger's if you use these. apply fixed COMM AMT @@ -2824,26 +2754,26 @@ Journal value EXPR --command-line-flags - See also https://hledger.org/ledger.html for a detailed hledger/Ledger + See also https://hledger.org/ledger.html for a detailed hledger/Ledger syntax comparison. Other cost/lot notations - A slight digression for Ledger and Beancount users. Ledger has a num- + A slight digression for Ledger and Beancount users. Ledger has a num- ber of cost/lot-related notations: o @ UNITCOST and @@ TOTALCOST o expresses a conversion rate, as in hledger - o when buying, also creates a lot than can be selected at selling + o when buying, also creates a lot than can be selected at selling time o (@) UNITCOST and (@@) TOTALCOST (virtual cost) - o like the above, but also means "this cost was exceptional, don't + o like the above, but also means "this cost was exceptional, don't use it when inferring market prices". - Currently, hledger treats the above like @ and @@; the parentheses are + Currently, hledger treats the above like @ and @@; the parentheses are ignored. o {=FIXEDUNITCOST} and {{=FIXEDTOTALCOST}} (fixed price) @@ -2853,10 +2783,10 @@ Journal o {UNITCOST} and {{TOTALCOST}} (lot price) - o can be used identically to @ UNITCOST and @@ TOTALCOST, also cre- + o can be used identically to @ UNITCOST and @@ TOTALCOST, also cre- ates a lot - o when selling, combined with @ ..., specifies an investment lot by + o when selling, combined with @ ..., specifies an investment lot by its cost basis; does not check if that lot is present o and related: [YYYY/MM/DD] (lot date) @@ -2871,7 +2801,7 @@ Journal o when selling, selects a lot by its note - Currently, hledger accepts any or all of the above in any order after + Currently, hledger accepts any or all of the above in any order after the posting amount, but ignores them. (This can break transaction bal- ancing.) @@ -2882,12 +2812,12 @@ Journal o expresses a cost without creating a lot, as in hledger o when buying (augmenting) or selling (reducing) a lot, combined with - {...}: documents the cost/selling price (not used for transaction + {...}: documents the cost/selling price (not used for transaction balancing) o {UNITCOST} and {{TOTALCOST}} - o when buying (augmenting), expresses the cost for transaction bal- + o when buying (augmenting), expresses the cost for transaction bal- ancing, and also creates a lot with this cost basis attached o when selling (reducing), @@ -2899,38 +2829,38 @@ Journal o expresses the selling price for transaction balancing - Currently, hledger accepts the {UNITCOST}/{{TOTALCOST}} notation but + Currently, hledger accepts the {UNITCOST}/{{TOTALCOST}} notation but ignores it. - o variations: {}, {YYYY-MM-DD}, {"LABEL"}, {UNITCOST, "LABEL"}, {UNIT- + o variations: {}, {YYYY-MM-DD}, {"LABEL"}, {UNITCOST, "LABEL"}, {UNIT- COST, YYYY-MM-DD, "LABEL"} etc. Currently, hledger rejects these. CSV - hledger can read CSV files (Character Separated Value - usually comma, - semicolon, or tab) containing dated records, automatically converting + hledger can read CSV files (Character Separated Value - usually comma, + semicolon, or tab) containing dated records, automatically converting each record into a transaction. (To learn about writing CSV, see CSV output.) - For best error messages when reading CSV/TSV/SSV files, make sure they + For best error messages when reading CSV/TSV/SSV files, make sure they have a corresponding .csv, .tsv or .ssv file extension or use a hledger file prefix (see File Extension below). Each CSV file must be described by a corresponding rules file. - This contains rules describing the CSV data (header line, fields lay- - out, date format etc.), how to construct hledger transactions from it, - and how to categorise transactions based on description or other at- + This contains rules describing the CSV data (header line, fields lay- + out, date format etc.), how to construct hledger transactions from it, + and how to categorise transactions based on description or other at- tributes. - By default, hledger expects this rules file to be named like the CSV - file, with an extra .rules extension added, in the same directory. Eg - when asked to read foo/FILE.csv, hledger looks for foo/FILE.csv.rules. + By default, hledger expects this rules file to be named like the CSV + file, with an extra .rules extension added, in the same directory. Eg + when asked to read foo/FILE.csv, hledger looks for foo/FILE.csv.rules. You can specify a different rules file with the --rules-file option. - At minimum, the rules file must identify the date and amount fields, - and often it also specifies the date format and how many header lines + At minimum, the rules file must identify the date and amount fields, + and often it also specifies the date format and how many header lines there are. Here's a simple CSV file and a rules file for it: Date, Description, Id, Amount @@ -2947,56 +2877,56 @@ CSV income:unknown -10.23 There's an introductory Importing CSV data tutorial on hledger.org, and - more CSV rules examples below, and a larger collection at + more CSV rules examples below, and a larger collection at https://github.com/simonmichael/hledger/tree/master/examples/csv. CSV rules cheatsheet The following kinds of rule can appear in the rules file, in any order. (Blank lines and lines beginning with # or ; or * are ignored.) - source optionally declare which file to read data + source optionally declare which file to read data from - separator declare the field separator, instead of rely- + separator declare the field separator, instead of rely- ing on file extension skip skip one or more header lines at start of file date-format declare how to parse CSV dates/date-times - timezone declare the time zone of ambiguous CSV + timezone declare the time zone of ambiguous CSV date-times - newest-first improve txn order when: there are multiple + newest-first improve txn order when: there are multiple records, newest first, all with the same date - intra-day-reversed improve txn order when: same-day txns are in + intra-day-reversed improve txn order when: same-day txns are in opposite order to the overall file - decimal-mark declare the decimal mark used in CSV amounts, + decimal-mark declare the decimal mark used in CSV amounts, when ambiguous - fields list name CSV fields for easy reference, and op- + fields list name CSV fields for easy reference, and op- tionally assign their values to hledger fields - Field assignment assign a CSV value or interpolated text value + Field assignment assign a CSV value or interpolated text value to a hledger field if block conditionally assign values to hledger fields, or skip a record or end (skip rest of file) if table conditionally assign values to hledger fields, using compact syntax - balance-type select which type of balance assertions/as- + balance-type select which type of balance assertions/as- signments to generate include inline another CSV rules file - Working with CSV tips can be found below, including How CSV rules are + Working with CSV tips can be found below, including How CSV rules are evaluated. source - If you tell hledger to read a csv file with -f foo.csv, it will look - for rules in foo.csv.rules. Or, you can tell it to read the rules - file, with -f foo.csv.rules, and it will look for data in foo.csv + If you tell hledger to read a csv file with -f foo.csv, it will look + for rules in foo.csv.rules. Or, you can tell it to read the rules + file, with -f foo.csv.rules, and it will look for data in foo.csv (since 1.30). - These are mostly equivalent, but the second method provides some extra - features. For one, the data file can be missing, without causing an - error; it is just considered empty. And, you can specify a different + These are mostly equivalent, but the second method provides some extra + features. For one, the data file can be missing, without causing an + error; it is just considered empty. And, you can specify a different data file by adding a "source" rule: source ./Checking1.csv - If you specify just a file name with no path, hledger will look for it + If you specify just a file name with no path, hledger will look for it in your system's downloads directory (~/Downloads, currently): source Checking1.csv @@ -3009,9 +2939,9 @@ CSV See also "Working with CSV > Reading files specified by rule". separator - You can use the separator rule to read other kinds of character-sepa- - rated data. The argument is any single separator character, or the - words tab or space (case insensitive). Eg, for comma-separated values + You can use the separator rule to read other kinds of character-sepa- + rated data. The argument is any single separator character, or the + words tab or space (case insensitive). Eg, for comma-separated values (CSV): separator , @@ -3024,32 +2954,32 @@ CSV separator TAB - If the input file has a .csv, .ssv or .tsv file extension (or a csv:, + If the input file has a .csv, .ssv or .tsv file extension (or a csv:, ssv:, tsv: prefix), the appropriate separator will be inferred automat- ically, and you won't need this rule. skip skip N - The word skip followed by a number (or no number, meaning 1) tells - hledger to ignore this many non-empty lines at the start of the input - data. You'll need this whenever your CSV data contains header lines. - Note, empty and blank lines are skipped automatically, so you don't + The word skip followed by a number (or no number, meaning 1) tells + hledger to ignore this many non-empty lines at the start of the input + data. You'll need this whenever your CSV data contains header lines. + Note, empty and blank lines are skipped automatically, so you don't need to count those. - skip has a second meaning: it can be used inside if blocks (described - below), to skip one or more records whenever the condition is true. + skip has a second meaning: it can be used inside if blocks (described + below), to skip one or more records whenever the condition is true. Records skipped in this way are ignored, except they are still required to be valid CSV. date-format date-format DATEFMT - This is a helper for the date (and date2) fields. If your CSV dates - are not formatted like YYYY-MM-DD, YYYY/MM/DD or YYYY.MM.DD, you'll - need to add a date-format rule describing them with a strptime-style - date parsing pattern - see https://hackage.haskell.org/pack- - age/time/docs/Data-Time-Format.html#v:formatTime. The pattern must + This is a helper for the date (and date2) fields. If your CSV dates + are not formatted like YYYY-MM-DD, YYYY/MM/DD or YYYY.MM.DD, you'll + need to add a date-format rule describing them with a strptime-style + date parsing pattern - see https://hackage.haskell.org/pack- + age/time/docs/Data-Time-Format.html#v:formatTime. The pattern must parse the CSV date value completely. Some examples: # MM/DD/YY @@ -3069,33 +2999,33 @@ CSV timezone timezone TIMEZONE - When CSV contains date-times that are implicitly in some time zone + When CSV contains date-times that are implicitly in some time zone other than yours, but containing no explicit time zone information, you - can use this rule to declare the CSV's native time zone, which helps + can use this rule to declare the CSV's native time zone, which helps prevent off-by-one dates. - When the CSV date-times do contain time zone information, you don't - need this rule; instead, use %Z in date-format (or %z, %EZ, %Ez; see + When the CSV date-times do contain time zone information, you don't + need this rule; instead, use %Z in date-format (or %z, %EZ, %Ez; see the formatTime link above). In either of these cases, hledger will do a time-zone-aware conversion, localising the CSV date-times to your current system time zone. If you prefer to localise to some other time zone, eg for reproducibility, you - can (on unix at least) set the output timezone with the TZ environment + can (on unix at least) set the output timezone with the TZ environment variable, eg: $ TZ=-1000 hledger print -f foo.csv # or TZ=-1000 hledger import foo.csv - timezone currently does not understand timezone names, except "UTC", - "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", or "PDT". For + timezone currently does not understand timezone names, except "UTC", + "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", or "PDT". For others, use numeric format: +HHMM or -HHMM. newest-first hledger tries to ensure that the generated transactions will be ordered chronologically, including same-day transactions. Usually it can - auto-detect how the CSV records are ordered. But if it encounters CSV + auto-detect how the CSV records are ordered. But if it encounters CSV where all records are on the same date, it assumes that the records are - oldest first. If in fact the CSV's records are normally newest first, + oldest first. If in fact the CSV's records are normally newest first, like: 2022-10-01, txn 3... @@ -3109,9 +3039,9 @@ CSV newest-first intra-day-reversed - If CSV records within a single day are ordered opposite to the overall - record order, you can add the intra-day-reversed rule to improve the - order of journal entries. Eg, here the overall record order is newest + If CSV records within a single day are ordered opposite to the overall + record order, you can add the intra-day-reversed rule to improve the + order of journal entries. Eg, here the overall record order is newest first, but same-day records are oldest first: 2022-10-02, txn 3... @@ -3129,10 +3059,10 @@ CSV decimal-mark , - hledger automatically accepts either period or comma as a decimal mark - when parsing numbers (cf Amounts). However if any numbers in the CSV - contain digit group marks, such as thousand-separating commas, you - should declare the decimal mark explicitly with this rule, to avoid + hledger automatically accepts either period or comma as a decimal mark + when parsing numbers (cf Amounts). However if any numbers in the CSV + contain digit group marks, such as thousand-separating commas, you + should declare the decimal mark explicitly with this rule, to avoid misparsed numbers. fields list @@ -3141,17 +3071,17 @@ CSV A fields list (the word fields followed by comma-separated field names) is optional, but convenient. It does two things: - 1. It names the CSV field in each column. This can be convenient if - you are referencing them in other rules, so you can say %SomeField + 1. It names the CSV field in each column. This can be convenient if + you are referencing them in other rules, so you can say %SomeField instead of remembering %13. - 2. Whenever you use one of the special hledger field names (described - below), it assigns the CSV value in this position to that hledger - field. This is the quickest way to populate hledger's fields and + 2. Whenever you use one of the special hledger field names (described + below), it assigns the CSV value in this position to that hledger + field. This is the quickest way to populate hledger's fields and build a transaction. - Here's an example that says "use the 1st, 2nd and 4th fields as the - transaction's date, description and amount; name the last two fields + Here's an example that says "use the 1st, 2nd and 4th fields as the + transaction's date, description and amount; name the last two fields for later reference; and ignore the others": fields date, description, , amount, , , somefield, anotherfield @@ -3161,35 +3091,35 @@ CSV o There must be least two items in the list (at least one comma). - o Field names may not contain spaces. Spaces before/after field names + o Field names may not contain spaces. Spaces before/after field names are optional. o Field names may contain _ (underscore) or - (hyphen). - o Fields you don't care about can be given a dummy name or an empty + o Fields you don't care about can be given a dummy name or an empty name. - If the CSV contains column headings, it's convenient to use these for - your field names, suitably modified (eg lower-cased with spaces re- + If the CSV contains column headings, it's convenient to use these for + your field names, suitably modified (eg lower-cased with spaces re- placed by underscores). - Sometimes you may want to alter a CSV field name to avoid assigning to - a hledger field with the same name. Eg you could call the CSV's "bal- - ance" field balance_ to avoid directly setting hledger's balance field + Sometimes you may want to alter a CSV field name to avoid assigning to + a hledger field with the same name. Eg you could call the CSV's "bal- + ance" field balance_ to avoid directly setting hledger's balance field (and generating a balance assertion). Field assignment HLEDGERFIELD FIELDVALUE - Field assignments are the more flexible way to assign CSV values to + Field assignments are the more flexible way to assign CSV values to hledger fields. They can be used instead of or in addition to a fields list (see above). - To assign a value to a hledger field, write the field name (any of the - standard hledger field/pseudo-field names, defined below), a space, - followed by a text value on the same line. This text value may inter- - polate CSV fields, referenced either by their 1-based position in the - CSV record (%N) or by the name they were given in the fields list + To assign a value to a hledger field, write the field name (any of the + standard hledger field/pseudo-field names, defined below), a space, + followed by a text value on the same line. This text value may inter- + polate CSV fields, referenced either by their 1-based position in the + CSV record (%N) or by the name they were given in the fields list (%CSVFIELD), and regular expression match groups (\N). Some examples: @@ -3202,26 +3132,26 @@ CSV Tips: - o Interpolation strips outer whitespace (so a CSV value like " 1 " be- + o Interpolation strips outer whitespace (so a CSV value like " 1 " be- comes 1 when interpolated) (#1051). - o Interpolations always refer to a CSV field - you can't interpolate a + o Interpolations always refer to a CSV field - you can't interpolate a hledger field. (See Referencing other fields below). Field names - Note the two kinds of field names mentioned here, and used only in + Note the two kinds of field names mentioned here, and used only in hledger CSV rules files: - 1. CSV field names (CSVFIELD in these docs): you can optionally name - the CSV columns for easy reference (since hledger doesn't yet auto- + 1. CSV field names (CSVFIELD in these docs): you can optionally name + the CSV columns for easy reference (since hledger doesn't yet auto- matically recognise column headings in a CSV file), by writing arbi- trary names in a fields list, eg: fields When, What, Some_Id, Net, Total, Foo, Bar - 2. Special hledger field names (HLEDGERFIELD in these docs): you must - set at least some of these to generate the hledger transaction from - a CSV record, by writing them as the left hand side of a field as- + 2. Special hledger field names (HLEDGERFIELD in these docs): you must + set at least some of these to generate the hledger transaction from + a CSV record, by writing them as the left hand side of a field as- signment, eg: date %When @@ -3236,7 +3166,7 @@ CSV currency $ comment %Foo %Bar - Here are all the special hledger field names available, and what hap- + Here are all the special hledger field names available, and what hap- pens when you assign values to them: date field @@ -3259,7 +3189,7 @@ CSV commentN, where N is a number, sets the Nth posting's comment. - You can assign multi-line comments by writing literal \n in the code. + You can assign multi-line comments by writing literal \n in the code. A comment starting with \n will begin on a new line. Comments can contain tags, as usual. @@ -3268,99 +3198,99 @@ CSV Assigning to accountN, where N is 1 to 99, sets the account name of the Nth posting, and causes that posting to be generated. - Most often there are two postings, so you'll want to set account1 and - account2. Typically account1 is associated with the CSV file, and is - set once with a top-level assignment, while account2 is set based on + Most often there are two postings, so you'll want to set account1 and + account2. Typically account1 is associated with the CSV file, and is + set once with a top-level assignment, while account2 is set based on each transaction's description, in conditional rules. - If a posting's account name is left unset but its amount is set (see - below), a default account name will be chosen (like "expenses:unknown" + If a posting's account name is left unset but its amount is set (see + below), a default account name will be chosen (like "expenses:unknown" or "income:unknown"). amount field - There are several ways to set posting amounts from CSV, useful in dif- + There are several ways to set posting amounts from CSV, useful in dif- ferent situations. - 1. amount is the oldest and simplest. Assigning to this sets the + 1. amount is the oldest and simplest. Assigning to this sets the amount of the first and second postings. In the second posting, the - amount will be negated; also, if it has a cost attached, it will be + amount will be negated; also, if it has a cost attached, it will be converted to cost. - 2. amount-in and amount-out work exactly like the above, but should be - used when the CSV has two amount fields (such as "Debit" and + 2. amount-in and amount-out work exactly like the above, but should be + used when the CSV has two amount fields (such as "Debit" and "Credit", or "Inflow" and "Outflow"). Whichever field has a - non-zero value will be used as the amount of the first and second + non-zero value will be used as the amount of the first and second postings. Here are some tips to avoid confusion: - o It's not "amount-in for posting 1 and amount-out for posting 2", - it is "extract a single amount from the amount-in or amount-out + o It's not "amount-in for posting 1 and amount-out for posting 2", + it is "extract a single amount from the amount-in or amount-out field, and use that for posting 1 and (negated) for posting 2". - o Don't use both amount and amount-in/amount-out in the same rules + o Don't use both amount and amount-in/amount-out in the same rules file; choose based on whether the amount is in a single CSV field or spread across two fields. - o In each record, at most one of the two CSV fields should contain - a non-zero amount; the other field must contain a zero or noth- + o In each record, at most one of the two CSV fields should contain + a non-zero amount; the other field must contain a zero or noth- ing. - o hledger assumes both CSV fields contain unsigned numbers, and it + o hledger assumes both CSV fields contain unsigned numbers, and it automatically negates the amount-out values. - o If the data doesn't fit these requirements, you'll probably need + o If the data doesn't fit these requirements, you'll probably need an if rule (see below). 3. amountN (where N is a number from 1 to 99) sets the amount of only a - single posting: the Nth posting in the transaction. You'll usually - need at least two such assignments to make a balanced transaction. + single posting: the Nth posting in the transaction. You'll usually + need at least two such assignments to make a balanced transaction. You can also generate more than two postings, to represent more com- - plex transactions. The posting numbers don't have to be consecu- - tive; with if rules, higher posting numbers can be useful to ensure + plex transactions. The posting numbers don't have to be consecu- + tive; with if rules, higher posting numbers can be useful to ensure a certain order of postings. - 4. amountN-in and amountN-out work exactly like the above, but should - be used when the CSV has two amount fields. This is analogous to + 4. amountN-in and amountN-out work exactly like the above, but should + be used when the CSV has two amount fields. This is analogous to amount-in and amount-out, and those tips also apply here. 5. Remember that a fields list can also do assignments. So in a fields - list if you name a CSV field "amount", that counts as assigning to - amount. (If you don't want that, call it something else in the + list if you name a CSV field "amount", that counts as assigning to + amount. (If you don't want that, call it something else in the fields list, like "amount_".) - 6. The above don't handle every situation; if you need more flexibil- + 6. The above don't handle every situation; if you need more flexibil- ity, use an if rule to set amounts conditionally. See "Working with - CSV > Setting amounts" below for more on this and on amount-setting + CSV > Setting amounts" below for more on this and on amount-setting generally. currency field - currency sets a currency symbol, to be prepended to all postings' - amounts. You can use this if the CSV amounts do not have a currency + currency sets a currency symbol, to be prepended to all postings' + amounts. You can use this if the CSV amounts do not have a currency symbol, eg if it is in a separate column. currencyN prepends a currency symbol to just the Nth posting's amount. balance field - balanceN sets a balance assertion amount (or if the posting amount is + balanceN sets a balance assertion amount (or if the posting amount is left empty, a balance assignment) on posting N. balance is a compatibility spelling for hledger <1.17; it is equivalent to balance1. - You can adjust the type of assertion/assignment with the balance-type + You can adjust the type of assertion/assignment with the balance-type rule (see below). - See the Working with CSV tips below for more about setting amounts and + See the Working with CSV tips below for more about setting amounts and currency. if block - Rules can be applied conditionally, depending on patterns in the CSV - data. This allows flexibility; in particular, it is how you can cate- - gorise transactions, selecting an appropriate account name based on - their description (for example). There are two ways to write condi- - tional rules: "if blocks", described here, and "if tables", described + Rules can be applied conditionally, depending on patterns in the CSV + data. This allows flexibility; in particular, it is how you can cate- + gorise transactions, selecting an appropriate account name based on + their description (for example). There are two ways to write condi- + tional rules: "if blocks", described here, and "if tables", described below. - An if block is the word if and one or more "matcher" expressions (can + An if block is the word if and one or more "matcher" expressions (can be a word or phrase), one per line, starting either on the same or next line; followed by one or more indented rules. Eg, @@ -3376,11 +3306,11 @@ CSV RULE RULE - If any of the matchers succeeds, all of the indented rules will be ap- - plied. They are usually field assignments, but the following special + If any of the matchers succeeds, all of the indented rules will be ap- + plied. They are usually field assignments, but the following special rules may also be used within an if block: - o skip - skips the matched CSV record (generating no transaction from + o skip - skips the matched CSV record (generating no transaction from it) o end - skips the rest of the current CSV file. @@ -3406,27 +3336,27 @@ CSV Matchers There are two kinds: - 1. A record matcher is a word or single-line text fragment or regular - expression (REGEX), which hledger will try to match case-insensi- + 1. A record matcher is a word or single-line text fragment or regular + expression (REGEX), which hledger will try to match case-insensi- tively anywhere within the CSV record. Eg: whole foods - 2. A field matcher is preceded with a percent sign and CSV field name - (%CSVFIELD REGEX). hledger will try to match these just within the + 2. A field matcher is preceded with a percent sign and CSV field name + (%CSVFIELD REGEX). hledger will try to match these just within the named CSV field. Eg: %date 2023 - The regular expression is (as usual in hledger) a POSIX extended regu- - lar expression, that also supports GNU word boundaries (\b, \B, \<, - \>), and nothing else. If you have trouble, see "Regular expressions" + The regular expression is (as usual in hledger) a POSIX extended regu- + lar expression, that also supports GNU word boundaries (\b, \B, \<, + \>), and nothing else. If you have trouble, see "Regular expressions" in the hledger manual (https://hledger.org/hledger.html#regular-expres- sions). What matchers match With record matchers, it's important to know that the record matched is - not the original CSV record, but a modified one: separators will be - converted to commas, and enclosing double quotes (but not enclosing - whitespace) are removed. So for example, when reading an SSV file, if + not the original CSV record, but a modified one: separators will be + converted to commas, and enclosing double quotes (but not enclosing + whitespace) are removed. So for example, when reading an SSV file, if the original record was: 2023-01-01; "Acme, Inc."; 1,000 @@ -3441,10 +3371,10 @@ CSV o By default they are OR'd (any of them can match) o When a matcher is preceded by ampersand (&, at the start of the line) - it will be AND'ed with the previous matcher (all in the AND'ed group + it will be AND'ed with the previous matcher (all in the AND'ed group must match) - o Added in 1.32 When a matcher is preceded by an exclamation mark (!), + o Added in 1.32 When a matcher is preceded by an exclamation mark (!), it is negated (it must not match). Note currently there is a limitation: you can't use both & and ! on the @@ -3454,13 +3384,13 @@ CSV Added in 1.32 Matchers can define match groups: parenthesised portions of the regular - expression which are available for reference in field assignments. + expression which are available for reference in field assignments. Groups are enclosed in regular parentheses (( and )) and can be nested. - Each group is available in field assignments using the token \N, where - N is an index into the match groups for this conditional block (e.g. + Each group is available in field assignments using the token \N, where + N is an index into the match groups for this conditional block (e.g. \1, \2, etc.). - Example: Warp credit card payment postings to the beginning of the + Example: Warp credit card payment postings to the beginning of the billing period (Month start), to match how they are presented in state- ments, using posting dates: @@ -3474,8 +3404,8 @@ CSV account1 \1 if table - "if tables" are an alternative to if blocks; they can express many - matchers and field assignments in a more compact tabular format, like + "if tables" are an alternative to if blocks; they can express many + matchers and field assignments in a more compact tabular format, like this: if,HLEDGERFIELD1,HLEDGERFIELD2,... @@ -3486,21 +3416,21 @@ CSV The first character after if is taken to be this if table's field sepa- - rator. It is unrelated to the separator used in the CSV file. It + rator. It is unrelated to the separator used in the CSV file. It should be a non-alphanumeric character like , or | that does not appear - anywhere else in the table (it should not be used in field names or + anywhere else in the table (it should not be used in field names or matchers or values, and it cannot be escaped with a backslash). - Each line must contain the same number of separators; empty values are - allowed. Whitespace can be used in the matcher lines for readability - (but not in the if line, currently). You can use the comment lines in - the table body. The table must be terminated by an empty line (or end + Each line must contain the same number of separators; empty values are + allowed. Whitespace can be used in the matcher lines for readability + (but not in the if line, currently). You can use the comment lines in + the table body. The table must be terminated by an empty line (or end of file). - An if table like the above is interpreted as follows: try all of the + An if table like the above is interpreted as follows: try all of the matchers; whenever a matcher succeeds, assign all of the values on that - line to the corresponding hledger fields; If multiple lines match, - later lines will override fields assigned by the earlier ones - just + line to the corresponding hledger fields; If multiple lines match, + later lines will override fields assigned by the earlier ones - just like the sequence of if blocks would behave. If table presented above is equivalent to this sequence of if blocks: @@ -3531,10 +3461,10 @@ CSV balance-type Balance assertions generated by assigning to balanceN are of the simple - = type by default, which is a single-commodity, subaccount-excluding + = type by default, which is a single-commodity, subaccount-excluding assertion. You may find the subaccount-including variants more useful, - eg if you have created some virtual subaccounts of checking to help - with budgeting. You can select a different type of assertion with the + eg if you have created some virtual subaccounts of checking to help + with budgeting. You can select a different type of assertion with the balance-type rule: # balance assertions will consider all commodities and all subaccounts @@ -3550,9 +3480,9 @@ CSV include include RULESFILE - This includes the contents of another CSV rules file at this point. - RULESFILE is an absolute file path or a path relative to the current - file's directory. This can be useful for sharing common rules between + This includes the contents of another CSV rules file at this point. + RULESFILE is an absolute file path or a path relative to the current + file's directory. This can be useful for sharing common rules between several rules files, eg: # someaccount.csv.rules @@ -3569,42 +3499,42 @@ CSV Some tips: Rapid feedback - It's a good idea to get rapid feedback while creating/troubleshooting + It's a good idea to get rapid feedback while creating/troubleshooting CSV rules. Here's a good way, using entr from eradman.com/entrproject: $ ls foo.csv* | entr bash -c 'echo ----; hledger -f foo.csv print desc:SOMEDESC' - A desc: query (eg) is used to select just one, or a few, transactions - of interest. "bash -c" is used to run multiple commands, so we can - echo a separator each time the command re-runs, making it easier to + A desc: query (eg) is used to select just one, or a few, transactions + of interest. "bash -c" is used to run multiple commands, so we can + echo a separator each time the command re-runs, making it easier to read the output. Valid CSV - Note that hledger will only accept valid CSV conforming to RFC 4180, + Note that hledger will only accept valid CSV conforming to RFC 4180, and equivalent SSV and TSV formats (like RFC 4180 but with semicolon or tab as separators). This means, eg: o Values may be enclosed in double quotes, or not. Enclosing in single quotes is not allowed. (Eg 'A','B' is rejected.) - o When values are enclosed in double quotes, spaces outside the quotes + o When values are enclosed in double quotes, spaces outside the quotes are not allowed. (Eg "A", "B" is rejected.) - o When values are not enclosed in quotes, they may not contain double + o When values are not enclosed in quotes, they may not contain double quotes. (Eg A"A, B is rejected.) - If your CSV/SSV/TSV is not valid in this sense, you'll need to trans- - form it before reading with hledger. Try using sed, or a more permis- + If your CSV/SSV/TSV is not valid in this sense, you'll need to trans- + form it before reading with hledger. Try using sed, or a more permis- sive CSV parser like python's csv lib. File Extension - To help hledger choose the CSV file reader and show the right error - messages (and choose the right field separator character by default), - it's best if CSV/SSV/TSV files are named with a .csv, .ssv or .tsv + To help hledger choose the CSV file reader and show the right error + messages (and choose the right field separator character by default), + it's best if CSV/SSV/TSV files are named with a .csv, .ssv or .tsv filename extension. (More about this at Data formats.) - When reading files with the "wrong" extension, you can ensure the CSV - reader (and the default field separator) by prefixing the file path + When reading files with the "wrong" extension, you can ensure the CSV + reader (and the default field separator) by prefixing the file path with csv:, ssv: or tsv:: Eg: $ hledger -f ssv:foo.dat print @@ -3613,29 +3543,29 @@ CSV if needed. Reading CSV from standard input - You'll need the file format prefix when reading CSV from stdin also, + You'll need the file format prefix when reading CSV from stdin also, since hledger assumes journal format by default. Eg: $ cat foo.dat | hledger -f ssv:- print Reading multiple CSV files - If you use multiple -f options to read multiple CSV files at once, - hledger will look for a correspondingly-named rules file for each CSV - file. But if you use the --rules-file option, that rules file will be + If you use multiple -f options to read multiple CSV files at once, + hledger will look for a correspondingly-named rules file for each CSV + file. But if you use the --rules-file option, that rules file will be used for all the CSV files. Reading files specified by rule Instead of specifying a CSV file in the command line, you can specify a - rules file, as in hledger -f foo.csv.rules CMD. By default this will - read data from foo.csv in the same directory, but you can add a source - rule to specify a different data file, perhaps located in your web + rules file, as in hledger -f foo.csv.rules CMD. By default this will + read data from foo.csv in the same directory, but you can add a source + rule to specify a different data file, perhaps located in your web browser's download directory. This feature was added in hledger 1.30, so you won't see it in most CSV - rules examples. But it helps remove some of the busywork of managing + rules examples. But it helps remove some of the busywork of managing CSV downloads. Most of your financial institutions's default CSV file- - names are different and can be recognised by a glob pattern. So you - can put a rule like source Checking1*.csv in foo-checking.csv.rules, + names are different and can be recognised by a glob pattern. So you + can put a rule like source Checking1*.csv in foo-checking.csv.rules, and then periodically follow a workflow like: 1. Download CSV from Foo's website, using your browser's defaults @@ -3643,45 +3573,45 @@ CSV 2. Run hledger import foo-checking.csv.rules to import any new transac- tions - After import, you can: discard the CSV, or leave it where it is for a - while, or move it into your archives, as you prefer. If you do noth- - ing, next time your browser will save something like Checking1-2.csv, - and hledger will use that because of the * wild card and because it is + After import, you can: discard the CSV, or leave it where it is for a + while, or move it into your archives, as you prefer. If you do noth- + ing, next time your browser will save something like Checking1-2.csv, + and hledger will use that because of the * wild card and because it is the most recent. Valid transactions After reading a CSV file, hledger post-processes and validates the gen- erated journal entries as it would for a journal file - balancing them, - applying balance assignments, and canonicalising amount styles. Any - errors at this stage will be reported in the usual way, displaying the + applying balance assignments, and canonicalising amount styles. Any + errors at this stage will be reported in the usual way, displaying the problem entry. There is one exception: balance assertions, if you have generated them, - will not be checked, since normally these will work only when the CSV - data is part of the main journal. If you do need to check balance as- + will not be checked, since normally these will work only when the CSV + data is part of the main journal. If you do need to check balance as- sertions generated from CSV right away, pipe into another hledger: $ hledger -f file.csv print | hledger -f- print Deduplicating, importing - When you download a CSV file periodically, eg to get your latest bank - transactions, the new file may overlap with the old one, containing + When you download a CSV file periodically, eg to get your latest bank + transactions, the new file may overlap with the old one, containing some of the same records. The import command will (a) detect the new transactions, and (b) append just those transactions to your main journal. It is idempotent, so you - don't have to remember how many times you ran it or with which version - of the CSV. (It keeps state in a hidden .latest.FILE.csv file.) This + don't have to remember how many times you ran it or with which version + of the CSV. (It keeps state in a hidden .latest.FILE.csv file.) This is the easiest way to import CSV data. Eg: # download the latest CSV files, then run this command. # Note, no -f flags needed here. $ hledger import *.csv [--dry] - This method works for most CSV files. (Where records have a stable + This method works for most CSV files. (Where records have a stable chronological order, and new records appear only at the new end.) - A number of other tools and workflows, hledger-specific and otherwise, + A number of other tools and workflows, hledger-specific and otherwise, exist for converting, deduplicating, classifying and managing CSV data. See: @@ -3690,16 +3620,16 @@ CSV o https://plaintextaccounting.org -> data import/conversion Setting amounts - Continuing from amount field above, here are more tips for amount-set- + Continuing from amount field above, here are more tips for amount-set- ting: 1. If the amount is in a single CSV field: a. If its sign indicates direction of flow: - Assign it to amountN, to set the Nth posting's amount. N is usu- + Assign it to amountN, to set the Nth posting's amount. N is usu- ally 1 or 2 but can go up to 99. b. If another field indicates direction of flow: - Use one or more conditional rules to set the appropriate amount + Use one or more conditional rules to set the appropriate amount sign. Eg: # assume a withdrawal unless Type contains "deposit": @@ -3707,15 +3637,15 @@ CSV if %Type deposit amount1 %Amount - 2. If the amount is in two CSV fields (such as Debit and Credit, or In + 2. If the amount is in two CSV fields (such as Debit and Credit, or In and Out): a. If both fields are unsigned: - Assign one field to amountN-in and the other to amountN-out. - hledger will automatically negate the "out" field, and will use + Assign one field to amountN-in and the other to amountN-out. + hledger will automatically negate the "out" field, and will use whichever field value is non-zero as posting N's amount. b. If either field is signed: - You will probably need to override hledger's sign for one or the + You will probably need to override hledger's sign for one or the other field, as in the following example: # Negate the -out value, but only if it is not empty: @@ -3723,12 +3653,12 @@ CSV if %amount1-out [1-9] amount1-out -%amount1-out - c. If both fields can contain a non-zero value (or both can be + c. If both fields can contain a non-zero value (or both can be empty): - The -in/-out rules normally choose the value which is - non-zero/non-empty. Some value pairs can be ambiguous, such as 1 + The -in/-out rules normally choose the value which is + non-zero/non-empty. Some value pairs can be ambiguous, such as 1 and none. For such cases, use conditional rules to help select the - amount. Eg, to handle the above you could select the value con- + amount. Eg, to handle the above you could select the value con- taining non-zero digits: fields date, description, in, out @@ -3741,8 +3671,8 @@ CSV Use the unnumbered amount (or amount-in and amount-out) syntax. 4. If the CSV has only balance amounts, not transaction amounts: - Assign to balanceN, to set a balance assignment on the Nth posting, - causing the posting's amount to be calculated automatically. balance + Assign to balanceN, to set a balance assignment on the Nth posting, + causing the posting's amount to be calculated automatically. balance with no number is equivalent to balance1. In this situation hledger is more likely to guess the wrong default account name, so you may need to set that explicitly. @@ -3758,20 +3688,20 @@ CSV o If an amount value is parenthesised: it will be de-parenthesised and sign-flipped: (AMT) becomes -AMT - o If an amount value has two minus signs (or two sets of parentheses, + o If an amount value has two minus signs (or two sets of parentheses, or a minus sign and parentheses): they cancel out and will be removed: --AMT or -(AMT) becomes AMT - o If an amount value contains just a sign (or just a set of parenthe- + o If an amount value contains just a sign (or just a set of parenthe- ses): - that is removed, making it an empty value. "+" or "-" or "()" becomes + that is removed, making it an empty value. "+" or "-" or "()" becomes "". - It's not possible (without preprocessing the CSV) to set an amount to + It's not possible (without preprocessing the CSV) to set an amount to its absolute value, ie discard its sign. Setting currency/commodity - If the currency/commodity symbol is included in the CSV's amount + If the currency/commodity symbol is included in the CSV's amount field(s): 2023-01-01,foo,$123.00 @@ -3790,7 +3720,7 @@ CSV 2023-01-01,foo,USD,123.00 You can assign that to the currency pseudo-field, which has the special - effect of prepending itself to every amount in the transaction (on the + effect of prepending itself to every amount in the transaction (on the left, with no separating space): fields date,description,currency,amount @@ -3799,7 +3729,7 @@ CSV expenses:unknown USD123.00 income:unknown USD-123.00 - Or, you can use a field assignment to construct the amount yourself, + Or, you can use a field assignment to construct the amount yourself, with more control. Eg to put the symbol on the right, and separated by a space: @@ -3810,16 +3740,33 @@ CSV expenses:unknown 123.00 USD income:unknown -123.00 USD - Note we used a temporary field name (cur) that is not currency - that + Note we used a temporary field name (cur) that is not currency - that would trigger the prepending effect, which we don't want here. Amount decimal places - Like amounts in a journal file, the amounts generated by CSV rules like - amount1 influence commodity display styles, such as the number of deci- - mal places displayed in reports. + When you are reading CSV data, eg with a command like hledger -f + foo.csv print, hledger will infer each commodity's decimal precision + (and other commodity display styles) from the amounts - much as when + reading a journal file without commodity directives (see the link). - The original amounts as written in the CSV file do not affect display - style (because we don't yet reliably know their commodity). + Note, the commodity styles are not inferred from the numbers in the + original CSV data; rather, they are inferred from the amounts generated + by the CSV rules. + + When you are importing CSV data with the import command, eg hledger im- + port foo.csv, there's another step: import tries to make the new en- + tries conform to the journal's existing styles. So for each commodity + - let's say it's EUR - import will choose: + + 1. the style declared for EUR by a commodity directive in the journal + + 2. otherwise, the style inferred from EUR amounts in the journal + + 3. otherwise, the style inferred from EUR amounts generated by the CSV + rules. + + TLDR: if import is not generating the precisions or styles you want, + add a commodity directive to specify them. Referencing other fields In field assignments, you can interpolate only CSV fields, not hledger @@ -4402,211 +4349,108 @@ Timedot 4.50 PART 3: REPORTING CONCEPTS -Amount formatting - Commodity display style - For the amounts in each commodity, hledger chooses a consistent display - style (symbol placement, decimal mark and digit group marks, number of - decimal digits) to use in most reports. This is inferred as follows: - - First, if there's a D directive declaring a default commodity, that - commodity symbol and amount format is applied to all no-symbol amounts - in the journal. - - Then each commodity's display style is determined from its commodity - directive. We recommend always declaring commodities with commodity - directives, since they help ensure consistent display styles and preci- - sions, and bring other benefits such as error checking for commodity - symbols. Here's an example: - - # Set display styles (and decimal marks, for parsing, if there is no decimal-mark directive) - # for the $, EUR, INR and no-symbol commodities: - commodity $1,000.00 - commodity EUR 1.000,00 - commodity INR 9,99,99,999.00 - commodity 1 000 000.9455 - - But for convenience, if a commodity directive is not present, hledger - infers a commodity's display styles from its amounts as they are writ- - ten in the journal (excluding cost amounts and amounts in periodic - transaction rules or auto posting rules). It uses - - o the symbol placement and decimal mark of the first amount seen - - o the digit group marks of the first amount with digit group marks - - o and the maximum number of decimal digits seen across all amounts. - - And as fallback if no applicable amounts are found, it would use a de- - fault style, like $1000.00 (symbol on the left with no space, period as - decimal mark, and two decimal digits). - - Finally, commodity styles can be overridden by the -c/--commodity-style - command line option. - - Rounding - Amounts are stored internally as decimal numbers with up to 255 decimal - places. They are displayed with their original journal precisions by - print and print-like reports, and rounded to their display precision - (the number of decimal digits specified by the commodity display style) - by other reports. When rounding, hledger uses banker's rounding (it - rounds to the nearest even digit). So eg 0.5 displayed with zero deci- - mal digits appears as "0". - - Trailing decimal marks - If you're wondering why your print report sometimes shows trailing dec- - imal marks, with no decimal digits; it does this when showing amounts - that have digit group marks but no decimal digits, to disambiguate them - and allow them to be re-parsed reliably (see Decimal marks). Eg: - - commodity $1,000.00 - - 2023-01-02 - (a) $1000 - - $ hledger print - 2023-01-02 - (a) $1,000. - - If this is a problem (eg when exporting to Ledger), you can avoid it by - disabling digit group marks, eg with -c/--commodity (for each affected - commodity): - - $ hledger print -c '$1000.00' - 2023-01-02 - (a) $1000 - - or by forcing print to always show decimal digits, with --round: - - $ hledger print -c '$1,000.00' --round=soft - 2023-01-02 - (a) $1,000.00 - - Amount parseability - More generally, hledger output falls into three rough categories, which - format amounts a little bit differently to suit different consumers: - - 1. "hledger-readable output" - should be readable by hledger (and by - humans) - - o This is produced by reports that show full journal entries: print, - import, close, rewrite etc. - - o It shows amounts with their original journal precisions, which may - not be consistent. - - o It adds a trailing decimal mark when needed to avoid showing ambigu- - ous amounts. - - o It can be parsed reliably (by hledger and ledger2beancount at least, - but perhaps not by Ledger..) - - 2. "human-readable output" - usually for humans - - o This is produced by all other reports. - - o It shows amounts with standard display precisions, which will be con- - sistent within each commodity. - - o It shows ambiguous amounts unmodified. - - o It can be parsed reliably in the context of a known report (when you - know decimals are consistently not being shown, you can assume a sin- - gle mark is a digit group mark). - - 3. "machine-readable output" - usually for other software - - o This is produced by all reports when an output format like csv, tsv, - json, or sql is selected. - - o It shows amounts as 1 or 2 do, but without digit group marks. - - o It can be parsed reliably (if needed, the decimal mark can be changed - with -c/--commodity-style). - Time periods Report start & end date - By default, most hledger reports will show the full span of time repre- - sented by the journal. The report start date will be the earliest + Most hledger reports will by default show the full time period repre- + sented by the journal. The report start date will be the earliest transaction or posting date, and the report end date will be the latest transaction, posting, or market price date. - Often you will want to see a shorter time span, such as the current - month. You can specify a start and/or end date using -b/--begin, - -e/--end, -p/--period or a date: query (described below). All of these - accept the smart date syntax (below). + Often you will want to see a shorter period, such as the current month. + You can specify a start and/or end date with the -b/--begin, -e/--end, + or -p/--period options, or a date: query argument, described below. + All of these accept the smart date syntax, also described below. - Some notes: + End dates are exclusive; specify the day after the last day you want to + see in the report. - o End dates are exclusive, as in Ledger, so you should write the date - after the last day you want to see in the report. - - o As noted in reporting options: among start/end dates specified with - options, the last (i.e. right-most) option takes precedence. - - o The effective report start and end dates are the intersection of the - start/end dates from options and that from date: queries. That is, - date:2019-01 date:2019 -p'2000 to 2030' yields January 2019, the - smallest common time span. - - o In some cases a report interval will adjust start/end dates to fall - on interval boundaries (see below). + When dates are specified by multiple options, the last (right-most) op- + tion wins. And when date: queries and date options are combined, the + report period will be their intersection. Examples: - -b 2016/3/17 begin on St. Patrick's day 2016 - -e 12/1 end at the start of december 1st of the current year - (11/30 will be the last date included) - -b thismonth all transactions on or after the 1st of the current month - -p thismonth all transactions in the current month - date:2016/3/17.. the above written as queries instead (.. can also be re- - placed with -) - date:..12/1 - date:thismonth.. - date:thismonth + -b 2016/3/17 + beginning on St. Patrick's day 2016 + + -e 12/1 + ending at the start of December 1st in the current year + + -p 'this month' + during the current month + + -p thismonth + same as above, spaces are optional + + -b 2023 + beginning on the first day of 2023 + + date:2023.. or date:2023- + same as above + + -b 2024 -e 2025 -p '2000 to 2030' date:2020-01 date:2020 : + during January 2020 (the smallest common period, with the -p overriding + -b and -e) Smart dates - hledger's user interfaces accept a "smart date" syntax for added conve- - nience. Smart dates optionally can be relative to today's date, be - written with english words, and have less-significant parts omitted - (missing parts are inferred as 1). Some examples: + In hledger's user interfaces (though not in the journal file), you can + optionally use "smart date" syntax. Smart dates can be written with + english words, can be relative, and can have parts omitted. Missing + parts are inferred as 1, when needed. Smart dates can be interpreted + as dates or periods depending on context. - 2004/10/1, 2004-01-01, exact date, several separators allowed. Year - 2004.9.1 is 4+ digits, month is 1-12, day is 1-31 - 2004 start of year - 2004/10 start of month - 10/1 month and day in current year - 21 day in current month - october, oct start of month in current year - yesterday, today, tomor- -1, 0, 1 days from today - row - last/this/next -1, 0, 1 periods from the current period - day/week/month/quar- - ter/year - in n n periods from the current period - days/weeks/months/quar- - ters/years - n n periods from the current period - days/weeks/months/quar- - ters/years ahead - n -n periods from the current period - days/weeks/months/quar- - ters/years ago - 20181201 8 digit YYYYMMDD with valid year month and day - 201812 6 digit YYYYMM with valid year and month + Examples: - Some counterexamples - malformed digit sequences might give surprising - results: + 2004-01-01, 2004/10/1, 2004.9.1, 20240504 : + Exact dates. The year must have at least four digits, the month must + be 1-12, the day must be 1-31, the separator can be - or / or . or + nothing. - 201813 6 digits with an invalid month is parsed as start of - 6-digit year - 20181301 8 digits with an invalid month is parsed as start of - 8-digit year - 20181232 8 digits with an invalid day gives an error - 201801012 9+ digits beginning with a valid YYYYMMDD gives an error + 2004-10 + start of month - "Today's date" can be overridden with the --today option, in case it's - needed for testing or for recreating old reports. (Except for periodic - transaction rules, which are not affected by --today.) + 2004 start of year + + 10/1 or oct or october + October 1st in current year + + 21 21st day in current month + + yesterday, today, tomorrow + -1, 0, 1 days from today + + last/this/next day/week/month/quarter/year + -1, 0, 1 periods from the current period + + in n days/weeks/months/quarters/years + n periods from the current period + + n days/weeks/months/quarters/years ahead + n periods from the current period + + n days/weeks/months/quarters/years ago + -n periods from the current period + + 20181201 + 8 digit YYYYMMDD with valid year month and day + + 201812 6 digit YYYYMM with valid year and month + + Dates with no separators are allowed but might give surprising results + if mistyped: + + o 20181301 (YYYYMMDD with an invalid month) is parsed as an eight-digit + year + + o 20181232 (YYYYMMDD with an invalid day) gives a parse error + + o 201801012 (a valid YYYYMMDD followed by additional digits) gives a + parse error + + The meaning of relative dates depends on today's date. If you need to + test or reproduce old reports, you can use the --today option to over- + ride that. (Except for periodic transaction rules, which are not af- + fected by --today.) Report intervals A report interval can be specified so that reports like register, bal- @@ -4730,7 +4574,8 @@ Time periods Monthly on a custom day: - o every Nth day [of month] + o every Nth day [of month] (31st day will be adjusted to each month's + last day) o every Nth WEEKDAYNAME [of month] @@ -4738,7 +4583,7 @@ Time periods o every MM/DD [of year] (month number and day of month number) - o every MONTHNAME DDth [of year] (full or three-letter english month + o every MONTHNAME DDth [of year] (full or three-letter english month name, case insensitive, and day of month number) o every DDth MONTHNAME [of year] (equivalent to the above) @@ -4751,21 +4596,21 @@ Time periods 2009/03" -p "every 2nd day of week" periods will go from Tue to Tue -p "every Tue" same - -p "every 15th day" period boundaries will be on 15th of each + -p "every 15th day" period boundaries will be on 15th of each month - -p "every 2nd Monday" period boundaries will be on second Monday + -p "every 2nd Monday" period boundaries will be on second Monday of each month - -p "every 11/05" yearly periods with boundaries on 5th of + -p "every 11/05" yearly periods with boundaries on 5th of November -p "every 5th November" same -p "every Nov 5th" same - Show historical balances at end of the 15th day of each month (N is an + Show historical balances at end of the 15th day of each month (N is an end date, exclusive as always): $ hledger balance -H -p "every 16th day" - Group postings from the start of wednesday to end of the following + Group postings from the start of wednesday to end of the following tuesday (N is both (inclusive) start date and (exclusive) end date): $ hledger register checking -p "every 3rd day of week" @@ -4776,10 +4621,10 @@ Time periods o every WEEKDAYNAME,WEEKDAYNAME,... (full or three-letter english week- day names, case insensitive) - Also, weekday and weekendday are shorthand for mon,tue,wed,thu,fri and + Also, weekday and weekendday are shorthand for mon,tue,wed,thu,fri and sat,sun. - This is mainly intended for use with --forecast, to generate periodic + This is mainly intended for use with --forecast, to generate periodic transactions on arbitrary days of the week. It may be less useful with -p, since it divides each week into subperiods of unequal length, which is unusual. (Related: #1632) @@ -4788,35 +4633,35 @@ Time periods -p "every dates will be Mon, Wed, Fri; periods will be mon,wed,fri" Mon-Tue, Wed-Thu, Fri-Sun - -p "every weekday" dates will be Mon, Tue, Wed, Thu, Fri; periods will + -p "every weekday" dates will be Mon, Tue, Wed, Thu, Fri; periods will be Mon, Tue, Wed, Thu, Fri-Sun -p "every weekend- dates will be Sat, Sun; periods will be Sat, Sun-Fri day" Depth - With the --depth NUM option (short form: -NUM), reports will show ac- - counts only to the specified depth, hiding deeper subaccounts. Use - this when you want a summary with less detail. This flag has the same + With the --depth NUM option (short form: -NUM), reports will show ac- + counts only to the specified depth, hiding deeper subaccounts. Use + this when you want a summary with less detail. This flag has the same effect as a depth: query argument: depth:2, --depth=2 or -2 are equiva- lent. Queries One of hledger's strengths is being able to quickly report on a precise - subset of your data. Most hledger commands accept query arguments, to + subset of your data. Most hledger commands accept query arguments, to restrict their scope. Multiple query terms can be provided to build up a more complex query. - o By default, a query term is interpreted as a case-insensitive sub- + o By default, a query term is interpreted as a case-insensitive sub- string pattern for matching account names: car:fuel dining groceries - o Patterns containing spaces or other special characters must be en- + o Patterns containing spaces or other special characters must be en- closed in single or double quotes: 'personal care' - o These patterns are actually regular expressions, so you can add reg- - exp metacharacters for more precision (see "Regular expressions" + o These patterns are actually regular expressions, so you can add reg- + exp metacharacters for more precision (see "Regular expressions" above for details): '^expenses\b' @@ -4837,15 +4682,15 @@ Queries not:status:'*' not:desc:'opening|closing' not:cur:USD - o Terms with different types are AND-ed, terms with the same type are - OR-ed (mostly; see "Combining query terms" below). The following + o Terms with different types are AND-ed, terms with the same type are + OR-ed (mostly; see "Combining query terms" below). The following query: date:2022 desc:amazon desc:amzn is interpreted as: - date is in 2022 AND ( transaction description contains "amazon" OR + date is in 2022 AND ( transaction description contains "amazon" OR "amzn" ) Query types @@ -4853,15 +4698,15 @@ Queries prefixed with not: to convert them into a negative match. acct:REGEX or REGEX - Match account names containing this case insensitive regular expres- + Match account names containing this case insensitive regular expres- sion. This is the default query type, so we usually don't bother writ- ing the "acct:" prefix. 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 + 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- + by a + or - sign (or is 0), the two signed numbers are compared. Oth- erwise, the absolute magnitudes are compared, ignoring sign. code:REGEX @@ -4869,10 +4714,10 @@ Queries 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 es- + 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 es- caping. So eg to match the dollar sign: hledger print cur:\\$. @@ -4880,21 +4725,21 @@ Queries Match transaction descriptions. date:PERIODEXPR - Match dates (or with the --date2 flag, secondary dates) within the + Match dates (or with the --date2 flag, secondary dates) within the specified period. PERIODEXPR is a period expression with no report in- terval. 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 + 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 + Match (or display, depending on command) accounts at or above this depth. expr:"TERM AND NOT (TERM OR TERM)" (eg) - Match with a boolean combination of queries (which must be enclosed in + Match with a boolean combination of queries (which must be enclosed in quotes). See Combining query terms below. note:REGEX @@ -4902,7 +4747,7 @@ Queries whole description if there's no |). payee:REGEX - Match transaction payee/payer names (the part of the description left + Match transaction payee/payer names (the part of the description left of |, or the whole description if there's no |). real:, real:0 @@ -4912,11 +4757,11 @@ Queries Match unmarked, pending, or cleared transactions respectively. type:TYPECODES - Match by account type (see Declaring accounts > Account types). TYPE- - CODES is one or more of the single-letter account type codes ALERXCV, + Match by account type (see Declaring accounts > Account types). TYPE- + CODES is one or more of the single-letter account type codes ALERXCV, case insensitive. Note type:A and type:E will also match their respec- - tive subtypes C (Cash) and V (Conversion). Certain kinds of account - alias can disrupt account types, see Rewriting accounts > Aliases and + tive subtypes C (Cash) and V (Conversion). Certain kinds of account + alias can disrupt account types, see Rewriting accounts > Aliases and account types. tag:REGEX[=REGEX] @@ -4932,11 +4777,11 @@ Queries o Transactions also acquire the tags of their postings. (inacct:ACCTNAME - A special query term used automatically in hledger-web only: tells + A special query term used automatically in hledger-web only: tells hledger-web to show the transaction register for an account.) Combining query terms - When given multiple space-separated query terms, most commands select + When given multiple space-separated query terms, most commands select things which match: o any of the description terms AND @@ -4957,8 +4802,8 @@ Queries o match all the other terms. - We also support more complex boolean queries with the expr: prefix. - This allows one to combine query terms using and, or, not keywords + We also support more complex boolean queries with the expr: prefix. + This allows one to combine query terms using and, or, not keywords (case insensitive), and to group them by enclosing in parentheses. Some examples: @@ -4971,45 +4816,45 @@ Queries expr:"desc:cool and tag:A" (expr:"desc:cool tag:A" is equivalent) - o Match things which either do not reference the 'expenses:food' ac- + o Match things which either do not reference the 'expenses:food' ac- count, or do have the 'A' tag: expr:"not expenses:food or tag:A" - o Match things which either do not reference the 'expenses:food' ac- - count, or which reference the 'expenses:drink' account and also have + o Match things which either do not reference the 'expenses:food' ac- + count, or which reference the 'expenses:drink' account and also have the 'A' tag: expr:"expenses:food or (expenses:drink and tag:A)" - expr: has a restriction: date: queries may not be used inside or ex- + expr: has a restriction: date: queries may not be used inside or ex- pressions. That would allow disjoint report periods or disjoint result sets, with unclear semantics for our reports. Queries and command options - Some queries can also be expressed as command-line options: depth:2 is + Some queries can also be expressed as command-line options: depth:2 is equivalent to --depth 2, date:2023 is equivalent to -p 2023, etc. When - you mix command options and query arguments, generally the resulting + you mix command options and query arguments, generally the resulting query is their intersection. Queries and account aliases - When account names are rewritten with --alias or alias, acct: will + When account names are rewritten with --alias or alias, acct: will match either the old or the new account name. Queries and valuation - When amounts are converted to other commodities in cost or value re- - ports, cur: and amt: match the old commodity symbol and the old amount + When amounts are converted to other commodities in cost or value re- + ports, cur: and amt: match the old commodity symbol and the old amount quantity, not the new ones. (Except in hledger 1.22, #1625.) Pivoting - Normally, hledger groups and sums amounts within each account. The - --pivot FIELD option substitutes some other transaction field for ac- - count names, causing amounts to be grouped and summed by that field's - value instead. FIELD can be any of the transaction fields acct, sta- - tus, code, desc, payee, note, or a tag name. When pivoting on a tag - and a posting has multiple values of that tag, only the first value is - displayed. Values containing colon:separated:parts will be displayed - hierarchically, like account names. Multiple, colon-delimited fields + Normally, hledger groups and sums amounts within each account. The + --pivot FIELD option substitutes some other transaction field for ac- + count names, causing amounts to be grouped and summed by that field's + value instead. FIELD can be any of the transaction fields acct, sta- + tus, code, desc, payee, note, or a tag name. When pivoting on a tag + and a posting has multiple values of that tag, only the first value is + displayed. Values containing colon:separated:parts will be displayed + hierarchically, like account names. Multiple, colon-delimited fields can be pivoted simultaneously, generating a hierarchical account name. Some examples: @@ -5041,7 +4886,7 @@ Pivoting -------------------- -2 EUR - Another way (the acct: query matches against the pivoted "account + Another way (the acct: query matches against the pivoted "account name"): $ hledger balance --pivot member acct:. @@ -5059,66 +4904,66 @@ Pivoting Generating data hledger has several features for generating data, such as: - o Periodic transaction rules can generate single or repeating transac- - tions following a template. These are usually dated in the future, - eg to help with forecasting. They are activated by the --forecast + o Periodic transaction rules can generate single or repeating transac- + tions following a template. These are usually dated in the future, + eg to help with forecasting. They are activated by the --forecast option. - o The balance command's --budget option uses these same periodic rules + o The balance command's --budget option uses these same periodic rules to generate goals for the budget report. - o Auto posting rules can generate extra postings on certain matched + o Auto posting rules can generate extra postings on certain matched transactions. They are always applied to forecast transactions; with - the --auto flag they are applied to transactions recorded in the + the --auto flag they are applied to transactions recorded in the journal as well. - o The --infer-equity flag infers missing conversion equity postings - from @/@@ costs. And the inverse --infer-costs flag infers missing + o The --infer-equity flag infers missing conversion equity postings + from @/@@ costs. And the inverse --infer-costs flag infers missing @/@@ costs from conversion equity postings. Generated data of this kind is temporary, existing only at report time. - But you can see it in the output of hledger print, and you can save - that to your journal, in effect converting it from temporary generated - data to permanent recorded data. This could be useful as a data entry + But you can see it in the output of hledger print, and you can save + that to your journal, in effect converting it from temporary generated + data to permanent recorded data. This could be useful as a data entry aid. - If you are wondering what data is being generated and why, add the - --verbose-tags flag. In hledger print output you will see extra tags - like generated-transaction, generated-posting, and modified on gener- - ated/modified data. Also, even without --verbose-tags, generated data + If you are wondering what data is being generated and why, add the + --verbose-tags flag. In hledger print output you will see extra tags + like generated-transaction, generated-posting, and modified on gener- + ated/modified data. Also, even without --verbose-tags, generated data always has equivalen hidden tags (with an underscore prefix), so eg you could match generated transactions with tag:_generated-transaction. Forecasting - Forecasting, or speculative future reporting, can be useful for esti- + Forecasting, or speculative future reporting, can be useful for esti- mating future balances, or for exploring different future scenarios. The simplest and most flexible way to do it with hledger is to manually record a bunch of future-dated transactions. You could keep these in a - separate future.journal and include that with -f only when you want to + separate future.journal and include that with -f only when you want to see them. --forecast - There is another way: with the --forecast option, hledger can generate - temporary "forecast transactions" for reporting purposes, according to - periodic transaction rules defined in the journal. Each rule can gen- - erate multiple recurring transactions, so by changing one rule you can + There is another way: with the --forecast option, hledger can generate + temporary "forecast transactions" for reporting purposes, according to + periodic transaction rules defined in the journal. Each rule can gen- + erate multiple recurring transactions, so by changing one rule you can change many forecasted transactions. - Forecast transactions usually start after ordinary transactions end. + Forecast transactions usually start after ordinary transactions end. By default, they begin after your latest-dated ordinary transaction, or - today, whichever is later, and they end six months from today. (The + today, whichever is later, and they end six months from today. (The exact rules are a little more complicated, and are given below.) This is the "forecast period", which need not be the same as the report - period. You can override it - eg to forecast farther into the future, + period. You can override it - eg to forecast farther into the future, or to force forecast transactions to overlap your ordinary transactions - - by giving the --forecast option a period expression argument, like - --forecast=..2099 or --forecast=2023-02-15... Note that the = is re- + - by giving the --forecast option a period expression argument, like + --forecast=..2099 or --forecast=2023-02-15... Note that the = is re- quired. Inspecting forecast transactions - print is the best command for inspecting and troubleshooting forecast + print is the best command for inspecting and troubleshooting forecast transactions. Eg: ~ monthly from 2022-12-20 rent @@ -5152,7 +4997,7 @@ Forecasting expenses:rent $1000 Here there are no ordinary transactions, so the forecasted transactions - begin on the first occurence after today's date. (You won't normally + begin on the first occurence after today's date. (You won't normally use --today; it's just to make these examples reproducible.) Forecast reports @@ -5176,19 +5021,19 @@ Forecasting || $1000 $1000 $1000 $1000 $1000 Forecast tags - Forecast transactions generated by --forecast have a hidden tag, _gen- - erated-transaction. So if you ever need to match forecast transac- + Forecast transactions generated by --forecast have a hidden tag, _gen- + erated-transaction. So if you ever need to match forecast transac- tions, you could use tag:_generated-transaction (or just tag:generated) in a query. - For troubleshooting, you can add the --verbose-tags flag. Then, visi- + For troubleshooting, you can add the --verbose-tags flag. Then, visi- ble generated-transaction tags will be added also, so you can view them - with the print command. Their value indicates which periodic rule was + with the print command. Their value indicates which periodic rule was responsible. Forecast period, in detail Forecast start/end dates are chosen so as to do something useful by de- - fault in almost all situations, while also being flexible. Here are + fault in almost all situations, while also being flexible. Here are (with luck) the exact rules, to help with troubleshooting: The forecast period starts on: @@ -5220,7 +5065,7 @@ Forecasting o otherwise: 180 days (~6 months) from today. Forecast troubleshooting - When --forecast is not doing what you expect, one of these tips should + When --forecast is not doing what you expect, one of these tips should help: o Remember to use the --forecast option. @@ -5230,22 +5075,22 @@ Forecasting o Test with print --forecast. - o Check for typos or too-restrictive start/end dates in your periodic + o Check for typos or too-restrictive start/end dates in your periodic transaction rule. - o Leave at least 2 spaces between the rule's period expression and de- + o Leave at least 2 spaces between the rule's period expression and de- scription fields. - o Check for future-dated ordinary transactions suppressing forecasted + o Check for future-dated ordinary transactions suppressing forecasted transactions. o Try setting explicit report start and/or end dates with -b, -e, -p or date: - o Try adding the -E flag to encourage display of empty periods/zero + o Try adding the -E flag to encourage display of empty periods/zero transactions. - o Try setting explicit forecast start and/or end dates with --fore- + o Try setting explicit forecast start and/or end dates with --fore- cast=START..END o Consult Forecast period, in detail, above. @@ -5253,30 +5098,151 @@ Forecasting o Check inside the engine: add --debug=2 (eg). Budgeting - With the balance command's --budget report, each periodic transaction - rule generates recurring budget goals in specified accounts, and goals - and actual performance can be compared. See the balance command's doc + With the balance command's --budget report, each periodic transaction + rule generates recurring budget goals in specified accounts, and goals + and actual performance can be compared. See the balance command's doc below. - You can generate budget goals and forecast transactions at the same - time, from the same or different periodic transaction rules: hledger + You can generate budget goals and forecast transactions at the same + time, from the same or different periodic transaction rules: hledger bal -M --budget --forecast ... See also: Budgeting and Forecasting. +Amount formatting + Commodity display style + For the amounts in each commodity, hledger chooses a consistent display + style (symbol placement, decimal mark and digit group marks, number of + decimal digits) to use in most reports. This is inferred as follows: + + First, if there's a D directive declaring a default commodity, that + commodity symbol and amount format is applied to all no-symbol amounts + in the journal. + + Then each commodity's display style is determined from its commodity + directive. We recommend always declaring commodities with commodity + directives, since they help ensure consistent display styles and preci- + sions, and bring other benefits such as error checking for commodity + symbols. Here's an example: + + # Set display styles (and decimal marks, for parsing, if there is no decimal-mark directive) + # for the $, EUR, INR and no-symbol commodities: + commodity $1,000.00 + commodity EUR 1.000,00 + commodity INR 9,99,99,999.00 + commodity 1 000 000.9455 + + But for convenience, if a commodity directive is not present, hledger + infers a commodity's display styles from its amounts as they are writ- + ten in the journal (excluding cost amounts and amounts in periodic + transaction rules or auto posting rules). It uses + + o the symbol placement and decimal mark of the first amount seen + + o the digit group marks of the first amount with digit group marks + + o and the maximum number of decimal digits seen across all amounts. + + And as fallback if no applicable amounts are found, it would use a de- + fault style, like $1000.00 (symbol on the left with no space, period as + decimal mark, and two decimal digits). + + Finally, commodity styles can be overridden by the -c/--commodity-style + command line option. + + Rounding + Amounts are stored internally as decimal numbers with up to 255 decimal + places. They are displayed with their original journal precisions by + print and print-like reports, and rounded to their display precision + (the number of decimal digits specified by the commodity display style) + by other reports. When rounding, hledger uses banker's rounding (it + rounds to the nearest even digit). So eg 0.5 displayed with zero deci- + mal digits appears as "0". + + Trailing decimal marks + If you're wondering why your print report sometimes shows trailing dec- + imal marks, with no decimal digits; it does this when showing amounts + that have digit group marks but no decimal digits, to disambiguate them + and allow them to be re-parsed reliably (see Decimal marks). Eg: + + commodity $1,000.00 + + 2023-01-02 + (a) $1000 + + $ hledger print + 2023-01-02 + (a) $1,000. + + If this is a problem (eg when exporting to Ledger), you can avoid it by + disabling digit group marks, eg with -c/--commodity (for each affected + commodity): + + $ hledger print -c '$1000.00' + 2023-01-02 + (a) $1000 + + or by forcing print to always show decimal digits, with --round: + + $ hledger print -c '$1,000.00' --round=soft + 2023-01-02 + (a) $1,000.00 + + Amount parseability + More generally, hledger output falls into three rough categories, which + format amounts a little bit differently to suit different consumers: + + 1. "hledger-readable output" - should be readable by hledger (and by + humans) + + o This is produced by reports that show full journal entries: print, + import, close, rewrite etc. + + o It shows amounts with their original journal precisions, which may + not be consistent. + + o It adds a trailing decimal mark when needed to avoid showing ambigu- + ous amounts. + + o It can be parsed reliably (by hledger and ledger2beancount at least, + but perhaps not by Ledger..) + + 2. "human-readable output" - usually for humans + + o This is produced by all other reports. + + o It shows amounts with standard display precisions, which will be con- + sistent within each commodity. + + o It shows ambiguous amounts unmodified. + + o It can be parsed reliably in the context of a known report (when you + know decimals are consistently not being shown, you can assume a sin- + gle mark is a digit group mark). + + 3. "machine-readable output" - usually for other software + + o This is produced by all reports when an output format like csv, tsv, + json, or sql is selected. + + o It shows amounts as 1 or 2 do, but without digit group marks. + + o It can be parsed reliably (if needed, the decimal mark can be changed + with -c/--commodity-style). + Cost reporting In some transactions - for example a currency conversion, or a purchase - or sale of stock - one commodity is exchanged for another. In these - transactions there is a conversion rate, also called the cost (when - buying) or selling price (when selling). In hledger docs we just say + or sale of stock - one commodity is exchanged for another. In these + transactions there is a conversion rate, also called the cost (when + buying) or selling price (when selling). In hledger docs we just say "cost", for convenience; feel free to mentally translate to "conversion rate" or "selling price" if helpful. Recording costs - We'll explore several ways of recording transactions involving costs. + We'll explore several ways of recording transactions involving costs. These are also summarised at hledger Cookbook > Cost notation. - Costs can be recorded explicitly in the journal, using the @ UNITCOST + Costs can be recorded explicitly in the journal, using the @ UNITCOST or @@ TOTALCOST notation described in Journal > Costs: Variant 1 @@ -5291,11 +5257,11 @@ Cost reporting assets:dollars $-135 assets:euros 100 @@ $135 ; $135 total cost - Typically, writing the unit cost (variant 1) is preferable; it can be + Typically, writing the unit cost (variant 1) is preferable; it can be more effort, requiring more attention to decimal digits; but it reveals the per-unit cost basis, and makes stock sales easier. - Costs can also be left implicit, and hledger will infer the cost that + Costs can also be left implicit, and hledger will infer the cost that is consistent with a balanced transaction: Variant 3 @@ -5304,49 +5270,49 @@ Cost reporting assets:dollars $-135 assets:euros 100 - Here, hledger will attach a @@ 100 cost to the first amount (you can - see it with hledger print -x). This form looks convenient, but there + Here, hledger will attach a @@ 100 cost to the first amount (you can + see it with hledger print -x). This form looks convenient, but there are downsides: - o It sacrifices some error checking. For example, if you accidentally + o It sacrifices some error checking. For example, if you accidentally wrote 10 instead of 100, hledger would not be able to detect the mis- take. - o It is sensitive to the order of postings - if they were reversed, a + o It is sensitive to the order of postings - if they were reversed, a different entry would be inferred and reports would be different. o The per-unit cost basis is not easy to read. - So generally this kind of entry is not recommended. You can make sure + So generally this kind of entry is not recommended. You can make sure you have none of these by using -s (strict mode), or by running hledger check balanced. Reporting at cost - Now when you add the -B/--cost flag to reports ("B" is from Ledger's - -B/--basis/--cost flag), any amounts which have been annotated with - costs will be converted to their cost's commodity (in the report out- + Now when you add the -B/--cost flag to reports ("B" is from Ledger's + -B/--basis/--cost flag), any amounts which have been annotated with + costs will be converted to their cost's commodity (in the report out- put). Ie they will be displayed "at cost" or "at sale price". Some things to note: - o Costs are attached to specific posting amounts in specific transac- - tions, and once recorded they do not change. This contrasts with + o Costs are attached to specific posting amounts in specific transac- + tions, and once recorded they do not change. This contrasts with market prices, which are ambient and fluctuating. - o Conversion to cost is performed before conversion to market value + o Conversion to cost is performed before conversion to market value (described below). Equity conversion postings - There is a problem with the entries above - they are not conventional - Double Entry Bookkeeping (DEB) notation, and because of the "magical" - transformation of one commodity into another, they cause an imbalance + There is a problem with the entries above - they are not conventional + Double Entry Bookkeeping (DEB) notation, and because of the "magical" + transformation of one commodity into another, they cause an imbalance in the Accounting Equation. This shows up as a non-zero grand total in balance reports like hledger bse. - For most hledger users, this doesn't matter in practice and can safely + For most hledger users, this doesn't matter in practice and can safely be ignored ! But if you'd like to learn more, keep reading. - Conventional DEB uses an extra pair of equity postings to balance the + Conventional DEB uses an extra pair of equity postings to balance the transaction. Of course you can do this in hledger as well: Variant 4 @@ -5357,10 +5323,10 @@ Cost reporting equity:conversion $135 equity:conversion -100 - Now the transaction is perfectly balanced according to standard DEB, + Now the transaction is perfectly balanced according to standard DEB, and hledger bse's total will not be disrupted. - And, hledger can still infer the cost for cost reporting, but it's not + And, hledger can still infer the cost for cost reporting, but it's not done by default - you must add the --infer-costs flag like so: $ hledger print --infer-costs @@ -5382,14 +5348,14 @@ Cost reporting o Instead of -B you must remember to type -B --infer-costs. - o --infer-costs works only where hledger can identify the two eq- - uity:conversion postings and match them up with the two non-equity - postings. So writing the journal entry in a particular format be- + o --infer-costs works only where hledger can identify the two eq- + uity:conversion postings and match them up with the two non-equity + postings. So writing the journal entry in a particular format be- comes more important. More on this below. Inferring equity conversion postings Can we go in the other direction ? Yes, if you have transactions writ- - ten with the @/@@ cost notation, hledger can infer the missing equity + ten with the @/@@ cost notation, hledger can infer the missing equity postings, if you add the --infer-equity flag. Eg: 2022-01-01 @@ -5403,15 +5369,15 @@ Cost reporting equity:conversion:$-: -100 equity:conversion:$-:$ $135.00 - The equity account names will be "equity:conversion:A-B:A" and "eq- - uity:conversion:A-B:B" where A is the alphabetically first commodity + The equity account names will be "equity:conversion:A-B:A" and "eq- + uity:conversion:A-B:B" where A is the alphabetically first commodity symbol. You can customise the "equity:conversion" part by declaring an account with the V/Conversion account type. Combining costs and equity conversion postings Finally, you can use both the @/@@ cost notation and equity postings at - the same time. This in theory gives the best of all worlds - preserv- - ing the accounting equation, revealing the per-unit cost basis, and + the same time. This in theory gives the best of all worlds - preserv- + ing the accounting equation, revealing the per-unit cost basis, and providing more flexibility in how you write the entry: Variant 5 @@ -5422,15 +5388,15 @@ Cost reporting equity:conversion -100 assets:euros 100 @ $1.35 - All the other variants above can (usually) be rewritten to this final + All the other variants above can (usually) be rewritten to this final form with: $ hledger print -x --infer-costs --infer-equity Downsides: - o The precise format of the journal entry becomes more important. If - hledger can't detect and match up the cost and equity postings, it + o The precise format of the journal entry becomes more important. If + hledger can't detect and match up the cost and equity postings, it will give a transaction balancing error. o The add command does not yet accept this kind of entry (#2056). @@ -5438,34 +5404,34 @@ Cost reporting o This is the most verbose form. Requirements for detecting equity conversion postings - --infer-costs has certain requirements (unlike --infer-equity, which + --infer-costs has certain requirements (unlike --infer-equity, which always works). It will infer costs only in transactions with: - o Two non-equity postings, in different commodities. Their order is + o Two non-equity postings, in different commodities. Their order is significant: the cost will be added to the first of them. - o Two postings to equity conversion accounts, next to one another, + o Two postings to equity conversion accounts, next to one another, which balance the two non-equity postings. This balancing is checked - to the same precision (number of decimal places) used in the conver- + to the same precision (number of decimal places) used in the conver- sion posting's amount. Equity conversion accounts are: o any accounts declared with account type V/Conversion, or their sub- accounts - o otherwise, accounts named equity:conversion, equity:trade, or eq- + o otherwise, accounts named equity:conversion, equity:trade, or eq- uity:trading, or their subaccounts. - And multiple such four-posting groups can coexist within a single - transaction. When --infer-costs fails, it does not infer a cost in - that transaction, and does not raise an error (ie, it infers costs + And multiple such four-posting groups can coexist within a single + transaction. When --infer-costs fails, it does not infer a cost in + that transaction, and does not raise an error (ie, it infers costs where it can). - Reading variant 5 journal entries, combining cost notation and equity - postings, has all the same requirements. When reading such an entry + Reading variant 5 journal entries, combining cost notation and equity + postings, has all the same requirements. When reading such an entry fails, hledger raises an "unbalanced transaction" error. Infer cost and equity by default ? - Should --infer-costs and --infer-equity be enabled by default ? Try + Should --infer-costs and --infer-equity be enabled by default ? Try using them always, eg with a shell alias: alias h="hledger --infer-equity --infer-costs" @@ -5473,101 +5439,101 @@ Cost reporting and let us know what problems you find. Value reporting - Instead of reporting amounts in their original commodity, hledger can + Instead of reporting amounts in their original commodity, hledger can convert them to cost/sale amount (using the conversion rate recorded in - the transaction), and/or to market value (using some market price on a - certain date). This is controlled by the --value=TYPE[,COMMODITY] op- - tion, which will be described below. We also provide the simpler -V + the transaction), and/or to market value (using some market price on a + certain date). This is controlled by the --value=TYPE[,COMMODITY] op- + tion, which will be described below. We also provide the simpler -V and -X COMMODITY options, and often one of these is all you need: -V: Value - The -V/--market flag converts amounts to market value in their default + The -V/--market flag converts amounts to market value in their default valuation commodity, using the market prices in effect on the valuation date(s), if any. More on these in a minute. -X: Value in specified commodity The -X/--exchange=COMM option is like -V, except you tell it which cur- - rency you want to convert to, and it tries to convert everything to + rency you want to convert to, and it tries to convert everything to that. Valuation date - Market prices can change from day to day. hledger will use the prices - on a particular valuation date (or on more than one date). By default + Market prices can change from day to day. hledger will use the prices + on a particular valuation date (or on more than one date). By default hledger uses "end" dates for valuation. More specifically: - o For single period reports (including normal print and register re- + o For single period reports (including normal print and register re- ports): o If an explicit report end date is specified, that is used - o Otherwise the latest transaction date or P directive date is used + o Otherwise the latest transaction date or P directive date is used (even if it's in the future) o For multiperiod reports, each period is valued on its last day. - This can be customised with the --value option described below, which + This can be customised with the --value option described below, which can select either "then", "end", "now", or "custom" dates. (Note, this has a bug in hledger-ui <=1.31: turning on valuation with the V key al- ways resets it to "end".) Finding market price - To convert a commodity A to its market value in another commodity B, - hledger looks for a suitable market price (exchange rate) as follows, + To convert a commodity A to its market value in another commodity B, + hledger looks for a suitable market price (exchange rate) as follows, in this order of preference: - 1. A declared market price or inferred market price: A's latest market + 1. A declared market price or inferred market price: A's latest market price in B on or before the valuation date as declared by a P direc- tive, or (with the --infer-market-prices flag) inferred from costs. 2. A reverse market price: the inverse of a declared or inferred market price from B to A. - 3. A forward chain of market prices: a synthetic price formed by com- + 3. A forward chain of market prices: a synthetic price formed by com- bining the shortest chain of "forward" (only 1 above) market prices, leading from A to B. - 4. Any chain of market prices: a chain of any market prices, including - both forward and reverse prices (1 and 2 above), leading from A to + 4. Any chain of market prices: a chain of any market prices, including + both forward and reverse prices (1 and 2 above), leading from A to B. - There is a limit to the length of these price chains; if hledger - reaches that length without finding a complete chain or exhausting all - possibilities, it will give up (with a "gave up" message visible in + There is a limit to the length of these price chains; if hledger + reaches that length without finding a complete chain or exhausting all + possibilities, it will give up (with a "gave up" message visible in --debug=2 output). That limit is currently 1000. - Amounts for which no suitable market price can be found, are not con- + Amounts for which no suitable market price can be found, are not con- verted. --infer-market-prices: market prices from transactions Normally, market value in hledger is fully controlled by, and requires, P directives in your journal. Since adding and updating those can be a - chore, and since transactions usually take place at close to market - value, why not use the recorded costs as additional market prices (as - Ledger does) ? Adding the --infer-market-prices flag to -V, -X or + chore, and since transactions usually take place at close to market + value, why not use the recorded costs as additional market prices (as + Ledger does) ? Adding the --infer-market-prices flag to -V, -X or --value enables this. - So for example, hledger bs -V --infer-market-prices will get market - prices both from P directives and from transactions. If both occur on + So for example, hledger bs -V --infer-market-prices will get market + prices both from P directives and from transactions. If both occur on the same day, the P directive takes precedence. There is a downside: value reports can sometimes be affected in confus- - ing/undesired ways by your journal entries. If this happens to you, - read all of this Value reporting section carefully, and try adding + ing/undesired ways by your journal entries. If this happens to you, + read all of this Value reporting section carefully, and try adding --debug or --debug=2 to troubleshoot. --infer-market-prices can infer market prices from: o multicommodity transactions with explicit prices (@/@@) - o multicommodity transactions with implicit prices (no @, two commodi- - ties, unbalanced). (With these, the order of postings matters. + o multicommodity transactions with implicit prices (no @, two commodi- + ties, unbalanced). (With these, the order of postings matters. hledger print -x can be useful for troubleshooting.) o multicommodity transactions with equity postings, if cost is inferred with --infer-costs. - There is a limitation (bug) currently: when a valuation commodity is - not specified, prices inferred with --infer-market-prices do not help + There is a limitation (bug) currently: when a valuation commodity is + not specified, prices inferred with --infer-market-prices do not help select a default valuation commodity, as P prices would. So conversion might not happen because no valuation commodity was detected (--debug=2 will show this). To be safe, specify the valuation commmodity, eg: @@ -5577,8 +5543,8 @@ Value reporting o --value=then,EUR --infer-market-prices, not --value=then --infer-mar- ket-prices - Signed costs and market prices can be confusing. For reference, here - is the current behaviour, since hledger 1.25. (If you think it should + Signed costs and market prices can be confusing. For reference, here + is the current behaviour, since hledger 1.25. (If you think it should work differently, see #1870.) 2022-01-01 Positive Unit prices @@ -5608,7 +5574,7 @@ Value reporting b B -1 @@ A -1 All of the transactions above are considered balanced (and on each day, - the two transactions are considered equivalent). Here are the market + the two transactions are considered equivalent). Here are the market prices inferred for B: $ hledger -f- --infer-market-prices prices @@ -5621,34 +5587,34 @@ Value reporting Valuation commodity When you specify a valuation commodity (-X COMM or --value TYPE,COMM): - hledger will convert all amounts to COMM, wherever it can find a suit- + hledger will convert all amounts to COMM, wherever it can find a suit- able market price (including by reversing or chaining prices). - When you leave the valuation commodity unspecified (-V or --value + When you leave the valuation commodity unspecified (-V or --value TYPE): - For each commodity A, hledger picks a default valuation commodity as + For each commodity A, hledger picks a default valuation commodity as follows, in this order of preference: 1. The price commodity from the latest P-declared market price for A on or before valuation date. 2. The price commodity from the latest P-declared market price for A on - any date. (Allows conversion to proceed when there are inferred + any date. (Allows conversion to proceed when there are inferred prices before the valuation date.) - 3. If there are no P directives at all (any commodity or date) and the - --infer-market-prices flag is used: the price commodity from the + 3. If there are no P directives at all (any commodity or date) and the + --infer-market-prices flag is used: the price commodity from the latest transaction-inferred price for A on or before valuation date. This means: - o If you have P directives, they determine which commodities -V will + o If you have P directives, they determine which commodities -V will convert, and to what. - o If you have no P directives, and use the --infer-market-prices flag, + o If you have no P directives, and use the --infer-market-prices flag, costs determine it. - Amounts for which no valuation commodity can be found are not con- + Amounts for which no valuation commodity can be found are not con- verted. --value: Flexible valuation @@ -5665,26 +5631,26 @@ Value reporting The TYPE part selects cost or value and valuation date: --value=then - Convert amounts to their value in the default valuation commod- + Convert amounts to their value in the default valuation commod- ity, using market prices on each posting's date. --value=end - Convert amounts to their value in the default valuation commod- - ity, using market prices on the last day of the report period - (or if unspecified, the journal's end date); or in multiperiod + Convert amounts to their value in the default valuation commod- + ity, using market prices on the last day of the report period + (or if unspecified, the journal's end date); or in multiperiod reports, market prices on the last day of each subperiod. --value=now - Convert amounts to their value in the default valuation commod- - ity using current market prices (as of when report is gener- + Convert amounts to their value in the default valuation commod- + ity using current market prices (as of when report is gener- ated). --value=YYYY-MM-DD - Convert amounts to their value in the default valuation commod- + Convert amounts to their value in the default valuation commod- ity using market prices on this date. To select a different valuation commodity, add the optional ,COMM part: - a comma, then the target commodity's symbol. Eg: --value=now,EUR. + a comma, then the target commodity's symbol. Eg: --value=now,EUR. hledger will do its best to convert amounts to this commodity, deducing market prices as described above. @@ -5712,13 +5678,13 @@ Value reporting $ hledger -f t.j bal -N euros -V -e 2016/11/4 $110.00 assets:euros - What are they worth after 2016/12/21 ? (no report end date specified, + What are they worth after 2016/12/21 ? (no report end date specified, defaults to today) $ hledger -f t.j bal -N euros -V $103.00 assets:euros - Here are some examples showing the effect of --value, as seen with + Here are some examples showing the effect of --value, as seen with print: P 2000-01-01 A 1 B @@ -5756,7 +5722,7 @@ Value reporting 2000-02-01 (a) 2 B - With no report period specified, that shows the value as of the last + With no report period specified, that shows the value as of the last day of the journal (2000-03-01): $ hledger -f- print --value=end @@ -5794,7 +5760,7 @@ Value reporting (a) 1 B Interaction of valuation and queries - When matching postings based on queries in the presence of valuation, + When matching postings based on queries in the presence of valuation, the following happens: 1. The query is separated into two parts: @@ -5808,45 +5774,45 @@ Value reporting 3. Valuation is applied to the postings. - 4. The postings are matched to the other parts of the query based on + 4. The postings are matched to the other parts of the query based on post-valued amounts. Related: #1625 Effect of valuation on reports - Here is a reference for how valuation is supposed to affect each part - of hledger's reports. (It's wide, you may need to scroll sideways.) - It may be useful when troubleshooting. If you find problems, please - report them, ideally with a reproducible example. Related: #329, + Here is a reference for how valuation is supposed to affect each part + of hledger's reports. (It's wide, you may need to scroll sideways.) + It may be useful when troubleshooting. If you find problems, please + report them, ideally with a reproducible example. Related: #329, #1083. First, a quick glossary: cost calculated using price(s) recorded in the transaction(s). - value market value using available market price declarations, or the + value market value using available market price declarations, or the unchanged amount if no conversion rate can be found. report start - the first day of the report period specified with -b or -p or + the first day of the report period specified with -b or -p or date:, otherwise today. report or journal start - the first day of the report period specified with -b or -p or - date:, otherwise the earliest transaction date in the journal, + the first day of the report period specified with -b or -p or + date:, otherwise the earliest transaction date in the journal, otherwise today. report end - the last day of the report period specified with -e or -p or + the last day of the report period specified with -e or -p or date:, otherwise today. report or journal end - the last day of the report period specified with -e or -p or - date:, otherwise the latest transaction date in the journal, + the last day of the report period specified with -e or -p or + date:, otherwise the latest transaction date in the journal, otherwise today. report interval - a flag (-D/-W/-M/-Q/-Y) or period expression that activates the + a flag (-D/-W/-M/-Q/-Y) or period expression that activates the report's multi-period mode (whether showing one or many subperi- ods). @@ -5854,8 +5820,8 @@ Value reporting type --value=now -------------------------------------------------------------------------------------------- print - posting cost value at re- value at posting value at re- value at - amounts port end or date port or DATE/today + posting cost value at re- value at posting value at re- value at + amounts port end or date port or DATE/today today journal end balance unchanged unchanged unchanged unchanged unchanged asser- @@ -5871,7 +5837,7 @@ Value reporting (-H) with port or posting was made port or report journal journal interval start start - posting cost value at re- value at posting value at re- value at + posting cost value at re- value at posting value at re- value at amounts port or date port or DATE/today journal end journal end summary summarised value at pe- sum of postings value at pe- value at @@ -5887,8 +5853,8 @@ Value reporting balance (bs, bse, cf, is) - balance sums of value at re- value at posting value at re- value at - changes costs port end or date port or DATE/today of + balance sums of value at re- value at posting value at re- value at + changes costs port end or date port or DATE/today of today of journal end sums of post- sums of of sums of ings postings postings @@ -5896,7 +5862,7 @@ Value reporting amounts changes changes changes ances changes (--bud- get) - grand to- sum of dis- sum of dis- sum of displayed sum of dis- sum of dis- + grand to- sum of dis- sum of dis- sum of displayed sum of dis- sum of dis- tal played val- played val- valued played val- played values ues ues ues @@ -5922,7 +5888,7 @@ Value reporting end bal- sums of same as sums of values of period end value at ances costs of --value=end postings from be- balances, DATE/today of (bal -H, postings fore period start valued at sums of post- - is --H, from before to period end at period ends ings + is --H, from before to period end at period ends ings bs, cf) report start respective post- to period ing dates end @@ -5931,10 +5897,10 @@ Value reporting (--bud- balances balances ances balances get) row to- sums, aver- sums, aver- sums, averages of sums, aver- sums, aver- - tals, row ages of dis- ages of dis- displayed values ages of dis- ages of dis- + tals, row ages of dis- ages of dis- displayed values ages of dis- ages of dis- averages played val- played val- played val- played values (-T, -A) ues ues ues - column sums of dis- sums of dis- sums of displayed sums of dis- sums of dis- + column sums of dis- sums of dis- sums of displayed sums of dis- sums of dis- totals played val- played val- values played val- played values ues ues ues grand to- sum, average sum, average sum, average of sum, average sum, average @@ -5947,53 +5913,33 @@ Value reporting starting balance. PART 4: COMMANDS - Commands overview - Here are the built-in commands: - DATA ENTRY - These data entry commands are the only ones which can modify your jour- - nal file. + + Here are the standard commands, which you can list by running hledger. + If you have installed more add-on commands, they also will be listed. + + Help commands + + o help - show the hledger manual with info/man/pager + + o demo - show small hledger demos in the terminal + + User interface commands + + o ui - (if installed) run hledger's terminal UI + + o web - (if installed) run hledger's web UI + + Data entry commands o add - add transactions using terminal prompts o import - add new transactions from other files, eg CSV files - DATA CREATION - o close - generate balance-zeroing/restoring transactions + Basic report commands - o rewrite - generate auto postings, like print --auto - - DATA MANAGEMENT - o check - check for various kinds of error in the data - - o diff - compare account transactions in two journal files - - REPORTS, FINANCIAL - o aregister (areg) - show transactions in a particular account - - o balancesheet (bs) - show assets, liabilities and net worth - - o balancesheetequity (bse) - show assets, liabilities and equity - - o cashflow (cf) - show changes in liquid assets - - o incomestatement (is) - show revenues and expenses - - REPORTS, VERSATILE - o balance (bal) - show balance changes, end balances, budgets, gains.. - - o print - show transactions or export journal data - - o register (reg) - show postings in one or more accounts & running to- - tal - - o roi - show return on investments - - REPORTS, BASIC o accounts - show account names - o activity - show bar charts of posting counts per period - o codes - show transaction codes o commodities - show commodity/currency symbols @@ -6012,33 +5958,306 @@ PART 4: COMMANDS o tags - show tag names + Standard report commands + + o print - show transactions or export journal data + + o aregister (areg) - show transactions in a particular account + + o register (reg) - show postings in one or more accounts & running to- + tal + + o balancesheet (bs) - show assets, liabilities and net worth + + o balancesheetequity (bse) - show assets, liabilities and equity + + o cashflow (cf) - show changes in liquid assets + + o incomestatement (is) - show revenues and expenses + + Advanced report commands + + o balance (bal) - show balance changes, end balances, budgets, gains.. + + o roi - show return on investments + + Chart commands + + o activity - show bar charts of posting counts per period + + Data generation commands + + o close - generate balance-zeroing/restoring transactions + + o rewrite - generate auto postings, like print --auto + + Maintenance commands + + o check - check for various kinds of error in the data + + o diff - compare account transactions in two journal files + o test - run self tests - HELP - o help - show the hledger manual with info/man/pager + Next, these commands are described in detail. - o demo - show small hledger demos in the terminal +Help commands + help + Show the hledger user manual with info, man, or a pager. With a (case + insensitive) TOPIC argument, try to open it at that section heading. - ADD-ONS - And here are some typical add-on commands. Some of these are installed - by the hledger-install script. If installed, they will appear in - hledger's commands list: + This command shows the hledger manual built in to your hledger exe- + cutable. It can be useful when offline, or when you prefer the termi- + nal to a web browser, or when the appropriate hledger manual or viewers + are not installed properly on your system. - o ui - run hledger's terminal UI + By default it chooses the best viewer found in $PATH, trying in this + order: info, man, $PAGER, less, more, stdout. (If a TOPIC is speci- + fied, $PAGER and more are not tried.) You can force the use of info, + man, or a pager with the -i, -m, or -p flags. If no viewer can be + found, or if running non-interactively, it just prints the manual to + stdout. - o web - run hledger's web UI + When using info, TOPIC can match either the full heading or a prefix. + If your info --version is < 6, you'll need to upgrade it, eg with 'brew + install texinfo' on mac. - o iadd - add transactions using a TUI (currently hard to build) + When using man or less, TOPIC must match the full heading. For a pre- + fix match, you can write 'TOPIC.*'. - o interest - generate interest transactions + Examples - o stockquotes - download market prices from AlphaVantage + $ hledger help -h # show the help command's usage + $ hledger help # show the manual with info, man or $PAGER + $ hledger help 'time periods' # show the manual's "Time periods" topic + $ hledger help 'time periods' -m # use man, even if info is installed - o Scripts and add-ons - check-fancyassertions, edit, fifo, git, move, - pijul, plot, and more.. + demo + Play demos of hledger usage in the terminal, if asciinema is installed. - Next, each command is described in detail, in alphabetical order. + Run this command with no argument to list the demos. To play a demo, + write its number or a prefix or substring of its title. Tips: + Make your terminal window large enough to see the demo clearly. + + Use the -s/--speed SPEED option to set your preferred playback speed, + eg -s4 to play at 4x original speed or -s.5 to play at half speed. The + default speed is 2x. + + Other asciinema options can be added following a double dash, eg -- + -i.1 to limit pauses or -- -h to list asciinema's other options. + + During playback, several keys are available: SPACE to pause/unpause, . + to step forward (while paused), CTRL-c quit. + + Examples: + + $ hledger demo # list available demos + $ hledger demo 1 # play the first demo at default speed (2x) + $ hledger demo install -s4 # play the "install" demo at 4x speed + +User interface commands + ui + Runs hledger-ui (if installed). + + web + Runs hledger-web (if installed). + +Data entry commands + add + Prompt for transactions and add them to the journal. Any arguments + will be used as default inputs for the first N prompts. + + Many hledger users edit their journals directly with a text editor, or + generate them from CSV. For more interactive data entry, there is the + add command, which prompts interactively on the console for new trans- + actions, and appends them to the main journal file (which should be in + journal format). Existing transactions are not changed. This is one + of the few hledger commands that writes to the journal file (see also + import). + + To use it, just run hledger add and follow the prompts. You can add as + many transactions as you like; when you are finished, enter . or press + control-d or control-c to exit. + + Features: + + o add tries to provide useful defaults, using the most similar (by de- + scription) recent transaction (filtered by the query, if any) as a + template. + + o You can also set the initial defaults with command line arguments. + + o Readline-style edit keys can be used during data entry. + + o The tab key will auto-complete whenever possible - accounts, pay- + ees/descriptions, dates (yesterday, today, tomorrow). If the input + area is empty, it will insert the default value. + + o If the journal defines a default commodity, it will be added to any + bare numbers entered. + + o A parenthesised transaction code may be entered following a date. + + o Comments and tags may be entered following a description or amount. + + o If you make a mistake, enter < at any prompt to go one step backward. + + o Input prompts are displayed in a different colour when the terminal + supports it. + + Notes: + + o If you enter a number with no commodity symbol, and you have declared + a default commodity with a D directive, you might expect add to add + this symbol for you. It does not do this; we assume that if you are + using a D directive you prefer not to see the commodity symbol re- + peated on amounts in the journal. + + Examples: + + o Record new transactions, saving to the default journal file: + + hledger add + + o Add transactions to 2024.journal, but also load 2023.journal for com- + pletions: + + hledger add --file 2024.journal --file 2023.journal + + o Provide answers for the first four prompts: + + hledger add today 'best buy' expenses:supplies '$20' + + There is a detailed tutorial at https://hledger.org/add.html. + + import + Read new transactions added to each FILE provided as arguments since + last run, and add them to the journal. Or with --dry-run, just print + the transactions that would be added. Or with --catchup, just mark all + of the FILEs' current transactions as imported, without importing them. + + This command may append new transactions to the main journal file + (which should be in journal format). Existing transactions are not + changed. This is one of the few hledger commands that writes to the + journal file (see also add). + + 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 + 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. + + Date skipping + import tries to import only the transactions which are new since the + last import, ignoring any that it has seen in previous runs. So if + your bank's CSV includes the last three months of data, you can down- + load and import it every month (or week, or day) and only the new + transactions will be imported each time. + + It works as follows: for each imported FILE, + + o It tries to read the latest date previously seen, from .latest.FILE + in the same directory + + o Then it processes FILE, ignoring transactions on or before that date + + And after a successful import, unless --dry-run was used, it updates + the .latest.FILE(s) for next time. This is a simple system that works + for most real-world CSV files; it assumes the following are true, or + true enough: + + 1. the name of the input file is stable across successive downloads + + 2. new items always have the newest dates + + 3. item dates are stable across downloads + + 4. the order of same-date items is stable across downloads. + + Tips: + + o To help ensure a stable file name, remember you can use a CSV rules + file as an input file. + + o If you have a bank whose CSV dates or ordering occasionally change, + you can reduce the chance of this happening in new transactions by + importing more often. (If it happens in old transactions, that's + harmless.) + + Note this is just one kind of "deduplication": not reprocessing the + same dates across successive runs. import doesn't detect other kinds + of duplication, such as the same transaction appearing multiple times + within a single run, or a new transaction that looks identical to a + transaction already in the journal. (Because these can happen legiti- + mately in real-world data.) + + Here's a situation where you need to run import with care: say you + download but forget to import bank.1.csv, and a week later you download + bank.2.csv with some overlapping data. You should not process both of + these as a single import (hledger import bank.1.csv bank.2.csv), be- + cause the overlapping transactions would not be deduplicated. Instead, + import one file at a time, using the same filename each time: + + $ mv bank.1.csv bank.csv; hledger import bank.csv + $ mv bank.2.csv bank.csv; hledger import bank.csv + + Normally you don't need to think about .latest.* files, but you can + create or modify them to catch up to a certain date, or delete them to + mark all transactions as new. Their format is a single ISO-format + YYYY-MM-DD date, optionally repeated on multiple lines, meaning "I have + seen the transactions before this date, and this many of them on this + date". + + hledger print --new also uses and updates these .latest.* files, but it + is less often used. + + Related: CSV > Working with CSV > Deduplicating, importing. + + Import testing + 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 + categorised: + + $ hledger import --dry bank.csv | hledger -f- -I print unknown + + or (live updating): + + $ ls bank.csv* | entr bash -c 'echo ====; hledger import --dry bank.csv | hledger -f- -I print unknown' + + Note: when importing from multiple files at once, it's currently possi- + ble for some .latest files to be updated successfully, while the actual + import fails because of a problem in one of the files, leaving them out + of sync (and causing some transactions to be missed). To prevent this, + do a --dry-run first and fix any problems before the real import. + + 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 + balance assignments (eg from an institution that provides only balances + 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, + please test it and send a pull request.) + + Import and commodity styles + Amounts in entries added by import will be formatted according to the + journal's canonical commodity styles, as declared by commodity direc- + tives or inferred from the journal's amounts. + + Related: CSV > Amount decimal places. + +Basic report commands accounts Show account names. @@ -6091,95 +6310,364 @@ PART 4: COMMANDS $ hledger accounts --undeclared --directives >> $LEDGER_FILE $ hledger check accounts - activity - Show an ascii barchart of posting counts per interval. + codes + List the codes seen in transactions, in the order parsed. - The activity command displays an ascii histogram showing transaction - counts by day, week, month or other reporting interval (by day is the - default). With query arguments, it counts only matched transactions. + 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 + printed as blank lines. + + You can add a query to select a subset of transactions. Examples: - $ hledger activity --quarterly - 2008-01-01 ** - 2008-04-01 ******* - 2008-07-01 - 2008-10-01 ** + 2022/1/1 (123) Supermarket + Food $5.00 + Checking - add - Prompt for transactions and add them to the journal. Any arguments - will be used as default inputs for the first N prompts. + 2022/1/2 (124) Post Office + Postage $8.32 + Checking - Many hledger users edit their journals directly with a text editor, or - generate them from CSV. For more interactive data entry, there is the - add command, which prompts interactively on the console for new trans- - actions, and appends them to the main journal file (which should be in - journal format). Existing transactions are not changed. This is one - of the few hledger commands that writes to the journal file (see also - import). + 2022/1/3 Supermarket + Food $11.23 + Checking - To use it, just run hledger add and follow the prompts. You can add as - many transactions as you like; when you are finished, enter . or press - control-d or control-c to exit. + 2022/1/4 (126) Post Office + Postage $3.21 + Checking - Features: + $ hledger codes + 123 + 124 + 126 - o add tries to provide useful defaults, using the most similar (by de- - scription) recent transaction (filtered by the query, if any) as a - template. + $ hledger codes -E + 123 + 124 - o You can also set the initial defaults with command line arguments. + 126 - o Readline-style edit keys can be used during data entry. + commodities + List all commodity/currency symbols used or declared in the journal. - o The tab key will auto-complete whenever possible - accounts, pay- - ees/descriptions, dates (yesterday, today, tomorrow). If the input - area is empty, it will insert the default value. + descriptions + List the unique descriptions that appear in transactions. - o If the journal defines a default commodity, it will be added to any - bare numbers entered. + This command lists the unique descriptions that appear in transactions, + in alphabetic order. You can add a query to select a subset of trans- + actions. - o A parenthesised transaction code may be entered following a date. + Example: - o Comments and tags may be entered following a description or amount. + $ hledger descriptions + Store Name + Gas Station | Petrol + Person A - o If you make a mistake, enter < at any prompt to go one step backward. + files + List all files included in the journal. With a REGEX argument, only + file names matching the regular expression (case sensitive) are shown. - o Input prompts are displayed in a different colour when the terminal - supports it. + notes + List the unique notes that appear in transactions. - Example (see https://hledger.org/add.html for a detailed tutorial): + This command lists the unique notes that appear in transactions, in al- + phabetic 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). - $ hledger add - Adding transactions to journal file /src/hledger/examples/sample.journal - Any command line arguments will be used as defaults. - Use tab key to complete, readline keys to edit, enter to accept defaults. - An optional (CODE) may follow transaction dates. - An optional ; COMMENT may follow descriptions or amounts. - If you make a mistake, enter < at any prompt to go one step backward. - To end a transaction, enter . when prompted. - To quit, enter . at a date prompt or press control-d or control-c. - Date [2015/05/22]: - Description: supermarket - Account 1: expenses:food - Amount 1: $10 - Account 2: assets:checking - Amount 2 [$-10.0]: - Account 3 (or . or enter to finish this transaction): . - 2015/05/22 supermarket - expenses:food $10 - assets:checking $-10.0 + Example: - Save this transaction to the journal ? [y]: - Saved. - Starting the next transaction (. or ctrl-D/ctrl-C to quit) - Date [2015/05/22]: $ + $ hledger notes + Petrol + Snacks - If you enter a number with no commodity symbol, and you have declared a - default commodity with a D directive, you might expect add to add this - symbol for you. It does not do this; we assume that if you are using a - D directive you prefer not to see the commodity symbol repeated on - amounts in the journal. + 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 + (--used), or both (the default). + + 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 + implies --used. + + Example: + + $ hledger payees + Store Name + Gas Station + Person A + + prices + Print the market prices declared with P directives. With --infer-mar- + ket-prices, also show any additional prices inferred from costs. With + --show-reverse, also show additional prices inferred by reversing known + prices. + + Price amounts are always displayed with their full precision, except + for reverse prices which are limited to 8 decimal digits. + + Prices can be filtered by a date:, cur: or amt: query. + + Generally if you run this command with --infer-market-prices --show-re- + verse, it will show the same prices used internally to calculate value + reports. But if in doubt, you can inspect those directly by running + the value report with --debug=2. + + stats + Show journal and performance statistics. + + The stats command shows summary information for the whole journal, or a + matched part of it. With a reporting interval, it shows a report for + each report period. + + The default output is fairly impersonal, though it reveals the main + file name. With -v/--verbose, more details are shown, like file paths, + included files, and commodity names. + + It also shows some run time statistics: + + o elapsed time + + o throughput: the number of transactions processed per second + + o live: the peak memory in use by the program to do its work + + o alloc: the peak memory allocation from the OS as seen by GHC. Mea- + suring this externally, eg with GNU time, is more accurate; usually + that will be a larger number; sometimes (with swapping?) smaller. + + The stats command's run time is similar to that of a balance report. + + Example: + + $ hledger stats -f examples/1ktxns-1kaccts.journal + Main file : .../1ktxns-1kaccts.journal + Included files : 0 + Txns span : 2000-01-01 to 2002-09-27 (1000 days) + Last txn : 2002-09-26 (7827 days ago) + Txns : 1000 (1.0 per day) + Txns last 30 days : 0 (0.0 per day) + Txns last 7 days : 0 (0.0 per day) + Payees/descriptions : 1000 + Accounts : 1000 (depth 10) + Commodities : 26 + Market prices : 1000 + Runtime stats : 0.12 s elapsed, 8266 txns/s, 4 MB live, 16 MB alloc + + This command supports the -o/--output-file option (but not -O/--out- + put-format). + + tags + List the tags used in the journal, or their values. + + This command lists the tag names used in the journal, whether on trans- + actions, postings, or account declarations. + + With a TAGREGEX argument, only tag names matching this regular expres- + sion (case insensitive, infix matched) are shown. + + With QUERY arguments, only transactions and accounts matching this + query are considered. If the query involves transaction fields (date:, + desc:, amt:, ...), the search is restricted to the matched transactions + and their accounts. + + With the --values flag, the tags' unique non-empty values are listed + instead. With -E/--empty, blank/empty values are also shown. + + With --parsed, tags or values are shown in the order they were parsed, + with duplicates included. (Except, tags from account declarations are + always shown first.) + + Tip: remember, accounts also acquire tags from their parents, postings + also acquire tags from their account and transaction, transactions also + acquire tags from their postings. + +Standard report commands + print + Show transaction journal entries, sorted by date. + + The print command displays full journal entries (transactions) from the + journal file, sorted by date (or with --date2, by secondary date). + + 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/regenerate your journal you should take care to also copy + over the directives and inter-transaction comments. + + Eg: + + $ hledger print -f examples/sample.journal date:200806 + 2008/06/01 gift + assets:bank:checking $1 + income:gifts $-1 + + 2008/06/02 save + assets:bank:saving $1 + assets:bank:checking $-1 + + 2008/06/03 * eat & shop + expenses:food $1 + expenses:supplies $1 + assets:cash $-2 + + print explicitness + Normally, whether posting amounts are implicit or explicit is pre- + served. For example, when an amount is omitted in the journal, it will + not appear in the output. Similarly, if a conversion cost is implied + but not written, it will not appear in the output. + + You can use the -x/--explicit flag to force explicit display of all + amounts and costs. This can be useful for troubleshooting or for mak- + ing your journal more readable and robust against data entry errors. + -x is also implied by using any of -B,-V,-X,--value. + + The -x/--explicit flag will cause any postings with a multi-commodity + amount (which can arise when a multi-commodity transaction has an im- + plicit amount) to be split into multiple single-commodity postings, + keeping the output parseable. + + print amount style + Amounts are shown right-aligned within each transaction (but not + aligned across all transactions; you can do that with ledger-mode in + Emacs). + + Amounts will be (mostly) normalised to their commodity display style: + their symbol placement, decimal mark, and digit group marks will be + made consistent. By default, decimal digits are shown as they are + written in the journal. + + With the --round (Added in 1.32) option, print will try increasingly + hard to display decimal digits according to the commodity display + styles: + + o --round=none show amounts with original precisions (default) + + o --round=soft add/remove decimal zeros in amounts (except costs) + + o --round=hard round amounts (except costs), possibly hiding signifi- + cant digits + + o --round=all round all amounts and costs + + soft is good for non-lossy cleanup, formatting amounts more consis- + tently where it's safe to do so. + + hard and all can cause print to show invalid unbalanced journal en- + tries; they may be useful eg for stronger cleanup, with manual fixups + when needed. + + print parseability + 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 (though the same can be achieved with expr: queries + now): + + # Show running total of food expenses paid from cash. + # -f- reads from stdin. -I/--ignore-assertions is sometimes needed. + $ hledger print assets:cash | hledger -f- -I reg expenses:food + + There are some situations where print's output can become unparseable: + + o Value reporting affects posting amounts but not balance assertion or + balance assignment amounts, potentially causing those to fail. + + o Auto postings can generate postings with too many missing amounts. + + o Account aliases can generate bad account names. + + print, other features + With -B/--cost, amounts with costs are shown converted to cost. + + With --new, print shows only transactions it has not seen on a previous + run. This uses the same deduplication system as the import command. + (See import's docs for details.) + + With -m DESC/--match=DESC, print shows one recent transaction whose de- + scription is most similar to DESC. DESC should contain at least two + characters. If there is no similar-enough match, no transaction will + be shown and the program exit code will be non-zero. + + print output format + This command also supports the output destination and output format op- + tions The output formats supported are txt, beancount (Added in 1.32), + csv, tsv (Added in 1.32), json and sql. + + The beancount format tries to produce Beancount-compatible output, as + follows: + + o Transaction and postings with unmarked status are converted to + cleared (*) status. + + o Transactions' payee and note are backslash-escaped and dou- + ble-quote-escaped and wrapped in double quotes. + + o Transaction tags are copied to Beancount #tag format. + + o Commodity symbols are converted to upper case, and a small number of + currency symbols like $ are converted to the corresponding currency + names. + + o Account name parts are capitalised and unsupported characters are re- + placed with -. If an account name part does not begin with a letter, + or if the first part is not Assets, Liabilities, Equity, Income, or + Expenses, an error is raised. (Use --alias options to bring your ac- + counts into compliance.) + + o An open directive is generated for each account used, on the earliest + transaction date. + + Some limitations: + + o Balance assertions are removed. + + o Balance assignments become missing amounts. + + o Virtual and balanced virtual postings become regular postings. + + o Directives are not converted. + + Here's an example of print's CSV output: + + $ hledger print -Ocsv + "txnidx","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","posting-status","posting-comment" + "1","2008/01/01","","","","income","","assets:bank:checking","1","$","","1","","" + "1","2008/01/01","","","","income","","income:salary","-1","$","1","","","" + "2","2008/06/01","","","","gift","","assets:bank:checking","1","$","","1","","" + "2","2008/06/01","","","","gift","","income:gifts","-1","$","1","","","" + "3","2008/06/02","","","","save","","assets:bank:saving","1","$","","1","","" + "3","2008/06/02","","","","save","","assets:bank:checking","-1","$","1","","","" + "4","2008/06/03","","*","","eat & shop","","expenses:food","1","$","","1","","" + "4","2008/06/03","","*","","eat & shop","","expenses:supplies","1","$","","1","","" + "4","2008/06/03","","*","","eat & shop","","assets:cash","-2","$","2","","","" + "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 + 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 + order, etc.) + + 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 + greater amounts under debit.) aregister (areg) @@ -6261,6 +6749,322 @@ PART 4: COMMANDS date, ignoring posting dates. This too can cause an inaccurate running balance. + register + (reg) + + 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 + 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 + see that account's activity: + + $ hledger register checking + 2008/01/01 income assets:bank:checking $1 $1 + 2008/06/01 gift assets:bank:checking $1 $2 + 2008/06/02 save assets:bank:checking $-1 $1 + 2008/12/31 pay off assets:bank:checking $-1 0 + + With --date2, it shows and sorts by secondary date instead. + + For performance reasons, column widths are chosen based on the first + 1000 lines; this means unusually wide values in later lines can cause + visual discontinuities as column widths are adjusted. If you want to + ensure perfect alignment, at the cost of more time and memory, use the + --align-all flag. + + The --historical/-H flag adds the balance from any undisplayed prior + postings to the running total. This is useful when you want to see + only recent activity, with a historically accurate running balance: + + $ hledger register checking -b 2008/6 --historical + 2008/06/01 gift assets:bank:checking $1 $2 + 2008/06/02 save assets:bank:checking $-1 $1 + 2008/12/31 pay off assets:bank:checking $-1 0 + + The --depth option limits the amount of sub-account detail displayed. + + 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 ac- + count and one commodity. + + 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 + an income account where amounts are normally displayed as negative num- + bers. It's also useful to show postings on the checking account to- + gether with the related account: + + $ hledger register --related --invert assets:checking + + With a reporting interval, register shows summary postings, one per in- + terval, aggregating the postings to each account: + + $ hledger register --monthly income + 2008/01 income:salary $-1 $-1 + 2008/06 income:gifts $-1 $-2 + + Periods with no activity, and summary postings with a zero amount, are + not shown by default; use the --empty/-E flag to see them: + + $ hledger register --monthly income -E + 2008/01 income:salary $-1 $-1 + 2008/02 0 $-1 + 2008/03 0 $-1 + 2008/04 0 $-1 + 2008/05 0 $-1 + 2008/06 income:gifts $-1 $-2 + 2008/07 0 $-2 + 2008/08 0 $-2 + 2008/09 0 $-2 + 2008/10 0 $-2 + 2008/11 0 $-2 + 2008/12 0 $-2 + + Often, you'll want to see just one line per interval. The --depth op- + tion helps with this, causing subaccounts to be aggregated: + + $ hledger register --monthly assets --depth 1h + 2008/01 assets $1 $1 + 2008/06 assets $-1 0 + 2008/12 assets $-1 $-1 + + Note when using report intervals, if you specify start/end dates these + will be adjusted outward if necessary to contain a whole number of in- + tervals. This ensures that the first and last intervals are full + length and comparable to the others in the report. + + With -m DESC/--match=DESC, register does a fuzzy search for one recent + posting whose description is most similar to DESC. DESC should contain + at least two characters. If there is no similar-enough match, no post- + ing will be shown and the program exit code will be non-zero. + + 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 + 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 de- + scription width as part of --width's argument, comma-separated: --width + W,D . Here's a diagram (won't display correctly in --help): + + <--------------------------------- width (W) ----------------------------------> + date (10) description (D) account (W-41-D) amount (12) balance (12) + DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA + + and some examples: + + $ hledger reg # use terminal width (or 80 on windows) + $ hledger reg -w 100 # use width 100 + $ COLUMNS=100 hledger reg # set with one-time environment variable + $ export COLUMNS=100; hledger reg # set till session end (or window resize) + $ hledger reg -w 100,40 # set overall width 100, description width 40 + $ hledger reg -w $COLUMNS,40 # use terminal width, & description width 40 + + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, tsv (Added in 1.32), + and json. + + balancesheet + (bs) + + 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 + sign, as in conventional financial statements. + + This report shows accounts declared with the Asset, Cash or Liability + type (see account types). Or if no such accounts are declared, it + shows top-level accounts named asset or liability (case insensitive, + plurals allowed) and their subaccounts. + + Example: + + $ hledger balancesheet + Balance Sheet 2008-12-31 + + || 2008-12-31 + ====================++============ + Assets || + --------------------++------------ + assets:bank:saving || $1 + assets:cash || $-2 + --------------------++------------ + || $-1 + ====================++============ + Liabilities || + --------------------++------------ + liabilities:debts || $-1 + --------------------++------------ + || $-1 + ====================++============ + Net: || 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 + flipped. + + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, tsv (Added in 1.32), + html, and json. + + balancesheetequity + (bse) + + 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. + + This report shows accounts declared with the Asset, Cash, Liability or + Equity type (see account types). Or if no such accounts are declared, + it shows top-level accounts named asset, liability or equity (case in- + sensitive, plurals allowed) and their subaccounts. + + Example: + + $ hledger balancesheetequity + Balance Sheet With Equity 2008-12-31 + + || 2008-12-31 + ====================++============ + Assets || + --------------------++------------ + assets:bank:saving || $1 + assets:cash || $-2 + --------------------++------------ + || $-1 + ====================++============ + Liabilities || + --------------------++------------ + liabilities:debts || $-1 + --------------------++------------ + || $-1 + ====================++============ + Equity || + --------------------++------------ + --------------------++------------ + || 0 + ====================++============ + Net: || 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 equity, but with + smarter account detection, and liabilities/equity displayed with their + sign flipped. + + This report is the easiest way to see if the accounting equation (A+L+E + = 0) is satisfied (after you have done a close --retain to merge rev- + enues and expenses with equity, and perhaps added --infer-equity to + balance your commodity conversions). + + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, tsv, html, and json. + + cashflow + (cf) + + This command displays a (simple) cashflow statement, showing the in- + flows and outflows affecting "cash" (ie, liquid, easily convertible) + assets. Amounts are shown with normal positive sign, as in conven- + tional financial statements. + + This report shows accounts declared with the Cash type (see account + types). Or if no such accounts are declared, it shows accounts + + o under a top-level account named asset (case insensitive, plural al- + lowed) + + o whose name contains some variation of cash, bank, checking or saving. + + More precisely: all accounts matching this case insensitive regular ex- + pression: + + ^assets?(:.+)?:(cash|bank|che(ck|que?)(ing)?|savings?|currentcash)(:|$) + + and their subaccounts. + + An example cashflow report: + + $ hledger cashflow + Cashflow Statement 2008 + + || 2008 + ====================++====== + Cash flows || + --------------------++------ + assets:bank:saving || $1 + assets:cash || $-2 + --------------------++------ + || $-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 + not:receivable, but with smarter account detection. + + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, tsv (Added in 1.32), + html, and json. + + incomestatement + (is) + + This command displays an income statement, showing revenues and ex- + penses during one or more periods. Amounts are shown with normal posi- + tive sign, as in conventional financial statements. + + This report shows accounts declared with the Revenue or Expense type + (see account types). Or if no such accounts are declared, it shows + top-level accounts named revenue or income or expense (case insensi- + tive, plurals allowed) and their subaccounts. + + Example: + + $ hledger incomestatement + Income Statement 2008 + + || 2008 + ===================++====== + Revenues || + -------------------++------ + income:gifts || $1 + income:salary || $1 + -------------------++------ + || $2 + ===================++====== + Expenses || + -------------------++------ + expenses:food || $1 + expenses:supplies || $1 + -------------------++------ + || $2 + ===================++====== + Net: || 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 '(revenues|income)' expenses, but with + smarter account detection, and revenues/income displayed with their + sign flipped. + + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, tsv (Added in 1.32), + html, and json. + +Advanced report commands balance (bal) @@ -6617,6 +7421,10 @@ PART 4: COMMANDS o The --pivot FIELD option causes a different transaction field to be used as "account name". See PIVOTING. + o The --summary-only flag (--summary also works) hides all but the To- + tal and Average columns (those should be enabled with --row-total and + -A/--average). + Multi-period reports with many periods can be too wide for easy viewing in the terminal. Here are some ways to handle that: @@ -6632,57 +7440,57 @@ PART 4: COMMANDS o Reduce the terminal's font size - o View with a pager like less, eg: hledger bal -D --color=yes | less + o View with a pager like less, eg: hledger bal -D --color=yes | less -RS - o Output as CSV and use a CSV viewer like visidata (hledger bal -D -O - csv | vd -f csv), Emacs' csv-mode (M-x csv-mode, C-c C-a), or a + o Output as CSV and use a CSV viewer like visidata (hledger bal -D -O + csv | vd -f csv), Emacs' csv-mode (M-x csv-mode, C-c C-a), or a spreadsheet (hledger bal -D -o a.csv && open a.csv) - o Output as HTML and view with a browser: hledger bal -D -o a.html && + o Output as HTML and view with a browser: hledger bal -D -o a.html && open a.html 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 ac- + A balance change is the net amount added to, or removed from, an ac- count 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 - The balance command is quite flexible; here is the full detail on how - to control what it reports. If the following seems complicated, don't - worry - this is for advanced reporting, and it does take time and ex- + The balance command is quite flexible; here is the full detail on how + to control what it reports. If the following seems complicated, don't + worry - this is for advanced reporting, and it does take time and ex- perimentation to get familiar with all the report modes. There are three important option groups: - hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] + hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] ... Calculation type @@ -6694,57 +7502,57 @@ PART 4: COMMANDS each account/period) o --valuechange : show the change in period-end historical balance val- - ues (caused by deposits, withdrawals, and/or market price fluctua- + ues (caused by deposits, withdrawals, and/or market price fluctua- tions) - o --gain : show the unrealised capital gain/loss, (the current valued + o --gain : show the unrealised capital gain/loss, (the current valued balance minus each amount's original cost) o --count : show the count of postings Accumulation type - How amounts should accumulate across a report's subperiods/columns. - Another way to say it: which time period's postings should contribute + How amounts should accumulate across a report's subperiods/columns. + Another way to say it: which time period's postings should contribute to each cell's calculation. It is one of: - o --change : calculate with postings from column start to column end, - ie "just this column". Typically used to see revenues/expenses. + o --change : calculate with postings from column start to column end, + ie "just this column". Typically used to see revenues/expenses. (default for balance, cashflow, incomestatement) - o --cumulative : calculate with postings from report start to column - end, ie "previous columns plus this column". Typically used to show + o --cumulative : calculate with postings from report start to column + end, ie "previous columns plus this column". Typically used to show changes accumulated since the report's start date. Not often used. - o --historical/-H : calculate with postings from journal start to col- - umn end, ie "all postings from before report start date until this - column's end". Typically used to see historical end balances of as- - sets/liabilities/equity. (default for balancesheet, balancesheete- + o --historical/-H : calculate with postings from journal start to col- + umn end, ie "all postings from before report start date until this + column's end". Typically used to see historical end balances of as- + sets/liabilities/equity. (default for balancesheet, balancesheete- quity) Valuation type - Which kind of value or cost conversion should be applied, if any, be- + Which kind of value or cost conversion should be applied, if any, be- fore displaying the report. It is one of: o no valuation type : don't convert to cost or value (default) - o --value=cost[,COMM] : convert amounts to cost (then optionally to + o --value=cost[,COMM] : convert amounts to cost (then optionally to some other commodity) - o --value=then[,COMM] : convert amounts to market value on transaction + o --value=then[,COMM] : convert amounts to market value on transaction dates - o --value=end[,COMM] : convert amounts to market value on period end + o --value=end[,COMM] : convert amounts to market value on period end date(s) (default with --valuechange, --gain) o --value=now[,COMM] : convert amounts to market value on today's date - o --value=YYYY-MM-DD[,COMM] : convert amounts to market value on an- + o --value=YYYY-MM-DD[,COMM] : convert amounts to market value on an- other date or one of the equivalent simpler flags: - o -B/--cost : like --value=cost (though, note --cost and --value are + o -B/--cost : like --value=cost (though, note --cost and --value are independent options which can both be used at once) o -V/--market : like --value=end @@ -6754,13 +7562,13 @@ PART 4: COMMANDS See Cost reporting and Value reporting for more about these. Combining balance report types - 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 @@ -6773,18 +7581,18 @@ PART 4: COMMANDS Accumu- /now lation:v ----------------------------------------------------------------------------------- - --change change in period sum of post- period-end DATE-value of - ing-date market value of change change in pe- + --change change in period sum of post- period-end DATE-value of + ing-date market value of change change in pe- values in period in period riod - --cumu- change from re- sum of post- period-end DATE-value of - lative port start to ing-date market value of change change from + --cumu- change from re- sum of post- period-end DATE-value of + lative port start to ing-date market value of change change from period end values from re- from report report start port start to pe- start to period to period end riod end end - --his- change from sum of post- period-end DATE-value of + --his- change from sum of post- period-end DATE-value of torical journal start to ing-date market value of change change from /-H period end (his- values from jour- from journal journal start - torical end bal- nal start to pe- start to period to period end + torical end bal- nal start to pe- start to period to period end ance) riod end end Budget report @@ -6795,11 +7603,11 @@ PART 4: COMMANDS o Accounts which don't have budget goals are hidden by default. - This is useful for comparing planned and actual income, expenses, time + This is useful for comparing planned and actual income, expenses, time usage, etc. - Periodic transaction rules are used to define budget goals. For exam- - ple, here's a periodic rule defining monthly goals for bus travel and + Periodic transaction rules are used to define budget goals. For exam- + ple, here's a periodic rule defining monthly goals for bus travel and food expenses: ;; Budget @@ -6841,66 +7649,66 @@ PART 4: COMMANDS || 0 [ 0% of $430] 0 [ 0% of $430] This is "goal-based budgeting"; you define goals for accounts and peri- - ods, often recurring, and hledger shows performance relative to the - goals. This contrasts with "envelope budgeting", which is more de- - tailed and strict - useful when cash is tight, but also quite a bit - more work. https://plaintextaccounting.org/Budgeting has more on this + ods, often recurring, and hledger shows performance relative to the + goals. This contrasts with "envelope budgeting", which is more de- + tailed and strict - useful when cash is tight, but also quite a bit + more work. https://plaintextaccounting.org/Budgeting has more on this topic. Using the budget report - Historically this report has been confusing and fragile. hledger's - version should be relatively robust and intuitive, but you may still - find surprises. Here are more notes to help with learning and trou- + Historically this report has been confusing and fragile. hledger's + version should be relatively robust and intuitive, but you may still + find surprises. Here are more notes to help with learning and trou- bleshooting. - o In the above example, expenses:bus and expenses:food are shown be- + o In the above example, expenses:bus and expenses:food are shown be- cause they have budget goals during the report period. - o Their parent expenses is also shown, with budget goals aggregated + o Their parent expenses is also shown, with budget goals aggregated from the children. - o The subaccounts expenses:food:groceries and expenses:food:dining are - not shown since they have no budget goal of their own, but they con- + o The subaccounts expenses:food:groceries and expenses:food:dining are + not shown since they have no budget goal of their own, but they con- tribute to expenses:food's actual amount. - o Unbudgeted accounts expenses:movies and expenses:gifts are also not + o Unbudgeted accounts expenses:movies and expenses:gifts are also not shown, but they contribute to expenses's actual amount. - o The other unbudgeted accounts income and assets:bank:checking are + o The other unbudgeted accounts income and assets:bank:checking are grouped as . - o --depth or depth: can be used to limit report depth in the usual way + o --depth or depth: can be used to limit report depth in the usual way (but will not reveal unbudgeted subaccounts). o Amounts are always inclusive of subaccounts (even in -l/--list mode). o Numbers displayed in a --budget report will not always agree with the - totals, because of hidden unbudgeted accounts; this is normal. + totals, because of hidden unbudgeted accounts; this is normal. -E/--empty can be used to reveal the hidden accounts. o In the periodic rules used for setting budget goals, unbalanced post- ings are convenient. - o You can filter budget reports with the usual queries, eg to focus on - particular accounts. It's common to restrict them to just expenses. - (The account is occasionally hard to exclude; this is + o You can filter budget reports with the usual queries, eg to focus on + particular accounts. It's common to restrict them to just expenses. + (The account is occasionally hard to exclude; this is because of date surprises, discussed below.) - o When you have multiple currencies, you may want to convert them to - one (-X COMM --infer-market-prices) and/or show just one at a time - (cur:COMM). If you do need to show multiple currencies at once, + o When you have multiple currencies, you may want to convert them to + one (-X COMM --infer-market-prices) and/or show just one at a time + (cur:COMM). If you do need to show multiple currencies at once, --layout bare can be helpful. - o You can "roll over" amounts (actual and budgeted) to the next period + o You can "roll over" amounts (actual and budgeted) to the next period with --cumulative. See also: https://hledger.org/budgeting.html. Budget date surprises - With small data, or when starting out, some of the generated budget - goal transaction dates might fall outside the report periods. Eg with - the following journal and report, the first period appears to have no - expenses:food budget. (Also the account should be ex- + With small data, or when starting out, some of the generated budget + goal transaction dates might fall outside the report periods. Eg with + the following journal and report, the first period appears to have no + expenses:food budget. (Also the account should be ex- cluded by the expenses query, but isn't.): ~ monthly in 2020 @@ -6920,64 +7728,64 @@ PART 4: COMMANDS ---------------++-------------------- || $400 [80% of $500] - In this case, the budget goal transactions are generated on first days - of of month (this can be seen with hledger print --forecast tag:gener- - ated expenses). Whereas the report period defaults to just the 15th - day of january (this can be seen from the report table's column head- + In this case, the budget goal transactions are generated on first days + of of month (this can be seen with hledger print --forecast tag:gener- + ated expenses). Whereas the report period defaults to just the 15th + day of january (this can be seen from the report table's column head- ings). - To fix this kind of thing, be more explicit about the report period - (and/or the periodic rules' dates). In this case, adding -b 2020 does + To fix this kind of thing, be more explicit about the report period + (and/or the periodic rules' dates). In this case, adding -b 2020 does the trick. Selecting budget goals - 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 + 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 + 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 between period - expression and description), and then select from multiple budgets de- + regular expression or query). This means you can give your periodic + rules descriptions (remember that two spaces are needed between period + expression and description), and then select from multiple budgets de- fined in your journal. Budgeting vs forecasting - --forecast and --budget both use the periodic transaction rules in the - journal to generate temporary transactions for reporting purposes. - However they are separate features - though you can use both at the + --forecast and --budget both use the periodic transaction rules in the + journal to generate temporary transactions for reporting purposes. + However they are separate features - though you can use both at the same time if you want. Here are some differences between them: --forecast --budget -------------------------------------------------------------------------- - is a general option; it enables fore- is a balance command option; it - casting with all reports selects the balance report's + is a general option; it enables fore- is a balance command option; it + casting with all reports selects the balance report's budget mode - generates visible transactions which generates invisible transactions + generates visible transactions which generates invisible transactions appear in reports which produce goal amounts - generates forecast transactions from generates budget goal transac- - after the last regular transaction, to tions throughout the report pe- - the end of the report period; or with riod, optionally restricted by - an argument --forecast=PERIODEXPR gen- periods specified in the peri- - erates them throughout the specified odic transaction rules - period, both optionally restricted by - periods specified in the periodic + generates forecast transactions from generates budget goal transac- + after the last regular transaction, to tions throughout the report pe- + the end of the report period; or with riod, optionally restricted by + an argument --forecast=PERIODEXPR gen- periods specified in the peri- + erates them throughout the specified odic transaction rules + period, both optionally restricted by + periods specified in the periodic transaction rules uses all periodic rules uses all periodic rules; or with an argument --budget=DESCPAT - uses just the rules matched by + uses just the rules matched by DESCPAT Balance report layout - The --layout option affects how balance reports show multi-commodity - amounts and commodity symbols, which can improve readability. It can + The --layout option affects how balance reports show multi-commodity + amounts and commodity symbols, which can improve readability. It can also normalise the data for easy consumption by other programs. It has four possible values: - o --layout=wide[,WIDTH]: commodities are shown on a single line, op- + o --layout=wide[,WIDTH]: commodities are shown on a single line, op- tionally elided to WIDTH o --layout=tall: each commodity is shown on a separate line @@ -6985,10 +7793,10 @@ PART 4: COMMANDS o --layout=bare: commodity symbols are in their own column, amounts are bare numbers - o --layout=tidy: data is normalised to easily-consumed "tidy" form, + o --layout=tidy: data is normalised to easily-consumed "tidy" form, with one row per data value - Here are the --layout modes supported by each output format Only CSV + Here are the --layout modes supported by each output format Only CSV output supports all of them: - txt csv html json sql @@ -7024,7 +7832,7 @@ PART 4: COMMANDS || 10.00 ITOT, 337.18 USD, 2 more.. 70.00 GLD, 18.00 ITOT, 3 more.. -11.00 ITOT, 3 more.. 70.00 GLD, 17.00 ITOT, 3 more.. Tall layout - Each commodity gets a new line (may be different in each column), and + Each commodity gets a new line (may be different in each column), and account names are repeated: $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=tall @@ -7045,7 +7853,7 @@ PART 4: COMMANDS || 18.00 VHT 294.00 VHT Bare layout - Commodity symbols are kept in one column, each commodity has its own + Commodity symbols are kept in one column, each commodity has its own row, amounts are bare numbers, account names are repeated: $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=bare @@ -7081,15 +7889,15 @@ PART 4: COMMANDS "total","VEA","36.00" "total","VHT","294.00" - Bare layout will sometimes display an extra row for the no-symbol com- - modity, because of zero amounts (hledger treats zeroes as commod- + Bare layout will sometimes display an extra row for the no-symbol com- + modity, because of zero amounts (hledger treats zeroes as commod- ity-less, usually). This can break hledger-bar confusingly (workaround: add a cur: query to exclude the no-symbol row). Tidy layout This produces normalised "tidy data" (see https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html) - where every variable has its own column and each row represents a sin- + where every variable has its own column and each row represents a sin- gle data point. This is the easiest kind of data for other software to consume: @@ -7115,25 +7923,25 @@ PART 4: 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 @@ -7146,237 +7954,195 @@ PART 4: COMMANDS [--invert] Show top gainers [or losers] last week - balancesheet - (bs) + roi + Shows the time-weighted (TWR) and money-weighted (IRR) rate of return + on your investments. - 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 - sign, as in conventional financial statements. + At a minimum, you need to supply a query (which could be just an ac- + count name) to select your investment(s) with --inv, and another query + to identify your profit and loss transactions with --pnl. - This report shows accounts declared with the Asset, Cash or Liability - type (see account types). Or if no such accounts are declared, it - shows top-level accounts named asset or liability (case insensitive, - plurals allowed) and their subaccounts. + 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). - Example: + This command will compute and display the internalized rate of return + (IRR, also known as money-weighted rate of return) and time-weighted + rate of return (TWR) for your investments for the time period re- + quested. IRR is always annualized due to the way it is computed, but + TWR is reported both as a rate over the chosen reporting period and as + an annual rate. - $ hledger balancesheet - Balance Sheet 2008-12-31 + Price directives will be taken into account if you supply appropriate + --cost or --value flags (see VALUATION). - || 2008-12-31 - ====================++============ - Assets || - --------------------++------------ - assets:bank:saving || $1 - assets:cash || $-2 - --------------------++------------ - || $-1 - ====================++============ - Liabilities || - --------------------++------------ - liabilities:debts || $-1 - --------------------++------------ - || $-1 - ====================++============ - Net: || 0 + Note, in some cases this report can fail, for these reasons: - 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 - flipped. + o Error (NotBracketed): No solution for Internal Rate of Return (IRR). + Possible causes: IRR is huge (>1000000%), balance of investment be- + comes negative at some point in time. - This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv (Added in 1.32), - html, and json. + 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. - balancesheetequity - (bse) + Examples: - 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. + o Using roi to compute total return of investment in stocks: + https://github.com/simonmichael/hledger/blob/master/examples/invest- + ing/roi-unrealised.ledger - This report shows accounts declared with the Asset, Cash, Liability or - Equity type (see account types). Or if no such accounts are declared, - it shows top-level accounts named asset, liability or equity (case in- - sensitive, plurals allowed) and their subaccounts. + o Cookbook > Return on Investment: https://hledger.org/roi.html - Example: + 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). - $ hledger balancesheetequity - Balance Sheet With Equity 2008-12-31 + To indicate that all search terms form single command-line argument, + you will need to put them in quotes (see Special characters): - || 2008-12-31 - ====================++============ - Assets || - --------------------++------------ - assets:bank:saving || $1 - assets:cash || $-2 - --------------------++------------ - || $-1 - ====================++============ - Liabilities || - --------------------++------------ - liabilities:debts || $-1 - --------------------++------------ - || $-1 - ====================++============ - Equity || - --------------------++------------ - --------------------++------------ - || 0 - ====================++============ - Net: || 0 + $ hledger roi --inv 'term1 term2 term3 ...' - 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 equity, but with - smarter account detection, and liabilities/equity displayed with their - sign flipped. + If any query terms contain spaces themselves, you will need an extra + level of nested quoting, eg: - This report is the easiest way to see if the accounting equation (A+L+E - = 0) is satisfied (after you have done a close --retain to merge rev- - enues and expenses with equity, and perhaps added --infer-equity to - balance your commodity conversions). + $ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'" - This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv, html, and json. + 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. - cashflow - (cf) + In these transactions, ROI will conside postings that match --inv to be + "investment postings" and other postings (not matching --inv) will be + sorted into two categories: "cash flow" and "profit and loss", as ROI + needs to know which part of the investment value is your contributions + and which is due to the return on investment. - This command displays a (simple) cashflow statement, showing the in- - flows and outflows affecting "cash" (ie, liquid, easily convertible) - assets. Amounts are shown with normal positive sign, as in conven- - tional financial statements. + o "Cash flow" is depositing or withdrawing money, buying or selling as- + sets, or otherwise converting between your investment commodity and + any other commodity. Example: - This report shows accounts declared with the Cash type (see account - types). Or if no such accounts are declared, it shows accounts + 2019-01-01 Investing in Snake Oil + assets:cash -$100 + investment:snake oil - o under a top-level account named asset (case insensitive, plural al- - lowed) + 2020-01-01 Selling my Snake Oil + assets:cash $10 + investment:snake oil = 0 - o whose name contains some variation of cash, bank, checking or saving. + o "Profit and loss" is change in the value of your investment: - More precisely: all accounts matching this case insensitive regular ex- - pression: + 2019-06-01 Snake Oil falls in value + investment:snake oil = $57 + equity:unrealized profit or loss - ^assets?(:.+)?:(cash|bank|che(ck|que?)(ing)?|savings?|currentcash)(:|$) + All non-investment postings are assumed to be "cash flow", unless they + match --pnl query. Changes in value of your investment due to "profit + and loss" postings will be considered as part of your investment re- + turn. - and their subaccounts. + Example: if you use --inv snake --pnl equity:unrealized, then postings + in the example below would be classifed as: - An example cashflow report: + 2019-01-01 Snake Oil #1 + assets:cash -$100 ; cash flow posting + investment:snake oil ; investment posting - $ hledger cashflow - Cashflow Statement 2008 + 2019-03-01 Snake Oil #2 + equity:unrealized pnl -$100 ; profit and loss posting + snake oil ; investment posting - || 2008 - ====================++====== - Cash flows || - --------------------++------ - assets:bank:saving || $1 - assets:cash || $-2 - --------------------++------ - || $-1 + 2019-07-01 Snake Oil #3 + equity:unrealized pnl ; profit and loss posting + cash -$100 ; cash flow posting + snake oil $50 ; investment posting - 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 - not:receivable, but with smarter account detection. + IRR and TWR explained + "ROI" stands for "return on investment". Traditionally this was com- + puted as a difference between current value of investment and its ini- + tial value, expressed in percentage of the initial value. - This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv (Added in 1.32), - html, and json. + However, this approach is only practical in simple cases, where invest- + ments receives no in-flows or out-flows of money, and where rate of + growth is fixed over time. For more complex scenarios you need differ- + ent ways to compute rate of return, and this command implements two of + them: IRR and TWR. - check - Check for various kinds of errors in your data. + Internal rate of return, or "IRR" (also called "money-weighted rate of + return") takes into account effects of in-flows and out-flows, and the + time between them. Investment at a particular fixed interest rate is + going to give you more interest than the same amount invested at the + same interest rate, but made later in time. If you are withdrawing + from your investment, your future gains would be smaller (in absolute + numbers), and will be a smaller percentage of your initial investment, + so your IRR will be smaller. And if you are adding to your investment, + you will receive bigger absolute gains, which will be a bigger percent- + age of your initial investment, so your IRR will be larger. - 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). + As mentioned before, in-flows and out-flows would be any cash that you + personally put in or withdraw, and for the "roi" command, these are the + postings that match the query in the--inv argument and NOT match the + query in the--pnl argument. - Some examples: + If you manually record changes in the value of your investment as + transactions that balance them against "profit and loss" (or "unreal- + ized gains") account or use price directives, then in order for IRR to + compute the precise effect of your in-flows and out-flows on the rate + of return, you will need to record the value of your investement on or + close to the days when in- or out-flows occur. - hledger check # basic checks - hledger check -s # basic + strict checks - hledger check ordereddates payees # basic + two other checks + In technical terms, IRR uses the same approach as computation of net + present value, and tries to find a discount rate that makes net present + value of all the cash flows of your investment to add up to zero. This + could be hard to wrap your head around, especially if you haven't done + discounted cash flow analysis before. Implementation of IRR in hledger + should produce results that match the =XIRR formula in Excel. - If you are an Emacs user, you can also configure flycheck-hledger to - run these checks, providing instant feedback as you edit the journal. + Second way to compute rate of return that roi command implements is + called "time-weighted rate of return" or "TWR". Like IRR, it will ac- + count for the effect of your in-flows and out-flows, but unlike IRR it + will try to compute the true rate of return of the underlying asset, + compensating for the effect that deposits and withdrawas have on the + apparent rate of growth of your investment. - Here are the checks currently available: + TWR represents your investment as an imaginary "unit fund" where + in-flows/ out-flows lead to buying or selling "units" of your invest- + ment and changes in its value change the value of "investment unit". + Change in "unit price" over the reporting period gives you rate of re- + turn of your investment, and make TWR less sensitive than IRR to the + effects of cash in-flows and out-flows. - Default checks - These checks are run automatically by (almost) all hledger commands: + References: - o parseable - data files are in a supported format, with no syntax er- - rors and no invalid include directives. + o Explanation of rate of return - o autobalanced - all transactions are balanced, after converting to - cost. Missing amounts and missing costs are inferred automatically - where possible. + o Explanation of IRR - o assertions - all balance assertions in the journal are passing. - (This check can be disabled with -I/--ignore-assertions.) + o Explanation of TWR - 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 - check: + o IRR vs TWR - o balanced - all transactions are balanced after converting to cost, - without inferring missing costs. If conversion costs are required, - they must be explicit. + o Examples of computing IRR and TWR and discussion of the limitations + of both metrics - o accounts - all account names used by transactions have been declared +Chart commands + activity + Show an ascii barchart of posting counts per interval. - o commodities - all commodity symbols used have been declared + The activity command displays an ascii histogram showing transaction + counts by day, week, month or other reporting interval (by day is the + default). With query arguments, it counts only matched transactions. - 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: + Examples: - o ordereddates - transactions are ordered by date within each file - - o payees - all payees used by transactions have been declared - - o recentassertions - all accounts with balance assertions have a bal- - ance assertion within 7 days of their latest posting - - o tags - all tags used by transactions have been declared - - o uniqueleafnames - all account leaf names are unique - - Custom checks - 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 - slash) exist as file paths - - o hledger-check-fancyassertions - more complex balance assertions are - passing - - You could make similar scripts to perform your own custom checks. See: - Cookbook -> Scripting. - - More about specific checks - hledger check recentassertions will complain if any balance-asserted - account has postings more than 7 days after its latest balance asser- - tion. This aims to prevent the situation where you are regularly up- - dating your journal, but forgetting to check your balances against the - real world, then one day must dig back through months of data to find - an error. It assumes that adding a balance assertion requires/reminds - you to check the real-world balance. (That may not be true if you - auto-generate balance assertions from bank data; in that case, I recom- - mend to import transactions uncleared, and when you manually review and - clear them, also check the latest assertion against the real-world bal- - ance.) + $ hledger activity --quarterly + 2008-01-01 ** + 2008-04-01 ******* + 2008-07-01 + 2008-10-01 ** +Data generation commands close (equity) @@ -7572,89 +8338,228 @@ PART 4: COMMANDS More detailed close examples See examples/multi-year. - codes - List the codes seen in transactions, in the order parsed. + rewrite + Print all transactions, rewriting the postings of matched transactions. + For now the only rewrite available is adding new postings, like print + --auto. - 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 - printed as blank lines. - - You can add a query to select a subset of transactions. + This is a start at a generic rewriter of transaction entries. It reads + 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- + tion's first posting amount. Examples: - 2022/1/1 (123) Supermarket - Food $5.00 - Checking + $ hledger-rewrite.hs ^income --add-posting '(liabilities:tax) *.33 ; income tax' --add-posting '(reserve:gifts) $100' + $ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts) *-1"' + $ hledger-rewrite.hs -f rewrites.hledger - 2022/1/2 (124) Post Office - Postage $8.32 - Checking + rewrites.hledger may consist of entries like: - 2022/1/3 Supermarket - Food $11.23 - Checking + = ^income amt:<0 date:2017 + (liabilities:tax) *0.33 ; tax on income + (reserve:grocery) *0.25 ; reserve 25% for grocery + (reserve:) *0.25 ; reserve 25% for grocery - 2022/1/4 (126) Post Office - Postage $3.21 - Checking + Note the single quotes to protect the dollar sign from bash, and the + two spaces between account and amount. - $ hledger codes - 123 - 124 - 126 + More: - $ hledger codes -E - 123 - 124 + $ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ... + $ hledger rewrite -- ^income --add-posting '(liabilities:tax) *.33' + $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"' + $ hledger rewrite -- ^income --add-posting '(budget:foreign currency) *0.25 JPY; diversify' - 126 + 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 in- + cludes a commodity name, the new posting amount will be in the new com- + modity; otherwise, it will be in the matched posting amount's commod- + ity. - commodities - List all commodity/currency symbols used or declared in the journal. + Re-write rules in a file + 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. - demo - Play demos of hledger usage in the terminal, if asciinema is installed. + $ rewrite-rules.journal - Run this command with no argument to list the demos. To play a demo, - write its number or a prefix or substring of its title. Tips: + Make contents look like this: - Make your terminal window large enough to see the demo clearly. + = ^income + (liabilities:tax) *.33 - Use the -s/--speed SPEED option to set your preferred playback speed, - eg -s4 to play at 4x original speed or -s.5 to play at half speed. The - default speed is 2x. + = expenses:gifts + budget:gifts *-1 + assets:budget *1 - Other asciinema options can be added following a double dash, eg -- - -i.1 to limit pauses or -- -h to list asciinema's other options. + 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. - During playback, several keys are available: SPACE to pause/unpause, . - to step forward (while paused), CTRL-c quit. + $ hledger rewrite -- -f input.journal -f rewrite-rules.journal > rewritten-tidy-output.journal - Examples: + This is something similar to the commands pipeline: - $ hledger demo # list available demos - $ hledger demo 1 # play the first demo at default speed (2x) - $ hledger demo install -s4 # play the "install" demo at 4x speed + $ hledger rewrite -- -f input.journal '^income' --add-posting '(liabilities:tax) *.33' \ + | hledger rewrite -- -f - expenses:gifts --add-posting 'budget:gifts *-1' \ + --add-posting 'assets:budget *1' \ + > rewritten-tidy-output.journal - descriptions - List the unique descriptions that appear in transactions. + 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. - This command lists the unique descriptions that appear in transactions, - in alphabetic order. You can add a query to select a subset of trans- - actions. + Diff output format + To use this tool for batch modification of your journal files you may + find useful output in form of unified diff. - Example: + $ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax) *.33' - $ hledger descriptions - Store Name - Gas Station | Petrol - Person A + Output might look like: + + --- /tmp/examples/sample.journal + +++ /tmp/examples/sample.journal + @@ -18,3 +18,4 @@ + 2008/01/01 income + - assets:bank:checking $1 + + assets:bank:checking $1 + income:salary + + (liabilities:tax) 0 + @@ -22,3 +23,4 @@ + 2008/06/01 gift + - assets:bank:checking $1 + + assets:bank:checking $1 + income:gifts + + (liabilities:tax) 0 + + 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 + --file options and include directives inside of these files. + + Be careful. Whole transaction being re-formatted in a style of output + from hledger print. + + See also: + + https://github.com/simonmichael/hledger/issues/99 + + rewrite vs. print --auto + 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 + only child files. + + 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. + print --auto applies rules specified in the journal. + +Maintenance commands + check + Check for various kinds of errors in your data. + + hledger provides a number of built-in correctness checks to help vali- + date your data and prevent errors. Some are run automatically, some + when you enable --strict mode; or you can run any of them on demand by + providing them as arguments to the check command. check produces no + output and a zero exit code if all is well. Eg: + + hledger check # run basic checks + hledger check -s # run basic and strict checks + hledger check ordereddates payees # run basic checks and two others + + If you are an Emacs user, you can also configure flycheck-hledger to + run these checks, providing instant feedback as you edit the journal. + + Here are the checks currently available. Generally, they are performed + in the order they are shown here (and only the first failure is re- + ported). + + Basic checks + These important checks are performed by default, by almost all hledger + commands: + + o parseable - data files are in a supported format, with no syntax er- + rors and no invalid include directives. This ensures that all files + exist and are readable. + + o autobalanced - all transactions are balanced, after inferring missing + amounts and conversion costs where possible, and then converting to + cost. This ensures that each individual transaction is well formed. + + o assertions - all balance assertions in the journal are passing. Bal- + ance assertions are like canaries in your journal, they catch many + problems. They can get in the way sometimes; you can disable them + temporarily with -I/--ignore-assertions (unless overridden with + -s/--strict or hledger check assertions). + + Strict checks + These additional checks are performed by any command when the + -s/--strict flag is used (strict mode). Strict mode always enables the + balance assertions check, also. These provide extra error-catching + power when you are serious about keeping your data clean and free of + typos: + + o balanced - like autobalanced, but in conversion transactions, costs + must be written explicitly. This ensures some redundancy in the en- + try, which helps prevent typos. + + o commodities - all commodity symbols used must be declared. This + guards against mistyping or omitting commodity symbols. + + o accounts - all account names used must be declared. This prevents + the use of mis-spelled or outdated account names. + + Other checks + These other checks are not wanted by everyone, but can be run using the + check command: + + o ordereddates - within each file, transactions are ordered by date. + This is a simple and effective error catcher, and you should use it. + Alas! not everyone wants it. If you do, use hledger check -s or- + dereddates. When enabled, this check is performed early, before bal- + ance assertions (because copy-pasted dates are often the root cause + of balance assertion failures). + + o payees - all payees used by transactions must be declared. This will + force you to always use known/declared payee names. For most people + this is a bit too restrictive. + + o tags - all tags used by transactions must be declared. This prevents + mistyped tag names. + + o recentassertions - all accounts with balance assertions must have a + balance assertion within the last 7 days before their latest posting. + This encourages you to add balance assertions fairly regularly for + your active asset/liability accounts, which in turn should encourage + you to check and reconcile with their real world balances fairly reg- + ularly. close --assert can be helpful. (The older balance asser- + tions become redundant; you can remove them periodically, or leave + them in place, perhaps commented, as documentation.) + + o uniqueleafnames - no two accounts may have the same leaf name. The + leaf name is the last colon-separated part of an account name, eg + checking in assets:bank:checking. This encourages you to keep those + unique, effectively giving each account a short name which is easier + to remember and to type in reporting commands. + + Custom checks + You can build your own custom checks with add-on command scripts. See + also Cookbook > Scripting. Here are some examples from hledger/bin/: + + o hledger-check-tagfiles - all tag values containing / (a forward + slash) exist as file paths + + o hledger-check-fancyassertions - more complex balance assertions are + passing diff Compares a particular account's transactions in two input files. It @@ -7684,922 +8589,6 @@ PART 4: COMMANDS These transactions are in the second file only: - files - List all files included in the journal. With a REGEX argument, only - file names matching the regular expression (case sensitive) are shown. - - help - Show the hledger user manual in the terminal, with info, man, or a - pager. With a TOPIC argument, open it at that topic if possible. - TOPIC can be any heading in the manual, or a heading prefix, case in- - sensitive. Eg: commands, print, forecast, journal, amount, "auto post- - ings". - - This command shows the hledger manual built in to your hledger version. - It can be useful when offline, or when you prefer the terminal to a web - browser, or when the appropriate hledger manual or viewing tools are - not installed on your system. - - By default it chooses the best viewer found in $PATH, trying (in this - order): info, man, $PAGER, less, more. You can force the use of info, - man, or a pager with the -i, -m, or -p flags, If no viewer can be - found, or the command is run non-interactively, it just prints the man- - ual to stdout. - - If using info, note that version 6 or greater is needed for TOPIC - lookup. If you are on mac you will likely have info 4.8, and should - consider installing a newer version, eg with brew install texinfo - (#1770). - - Examples - - $ hledger help --help # show how the help command works - $ hledger help # show the hledger manual with info, man or $PAGER - $ hledger help journal # show the journal topic in the hledger manual - $ hledger help -m journal # show it with man, even if info is installed - - import - Read new transactions added to each FILE provided as arguments since - last run, and add them to the journal. Or with --dry-run, just print - the transactions that would be added. Or with --catchup, just mark all - of the FILEs' current transactions as imported, without importing them. - - This command may append new transactions to the main journal file - (which should be in journal format). Existing transactions are not - changed. This is one of the few hledger commands that writes to the - journal file (see also add). - - 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 - 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 - import tries to import only the transactions which are new since the - last import, ignoring any that it has seen in previous runs. So if - your bank's CSV includes the last three months of data, you can down- - load and import it every month (or week, or day) and only the new - transactions will be imported each time. - - It works as follows. For each imported FILE (usually CSV, but they - could be any of hledger's input formats): - - o It tries to recall the latest date seen previously, reading it from a - hidden .latest.FILE in the same directory. - - o Then it processes FILE, ignoring any transactions on or before the - "latest seen" date. - - And after a successful import, it updates the .latest.FILE(s) for next - time (unless --dry-run was used). - - This is a limited kind of deduplication, let's call it "date skipping". - Within each input file, it avoids reprocessing the same dates across - successive runs. This is a simple system that works for most - real-world CSV files; it assumes these are true, or true enough: - - 1. new items always have the newest dates - - 2. item dates are stable across successive downloads - - 3. the order of same-date items is stable across downloads - - 4. the name of the input file is stable across downloads - - If you have a bank whose CSV dates or ordering occasionally change, you - can reduce the chance of this happening in new transactions by import- - ing more often, and in old transactions it doesn't matter. And remem- - ber you can use CSV rules files as input, which is one way to ensure a - stable file name. - - import doesn't detect other kinds of duplication, such as duplicate - transactions within a single run. (In part, because legitimate dupli- - cate transactions can easily occur in real-world data.) So, say you - downloaded but forgot to import bank.1.csv, and a week later you down- - loaded bank.2.csv with overlapping data. Now you should not import - both of these at once (hledger import bank.1.csv bank.2.csv); the over- - lapping transactions which appear twice would not be deduplicated since - this is considered a single import. Instead, import these files one at - a time, and also use the same filename each time for a common "latest - seen" state: - - $ mv bank.1.csv bank.csv; hledger import bank.csv - $ mv bank.2.csv bank.csv; hledger import bank.csv - - Normally you can ignore the .latest.* files, but if needed, you can - delete them (to make all transactions unseen), or construct/modify them - (to catch up to a certain date). The format is just a single ISO-for- - mat date (YYYY-MM-DD), possibly repeated on multiple lines. It means - "I have seen transactions up to this date, and this many of them occur- - ring on that date". - - hledger print --new also uses and updates these .latest.* files, but it - is less often used. - - Related: CSV > Working with CSV > Deduplicating, importing. - - Import testing - 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 - categorised: - - $ hledger import --dry bank.csv | hledger -f- -I print unknown - - or (live updating): - - $ ls bank.csv* | entr bash -c 'echo ====; hledger import --dry bank.csv | hledger -f- -I print unknown' - - Note: when importing from multiple files at once, it's currently possi- - ble for some .latest files to be updated successfully, while the actual - import fails because of a problem in one of the files, leaving them out - of sync (and causing some transactions to be missed). To prevent this, - do a --dry-run first and fix any problems before the real import. - - 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 - balance assignments (eg from an institution that provides only balances - 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, - please test it and send a pull request.) - - Commodity display styles - Imported amounts will be formatted according to the canonical commodity - styles (declared or inferred) in the main journal file. - - incomestatement - (is) - - This command displays an income statement, showing revenues and ex- - penses during one or more periods. Amounts are shown with normal posi- - tive sign, as in conventional financial statements. - - This report shows accounts declared with the Revenue or Expense type - (see account types). Or if no such accounts are declared, it shows - top-level accounts named revenue or income or expense (case insensi- - tive, plurals allowed) and their subaccounts. - - Example: - - $ hledger incomestatement - Income Statement 2008 - - || 2008 - ===================++====== - Revenues || - -------------------++------ - income:gifts || $1 - income:salary || $1 - -------------------++------ - || $2 - ===================++====== - Expenses || - -------------------++------ - expenses:food || $1 - expenses:supplies || $1 - -------------------++------ - || $2 - ===================++====== - Net: || 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 '(revenues|income)' expenses, but with - smarter account detection, and revenues/income displayed with their - sign flipped. - - This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv (Added in 1.32), - html, and json. - - notes - List the unique notes that appear in transactions. - - This command lists the unique notes that appear in transactions, in al- - phabetic 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: - - $ hledger notes - Petrol - Snacks - - 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 - (--used), or both (the default). - - 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 - implies --used. - - Example: - - $ hledger payees - Store Name - Gas Station - Person A - - prices - Print the market prices declared with P directives. With --infer-mar- - ket-prices, also show any additional prices inferred from costs. With - --show-reverse, also show additional prices inferred by reversing known - prices. - - Price amounts are always displayed with their full precision, except - for reverse prices which are limited to 8 decimal digits. - - Prices can be filtered by a date:, cur: or amt: query. - - Generally if you run this command with --infer-market-prices --show-re- - verse, it will show the same prices used internally to calculate value - reports. But if in doubt, you can inspect those directly by running - the value report with --debug=2. - - print - Show transaction journal entries, sorted by date. - - The print command displays full journal entries (transactions) from the - journal file, sorted by date (or with --date2, by secondary date). - - 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/regenerate your journal you should take care to also copy - over the directives and inter-transaction comments. - - Eg: - - $ hledger print -f examples/sample.journal date:200806 - 2008/06/01 gift - assets:bank:checking $1 - income:gifts $-1 - - 2008/06/02 save - assets:bank:saving $1 - assets:bank:checking $-1 - - 2008/06/03 * eat & shop - expenses:food $1 - expenses:supplies $1 - assets:cash $-2 - - print explicitness - Normally, whether posting amounts are implicit or explicit is pre- - served. For example, when an amount is omitted in the journal, it will - not appear in the output. Similarly, if a conversion cost is implied - but not written, it will not appear in the output. - - You can use the -x/--explicit flag to force explicit display of all - amounts and costs. This can be useful for troubleshooting or for mak- - ing your journal more readable and robust against data entry errors. - -x is also implied by using any of -B,-V,-X,--value. - - The -x/--explicit flag will cause any postings with a multi-commodity - amount (which can arise when a multi-commodity transaction has an im- - plicit amount) to be split into multiple single-commodity postings, - keeping the output parseable. - - print amount style - Amounts are shown right-aligned within each transaction (but not - aligned across all transactions; you can do that with ledger-mode in - Emacs). - - Amounts will be (mostly) normalised to their commodity display style: - their symbol placement, decimal mark, and digit group marks will be - made consistent. By default, decimal digits are shown as they are - written in the journal. - - With the --round (Added in 1.32) option, print will try increasingly - hard to display decimal digits according to the commodity display - styles: - - o --round=none show amounts with original precisions (default) - - o --round=soft add/remove decimal zeros in amounts (except costs) - - o --round=hard round amounts (except costs), possibly hiding signifi- - cant digits - - o --round=all round all amounts and costs - - soft is good for non-lossy cleanup, formatting amounts more consis- - tently where it's safe to do so. - - hard and all can cause print to show invalid unbalanced journal en- - tries; they may be useful eg for stronger cleanup, with manual fixups - when needed. - - print parseability - 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 (though the same can be achieved with expr: queries - now): - - # Show running total of food expenses paid from cash. - # -f- reads from stdin. -I/--ignore-assertions is sometimes needed. - $ hledger print assets:cash | hledger -f- -I reg expenses:food - - There are some situations where print's output can become unparseable: - - o Value reporting affects posting amounts but not balance assertion or - balance assignment amounts, potentially causing those to fail. - - o Auto postings can generate postings with too many missing amounts. - - o Account aliases can generate bad account names. - - print, other features - With -B/--cost, amounts with costs are shown converted to cost. - - With --new, print shows only transactions it has not seen on a previous - run. This uses the same deduplication system as the import command. - (See import's docs for details.) - - With -m DESC/--match=DESC, print shows one recent transaction whose de- - scription is most similar to DESC. DESC should contain at least two - characters. If there is no similar-enough match, no transaction will - be shown and the program exit code will be non-zero. - - print output format - This command also supports the output destination and output format op- - tions The output formats supported are txt, beancount (Added in 1.32), - csv, tsv (Added in 1.32), json and sql. - - The beancount format tries to produce Beancount-compatible output, as - follows: - - o Transaction and postings with unmarked status are converted to - cleared (*) status. - - o Transactions' payee and note are backslash-escaped and dou- - ble-quote-escaped and wrapped in double quotes. - - o Transaction tags are copied to Beancount #tag format. - - o Commodity symbols are converted to upper case, and a small number of - currency symbols like $ are converted to the corresponding currency - names. - - o Account name parts are capitalised and unsupported characters are re- - placed with -. If an account name part does not begin with a letter, - or if the first part is not Assets, Liabilities, Equity, Income, or - Expenses, an error is raised. (Use --alias options to bring your ac- - counts into compliance.) - - o An open directive is generated for each account used, on the earliest - transaction date. - - Some limitations: - - o Balance assertions are removed. - - o Balance assignments become missing amounts. - - o Virtual and balanced virtual postings become regular postings. - - o Directives are not converted. - - Here's an example of print's CSV output: - - $ hledger print -Ocsv - "txnidx","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","posting-status","posting-comment" - "1","2008/01/01","","","","income","","assets:bank:checking","1","$","","1","","" - "1","2008/01/01","","","","income","","income:salary","-1","$","1","","","" - "2","2008/06/01","","","","gift","","assets:bank:checking","1","$","","1","","" - "2","2008/06/01","","","","gift","","income:gifts","-1","$","1","","","" - "3","2008/06/02","","","","save","","assets:bank:saving","1","$","","1","","" - "3","2008/06/02","","","","save","","assets:bank:checking","-1","$","1","","","" - "4","2008/06/03","","*","","eat & shop","","expenses:food","1","$","","1","","" - "4","2008/06/03","","*","","eat & shop","","expenses:supplies","1","$","","1","","" - "4","2008/06/03","","*","","eat & shop","","assets:cash","-2","$","2","","","" - "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 - 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 - order, etc.) - - 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 - greater amounts under debit.) - - register - (reg) - - 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 - 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 - see that account's activity: - - $ hledger register checking - 2008/01/01 income assets:bank:checking $1 $1 - 2008/06/01 gift assets:bank:checking $1 $2 - 2008/06/02 save assets:bank:checking $-1 $1 - 2008/12/31 pay off assets:bank:checking $-1 0 - - With --date2, it shows and sorts by secondary date instead. - - For performance reasons, column widths are chosen based on the first - 1000 lines; this means unusually wide values in later lines can cause - visual discontinuities as column widths are adjusted. If you want to - ensure perfect alignment, at the cost of more time and memory, use the - --align-all flag. - - The --historical/-H flag adds the balance from any undisplayed prior - postings to the running total. This is useful when you want to see - only recent activity, with a historically accurate running balance: - - $ hledger register checking -b 2008/6 --historical - 2008/06/01 gift assets:bank:checking $1 $2 - 2008/06/02 save assets:bank:checking $-1 $1 - 2008/12/31 pay off assets:bank:checking $-1 0 - - The --depth option limits the amount of sub-account detail displayed. - - 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 ac- - count and one commodity. - - 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 - an income account where amounts are normally displayed as negative num- - bers. It's also useful to show postings on the checking account to- - gether with the related account: - - $ hledger register --related --invert assets:checking - - With a reporting interval, register shows summary postings, one per in- - terval, aggregating the postings to each account: - - $ hledger register --monthly income - 2008/01 income:salary $-1 $-1 - 2008/06 income:gifts $-1 $-2 - - Periods with no activity, and summary postings with a zero amount, are - not shown by default; use the --empty/-E flag to see them: - - $ hledger register --monthly income -E - 2008/01 income:salary $-1 $-1 - 2008/02 0 $-1 - 2008/03 0 $-1 - 2008/04 0 $-1 - 2008/05 0 $-1 - 2008/06 income:gifts $-1 $-2 - 2008/07 0 $-2 - 2008/08 0 $-2 - 2008/09 0 $-2 - 2008/10 0 $-2 - 2008/11 0 $-2 - 2008/12 0 $-2 - - Often, you'll want to see just one line per interval. The --depth op- - tion helps with this, causing subaccounts to be aggregated: - - $ hledger register --monthly assets --depth 1h - 2008/01 assets $1 $1 - 2008/06 assets $-1 0 - 2008/12 assets $-1 $-1 - - Note when using report intervals, if you specify start/end dates these - will be adjusted outward if necessary to contain a whole number of in- - tervals. This ensures that the first and last intervals are full - length and comparable to the others in the report. - - With -m DESC/--match=DESC, register does a fuzzy search for one recent - posting whose description is most similar to DESC. DESC should contain - at least two characters. If there is no similar-enough match, no post- - ing will be shown and the program exit code will be non-zero. - - 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 - 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 de- - scription width as part of --width's argument, comma-separated: --width - W,D . Here's a diagram (won't display correctly in --help): - - <--------------------------------- width (W) ----------------------------------> - date (10) description (D) account (W-41-D) amount (12) balance (12) - DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA - - and some examples: - - $ hledger reg # use terminal width (or 80 on windows) - $ hledger reg -w 100 # use width 100 - $ COLUMNS=100 hledger reg # set with one-time environment variable - $ export COLUMNS=100; hledger reg # set till session end (or window resize) - $ hledger reg -w 100,40 # set overall width 100, description width 40 - $ hledger reg -w $COLUMNS,40 # use terminal width, & description width 40 - - This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv (Added in 1.32), - and json. - - rewrite - Print all transactions, rewriting the postings of matched transactions. - 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 - one or more specified postings to any transactions matching QUERY. The - posting amounts can be fixed, or a multiplier of the existing transac- - tion's first posting amount. - - Examples: - - $ hledger-rewrite.hs ^income --add-posting '(liabilities:tax) *.33 ; income tax' --add-posting '(reserve:gifts) $100' - $ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts) *-1"' - $ hledger-rewrite.hs -f rewrites.hledger - - rewrites.hledger may consist of entries like: - - = ^income amt:<0 date:2017 - (liabilities:tax) *0.33 ; tax on income - (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 - two spaces between account and amount. - - More: - - $ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ... - $ hledger rewrite -- ^income --add-posting '(liabilities:tax) *.33' - $ 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 - use '*' (star symbol) before the amount to indicate that that this is a - factor for an amount of original matched posting. If the amount in- - cludes a commodity name, the new posting amount will be in the new com- - modity; otherwise, it will be in the matched posting amount's commod- - ity. - - Re-write rules in a file - 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. - - $ rewrite-rules.journal - - Make contents look like this: - - = ^income - (liabilities:tax) *.33 - - = expenses:gifts - budget:gifts *-1 - assets:budget *1 - - 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. - - $ hledger rewrite -- -f input.journal -f rewrite-rules.journal > rewritten-tidy-output.journal - - This is something similar to the commands pipeline: - - $ hledger rewrite -- -f input.journal '^income' --add-posting '(liabilities:tax) *.33' \ - | hledger rewrite -- -f - expenses:gifts --add-posting 'budget:gifts *-1' \ - --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- - ings. - - Diff output format - 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' - - Output might look like: - - --- /tmp/examples/sample.journal - +++ /tmp/examples/sample.journal - @@ -18,3 +18,4 @@ - 2008/01/01 income - - assets:bank:checking $1 - + assets:bank:checking $1 - income:salary - + (liabilities:tax) 0 - @@ -22,3 +23,4 @@ - 2008/06/01 gift - - assets:bank:checking $1 - + assets:bank:checking $1 - income:gifts - + (liabilities:tax) 0 - - 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 - --file options and include directives inside of these files. - - Be careful. Whole transaction being re-formatted in a style of output - from hledger print. - - See also: - - https://github.com/simonmichael/hledger/issues/99 - - rewrite vs. print --auto - 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 - only child files. - - 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. - print --auto applies rules specified in the journal. - - roi - 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 ac- - count 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 - 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, also known as money-weighted rate of return) and time-weighted - rate of return (TWR) for your investments for the time period re- - quested. IRR is always annualized due to the way it is computed, but - TWR is reported both as a rate over the chosen reporting period and as - an annual rate. - - 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 be- - comes negative at some point in time. - - 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: - https://github.com/simonmichael/hledger/blob/master/examples/invest- - ing/roi-unrealised.ledger - - o Cookbook > Return on Investment: https://hledger.org/roi.html - - 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. - - In these transactions, ROI will conside postings that match --inv to be - "investment postings" and other postings (not matching --inv) will be - sorted into two categories: "cash flow" and "profit and loss", as ROI - needs to know which part of the investment value is your contributions - and which is due to the return on investment. - - o "Cash flow" is depositing or withdrawing money, buying or selling as- - sets, or otherwise converting between your investment commodity and - any other commodity. Example: - - 2019-01-01 Investing in Snake Oil - assets:cash -$100 - investment:snake oil - - 2020-01-01 Selling my Snake Oil - assets:cash $10 - investment:snake oil = 0 - - o "Profit and loss" is change in the value of your investment: - - 2019-06-01 Snake Oil falls in value - investment:snake oil = $57 - equity:unrealized profit or loss - - All non-investment postings are assumed to be "cash flow", unless they - match --pnl query. Changes in value of your investment due to "profit - and loss" postings will be considered as part of your investment re- - turn. - - Example: if you use --inv snake --pnl equity:unrealized, then postings - in the example below would be classifed as: - - 2019-01-01 Snake Oil #1 - assets:cash -$100 ; cash flow posting - investment:snake oil ; investment posting - - 2019-03-01 Snake Oil #2 - equity:unrealized pnl -$100 ; profit and loss posting - snake oil ; investment posting - - 2019-07-01 Snake Oil #3 - equity:unrealized pnl ; profit and loss posting - cash -$100 ; cash flow posting - snake oil $50 ; investment posting - - IRR and TWR explained - "ROI" stands for "return on investment". Traditionally this was com- - puted as a difference between current value of investment and its ini- - tial value, expressed in percentage of the initial value. - - However, this approach is only practical in simple cases, where invest- - ments receives no in-flows or out-flows of money, and where rate of - growth is fixed over time. For more complex scenarios you need differ- - ent ways to compute rate of return, and this command implements two of - them: IRR and TWR. - - Internal rate of return, or "IRR" (also called "money-weighted rate of - return") takes into account effects of in-flows and out-flows, and the - time between them. Investment at a particular fixed interest rate is - going to give you more interest than the same amount invested at the - same interest rate, but made later in time. If you are withdrawing - from your investment, your future gains would be smaller (in absolute - numbers), and will be a smaller percentage of your initial investment, - so your IRR will be smaller. And if you are adding to your investment, - you will receive bigger absolute gains, which will be a bigger percent- - age of your initial investment, so your IRR will be larger. - - As mentioned before, in-flows and out-flows would be any cash that you - personally put in or withdraw, and for the "roi" command, these are the - postings that match the query in the--inv argument and NOT match the - query in the--pnl argument. - - If you manually record changes in the value of your investment as - transactions that balance them against "profit and loss" (or "unreal- - ized gains") account or use price directives, then in order for IRR to - compute the precise effect of your in-flows and out-flows on the rate - of return, you will need to record the value of your investement on or - close to the days when in- or out-flows occur. - - In technical terms, IRR uses the same approach as computation of net - present value, and tries to find a discount rate that makes net present - value of all the cash flows of your investment to add up to zero. This - could be hard to wrap your head around, especially if you haven't done - discounted cash flow analysis before. Implementation of IRR in hledger - should produce results that match the =XIRR formula in Excel. - - Second way to compute rate of return that roi command implements is - called "time-weighted rate of return" or "TWR". Like IRR, it will ac- - count for the effect of your in-flows and out-flows, but unlike IRR it - will try to compute the true rate of return of the underlying asset, - compensating for the effect that deposits and withdrawas have on the - apparent rate of growth of your investment. - - TWR represents your investment as an imaginary "unit fund" where - in-flows/ out-flows lead to buying or selling "units" of your invest- - ment and changes in its value change the value of "investment unit". - Change in "unit price" over the reporting period gives you rate of re- - turn of your investment, and make TWR less sensitive than IRR to the - effects of cash in-flows and out-flows. - - References: - - o Explanation of rate of return - - o Explanation of IRR - - o Explanation of TWR - - o IRR vs TWR - - o Examples of computing IRR and TWR and discussion of the limitations - of both metrics - - stats - Show journal and performance statistics. - - The stats command shows summary information for the whole journal, or a - matched part of it. With a reporting interval, it shows a report for - each report period. - - The default output is fairly impersonal, though it reveals the main - file name. With -v/--verbose, more details are shown, like file paths, - included files, and commodity names. - - It also shows some run time statistics: - - o elapsed time - - o throughput: the number of transactions processed per second - - o live: the peak memory in use by the program to do its work - - o alloc: the peak memory allocation from the OS as seen by GHC. Mea- - suring this externally, eg with GNU time, is more accurate; usually - that will be a larger number; sometimes (with swapping?) smaller. - - The stats command's run time is similar to that of a balance report. - - Example: - - $ hledger stats -f examples/1ktxns-1kaccts.journal - Main file : .../1ktxns-1kaccts.journal - Included files : 0 - Txns span : 2000-01-01 to 2002-09-27 (1000 days) - Last txn : 2002-09-26 (7827 days ago) - Txns : 1000 (1.0 per day) - Txns last 30 days : 0 (0.0 per day) - Txns last 7 days : 0 (0.0 per day) - Payees/descriptions : 1000 - Accounts : 1000 (depth 10) - Commodities : 26 - Market prices : 1000 - Runtime stats : 0.12 s elapsed, 8266 txns/s, 4 MB live, 16 MB alloc - - This command supports the -o/--output-file option (but not -O/--out- - put-format). - - tags - List the tags used in the journal, or their values. - - This command lists the tag names used in the journal, whether on trans- - actions, postings, or account declarations. - - With a TAGREGEX argument, only tag names matching this regular expres- - sion (case insensitive, infix matched) are shown. - - With QUERY arguments, only transactions and accounts matching this - query are considered. If the query involves transaction fields (date:, - desc:, amt:, ...), the search is restricted to the matched transactions - and their accounts. - - With the --values flag, the tags' unique non-empty values are listed - instead. With -E/--empty, blank/empty values are also shown. - - With --parsed, tags or values are shown in the order they were parsed, - with duplicates included. (Except, tags from account declarations are - always shown first.) - - Tip: remember, accounts also acquire tags from their parents, postings - also acquire tags from their account and transaction, transactions also - acquire tags from their postings. - test Run built-in unit tests. @@ -8625,7 +8614,7 @@ PART 5: COMMON TASKS Here are some quick examples of how to do some basic tasks with hledger. - Getting help +Getting help Here's how to list commands and view options and command docs: $ hledger # show available commands @@ -8643,7 +8632,7 @@ PART 5: COMMON TASKS https://hledger.org. Chat and mail list support and discussion archives can be found at https://hledger.org/support. - Constructing command lines +Constructing command lines hledger has a flexible command line interface. We strive to keep it simple and ergonomic, but if you run into one of the sharp edges de- scribed in OPTIONS, here are some tips that might help: @@ -8661,7 +8650,7 @@ PART 5: COMMON TASKS o to see how a misbehaving command line is being parsed, add --debug=2. - Starting a journal file +Starting a journal file hledger looks for your accounting data in a journal file, $HOME/.hledger.journal by default: @@ -8695,7 +8684,7 @@ PART 5: COMMON TASKS Commodities : 0 () Market prices : 0 () - Setting LEDGER_FILE +Setting LEDGER_FILE How to set LEDGER_FILE permanently depends on your setup: On unix and mac, running these commands in the terminal will work for @@ -8726,7 +8715,7 @@ PART 5: COMMON TASKS > MKDIR finance > SETX LEDGER_FILE "C:\Users\USERNAME\finance\2023.journal" - Setting opening balances +Setting opening balances Pick a starting date for which you can look up the balances of some real-world assets (bank accounts, wallet..) and liabilities (credit cards..). @@ -8804,7 +8793,7 @@ PART 5: COMMON TASKS $ git commit -m 'initial balances' 2023.journal - Recording transactions +Recording transactions As you spend or receive money, you can record these transactions using one of the methods above (text editor, hledger add) or by using the hledger-iadd or hledger-web add-ons, or by using the import command to @@ -8825,7 +8814,7 @@ PART 5: COMMON TASKS income:salary assets:bank:checking $1000 - Reconciling +Reconciling Periodically you should reconcile - compare your hledger-reported bal- ances against external sources of truth, like bank statements or your bank's website - to be sure that your ledger accurately represents the @@ -8875,7 +8864,7 @@ PART 5: COMMON TASKS $ git commit -m 'txns' 2023.journal - Reporting +Reporting Here are some basic reports. Show all transactions: @@ -9018,7 +9007,7 @@ PART 5: COMMON TASKS 2023-01-06 **** 2023-01-13 **** - Migrating to a new file +Migrating to a new file At the end of the year, you may want to continue your journal in a new file, so that old transactions don't slow down or clutter your reports, and to help ensure the integrity of your accounting history. See the @@ -9116,4 +9105,4 @@ LICENSE SEE ALSO hledger(1), hledger-ui(1), hledger-web(1), ledger(1) -hledger-1.33.99 April 2024 HLEDGER(1) +hledger-1.33.99 May 2024 HLEDGER(1)