From 1fa8b796402049c8a203a5cf4ce9c608e334c147 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 15 Oct 2024 16:35:36 -1000 Subject: [PATCH] ;doc: update manuals --- hledger-lib/.date.m4 | 2 +- hledger-ui/.date.m4 | 2 +- hledger-ui/hledger-ui.1 | 2 +- hledger-ui/hledger-ui.info | 49 +- hledger-ui/hledger-ui.txt | 2 +- hledger-web/.date.m4 | 2 +- hledger-web/hledger-web.1 | 2 +- hledger-web/hledger-web.info | 31 +- hledger-web/hledger-web.txt | 2 +- hledger/.date.m4 | 2 +- hledger/hledger.1 | 372 ++++-- hledger/hledger.info | 1388 +++++++++----------- hledger/hledger.txt | 2295 ++++++++++++++++++---------------- 13 files changed, 2051 insertions(+), 2100 deletions(-) diff --git a/hledger-lib/.date.m4 b/hledger-lib/.date.m4 index c5f4680a4..a1b31d7e3 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_}}, {{September 2024}})m4_dnl +m4_define({{_monthyear_}}, {{October 2024}})m4_dnl diff --git a/hledger-ui/.date.m4 b/hledger-ui/.date.m4 index c5f4680a4..a1b31d7e3 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_}}, {{September 2024}})m4_dnl +m4_define({{_monthyear_}}, {{October 2024}})m4_dnl diff --git a/hledger-ui/hledger-ui.1 b/hledger-ui/hledger-ui.1 index 889fdb020..7d735e38e 100644 --- a/hledger-ui/hledger-ui.1 +++ b/hledger-ui/hledger-ui.1 @@ -1,5 +1,5 @@ -.TH "HLEDGER\-UI" "1" "September 2024" "hledger-ui-1.40.99 " "hledger User Manuals" +.TH "HLEDGER\-UI" "1" "October 2024" "hledger-ui-1.40.99 " "hledger User Manuals" diff --git a/hledger-ui/hledger-ui.info b/hledger-ui/hledger-ui.info index 7304b53b3..53965f1ee 100644 --- a/hledger-ui/hledger-ui.info +++ b/hledger-ui/hledger-ui.info @@ -1,4 +1,4 @@ -This is hledger-ui.info, produced by makeinfo version 7.1 from stdin. +This is hledger-ui.info, produced by makeinfo version 7.1.1 from stdin. INFO-DIR-SECTION User Applications START-INFO-DIR-ENTRY @@ -538,37 +538,22 @@ above).  Tag Table: -Node: Top221 -Node: OPTIONS1872 -Ref: #options1970 -Node: MOUSE8389 -Ref: #mouse8484 -Node: KEYS8721 -Ref: #keys8814 -Node: SCREENS13549 -Ref: #screens13653 -Node: Menu screen14289 -Ref: #menu-screen14410 -Node: Cash accounts screen14605 -Ref: #cash-accounts-screen14782 -Node: Balance sheet accounts screen14966 -Ref: #balance-sheet-accounts-screen15182 -Node: Income statement accounts screen15302 -Ref: #income-statement-accounts-screen15523 -Node: All accounts screen15687 -Ref: #all-accounts-screen15868 -Node: Register screen16050 -Ref: #register-screen16209 -Node: Transaction screen18493 -Ref: #transaction-screen18651 -Node: Error screen20068 -Ref: #error-screen20190 -Node: WATCH MODE20434 -Ref: #watch-mode20551 -Node: ENVIRONMENT22010 -Ref: #environment22126 -Node: BUGS22317 -Ref: #bugs22400 +Node: Top223 +Node: OPTIONS1874 +Node: MOUSE8391 +Node: KEYS8723 +Node: SCREENS13551 +Node: Menu screen14291 +Node: Cash accounts screen14607 +Node: Balance sheet accounts screen14968 +Node: Income statement accounts screen15304 +Node: All accounts screen15689 +Node: Register screen16052 +Node: Transaction screen18495 +Node: Error screen20070 +Node: WATCH MODE20436 +Node: ENVIRONMENT22012 +Node: BUGS22319  End Tag Table diff --git a/hledger-ui/hledger-ui.txt b/hledger-ui/hledger-ui.txt index 28070e874..92291353a 100644 --- a/hledger-ui/hledger-ui.txt +++ b/hledger-ui/hledger-ui.txt @@ -448,4 +448,4 @@ LICENSE SEE ALSO hledger(1), hledger-ui(1), hledger-web(1), ledger(1) -hledger-ui-1.40.99 September 2024 HLEDGER-UI(1) +hledger-ui-1.40.99 October 2024 HLEDGER-UI(1) diff --git a/hledger-web/.date.m4 b/hledger-web/.date.m4 index c5f4680a4..a1b31d7e3 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_}}, {{September 2024}})m4_dnl +m4_define({{_monthyear_}}, {{October 2024}})m4_dnl diff --git a/hledger-web/hledger-web.1 b/hledger-web/hledger-web.1 index 491af36da..0c1c14e63 100644 --- a/hledger-web/hledger-web.1 +++ b/hledger-web/hledger-web.1 @@ -1,5 +1,5 @@ -.TH "HLEDGER\-WEB" "1" "September 2024" "hledger-web-1.40.99 " "hledger User Manuals" +.TH "HLEDGER\-WEB" "1" "October 2024" "hledger-web-1.40.99 " "hledger User Manuals" diff --git a/hledger-web/hledger-web.info b/hledger-web/hledger-web.info index 4457e3d87..a7d1baa1c 100644 --- a/hledger-web/hledger-web.info +++ b/hledger-web/hledger-web.info @@ -1,4 +1,4 @@ -This is hledger-web.info, produced by makeinfo version 7.1 from stdin. +This is hledger-web.info, produced by makeinfo version 7.1.1 from stdin. INFO-DIR-SECTION User Applications START-INFO-DIR-ENTRY @@ -526,25 +526,16 @@ http://bugs.hledger.org), or on the #hledger chat or hledger mail list  Tag Table: -Node: Top223 -Node: OPTIONS2569 -Ref: #options2674 -Node: PERMISSIONS11101 -Ref: #permissions11240 -Node: EDITING UPLOADING DOWNLOADING12452 -Ref: #editing-uploading-downloading12633 -Node: RELOADING13467 -Ref: #reloading13601 -Node: JSON API14034 -Ref: #json-api14149 -Node: DEBUG OUTPUT19683 -Ref: #debug-output19808 -Node: Debug output19835 -Ref: #debug-output-119936 -Node: ENVIRONMENT20353 -Ref: #environment20472 -Node: BUGS20589 -Ref: #bugs20673 +Node: Top225 +Node: OPTIONS2571 +Node: PERMISSIONS11103 +Node: EDITING UPLOADING DOWNLOADING12454 +Node: RELOADING13469 +Node: JSON API14036 +Node: DEBUG OUTPUT19685 +Node: Debug output19837 +Node: ENVIRONMENT20355 +Node: BUGS20591  End Tag Table diff --git a/hledger-web/hledger-web.txt b/hledger-web/hledger-web.txt index 4dc97ef99..549e0cfbb 100644 --- a/hledger-web/hledger-web.txt +++ b/hledger-web/hledger-web.txt @@ -478,4 +478,4 @@ LICENSE SEE ALSO hledger(1), hledger-ui(1), hledger-web(1), ledger(1) -hledger-web-1.40.99 September 2024 HLEDGER-WEB(1) +hledger-web-1.40.99 October 2024 HLEDGER-WEB(1) diff --git a/hledger/.date.m4 b/hledger/.date.m4 index c5f4680a4..a1b31d7e3 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_}}, {{September 2024}})m4_dnl +m4_define({{_monthyear_}}, {{October 2024}})m4_dnl diff --git a/hledger/hledger.1 b/hledger/hledger.1 index 978212be7..b5ed772ac 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -1,6 +1,6 @@ .\"t -.TH "HLEDGER" "1" "September 2024" "hledger-1.40.99 " "hledger User Manuals" +.TH "HLEDGER" "1" "October 2024" "hledger-1.40.99 " "hledger User Manuals" @@ -723,91 +723,99 @@ then reuse them by writing \f[CR]\[at]FILENAME\f[R] as a command line argument. Eg: \f[CR]hledger bal \[at]foo.args\f[R]. .PP -(Inside the argument file, each line should contain just one option or -argument. +An argument file\[aq]s format is more restrictive than the command line. +Each line should contain just one option or argument. Don\[aq]t use spaces except inside quotes; write \f[CR]=\f[R] or nothing between a flag and its argument. +If you use quotes, they must enclose the whole line. For the special characters mentioned above, use one less level of -quoting than you would at the command prompt.) -.PP -Argument files are now superseded by.. +quoting than you would at the command line. .SS Config files -As of hledger 1.40, you can optionally save command line options (or -arguments) to be used when running hledger commands, in a config file. +With hledger 1.40+, you can save extra command line options and +arguments in a more featureful hledger config file. Here\[aq]s a small example: .IP .EX -\f[I]# General options are listed first, one or more per line.\f[R] -\f[I]# These will be used with all hledger commands that support them.\f[R] +\f[I]# General options are listed first, and used with hledger commands that support them.\f[R] \-\-pretty -\f[I]# Options following a \[ga][COMMANDNAME]\[ga] heading are used with that hledger command only.\f[R] +\f[I]# Options following a \[ga][COMMAND]\[ga] heading are used with that hledger command only.\f[R] \f[B][print]\f[R] \-\-explicit \-\-show\-costs .EE .PP To use a config file, specify it with the \f[CR]\-\-conf\f[R] option. -Its options will be inserted near the start of your command line (so you -can override them if needed). +Its options will be inserted near the start of your command line, so you +can override them with command line options if needed. .PP Or, you can set up an automatic config file that is used whenever you -run hledger. -This can be \f[CR]hledger.conf\f[R] in the current directory or above, -or \f[CR].hledger.conf\f[R] in your home directory +run hledger, by creating \f[CR]hledger.conf\f[R] in the current +directory or above, or \f[CR].hledger.conf\f[R] in your home directory (\f[CR]\[ti]/.hledger.conf\f[R]), or \f[CR]hledger.conf\f[R] in your XDG config directory (\f[CR]\[ti]/.config/hledger/hledger.conf\f[R]). .PP -You can ignore config files by adding the \f[CR]\-n/\-\-no\-conf\f[R] -flag. -This is useful when using hledger in scripts, or when troubleshooting. -(When both \f[CR]\-\-conf\f[R] and \f[CR]\-\-no\-conf\f[R] options are -used, the right\-most wins.) -To inspect the processing of config files, use \f[CR]\-\-debug\f[R] or -\f[CR]\-\-debug=8\f[R]. -.PP -Here is another example config file you could start with: +Here is another example config you could start with: https://github.com/simonmichael/hledger/blob/master/hledger.conf.sample .PP -Tips: -.PP -Automatic config files are convenient, but have a cost: it\[aq]s easy to -change a report\[aq]s behaviour, or break scripts/applications which use -hledger, in unintended ways that will surprise you later. -They change the nature of hledger somewhat, making it less transparent -and predictable. -If you decide to use one: -.IP \[bu] 2 -Be conservative about what you put in it. -Try to consider the effect on all your reports. -.IP \[bu] 2 -Whenever a hledger command does not work as expected, try it again with -\f[CR]\-n\f[R]. -.IP \[bu] 2 -If that helps, you can run it with \f[CR]\-\-debug\f[R] to see how a -config file affected it. +You can put not only options, but also arguments in a config file. +If the first word in a config file\[aq]s top (general) section does not +begin with a dash (eg: \f[CR]print\f[R]), it is treated as the command +argument (overriding any argument on the command line). .PP On unix machines, you can add a shebang line at the top of a config file, set executable permission on the file, and use it like a script. -Eg (some operating systems need the \f[CR]\-S\f[R], some don\[aq]t): +Eg (the \f[CR]\-S\f[R] is needed on some operating systems): .IP .EX #!/usr/bin/env \-S hledger \-\-conf .EE .PP -You can put not only options, but also arguments in a config file. -This is probably more useful in special\-purpose config files, not an -automatic one. +You can ignore config files by adding the +\f[CR]\-n\f[R]/\f[CR]\-\-no\-conf\f[R] flag to the command line. +This is useful when using hledger in scripts, or when troubleshooting. +When both \f[CR]\-\-conf\f[R] and \f[CR]\-\-no\-conf\f[R] options are +used, the right\-most wins. .PP -There\[aq]s an exception to this: a config file can\[aq]t provide the -command argument, currently (#2231). -If you need that, you can do it in the shebang line instead. -Eg: -.IP -.EX -#!/usr/bin/env \-S hledger balance \-\-conf -.EE +To inspect the processing of config files, use \f[CR]\-\-debug\f[R] or +\f[CR]\-\-debug=8\f[R]. .PP -The config file feature has been added in hledger 1.40 and is considered +\f[B]Warning!\f[R] +.PP +There aren\[aq]t many hledger features that need a warning, but this is +one! +.PP +Automatic config files, while convenient, also make hledger less +predictable and dependable. +It\[aq]s easy to make a config file that changes a report\[aq]s +behaviour, or breaks your hledger\-using scripts/applications, in ways +that will surprise you later. +.PP +If you don\[aq]t want this, +.IP "1." 3 +Just don\[aq]t create a hledger.conf file on your machine. +.IP "2." 3 +Also be alert to downloaded directories which may contain a hledger.conf +file. +.IP "3." 3 +Also if you are sharing scripts or examples or support, consider that +others may have a hledger.conf file. +.PP +Conversely, once you decide to use this feature, try to remember: +.IP "1." 3 +Whenever a hledger command does not work as expected, try it again with +\f[CR]\-n\f[R] (\f[CR]\-\-no\-conf\f[R]) to see if a config file was to +blame. +.IP "2." 3 +Whenever you call hledger from a script, consider whether that call +should use \f[CR]\-n\f[R] or not. +.IP "3." 3 +Be conservative about what you put in your config file; try to consider +the effect on all your reports. +.IP "4." 3 +To troubleshoot the effect of config files, run with +\f[CR]\-\-debug\f[R] or \f[CR]\-\-debug 8\f[R]. +.PP +The config file feature was added in hledger 1.40 and is considered \f[I]experimental\f[R]. .SS Shell completions If you use the bash shell, you can optionally set up context\-sensitive @@ -829,8 +837,8 @@ $ hledger print > foo.txt .EE .PP Some commands (print, register, stats, the balance commands) also -provide the \f[CR]\-o/\-\-output\-file\f[R] option, which does the same -thing without needing the shell. +provide the \f[CR]\-o\f[R]/\f[CR]\-\-output\-file\f[R] option, which +does the same thing without needing the shell. Eg: .IP .EX @@ -844,21 +852,23 @@ Here are those commands and the formats currently supported: .PP .TS tab(@); -lw(13.6n) lw(12.2n) lw(12.2n) lw(12.2n) lw(12.2n) lw(4.1n) lw(3.4n). +lw(20.6n) lw(5.1n) lw(6.2n) lw(9.3n) lw(6.2n) lw(11.3n) lw(5.1n) lw(6.2n). T{ -\- +command T}@T{ txt T}@T{ -csv/tsv -T}@T{ html T}@T{ +csv/tsv +T}@T{ fods T}@T{ -json +beancount T}@T{ sql +T}@T{ +json T} _ T{ @@ -871,83 +881,91 @@ T}@T{ Y T}@T{ T}@T{ -Y T}@T{ +T}@T{ +Y T} T{ balance T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] +Y T}@T{ Y T}@T{ +Y +T}@T{ +Y +T}@T{ +T}@T{ +T}@T{ +Y T} T{ balancesheet T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] -T}@T{ +Y T}@T{ Y T}@T{ +Y +T}@T{ +T}@T{ +T}@T{ +T}@T{ +Y T} T{ balancesheetequity T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] -T}@T{ +Y T}@T{ Y T}@T{ +Y +T}@T{ +T}@T{ +T}@T{ +T}@T{ +Y T} T{ cashflow T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] -T}@T{ +Y T}@T{ Y T}@T{ +Y +T}@T{ +T}@T{ +T}@T{ +T}@T{ +Y T} T{ incomestatement T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] -T}@T{ -Y \f[I]1\f[R] -T}@T{ +Y T}@T{ Y T}@T{ +Y +T}@T{ +T}@T{ +T}@T{ +T}@T{ +Y T} T{ print T}@T{ Y T}@T{ +T}@T{ Y T}@T{ T}@T{ +Y T}@T{ Y T}@T{ @@ -958,27 +976,25 @@ register T}@T{ Y T}@T{ +T}@T{ Y T}@T{ T}@T{ T}@T{ +T}@T{ Y -T}@T{ T} .TE -.IP \[bu] 2 -\f[I]1 Also affected by the balance commands\[aq] \f[CI]\-\-layout\f[I] -option.\f[R] .PP The output format is selected by the -\f[CR]\-O/\-\-output\-format=FMT\f[R] option: +\f[CR]\-O\f[R]/\f[CR]\-\-output\-format=FMT\f[R] option: .IP .EX $ hledger print \-O csv # print CSV on stdout .EE .PP or by the filename extension of an output file specified with the -\f[CR]\-o/\-\-output\-file=FILE.FMT\f[R] option: +\f[CR]\-o\f[R]/\f[CR]\-\-output\-file=FILE.FMT\f[R] option: .IP .EX $ hledger balancesheet \-o foo.csv # write CSV to foo.csv @@ -991,11 +1007,10 @@ override the file extension, if needed: $ hledger balancesheet \-o foo.txt \-O csv # write CSV to foo.txt .EE .PP -Some notes about the various output formats: -.SS CSV output -.IP \[bu] 2 -In CSV output, digit group marks (such as thousands separators) are -disabled automatically. +Here are some notes about the various output formats. +.SS Text output +This is the default: human readable, plain text report output, suitable +for a terminal. .SS HTML output .IP \[bu] 2 HTML output can be styled by an optional \f[CR]hledger.css\f[R] file in @@ -1006,28 +1021,74 @@ If your web browser is showing junk characters, you may need to change its text encoding to UTF\-8. Eg in Safari, see View \-> Text Encoding and Settings \-> Advanced \-> Default Encoding. -.SS JSON output +.SS CSV / TSV output .IP \[bu] 2 -This is not yet much used; real\-world feedback is welcome. -.IP \[bu] 2 -Our JSON is rather large and verbose, since it is a faithful -representation of hledger\[aq]s internal data types. -To understand the JSON, read the Haskell type definitions, which are -mostly in -https://github.com/simonmichael/hledger/blob/master/hledger\-lib/Hledger/Data/Types.hs. -hledger\-web\[aq]s OpenAPI specification may also be relevant. -.IP \[bu] 2 -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 as simple Numbers with at most 10 decimal -places. -We don\[aq]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 -otherwise, please let us know. -(Cf #1195) +In CSV or TSV output, digit group marks (such as thousands separators) +are disabled automatically. +.SS FODS output +FODS is the OpenDocument spreadsheet format used by LibreOffice and +OpenOffice. +It is a good format to use if you are exporting to their spreadsheet +app. +.SS Beancount output +This is Beancount\[aq]s journal format. +You can use this to export your hledger data to Beancount, perhaps to +query it with Beancount Query Language or with the Fava web app. +hledger will try to adjust your data to suit Beancount. +If you plan to export often, you may want to follow Beancount\[aq]s +conventions in your hledger data, to ease conversion. +Eg use Beancount\-friendly account names, currency codes instead of +currency symbols, and avoid virtual postings, redundant cost notation, +etc. +.PP +Here are more details, included here for now (see also \[dq]hledger and +Beancount\[dq] https://hledger.org/beancount.html). +.SS Beancount account names +hledger will try adjust your account names, if needed, to Beancount +account names, by capitalising, replacing unsupported characters with +\f[CR]\-\f[R], and prepending \f[CR]B\f[R] to parts which don\[aq]t +begin with a letter or digit. +(It\[aq]s possible for this to convert distinct hledger account names to +the same beancount name. +Eg, hledger\[aq]s automatic equity conversion accounts can have currency +symbols in their name, so \f[CR]equity:conversion:$\-€\f[R] becomes +\f[CR]equity:conversion:B\-\-\-\f[R].) +.PP +In addition, you must ensure that the top level account names are +\f[CR]Assets\f[R], \f[CR]Liabilities\f[R], \f[CR]Equity\f[R], +\f[CR]Income\f[R], and \f[CR]Expenses\f[R], which Beancount requires. +If yours are named differently, you can use account aliases, usually in +the form of \f[CR]\-\-alias\f[R] options, possibly stored in a config +file. +(An example: hledger2beancount.conf) +.SS Beancount commodity names +hledger will adjust your commodity names, if needed, to Beancount +commodity/currency names, which must be 2\-24 uppercase letters, digits, +or \f[CR]\[aq]\f[R], \f[CR].\f[R], \f[CR]_\f[R], \f[CR]\-\f[R], +beginning with a letter and ending with a letter or digit. +hledger will convert known currency symbols to ISO 4217 currency codes. +Otherwise, it will capitalise letters, replace unsupported characters +with a dash (\-), and prepend/append a \[dq]B\[dq] when needed. +(It\[aq]s possible for this to generate unreadable commodity names, or +to convert distinct hledger commodity names to the same beancount name.) +.SS Beancount virtual postings +Beancount doesn\[aq]t allow unbalanced/virtual postings, so you will +need to comment those, or use \f[CR]\-\-real\f[R] to exclude +transactions that use them. +(If you have transactions which are a mixture of balanced and unbalanced +postings, you\[aq]ll have to do something more.) +.SS Beancount costs +Beancount doesn\[aq]t allow redundant cost notation as hledger does. +If you have entries like this, you will need to comment out either the +costs or the equity postings. +.SS Beancount operating currency +Declaring an operating currency improves Beancount and Fava reports. +You can do this manually by adding a line like this to the beancount +journal: +.IP +.EX +option \[dq]operating_currency\[dq] \[dq]USD\[dq] +.EE .SS SQL output .IP \[bu] 2 This is not yet much used; real\-world feedback is welcome. @@ -1050,6 +1111,28 @@ If you already have tables created via SQL output of hledger, you would probably want to either clear tables of existing data (via \f[CR]delete\f[R] or \f[CR]truncate\f[R] SQL statements) or drop tables completely as otherwise your postings will be duped. +.SS JSON output +.IP \[bu] 2 +This is not yet much used; real\-world feedback is welcome. +.IP \[bu] 2 +Our JSON is rather large and verbose, since it is a faithful +representation of hledger\[aq]s internal data types. +To understand the JSON, read the Haskell type definitions, which are +mostly in +https://github.com/simonmichael/hledger/blob/master/hledger\-lib/Hledger/Data/Types.hs. +hledger\-web\[aq]s OpenAPI specification may also be relevant. +.IP \[bu] 2 +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 as simple Numbers with at most 10 decimal +places. +We don\[aq]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 +otherwise, please let us know. +(Cf #1195) .SS Commodity styles When displaying amounts, hledger infers a standard display style for each commodity/currency, as described below in Commodity display style. @@ -2156,16 +2239,18 @@ Tags hledger adds to indicate generated data: generated\-transaction \-\- appears on generated periodic txns (with \-\-verbose\-tags) generated\-posting \-\- appears on generated auto postings (with \-\-verbose\-tags) modified \-\- appears on txns which have had auto postings added (with \-\-verbose\-tags) + Not displayed, but queryable: _generated\-transaction \-\- exists on generated periodic txns (always) _generated\-posting \-\- exists on generated auto postings (always) _modified \-\- exists on txns which have had auto postings added (always) .EE .PP -Tags hledger uses internally: +Other tags hledger uses internally: .IP .EX - _conversion\-matched \-\- exists on postings which have been matched with a nearby \[at]/\[at]\[at] cost annotation + _cost\-matched \-\- marks postings with a cost which have been matched with a nearby pair of equity conversion postings + _conversion\-matched \-\- marks equity conversion postings which have been matched with a nearby posting with a cost .EE .SS Tag values Tags can have a value, which is any text after the colon up until a @@ -2510,8 +2595,9 @@ Usually you\[aq]ll find that error later, as an extra account in balance reports, or an incorrect balance when reconciling. .PP In strict mode, enabled with the \f[CR]\-s\f[R]/\f[CR]\-\-strict\f[R] -flag, hledger will report an error if any transaction uses an account -name that has not been declared by an account directive. +flag, or when you run \f[CR]hledger check accounts\f[R], hledger will +report an error if any transaction uses an account name that has not +been declared by an account directive. Some notes: .IP \[bu] 2 The declaration is case\-sensitive; transactions must use the correct @@ -2530,6 +2616,9 @@ affect included files of all types. It\[aq]s currently not possible to declare \[dq]all possible subaccounts\[dq] with a wildcard; every account posted to must be declared. +.IP \[bu] 2 +If you use the \-\-infer\-equity flag, you will also need declarations +for the account names it generates. .SS Account display order Account directives also cause hledger to display accounts in a particular order, not just alphabetically. @@ -7073,6 +7162,10 @@ The equity account names will be \[dq]equity:conversion:A\-B:A\[dq] and commodity symbol. You can customise the \[dq]equity:conversion\[dq] part by declaring an account with the \f[CR]V\f[R]/\f[CR]Conversion\f[R] account type. +.PP +Note you will need to add account declarations for these to your +journal, if you use \f[CR]check accounts\f[R] or +\f[CR]check \-\-strict\f[R]. .SS Combining costs and equity conversion postings Finally, you can use both the \[at]/\[at]\[at] cost notation and equity postings at the same time. @@ -10439,10 +10532,10 @@ uses all periodic rules; or with an argument T} .TE .SS Balance report layout -The \f[CR]\-\-layout\f[R] 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. +The \f[CR]\-\-layout\f[R] option affects how \f[CR]balance\f[R] and the +other balance\-like commands show multi\-commodity amounts and commodity +symbols. +It can improve readability, for humans and/or machines (other software). It has four possible values: .IP \[bu] 2 \f[CR]\-\-layout=wide[,WIDTH]\f[R]: commodities are shown on a single @@ -10454,7 +10547,9 @@ line, optionally elided to WIDTH amounts are bare numbers .IP \[bu] 2 \f[CR]\-\-layout=tidy\f[R]: data is normalised to easily\-consumed -\[dq]tidy\[dq] form, with one row per data value +\[dq]tidy\[dq] form, with one row per data value. +(This one is currently supported only by the \f[CR]balance\f[R] +command.) .PP Here are the \f[CR]\-\-layout\f[R] modes supported by each output format Only CSV output supports all of them: @@ -10658,10 +10753,9 @@ You can also produce relative links, like \f[CR]\-\-base\-url=\[dq]some/path\[dq]\f[R] or \f[CR]\-\-base\-url=\[dq]\[dq]\f[R].) .PP -The balance reports\[aq] HTML output currently does not display tree -mode reports properly (#1846). -For now, if generating HTML you should probabBly use the default -\f[CR]\-\-flat\f[R] mode. +The balance reports\[aq] HTML output currently does not indent tree mode +reports properly (#1846). +So in HTML balance reports, use list mode for now (it is the default). .SS Some useful balance reports Some frequently used \f[CR]balance\f[R] options/reports are: .IP \[bu] 2 diff --git a/hledger/hledger.info b/hledger/hledger.info index fe55d097b..ca5957d24 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -1,4 +1,4 @@ -This is hledger.info, produced by makeinfo version 7.1 from stdin. +This is hledger.info, produced by makeinfo version 7.1.1 from stdin. INFO-DIR-SECTION User Applications START-INFO-DIR-ENTRY @@ -733,13 +733,12 @@ 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: 'hledger bal @foo.args'. - (Inside the argument file, each line should contain just one option -or argument. Don't use spaces except inside quotes; write '=' or -nothing between a flag and its argument. For the special characters -mentioned above, use one less level of quoting than you would at the -command prompt.) - - Argument files are now superseded by.. + An argument file's format is more restrictive than the command line. +Each line should contain just one option or argument. Don't use spaces +except inside quotes; write '=' or nothing between a flag and its +argument. If you use quotes, they must enclose the whole line. For the +special characters mentioned above, use one less level of quoting than +you would at the command line.  File: hledger.info, Node: Config files, Next: Shell completions, Prev: Argument files, Up: Options @@ -747,69 +746,80 @@ File: hledger.info, Node: Config files, Next: Shell completions, Prev: Argume 4.5 Config files ================ -As of hledger 1.40, you can optionally save command line options (or -arguments) to be used when running hledger commands, in a config file. -Here's a small example: +With hledger 1.40+, you can save extra command line options and +arguments in a more featureful hledger config file. Here's a small +example: -# General options are listed first, one or more per line. -# These will be used with all hledger commands that support them. +# General options are listed first, and used with hledger commands that support them. --pretty -# Options following a `[COMMANDNAME]` heading are used with that hledger command only. +# Options following a `[COMMAND]` heading are used with that hledger command only. [print] --explicit --show-costs To use a config file, specify it with the '--conf' option. Its -options will be inserted near the start of your command line (so you can -override them if needed). +options will be inserted near the start of your command line, so you can +override them with command line options if needed. Or, you can set up an automatic config file that is used whenever you -run hledger. This can be 'hledger.conf' in the current directory or +run hledger, by creating 'hledger.conf' in the current directory or above, or '.hledger.conf' in your home directory ('~/.hledger.conf'), or 'hledger.conf' in your XDG config directory ('~/.config/hledger/hledger.conf'). - You can ignore config files by adding the '-n/--no-conf' flag. This -is useful when using hledger in scripts, or when troubleshooting. (When -both '--conf' and '--no-conf' options are used, the right-most wins.) -To inspect the processing of config files, use '--debug' or '--debug=8'. - - Here is another example config file you could start with: + Here is another example config you could start with: https://github.com/simonmichael/hledger/blob/master/hledger.conf.sample - Tips: - - Automatic config files are convenient, but have a cost: it's easy to -change a report's behaviour, or break scripts/applications which use -hledger, in unintended ways that will surprise you later. They change -the nature of hledger somewhat, making it less transparent and -predictable. If you decide to use one: - - * Be conservative about what you put in it. Try to consider the - effect on all your reports. - * Whenever a hledger command does not work as expected, try it again - with '-n'. - * If that helps, you can run it with '--debug' to see how a config - file affected it. + You can put not only options, but also arguments in a config file. +If the first word in a config file's top (general) section does not +begin with a dash (eg: 'print'), it is treated as the command argument +(overriding any argument on the command line). On unix machines, you can add a shebang line at the top of a config file, set executable permission on the file, and use it like a script. -Eg (some operating systems need the '-S', some don't): +Eg (the '-S' is needed on some operating systems): #!/usr/bin/env -S hledger --conf - You can put not only options, but also arguments in a config file. -This is probably more useful in special-purpose config files, not an -automatic one. + You can ignore config files by adding the '-n'/'--no-conf' flag to +the command line. This is useful when using hledger in scripts, or when +troubleshooting. When both '--conf' and '--no-conf' options are used, +the right-most wins. - There's an exception to this: a config file can't provide the command -argument, currently (#2231). If you need that, you can do it in the -shebang line instead. Eg: + To inspect the processing of config files, use '--debug' or +'--debug=8'. -#!/usr/bin/env -S hledger balance --conf + *Warning!* - The config file feature has been added in hledger 1.40 and is -considered _experimental_. + There aren't many hledger features that need a warning, but this is +one! + + Automatic config files, while convenient, also make hledger less +predictable and dependable. It's easy to make a config file that +changes a report's behaviour, or breaks your hledger-using +scripts/applications, in ways that will surprise you later. + + If you don't want this, + + 1. Just don't create a hledger.conf file on your machine. + 2. Also be alert to downloaded directories which may contain a + hledger.conf file. + 3. Also if you are sharing scripts or examples or support, consider + that others may have a hledger.conf file. + + Conversely, once you decide to use this feature, try to remember: + + 1. Whenever a hledger command does not work as expected, try it again + with '-n' ('--no-conf') to see if a config file was to blame. + 2. Whenever you call hledger from a script, consider whether that call + should use '-n' or not. + 3. Be conservative about what you put in your config file; try to + consider the effect on all your reports. + 4. To troubleshoot the effect of config files, run with '--debug' or + '--debug 8'. + + The config file feature was added in hledger 1.40 and is considered +_experimental_.  File: hledger.info, Node: Shell completions, Prev: Config files, Up: Options @@ -852,8 +862,8 @@ of course redirect this, eg into a file, using standard shell syntax: $ hledger print > foo.txt Some commands (print, register, stats, the balance commands) also -provide the '-o/--output-file' option, which does the same thing without -needing the shell. Eg: +provide 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) @@ -867,25 +877,24 @@ File: hledger.info, Node: Output format, Next: Commodity styles, Prev: Output Some commands offer other kinds of output, not just text on the terminal. Here are those commands and the formats currently supported: -- txt csv/tsv html fods json sql ------------------------------------------------------------------------------ -aregister Y Y Y Y -balance Y _1_ Y _1_ Y _1_ Y _1_ Y -balancesheet Y _1_ Y _1_ Y _1_ Y -balancesheetequityY _1_ Y _1_ Y _1_ Y -cashflow Y _1_ Y _1_ Y _1_ Y -incomestatementY _1_ Y _1_ Y _1_ Y -print Y Y Y Y -register Y Y Y +command txt html csv/tsv fods beancount sql json +------------------------------------------------------------------------------ +aregister Y Y Y Y +balance Y Y Y Y Y +balancesheet Y Y Y Y +balancesheetequity Y Y Y Y +cashflow Y Y Y Y +incomestatement Y Y Y Y +print Y Y Y Y Y +register Y Y Y - * _1 Also affected by the balance commands' '--layout' option._ - - The output format is selected by the '-O/--output-format=FMT' option: + 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 -'-o/--output-file=FILE.FMT' option: +'-o'/'--output-file=FILE.FMT' option: $ hledger balancesheet -o foo.csv # write CSV to foo.csv @@ -894,26 +903,29 @@ extension, if needed: $ hledger balancesheet -o foo.txt -O csv # write CSV to foo.txt - Some notes about the various output formats: + Here are some notes about the various output formats. * Menu: -* CSV output:: +* Text output:: * HTML output:: -* JSON output:: +* CSV / TSV output:: +* FODS output:: +* Beancount output:: * SQL output:: +* JSON output::  -File: hledger.info, Node: CSV output, Next: HTML output, Up: Output format +File: hledger.info, Node: Text output, Next: HTML output, Up: Output format -5.2.1 CSV output ----------------- +5.2.1 Text output +----------------- - * In CSV output, digit group marks (such as thousands separators) are - disabled automatically. +This is the default: human readable, plain text report output, suitable +for a terminal.  -File: hledger.info, Node: HTML output, Next: JSON output, Prev: CSV output, Up: Output format +File: hledger.info, Node: HTML output, Next: CSV / TSV output, Prev: Text output, Up: Output format 5.2.2 HTML output ----------------- @@ -927,32 +939,122 @@ File: hledger.info, Node: HTML output, Next: JSON output, Prev: CSV output, Default Encoding.  -File: hledger.info, Node: JSON output, Next: SQL output, Prev: HTML output, Up: Output format +File: hledger.info, Node: CSV / TSV output, Next: FODS output, Prev: HTML output, Up: Output format -5.2.3 JSON output ------------------ +5.2.3 CSV / TSV output +---------------------- - * This is not yet much used; real-world feedback is welcome. - - * Our JSON is rather large and verbose, since it is a faithful - representation 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/master/hledger-lib/Hledger/Data/Types.hs. - hledger-web's OpenAPI specification may also be relevant. - - * 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 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 otherwise, please let us know. (Cf #1195) + * In CSV or TSV output, digit group marks (such as thousands + separators) are disabled automatically.  -File: hledger.info, Node: SQL output, Prev: JSON output, Up: Output format +File: hledger.info, Node: FODS output, Next: Beancount output, Prev: CSV / TSV output, Up: Output format -5.2.4 SQL output +5.2.4 FODS output +----------------- + +FODS is the OpenDocument spreadsheet format used by LibreOffice and +OpenOffice. It is a good format to use if you are exporting to their +spreadsheet app. + + +File: hledger.info, Node: Beancount output, Next: SQL output, Prev: FODS output, Up: Output format + +5.2.5 Beancount output +---------------------- + +This is Beancount's journal format. You can use this to export your +hledger data to Beancount, perhaps to query it with Beancount Query +Language or with the Fava web app. hledger will try to adjust your data +to suit Beancount. If you plan to export often, you may want to follow +Beancount's conventions in your hledger data, to ease conversion. Eg +use Beancount-friendly account names, currency codes instead of currency +symbols, and avoid virtual postings, redundant cost notation, etc. + + Here are more details, included here for now (see also "hledger and +Beancount" https://hledger.org/beancount.html). + +* Menu: + +* Beancount account names:: +* Beancount commodity names:: +* Beancount virtual postings:: +* Beancount costs:: +* Beancount operating currency:: + + +File: hledger.info, Node: Beancount account names, Next: Beancount commodity names, Up: Beancount output + +5.2.5.1 Beancount account names +............................... + +hledger will try adjust your account names, if needed, to Beancount +account names, by capitalising, replacing unsupported characters with +'-', and prepending 'B' to parts which don't begin with a letter or +digit. (It's possible for this to convert distinct hledger account +names to the same beancount name. Eg, hledger's automatic equity +conversion accounts can have currency symbols in their name, so +'equity:conversion:$-€' becomes 'equity:conversion:B---'.) + + In addition, you must ensure that the top level account names are +'Assets', 'Liabilities', 'Equity', 'Income', and 'Expenses', which +Beancount requires. If yours are named differently, you can use account +aliases, usually in the form of '--alias' options, possibly stored in a +config file. (An example: hledger2beancount.conf) + + +File: hledger.info, Node: Beancount commodity names, Next: Beancount virtual postings, Prev: Beancount account names, Up: Beancount output + +5.2.5.2 Beancount commodity names +................................. + +hledger will adjust your commodity names, if needed, to Beancount +commodity/currency names, which must be 2-24 uppercase letters, digits, +or ''', '.', '_', '-', beginning with a letter and ending with a letter +or digit. hledger will convert known currency symbols to ISO 4217 +currency codes. Otherwise, it will capitalise letters, replace +unsupported characters with a dash (-), and prepend/append a "B" when +needed. (It's possible for this to generate unreadable commodity names, +or to convert distinct hledger commodity names to the same beancount +name.) + + +File: hledger.info, Node: Beancount virtual postings, Next: Beancount costs, Prev: Beancount commodity names, Up: Beancount output + +5.2.5.3 Beancount virtual postings +.................................. + +Beancount doesn't allow unbalanced/virtual postings, so you will need to +comment those, or use '--real' to exclude transactions that use them. +(If you have transactions which are a mixture of balanced and unbalanced +postings, you'll have to do something more.) + + +File: hledger.info, Node: Beancount costs, Next: Beancount operating currency, Prev: Beancount virtual postings, Up: Beancount output + +5.2.5.4 Beancount costs +....................... + +Beancount doesn't allow redundant cost notation as hledger does. If you +have entries like this, you will need to comment out either the costs or +the equity postings. + + +File: hledger.info, Node: Beancount operating currency, Prev: Beancount costs, Up: Beancount output + +5.2.5.5 Beancount operating currency +.................................... + +Declaring an operating currency improves Beancount and Fava reports. +You can do this manually by adding a line like this to the beancount +journal: + +option "operating_currency" "USD" + + +File: hledger.info, Node: SQL output, Next: JSON output, Prev: Beancount output, Up: Output format + +5.2.6 SQL output ---------------- * This is not yet much used; real-world feedback is welcome. @@ -972,6 +1074,29 @@ File: hledger.info, Node: SQL output, Prev: JSON output, Up: Output format SQL statements) or drop tables completely as otherwise your postings will be duped. + +File: hledger.info, Node: JSON output, Prev: SQL output, Up: Output format + +5.2.7 JSON output +----------------- + + * This is not yet much used; real-world feedback is welcome. + + * Our JSON is rather large and verbose, since it is a faithful + representation 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/master/hledger-lib/Hledger/Data/Types.hs. + hledger-web's OpenAPI specification may also be relevant. + + * 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 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 otherwise, please let us know. (Cf #1195) +  File: hledger.info, Node: Commodity styles, Next: Colour, Prev: Output format, Up: Output @@ -2184,14 +2309,16 @@ elsewhere, but here is a quick list for reference: generated-transaction -- appears on generated periodic txns (with --verbose-tags) generated-posting -- appears on generated auto postings (with --verbose-tags) modified -- appears on txns which have had auto postings added (with --verbose-tags) + Not displayed, but queryable: _generated-transaction -- exists on generated periodic txns (always) _generated-posting -- exists on generated auto postings (always) _modified -- exists on txns which have had auto postings added (always) - Tags hledger uses internally: + Other tags hledger uses internally: - _conversion-matched -- exists on postings which have been matched with a nearby @/@@ cost annotation + _cost-matched -- marks postings with a cost which have been matched with a nearby pair of equity conversion postings + _conversion-matched -- marks equity conversion postings which have been matched with a nearby posting with a cost  File: hledger.info, Node: Tag values, Prev: Special tags, Up: Tags @@ -2413,9 +2540,10 @@ can't warn you when you mis-spell an account name in the journal. Usually you'll find that error later, as an extra account in balance 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 declared by an account directive. Some notes: + In strict mode, enabled with the '-s'/'--strict' flag, or when you +run 'hledger check accounts', hledger will report an error if any +transaction uses an account name that has not been declared by an +account directive. Some notes: * The declaration is case-sensitive; transactions must use the correct account name capitalisation. @@ -2428,6 +2556,8 @@ been declared by an account directive. Some notes: included files of all types. * It's currently not possible to declare "all possible subaccounts" with a wildcard; every account posted to must be declared. + * If you use the -infer-equity flag, you will also need declarations + for the account names it generates.  File: hledger.info, Node: Account display order, Next: Account types, Prev: Account error checking, Up: account directive @@ -6864,6 +6994,9 @@ $ hledger print --infer-equity symbol. You can customise the "equity:conversion" part by declaring an account with the 'V'/'Conversion' account type. + Note you will need to add account declarations for these to your +journal, if you use 'check accounts' or 'check --strict'. +  File: hledger.info, Node: Combining costs and equity conversion postings, Next: Requirements for detecting equity conversion postings, Prev: Inferring equity conversion postings, Up: Cost reporting @@ -10095,10 +10228,10 @@ File: hledger.info, Node: Balance report layout, Next: Balance report output, 29.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: +The '--layout' option affects how 'balance' and the other balance-like +commands show multi-commodity amounts and commodity symbols. It can +improve readability, for humans and/or machines (other software). It +has four possible values: * '--layout=wide[,WIDTH]': commodities are shown on a single line, optionally elided to WIDTH @@ -10106,7 +10239,8 @@ four possible values: * '--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 + with one row per data value. (This one is currently supported only + by the 'balance' command.) Here are the '--layout' modes supported by each output format Only CSV output supports all of them: @@ -10276,9 +10410,9 @@ might run the 'balance' command with the extra option '--base-url=http://localhost:5000'. You can also produce relative links, like '--base-url="some/path"' or '--base-url=""'.) - The balance reports' HTML output currently does not display tree mode -reports properly (#1846). For now, if generating HTML you should -probabBly use the default '--flat' mode. + The balance reports' HTML output currently does not indent tree mode +reports properly (#1846). So in HTML balance reports, use list mode for +now (it is the default).  File: hledger.info, Node: Some useful balance reports, Prev: Balance report output, Up: balance @@ -11788,695 +11922,359 @@ See hledger and Ledger for full details.  Tag Table: -Node: Top208 -Node: PART 1 USER INTERFACE4363 -Ref: #part-1-user-interface4502 -Node: Input4502 -Ref: #input4612 -Node: Text encoding5594 -Ref: #text-encoding5708 -Node: Data formats6274 -Ref: #data-formats6409 -Node: Standard input7998 -Ref: #standard-input8138 -Node: Multiple files8387 -Ref: #multiple-files8526 -Node: Strict mode9124 -Ref: #strict-mode9234 -Node: Commands9958 -Ref: #commands10060 -Node: Add-on commands11144 -Ref: #add-on-commands11246 -Node: Options12362 -Ref: #options12463 -Node: Special characters18779 -Ref: #special-characters18916 -Node: Single escaping shell metacharacters19079 -Ref: #single-escaping-shell-metacharacters19320 -Node: Double escaping regular expression metacharacters19923 -Ref: #double-escaping-regular-expression-metacharacters20234 -Node: Triple escaping for add-on commands20760 -Ref: #triple-escaping-for-add-on-commands21020 -Node: Less escaping21664 -Ref: #less-escaping21818 -Node: Unicode characters22142 -Ref: #unicode-characters22307 -Node: Regular expressions23806 -Ref: #regular-expressions23969 -Node: hledger's regular expressions27065 -Ref: #hledgers-regular-expressions27224 -Node: Argument files28610 -Ref: #argument-files28757 -Node: Config files29263 -Ref: #config-files29404 -Node: Shell completions32010 -Ref: #shell-completions32138 -Node: Output32535 -Ref: #output32637 -Node: Output destination32764 -Ref: #output-destination32895 -Node: Output format33320 -Ref: #output-format33466 -Node: CSV output34951 -Ref: #csv-output35067 -Node: HTML output35170 -Ref: #html-output35308 -Node: JSON output35644 -Ref: #json-output35782 -Node: SQL output36767 -Ref: #sql-output36883 -Node: Commodity styles37618 -Ref: #commodity-styles37758 -Node: Colour38496 -Ref: #colour38614 -Node: Box-drawing39018 -Ref: #box-drawing39136 -Node: Paging39420 -Ref: #paging39534 -Node: Debug output40487 -Ref: #debug-output40593 -Node: Environment41256 -Ref: #environment41380 -Node: PART 2 DATA FORMATS41947 -Ref: #part-2-data-formats42090 -Node: Journal42090 -Ref: #journal42199 -Node: Journal cheatsheet44568 -Ref: #journal-cheatsheet44695 -Node: Comments50782 -Ref: #comments50910 -Node: Transactions51726 -Ref: #transactions51849 -Node: Dates52863 -Ref: #dates52970 -Node: Simple dates53015 -Ref: #simple-dates53131 -Node: Posting dates53631 -Ref: #posting-dates53749 -Node: Status54718 -Ref: #status54819 -Node: Code56484 -Ref: #code56587 -Node: Description56819 -Ref: #description56950 -Node: Payee and note57506 -Ref: #payee-and-note57612 -Node: Transaction comments58597 -Ref: #transaction-comments58750 -Node: Postings59113 -Ref: #postings59244 -Node: Debits and credits60276 -Ref: #debits-and-credits60423 -Node: The two space delimiter60886 -Ref: #the-two-space-delimiter61043 -Node: Account names61451 -Ref: #account-names61581 -Node: Amounts63255 -Ref: #amounts63383 -Node: Decimal marks64284 -Ref: #decimal-marks64411 -Node: Digit group marks65388 -Ref: #digit-group-marks65541 -Node: Commodity66023 -Ref: #commodity66152 -Node: Costs67140 -Ref: #costs67235 -Node: Balance assertions69392 -Ref: #balance-assertions69545 -Node: Assertions and ordering70629 -Ref: #assertions-and-ordering70818 -Node: Assertions and multiple included files71357 -Ref: #assertions-and-multiple-included-files71617 -Node: Assertions and multiple -f files72117 -Ref: #assertions-and-multiple--f-files72362 -Node: Assertions and costs72759 -Ref: #assertions-and-costs72968 -Node: Assertions and commodities73409 -Ref: #assertions-and-commodities73624 -Node: Assertions and subaccounts75068 -Ref: #assertions-and-subaccounts75294 -Node: Assertions and virtual postings75738 -Ref: #assertions-and-virtual-postings75976 -Node: Assertions and auto postings76108 -Ref: #assertions-and-auto-postings76338 -Node: Assertions and precision76983 -Ref: #assertions-and-precision77165 -Node: Posting comments77432 -Ref: #posting-comments77595 -Node: Transaction balancing77972 -Ref: #transaction-balancing78131 -Node: Tags79974 -Ref: #tags80093 -Node: Tag names81436 -Ref: #tag-names81543 -Node: Special tags81931 -Ref: #special-tags82063 -Node: Tag values83576 -Ref: #tag-values83686 -Node: Directives84558 -Ref: #directives84685 -Node: Directives and multiple files86015 -Ref: #directives-and-multiple-files86193 -Node: Directive effects86960 -Ref: #directive-effects87114 -Node: account directive90116 -Ref: #account-directive90272 -Node: Account comments91566 -Ref: #account-comments91717 -Node: Account error checking92225 -Ref: #account-error-checking92418 -Node: Account display order93607 -Ref: #account-display-order93795 -Node: Account types94805 -Ref: #account-types94946 -Node: alias directive98579 -Ref: #alias-directive98740 -Node: Basic aliases99790 -Ref: #basic-aliases99921 -Node: Regex aliases100665 -Ref: #regex-aliases100822 -Node: Combining aliases101712 -Ref: #combining-aliases101890 -Node: Aliases and multiple files103166 -Ref: #aliases-and-multiple-files103370 -Node: end aliases directive103949 -Ref: #end-aliases-directive104168 -Node: Aliases can generate bad account names104317 -Ref: #aliases-can-generate-bad-account-names104565 -Node: Aliases and account types105150 -Ref: #aliases-and-account-types105342 -Node: commodity directive106038 -Ref: #commodity-directive106212 -Node: Commodity directive syntax107625 -Ref: #commodity-directive-syntax107810 -Node: Commodity error checking109261 -Ref: #commodity-error-checking109442 -Node: decimal-mark directive109736 -Ref: #decimal-mark-directive109918 -Node: include directive110315 -Ref: #include-directive110479 -Node: P directive111391 -Ref: #p-directive111536 -Node: payee directive112425 -Ref: #payee-directive112574 -Node: tag directive113047 -Ref: #tag-directive113202 -Node: Periodic transactions113659 -Ref: #periodic-transactions113824 -Node: Periodic rule syntax115813 -Ref: #periodic-rule-syntax115991 -Node: Periodic rules and relative dates116636 -Ref: #periodic-rules-and-relative-dates116902 -Node: Two spaces between period expression and description!117413 -Ref: #two-spaces-between-period-expression-and-description117690 -Node: Auto postings118374 -Ref: #auto-postings118522 -Node: Auto postings and multiple files121534 -Ref: #auto-postings-and-multiple-files121730 -Node: Auto postings and dates121939 -Ref: #auto-postings-and-dates122205 -Node: Auto postings and transaction balancing / inferred amounts / balance assertions122380 -Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions122723 -Node: Auto posting tags123226 -Ref: #auto-posting-tags123485 -Node: Auto postings on forecast transactions only124121 -Ref: #auto-postings-on-forecast-transactions-only124344 -Node: Other syntax124591 -Ref: #other-syntax124707 -Node: Balance assignments125363 -Ref: #balance-assignments125519 -Node: Balance assignments and costs126891 -Ref: #balance-assignments-and-costs127103 -Node: Balance assignments and multiple files127313 -Ref: #balance-assignments-and-multiple-files127543 -Node: Bracketed posting dates127736 -Ref: #bracketed-posting-dates127920 -Node: D directive128434 -Ref: #d-directive128602 -Node: apply account directive130207 -Ref: #apply-account-directive130387 -Node: Y directive131074 -Ref: #y-directive131234 -Node: Secondary dates132062 -Ref: #secondary-dates132216 -Node: Star comments133547 -Ref: #star-comments133707 -Node: Valuation expressions134239 -Ref: #valuation-expressions134416 -Node: Virtual postings134538 -Ref: #virtual-postings134715 -Node: Other Ledger directives136162 -Ref: #other-ledger-directives136358 -Node: Other cost/lot notations136924 -Ref: #other-costlot-notations137097 -Node: CSV139686 -Ref: #csv139777 -Node: CSV rules cheatsheet141769 -Ref: #csv-rules-cheatsheet141896 -Node: source143694 -Ref: #source143815 -Node: separator144695 -Ref: #separator144806 -Node: skip145346 -Ref: #skip145452 -Node: date-format145996 -Ref: #date-format146115 -Node: timezone146839 -Ref: #timezone146960 -Node: newest-first147965 -Ref: #newest-first148101 -Node: intra-day-reversed148678 -Ref: #intra-day-reversed148830 -Node: decimal-mark149278 -Ref: #decimal-mark149417 -Node: fields list149756 -Ref: #fields-list149893 -Node: Field assignment151564 -Ref: #field-assignment151706 -Node: Field names152783 -Ref: #field-names152912 -Node: date field154115 -Ref: #date-field154231 -Node: date2 field154279 -Ref: #date2-field154418 -Node: status field154474 -Ref: #status-field154615 -Node: code field154664 -Ref: #code-field154807 -Node: description field154852 -Ref: #description-field155010 -Node: comment field155069 -Ref: #comment-field155222 -Node: account field155626 -Ref: #account-field155774 -Node: amount field156344 -Ref: #amount-field156491 -Node: currency field159183 -Ref: #currency-field159334 -Node: balance field159591 -Ref: #balance-field159721 -Node: if block160114 -Ref: #if-block160233 -Node: Matchers161641 -Ref: #matchers161753 -Node: What matchers match162550 -Ref: #what-matchers-match162697 -Node: Combining matchers163137 -Ref: #combining-matchers163303 -Node: Match groups163840 -Ref: #match-groups163966 -Node: if table164734 -Ref: #if-table164854 -Node: balance-type166735 -Ref: #balance-type166862 -Node: include167562 -Ref: #include167687 -Node: Working with CSV168131 -Ref: #working-with-csv168276 -Node: Rapid feedback168683 -Ref: #rapid-feedback168814 -Node: Valid CSV169266 -Ref: #valid-csv169410 -Node: File Extension170142 -Ref: #file-extension170313 -Node: Reading CSV from standard input170877 -Ref: #reading-csv-from-standard-input171099 -Node: Reading multiple CSV files171263 -Ref: #reading-multiple-csv-files171492 -Node: Reading files specified by rule171739 -Ref: #reading-files-specified-by-rule171965 -Node: Valid transactions173136 -Ref: #valid-transactions173333 -Node: Deduplicating importing173961 -Ref: #deduplicating-importing174154 -Node: Setting amounts175190 -Ref: #setting-amounts175359 -Node: Amount signs177717 -Ref: #amount-signs177885 -Node: Setting currency/commodity178782 -Ref: #setting-currencycommodity178984 -Node: Amount decimal places180158 -Ref: #amount-decimal-places180362 -Node: Referencing other fields181415 -Ref: #referencing-other-fields181626 -Node: How CSV rules are evaluated182523 -Ref: #how-csv-rules-are-evaluated182738 -Node: Well factored rules184191 -Ref: #well-factored-rules184357 -Node: CSV rules examples184681 -Ref: #csv-rules-examples184814 -Node: Bank of Ireland184879 -Ref: #bank-of-ireland185014 -Node: Coinbase186476 -Ref: #coinbase186612 -Node: Amazon187659 -Ref: #amazon187782 -Node: Paypal189501 -Ref: #paypal189607 -Node: Timeclock197251 -Ref: #timeclock197356 -Node: Timedot199520 -Ref: #timedot199643 -Node: Timedot examples202997 -Ref: #timedot-examples203103 -Node: PART 3 REPORTING CONCEPTS205274 -Ref: #part-3-reporting-concepts205438 -Node: Time periods205438 -Ref: #time-periods205572 -Node: Report start & end date205711 -Ref: #report-start-end-date205863 -Node: Smart dates207187 -Ref: #smart-dates207340 -Node: Report intervals209130 -Ref: #report-intervals209286 -Node: Date adjustments209704 -Ref: #date-adjustments209864 -Node: Start date adjustment209924 -Ref: #start-date-adjustment210086 -Node: End date adjustment210827 -Ref: #end-date-adjustment210985 -Node: Period headings211572 -Ref: #period-headings211732 -Node: Period expressions212505 -Ref: #period-expressions212646 -Node: Period expressions with a report interval214410 -Ref: #period-expressions-with-a-report-interval214644 -Node: More complex report intervals214858 -Ref: #more-complex-report-intervals215103 -Node: Multiple weekday intervals216974 -Ref: #multiple-weekday-intervals217163 -Node: Depth217985 -Ref: #depth218087 -Node: Queries218383 -Ref: #queries218485 -Node: Query types220081 -Ref: #query-types220202 -Node: Combining query terms223436 -Ref: #combining-query-terms223613 -Node: Queries and command options225176 -Ref: #queries-and-command-options225381 -Node: Queries and account aliases225630 -Ref: #queries-and-account-aliases225835 -Node: Queries and valuation225955 -Ref: #queries-and-valuation226112 -Node: Pivoting226317 -Ref: #pivoting226431 -Node: Generating data228208 -Ref: #generating-data228340 -Node: Forecasting230008 -Ref: #forecasting230133 -Node: --forecast230664 -Ref: #forecast230795 -Node: Inspecting forecast transactions231765 -Ref: #inspecting-forecast-transactions231967 -Node: Forecast reports233098 -Ref: #forecast-reports233271 -Node: Forecast tags234207 -Ref: #forecast-tags234367 -Node: Forecast period in detail234827 -Ref: #forecast-period-in-detail235021 -Node: Forecast troubleshooting235915 -Ref: #forecast-troubleshooting236083 -Node: Budgeting236986 -Ref: #budgeting237109 -Node: Amount formatting237546 -Ref: #amount-formatting237688 -Node: Commodity display style237790 -Ref: #commodity-display-style237944 -Node: Rounding239631 -Ref: #rounding239786 -Node: Trailing decimal marks240236 -Ref: #trailing-decimal-marks240415 -Node: Amount parseability241169 -Ref: #amount-parseability241325 -Node: Cost reporting242750 -Ref: #cost-reporting242892 -Node: Recording costs243553 -Ref: #recording-costs243689 -Node: Reporting at cost245280 -Ref: #reporting-at-cost245455 -Node: Equity conversion postings246045 -Ref: #equity-conversion-postings246259 -Node: Inferring equity conversion postings248690 -Ref: #inferring-equity-conversion-postings248953 -Node: Combining costs and equity conversion postings249705 -Ref: #combining-costs-and-equity-conversion-postings250015 -Node: Requirements for detecting equity conversion postings250930 -Ref: #requirements-for-detecting-equity-conversion-postings251252 -Node: Infer cost and equity by default ?252452 -Ref: #infer-cost-and-equity-by-default252681 -Node: Value reporting252889 -Ref: #value-reporting253031 -Node: -V Value253770 -Ref: #v-value253902 -Node: -X Value in specified commodity254097 -Ref: #x-value-in-specified-commodity254298 -Node: Valuation date254447 -Ref: #valuation-date254624 -Node: Finding market price255407 -Ref: #finding-market-price255618 -Node: --infer-market-prices market prices from transactions256787 -Ref: #infer-market-prices-market-prices-from-transactions257069 -Node: Valuation commodity259831 -Ref: #valuation-commodity260051 -Node: --value Flexible valuation261264 -Ref: #value-flexible-valuation261463 -Node: Valuation examples263107 -Ref: #valuation-examples263307 -Node: Interaction of valuation and queries265239 -Ref: #interaction-of-valuation-and-queries265479 -Node: Effect of valuation on reports265956 -Ref: #effect-of-valuation-on-reports266159 -Node: PART 4 COMMANDS273854 -Ref: #part-4-commands273997 -Node: Help commands276070 -Ref: #help-commands276215 -Node: help276243 -Ref: #help276332 -Node: demo277920 -Ref: #demo278009 -Node: User interface commands279053 -Ref: #user-interface-commands279222 -Node: ui279247 -Ref: #ui279339 -Node: web279372 -Ref: #web279466 -Node: Data entry commands279500 -Ref: #data-entry-commands279669 -Node: add279698 -Ref: #add279792 -Node: import282153 -Ref: #import282253 -Node: Date skipping283414 -Ref: #date-skipping283537 -Node: Import testing286315 -Ref: #import-testing286478 -Node: Importing balance assignments287321 -Ref: #importing-balance-assignments287528 -Node: Import and commodity styles288177 -Ref: #import-and-commodity-styles288357 -Node: Basic report commands288586 -Ref: #basic-report-commands288760 -Node: accounts288887 -Ref: #accounts288997 -Node: codes291760 -Ref: #codes291884 -Node: commodities292782 -Ref: #commodities292922 -Node: descriptions293026 -Ref: #descriptions293168 -Node: files293493 -Ref: #files293615 -Node: notes293790 -Ref: #notes293906 -Node: payees294302 -Ref: #payees294421 -Node: prices295086 -Ref: #prices295205 -Node: stats295978 -Ref: #stats296093 -Node: tags297719 -Ref: #tags-1297819 -Node: Standard report commands299026 -Ref: #standard-report-commands299211 -Node: print299331 -Ref: #print299439 -Node: print explicitness301777 -Ref: #print-explicitness301918 -Node: print amount style302697 -Ref: #print-amount-style302865 -Node: print parseability303935 -Ref: #print-parseability304105 -Node: print other features304854 -Ref: #print-other-features305031 -Node: print output format305552 -Ref: #print-output-format305698 -Node: aregister308837 -Ref: #aregister308970 -Node: aregister and posting dates312617 -Ref: #aregister-and-posting-dates312762 -Node: register313518 -Ref: #register313656 -Node: Custom register output320477 -Ref: #custom-register-output320606 -Node: balancesheet321953 -Ref: #balancesheet322108 -Node: balancesheetequity326865 -Ref: #balancesheetequity327032 -Node: cashflow332147 -Ref: #cashflow332297 -Node: incomestatement336851 -Ref: #incomestatement336988 -Node: Advanced report commands341591 -Ref: #advanced-report-commands341769 -Node: balance341799 -Ref: #balance341907 -Node: balance features346969 -Ref: #balance-features347109 -Node: Simple balance report349045 -Ref: #simple-balance-report349230 -Node: Balance report line format350855 -Ref: #balance-report-line-format351057 -Node: Filtered balance report353215 -Ref: #filtered-balance-report353407 -Node: List or tree mode353734 -Ref: #list-or-tree-mode353902 -Node: Depth limiting355247 -Ref: #depth-limiting355413 -Node: Dropping top-level accounts356014 -Ref: #dropping-top-level-accounts356214 -Node: Showing declared accounts356524 -Ref: #showing-declared-accounts356723 -Node: Sorting by amount357254 -Ref: #sorting-by-amount357421 -Node: Percentages358091 -Ref: #percentages358250 -Node: Multi-period balance report358798 -Ref: #multi-period-balance-report358998 -Node: Balance change end balance361550 -Ref: #balance-change-end-balance361759 -Node: Balance report types363187 -Ref: #balance-report-types363368 -Node: Calculation type363866 -Ref: #calculation-type364021 -Node: Accumulation type364570 -Ref: #accumulation-type364750 -Node: Valuation type365671 -Ref: #valuation-type365859 -Node: Combining balance report types366860 -Ref: #combining-balance-report-types367054 -Node: Budget report368892 -Ref: #budget-report369054 -Node: Using the budget report371197 -Ref: #using-the-budget-report371370 -Node: Budget date surprises373473 -Ref: #budget-date-surprises373673 -Node: Selecting budget goals374837 -Ref: #selecting-budget-goals375040 -Node: Budgeting vs forecasting375785 -Ref: #budgeting-vs-forecasting375962 -Node: Balance report layout377462 -Ref: #balance-report-layout377641 -Node: Wide layout378594 -Ref: #wide-layout378729 -Node: Tall layout380999 -Ref: #tall-layout381154 -Node: Bare layout382305 -Ref: #bare-layout382460 -Node: Tidy layout384369 -Ref: #tidy-layout384504 -Node: Balance report output385913 -Ref: #balance-report-output386106 -Node: Some useful balance reports386909 -Ref: #some-useful-balance-reports387084 -Node: roi388169 -Ref: #roi388269 -Node: Spaces and special characters in --inv and --pnl390416 -Ref: #spaces-and-special-characters-in---inv-and---pnl390654 -Node: Semantics of --inv and --pnl391142 -Ref: #semantics-of---inv-and---pnl391379 -Node: IRR and TWR explained393229 -Ref: #irr-and-twr-explained393387 -Node: Chart commands396640 -Ref: #chart-commands396798 -Node: activity396821 -Ref: #activity396910 -Node: Data generation commands397318 -Ref: #data-generation-commands397492 -Node: close397524 -Ref: #close397630 -Node: close --migrate400116 -Ref: #close---migrate400241 -Node: close --close401880 -Ref: #close---close402022 -Node: close --open402258 -Ref: #close---open402397 -Node: close --assert402507 -Ref: #close---assert402651 -Node: close --assign402872 -Ref: #close---assign403018 -Node: close --retain403544 -Ref: #close---retain403695 -Node: close customisation404440 -Ref: #close-customisation404617 -Node: close and balance assertions406084 -Ref: #close-and-balance-assertions406279 -Node: close examples407606 -Ref: #close-examples407745 -Node: Retain earnings407843 -Ref: #retain-earnings408000 -Node: Migrate balances to a new file408346 -Ref: #migrate-balances-to-a-new-file408570 -Node: More detailed close examples409698 -Ref: #more-detailed-close-examples409894 -Node: rewrite409920 -Ref: #rewrite410030 -Node: Re-write rules in a file412492 -Ref: #re-write-rules-in-a-file412653 -Node: Diff output format413802 -Ref: #diff-output-format413983 -Node: rewrite vs print --auto415075 -Ref: #rewrite-vs.-print---auto415233 -Node: Maintenance commands415789 -Ref: #maintenance-commands415960 -Node: check415998 -Ref: #check416097 -Node: Basic checks417080 -Ref: #basic-checks417198 -Node: Strict checks418033 -Ref: #strict-checks418174 -Node: Other checks418908 -Ref: #other-checks419048 -Node: Custom checks420763 -Ref: #custom-checks420883 -Node: diff421218 -Ref: #diff421328 -Node: test422425 -Ref: #test422521 -Node: PART 5 COMMON TASKS423297 -Ref: #part-5-common-tasks423456 -Node: Getting help423530 -Ref: #getting-help423679 -Node: Constructing command lines424439 -Ref: #constructing-command-lines424620 -Node: Starting a journal file425277 -Ref: #starting-a-journal-file425459 -Node: Setting LEDGER_FILE426661 -Ref: #setting-ledger_file426833 -Node: Setting opening balances427790 -Ref: #setting-opening-balances427971 -Node: Recording transactions431112 -Ref: #recording-transactions431281 -Node: Reconciling431837 -Ref: #reconciling431969 -Node: Reporting434226 -Ref: #reporting434355 -Node: Migrating to a new file438340 -Ref: #migrating-to-a-new-file438490 -Node: BUGS438789 -Ref: #bugs438883 -Node: Troubleshooting439762 -Ref: #troubleshooting439862 +Node: Top210 +Node: PART 1 USER INTERFACE4365 +Node: Input4504 +Node: Text encoding5596 +Node: Data formats6276 +Node: Standard input8000 +Node: Multiple files8389 +Node: Strict mode9126 +Node: Commands9960 +Node: Add-on commands11146 +Node: Options12364 +Node: Special characters18781 +Node: Single escaping shell metacharacters19081 +Node: Double escaping regular expression metacharacters19925 +Node: Triple escaping for add-on commands20762 +Node: Less escaping21666 +Node: Unicode characters22144 +Node: Regular expressions23808 +Node: hledger's regular expressions27067 +Node: Argument files28612 +Node: Config files29315 +Node: Shell completions32468 +Node: Output32993 +Node: Output destination33222 +Node: Output format33780 +Node: Text output35443 +Node: HTML output35651 +Node: CSV / TSV output36131 +Node: FODS output36395 +Node: Beancount output36700 +Node: Beancount account names37618 +Node: Beancount commodity names38593 +Node: Beancount virtual postings39369 +Node: Beancount costs39840 +Node: Beancount operating currency40198 +Node: SQL output40562 +Node: JSON output41438 +Node: Commodity styles42541 +Node: Colour43419 +Node: Box-drawing43941 +Node: Paging44343 +Node: Debug output45410 +Node: Environment46179 +Node: PART 2 DATA FORMATS46870 +Node: Journal47013 +Node: Journal cheatsheet49491 +Node: Comments55705 +Node: Transactions56649 +Node: Dates57786 +Node: Simple dates57938 +Node: Posting dates58554 +Node: Status59641 +Node: Code61407 +Node: Description61742 +Node: Payee and note62429 +Node: Transaction comments63520 +Node: Postings64036 +Node: Debits and credits65199 +Node: The two space delimiter65809 +Node: Account names66374 +Node: Amounts68178 +Node: Decimal marks69207 +Node: Digit group marks70311 +Node: Commodity70946 +Node: Costs72063 +Node: Balance assertions74315 +Node: Assertions and ordering75552 +Node: Assertions and multiple included files76280 +Node: Assertions and multiple -f files77040 +Node: Assertions and costs77682 +Node: Assertions and commodities78332 +Node: Assertions and subaccounts79991 +Node: Assertions and virtual postings80661 +Node: Assertions and auto postings81031 +Node: Assertions and precision81906 +Node: Posting comments82355 +Node: Transaction balancing82895 +Node: Tags84897 +Node: Tag names86359 +Node: Special tags86854 +Node: Tag values88646 +Node: Directives89628 +Node: Directives and multiple files91085 +Node: Directive effects92030 +Node: account directive95186 +Node: Account comments96636 +Node: Account error checking97295 +Node: Account display order98832 +Node: Account types100030 +Node: alias directive103804 +Node: Basic aliases105015 +Node: Regex aliases105890 +Node: Combining aliases106937 +Node: Aliases and multiple files108391 +Node: end aliases directive109174 +Node: Aliases can generate bad account names109542 +Node: Aliases and account types110375 +Node: commodity directive111263 +Node: Commodity directive syntax112850 +Node: Commodity error checking114486 +Node: decimal-mark directive114961 +Node: include directive115540 +Node: P directive116616 +Node: payee directive117650 +Node: tag directive118272 +Node: Periodic transactions118884 +Node: Periodic rule syntax121038 +Node: Periodic rules and relative dates121861 +Node: Two spaces between period expression and description!122638 +Node: Auto postings123599 +Node: Auto postings and multiple files126759 +Node: Auto postings and dates127164 +Node: Auto postings and transaction balancing / inferred amounts / balance assertions127605 +Node: Auto posting tags128451 +Node: Auto postings on forecast transactions only129346 +Node: Other syntax129816 +Node: Balance assignments130588 +Node: Balance assignments and costs132116 +Node: Balance assignments and multiple files132538 +Node: Bracketed posting dates132961 +Node: D directive133659 +Node: apply account directive135432 +Node: Y directive136299 +Node: Secondary dates137287 +Node: Star comments138772 +Node: Valuation expressions139464 +Node: Virtual postings139763 +Node: Other Ledger directives141387 +Node: Other cost/lot notations142149 +Node: CSV144911 +Node: CSV rules cheatsheet146994 +Node: source148919 +Node: separator149920 +Node: skip150571 +Node: date-format151221 +Node: timezone152064 +Node: newest-first153190 +Node: intra-day-reversed153903 +Node: decimal-mark154503 +Node: fields list154981 +Node: Field assignment156789 +Node: Field names158008 +Node: date field159340 +Node: date2 field159504 +Node: status field159699 +Node: code field159889 +Node: description field160077 +Node: comment field160294 +Node: account field160851 +Node: amount field161569 +Node: currency field164408 +Node: balance field164816 +Node: if block165339 +Node: Matchers166866 +Node: What matchers match167775 +Node: Combining matchers168362 +Node: Match groups169065 +Node: if table169959 +Node: balance-type171960 +Node: include172787 +Node: Working with CSV173356 +Node: Rapid feedback173908 +Node: Valid CSV174491 +Node: File Extension175367 +Node: Reading CSV from standard input176102 +Node: Reading multiple CSV files176488 +Node: Reading files specified by rule176964 +Node: Valid transactions178361 +Node: Deduplicating importing179186 +Node: Setting amounts180415 +Node: Amount signs182942 +Node: Setting currency/commodity184007 +Node: Amount decimal places185383 +Node: Referencing other fields186640 +Node: How CSV rules are evaluated187748 +Node: Well factored rules189416 +Node: CSV rules examples189906 +Node: Bank of Ireland190104 +Node: Coinbase191701 +Node: Amazon192884 +Node: Paypal194726 +Node: Timeclock202476 +Node: Timedot204745 +Node: Timedot examples208222 +Node: PART 3 REPORTING CONCEPTS210499 +Node: Time periods210663 +Node: Report start & end date210936 +Node: Smart dates212412 +Node: Report intervals214355 +Node: Date adjustments214929 +Node: Start date adjustment215149 +Node: End date adjustment216052 +Node: Period headings216797 +Node: Period expressions217730 +Node: Period expressions with a report interval219635 +Node: More complex report intervals220083 +Node: Multiple weekday intervals222199 +Node: Depth223210 +Node: Queries223608 +Node: Query types225306 +Node: Combining query terms228661 +Node: Queries and command options230401 +Node: Queries and account aliases230855 +Node: Queries and valuation231180 +Node: Pivoting231542 +Node: Generating data233433 +Node: Forecasting235233 +Node: --forecast235889 +Node: Inspecting forecast transactions236990 +Node: Forecast reports238323 +Node: Forecast tags239432 +Node: Forecast period in detail240052 +Node: Forecast troubleshooting241140 +Node: Budgeting242211 +Node: Amount formatting242771 +Node: Commodity display style243015 +Node: Rounding244856 +Node: Trailing decimal marks245461 +Node: Amount parseability246394 +Node: Cost reporting247975 +Node: Recording costs248778 +Node: Reporting at cost250505 +Node: Equity conversion postings251270 +Node: Inferring equity conversion postings253915 +Node: Combining costs and equity conversion postings255057 +Node: Requirements for detecting equity conversion postings256282 +Node: Infer cost and equity by default ?257804 +Node: Value reporting258241 +Node: -V Value259122 +Node: -X Value in specified commodity259449 +Node: Valuation date259799 +Node: Finding market price260759 +Node: --infer-market-prices market prices from transactions262139 +Node: Valuation commodity265183 +Node: --value Flexible valuation266616 +Node: Valuation examples268459 +Node: Interaction of valuation and queries270591 +Node: Effect of valuation on reports271308 +Node: PART 4 COMMANDS279206 +Node: Help commands281422 +Node: help281595 +Node: demo283272 +Node: User interface commands284405 +Node: ui284599 +Node: web284724 +Node: Data entry commands284852 +Node: add285050 +Node: import287505 +Node: Date skipping288766 +Node: Import testing291667 +Node: Importing balance assignments292673 +Node: Import and commodity styles293529 +Node: Basic report commands293938 +Node: accounts294239 +Node: codes297112 +Node: commodities298134 +Node: descriptions298378 +Node: files298845 +Node: notes299142 +Node: payees299654 +Node: prices300438 +Node: stats301330 +Node: tags303071 +Node: Standard report commands304378 +Node: print304683 +Node: print explicitness307129 +Node: print amount style308049 +Node: print parseability309287 +Node: print other features310206 +Node: print output format310904 +Node: aregister314189 +Node: aregister and posting dates317969 +Node: register318870 +Node: Custom register output325829 +Node: balancesheet327305 +Node: balancesheetequity332217 +Node: cashflow337499 +Node: incomestatement342203 +Node: Advanced report commands346943 +Node: balance347151 +Node: balance features352321 +Node: Simple balance report354397 +Node: Balance report line format356207 +Node: Filtered balance report358567 +Node: List or tree mode359086 +Node: Depth limiting360599 +Node: Dropping top-level accounts361366 +Node: Showing declared accounts361876 +Node: Sorting by amount362606 +Node: Percentages363443 +Node: Multi-period balance report364150 +Node: Balance change end balance366902 +Node: Balance report types368539 +Node: Calculation type369218 +Node: Accumulation type369922 +Node: Valuation type371023 +Node: Combining balance report types372212 +Node: Budget report374244 +Node: Using the budget report376549 +Node: Budget date surprises378825 +Node: Selecting budget goals380189 +Node: Budgeting vs forecasting381137 +Node: Balance report layout382814 +Node: Wide layout384019 +Node: Tall layout386424 +Node: Bare layout387730 +Node: Tidy layout389794 +Node: Balance report output391338 +Node: Some useful balance reports392324 +Node: roi393584 +Node: Spaces and special characters in --inv and --pnl395831 +Node: Semantics of --inv and --pnl396557 +Node: IRR and TWR explained398644 +Node: Chart commands402055 +Node: activity402236 +Node: Data generation commands402733 +Node: close402939 +Node: close --migrate405531 +Node: close --close407295 +Node: close --open407673 +Node: close --assert407922 +Node: close --assign408287 +Node: close --retain408959 +Node: close customisation409855 +Node: close and balance assertions411499 +Node: close examples413021 +Node: Retain earnings413258 +Node: Migrate balances to a new file413761 +Node: More detailed close examples415113 +Node: rewrite415335 +Node: Re-write rules in a file417907 +Node: Diff output format419217 +Node: rewrite vs print --auto420490 +Node: Maintenance commands421204 +Node: check421413 +Node: Basic checks422495 +Node: Strict checks423448 +Node: Other checks424323 +Node: Custom checks426178 +Node: diff426633 +Node: test427840 +Node: PART 5 COMMON TASKS428712 +Node: Getting help428945 +Node: Constructing command lines429854 +Node: Starting a journal file430692 +Node: Setting LEDGER_FILE432076 +Node: Setting opening balances433205 +Node: Recording transactions436527 +Node: Reconciling437252 +Node: Reporting439641 +Node: Migrating to a new file443755 +Node: BUGS444204 +Node: Troubleshooting445177  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index d839bec07..456441341 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -559,80 +559,92 @@ Options 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; write = or nothing - between a flag and its argument. For the special characters mentioned - above, use one less level of quoting than you would at the command - prompt.) - - Argument files are now superseded by.. + An argument file's format is more restrictive than the command line. + Each line should contain just one option or argument. Don't use spaces + except inside quotes; write = or nothing between a flag and its argu- + ment. If you use quotes, they must enclose the whole line. For the + special characters mentioned above, use one less level of quoting than + you would at the command line. Config files - As of hledger 1.40, you can optionally save command line options (or - arguments) to be used when running hledger commands, in a config file. - Here's a small example: + With hledger 1.40+, you can save extra command line options and argu- + ments in a more featureful hledger config file. Here's a small exam- + ple: - # General options are listed first, one or more per line. - # These will be used with all hledger commands that support them. + # General options are listed first, and used with hledger commands that support them. --pretty - # Options following a `[COMMANDNAME]` heading are used with that hledger command only. + # Options following a `[COMMAND]` heading are used with that hledger command only. [print] --explicit --show-costs To use a config file, specify it with the --conf option. Its options - will be inserted near the start of your command line (so you can over- - ride them if needed). + will be inserted near the start of your command line, so you can over- + ride them with command line options if needed. Or, you can set up an automatic config file that is used whenever you - run hledger. This can be hledger.conf in the current directory or + run hledger, by creating hledger.conf in the current directory or above, or .hledger.conf in your home directory (~/.hledger.conf), or hledger.conf in your XDG config directory (~/.con- fig/hledger/hledger.conf). - You can ignore config files by adding the -n/--no-conf flag. This is - useful when using hledger in scripts, or when troubleshooting. (When - both --conf and --no-conf options are used, the right-most wins.) To - inspect the processing of config files, use --debug or --debug=8. - - Here is another example config file you could start with: + Here is another example config you could start with: https://github.com/simonmichael/hledger/blob/master/hledger.conf.sample - Tips: - - Automatic config files are convenient, but have a cost: it's easy to - change a report's behaviour, or break scripts/applications which use - hledger, in unintended ways that will surprise you later. They change - the nature of hledger somewhat, making it less transparent and pre- - dictable. If you decide to use one: - - o Be conservative about what you put in it. Try to consider the effect - on all your reports. - - o Whenever a hledger command does not work as expected, try it again - with -n. - - o If that helps, you can run it with --debug to see how a config file - affected it. + You can put not only options, but also arguments in a config file. If + the first word in a config file's top (general) section does not begin + with a dash (eg: print), it is treated as the command argument (over- + riding any argument on the command line). On unix machines, you can add a shebang line at the top of a config file, set executable permission on the file, and use it like a script. - Eg (some operating systems need the -S, some don't): + Eg (the -S is needed on some operating systems): #!/usr/bin/env -S hledger --conf - You can put not only options, but also arguments in a config file. - This is probably more useful in special-purpose config files, not an - automatic one. + You can ignore config files by adding the -n/--no-conf flag to the com- + mand line. This is useful when using hledger in scripts, or when trou- + bleshooting. When both --conf and --no-conf options are used, the + right-most wins. - There's an exception to this: a config file can't provide the command - argument, currently (#2231). If you need that, you can do it in the - shebang line instead. Eg: + To inspect the processing of config files, use --debug or --debug=8. - #!/usr/bin/env -S hledger balance --conf + Warning! - The config file feature has been added in hledger 1.40 and is consid- - ered experimental. + There aren't many hledger features that need a warning, but this is + one! + + Automatic config files, while convenient, also make hledger less pre- + dictable and dependable. It's easy to make a config file that changes + a report's behaviour, or breaks your hledger-using scripts/applica- + tions, in ways that will surprise you later. + + If you don't want this, + + 1. Just don't create a hledger.conf file on your machine. + + 2. Also be alert to downloaded directories which may contain a + hledger.conf file. + + 3. Also if you are sharing scripts or examples or support, consider + that others may have a hledger.conf file. + + Conversely, once you decide to use this feature, try to remember: + + 1. Whenever a hledger command does not work as expected, try it again + with -n (--no-conf) to see if a config file was to blame. + + 2. Whenever you call hledger from a script, consider whether that call + should use -n or not. + + 3. Be conservative about what you put in your config file; try to con- + sider the effect on all your reports. + + 4. To troubleshoot the effect of config files, run with --debug or + --debug 8. + + The config file feature was added in hledger 1.40 and is considered ex- + perimental. Shell completions If you use the bash shell, you can optionally set up context-sensitive @@ -660,20 +672,16 @@ Output 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 fods json sql - ----------------------------------------------------------------------------------------- - aregister Y Y Y Y - balance Y 1 Y 1 Y 1 Y 1 Y - balancesheet Y 1 Y 1 Y 1 Y - balancesheete- Y 1 Y 1 Y 1 Y - quity - cashflow Y 1 Y 1 Y 1 Y - incomestate- Y 1 Y 1 Y 1 Y - ment - print Y Y Y Y - register Y Y Y - - o 1 Also affected by the balance commands' --layout option. + command txt html csv/tsv fods beancount sql json + -------------------------------------------------------------------------------------------- + aregister Y Y Y Y + balance Y Y Y Y Y + balancesheet Y Y Y Y + balancesheetequity Y Y Y Y + cashflow Y Y Y Y + incomestatement Y Y Y Y + print Y Y Y Y Y + register Y Y Y The output format is selected by the -O/--output-format=FMT option: @@ -689,57 +697,122 @@ Output $ hledger balancesheet -o foo.txt -O csv # write CSV to foo.txt - Some notes about the various output formats: + Here are some notes about the various output formats. - CSV output - o In CSV output, digit group marks (such as thousands separators) are - disabled automatically. + Text output + This is the default: human readable, plain text report output, suitable + for a terminal. HTML output o HTML output can be styled by an optional hledger.css file in the same directory. - o HTML output will be UTF-8 encoded. If your web browser is showing - junk characters, you may need to change its text encoding to UTF-8. - Eg in Safari, see View -> Text Encoding and Settings -> Advanced -> + o HTML output will be UTF-8 encoded. If your web browser is showing + junk characters, you may need to change its text encoding to UTF-8. + Eg in Safari, see View -> Text Encoding and Settings -> Advanced -> Default Encoding. - JSON output - o This is not yet much used; real-world feedback is welcome. + CSV / TSV output + o In CSV or TSV output, digit group marks (such as thousands separa- + tors) are disabled automatically. - 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. hledger-web's OpenAPI speci- - fication may also be relevant. + FODS output + FODS is the OpenDocument spreadsheet format used by LibreOffice and + OpenOffice. It is a good format to use if you are exporting to their + spreadsheet app. - 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 - 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 - otherwise, please let us know. (Cf #1195) + Beancount output + This is Beancount's journal format. You can use this to export your + hledger data to Beancount, perhaps to query it with Beancount Query + Language or with the Fava web app. hledger will try to adjust your + data to suit Beancount. If you plan to export often, you may want to + follow Beancount's conventions in your hledger data, to ease conver- + sion. Eg use Beancount-friendly account names, currency codes instead + of currency symbols, and avoid virtual postings, redundant cost nota- + tion, etc. + + Here are more details, included here for now (see also "hledger and + Beancount" https://hledger.org/beancount.html). + + Beancount account names + hledger will try adjust your account names, if needed, to Beancount ac- + count names, by capitalising, replacing unsupported characters with -, + and prepending B to parts which don't begin with a letter or digit. + (It's possible for this to convert distinct hledger account names to + the same beancount name. Eg, hledger's automatic equity conversion ac- + counts can have currency symbols in their name, so equity:conversion:$- + becomes equity:conversion:B---.) + + In addition, you must ensure that the top level account names are As- + sets, Liabilities, Equity, Income, and Expenses, which Beancount re- + quires. If yours are named differently, you can use account aliases, + usually in the form of --alias options, possibly stored in a config + file. (An example: hledger2beancount.conf) + + Beancount commodity names + hledger will adjust your commodity names, if needed, to Beancount com- + modity/currency names, which must be 2-24 uppercase letters, digits, or + ', ., _, -, beginning with a letter and ending with a letter or digit. + hledger will convert known currency symbols to ISO 4217 currency codes. + Otherwise, it will capitalise letters, replace unsupported characters + with a dash (-), and prepend/append a "B" when needed. (It's possible + for this to generate unreadable commodity names, or to convert distinct + hledger commodity names to the same beancount name.) + + Beancount virtual postings + Beancount doesn't allow unbalanced/virtual postings, so you will need + to comment those, or use --real to exclude transactions that use them. + (If you have transactions which are a mixture of balanced and unbal- + anced postings, you'll have to do something more.) + + Beancount costs + Beancount doesn't allow redundant cost notation as hledger does. If + you have entries like this, you will need to comment out either the + costs or the equity postings. + + Beancount operating currency + Declaring an operating currency improves Beancount and Fava reports. + You can do this manually by adding a line like this to the beancount + journal: + + option "operating_currency" "USD" 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. + 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 + https://github.com/simonmichael/hledger/blob/mas- + ter/hledger-lib/Hledger/Data/Types.hs. hledger-web's OpenAPI speci- + fication may also be relevant. + + 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 + 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 + otherwise, please let us know. (Cf #1195) + Commodity styles When displaying amounts, hledger infers a standard display style for each commodity/currency, as described below in Commodity display style. @@ -1675,14 +1748,16 @@ Journal generated-transaction -- appears on generated periodic txns (with --verbose-tags) generated-posting -- appears on generated auto postings (with --verbose-tags) modified -- appears on txns which have had auto postings added (with --verbose-tags) + Not displayed, but queryable: _generated-transaction -- exists on generated periodic txns (always) _generated-posting -- exists on generated auto postings (always) _modified -- exists on txns which have had auto postings added (always) - Tags hledger uses internally: + Other tags hledger uses internally: - _conversion-matched -- exists on postings which have been matched with a nearby @/@@ cost annotation + _cost-matched -- marks postings with a cost which have been matched with a nearby pair of equity conversion postings + _conversion-matched -- marks equity conversion postings which have been matched with a nearby posting with a cost Tag values Tags can have a value, which is any text after the colon up until a @@ -1859,9 +1934,10 @@ Journal 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- - clared by an account directive. Some notes: + In strict mode, enabled with the -s/--strict flag, or when you run + hledger check accounts, hledger will report an error if any transaction + uses an account name that has not been declared by an account direc- + tive. Some notes: o The declaration is case-sensitive; transactions must use the correct account name capitalisation. @@ -1878,9 +1954,12 @@ Journal o It's currently not possible to declare "all possible subaccounts" with a wildcard; every account posted to must be declared. + o If you use the --infer-equity flag, you will also need declarations + for the account names it generates. + 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 @@ -1898,42 +1977,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) @@ -1943,7 +2022,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 @@ -1962,7 +2041,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. @@ -1977,25 +2056,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. @@ -2021,7 +2100,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- @@ -2031,9 +2110,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 @@ -2041,17 +2120,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: @@ -2062,13 +2141,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 @@ -2078,21 +2157,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: @@ -2103,20 +2182,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 @@ -2144,7 +2223,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: @@ -2156,8 +2235,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 @@ -2174,15 +2253,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 @@ -2190,37 +2269,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 @@ -2229,19 +2308,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 $ @@ -2250,7 +2329,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, @@ -2261,10 +2340,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 @@ -2278,20 +2357,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. @@ -2300,27 +2379,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: @@ -2330,15 +2409,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 @@ -2354,58 +2433,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 @@ -2423,14 +2502,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 @@ -2439,11 +2518,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: @@ -2457,51 +2536,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: @@ -2536,38 +2615,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 @@ -2576,11 +2655,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 @@ -2589,24 +2668,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 @@ -2624,15 +2703,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 @@ -2647,31 +2726,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: @@ -2686,23 +2765,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: @@ -2724,10 +2803,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 @@ -2737,7 +2816,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 @@ -2758,38 +2837,38 @@ 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: DATE1=DATE2. If the year is omitted, the primary date's year is + sign: DATE1=DATE2. If the year is omitted, the primary date's year is assumed. When running reports, the primary (left side) date is used by default, but with the --date2 flag (--aux-date or--effective also work, - for Ledger users), the secondary (right side) date will be used in- + for Ledger users), the secondary (right side) date will be used in- stead. - The meaning of secondary dates is up to you. Eg it could be "primary - is the bank's clearing date, secondary is the date the transaction was + The meaning of secondary dates is up to you. Eg it could be "primary + is the bank's clearing date, secondary is the date the transaction was initiated, if different". In practice, this feature usually adds confusion: - o You have to remember the primary and secondary dates' meaning, and + o You have to remember the primary and secondary dates' meaning, and follow that consistently. - o It splits your bookkeeping into two modes, and you have to remember + o It splits your bookkeeping into two modes, and you have to remember which mode is appropriate for a given report. - o Usually your balance assertions will work with only one of these + o Usually your balance assertions will work with only one of these modes. - o It makes your financial data more complicated, less portable, and + o It makes your financial data more complicated, less portable, and less clear in an audit. - o It interacts with every feature, creating an ongoing cost for imple- + o It interacts with every feature, creating an ongoing cost for imple- mentors. o It distracts new users and supporters. @@ -2797,38 +2876,38 @@ Journal o Posting dates are simpler and work better. So secondary dates are officially deprecated in hledger, remaining only - as a Ledger compatibility aid; we recommend using posting dates in- + as a Ledger compatibility aid; we recommend using posting dates in- stead. 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 @@ -2839,13 +2918,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 @@ -2866,26 +2945,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) @@ -2895,10 +2974,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) @@ -2913,7 +2992,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.) @@ -2924,12 +3003,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), @@ -2941,38 +3020,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 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 @@ -2989,56 +3068,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 @@ -3051,9 +3130,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 , @@ -3066,32 +3145,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 @@ -3111,33 +3190,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... @@ -3151,9 +3230,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... @@ -3171,10 +3250,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 @@ -3183,17 +3262,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 @@ -3203,35 +3282,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: @@ -3244,26 +3323,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 @@ -3278,7 +3357,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 @@ -3301,7 +3380,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. @@ -3313,99 +3392,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, @@ -3421,11 +3500,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. @@ -3451,27 +3530,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 @@ -3486,10 +3565,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 @@ -3499,13 +3578,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: @@ -3519,8 +3598,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,... @@ -3531,21 +3610,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: @@ -3576,10 +3655,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 @@ -3595,9 +3674,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 @@ -3614,42 +3693,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 @@ -3658,29 +3737,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 specify a rules file with --rules, that rules file + 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 specify a rules file with --rules, 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 @@ -3688,45 +3767,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: @@ -3735,16 +3814,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": @@ -3752,15 +3831,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: @@ -3768,12 +3847,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 @@ -3786,8 +3865,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. @@ -3803,20 +3882,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 @@ -3835,7 +3914,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 @@ -3844,7 +3923,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: @@ -3855,38 +3934,38 @@ 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 - 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 + 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). - Note, the commodity styles are not inferred from the numbers in the + 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 + 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 + 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, + 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 - fields. In the example below, there's both a CSV field and a hledger - field named amount1, but %amount1 always means the CSV field, not the + In field assignments, you can interpolate only CSV fields, not hledger + fields. In the example below, there's both a CSV field and a hledger + field named amount1, but %amount1 always means the CSV field, not the hledger field: # Name the third CSV field "amount1" @@ -3898,7 +3977,7 @@ CSV # Set comment to the CSV amount1 (not the amount1 assigned above) comment %amount1 - Here, since there's no CSV amount1 field, %amount1 will produce a lit- + Here, since there's no CSV amount1 field, %amount1 will produce a lit- eral "amount1": fields date,description,csvamount @@ -3906,7 +3985,7 @@ CSV # Can't interpolate amount1 here comment %amount1 - When there are multiple field assignments to the same hledger field, + When there are multiple field assignments to the same hledger field, only the last one takes effect. Here, comment's value will be be B, or C if "something" is matched, but never A: @@ -3916,14 +3995,14 @@ CSV comment C How CSV rules are evaluated - Here's how to think of CSV rules being evaluated (if you really need + Here's how to think of CSV rules being evaluated (if you really need to). First, - o include - all includes are inlined, from top to bottom, depth first. - (At each include point the file is inlined and scanned for further + o include - all includes are inlined, from top to bottom, depth first. + (At each include point the file is inlined and scanned for further includes, recursively, before proceeding.) - Then "global" rules are evaluated, top to bottom. If a rule is re- + Then "global" rules are evaluated, top to bottom. If a rule is re- peated, the last one wins: o skip (at top level) @@ -3937,30 +4016,30 @@ CSV Then for each CSV record in turn: - o test all if blocks. If any of them contain a end rule, skip all re- - maining CSV records. Otherwise if any of them contain a skip rule, - skip that many CSV records. If there are multiple matched skip + o test all if blocks. If any of them contain a end rule, skip all re- + maining CSV records. Otherwise if any of them contain a skip rule, + skip that many CSV records. If there are multiple matched skip rules, the first one wins. - o collect all field assignments at top level and in matched if blocks. - When there are multiple assignments for a field, keep only the last + o collect all field assignments at top level and in matched if blocks. + When there are multiple assignments for a field, keep only the last one. - o compute a value for each hledger field - either the one that was as- + o compute a value for each hledger field - either the one that was as- signed to it (and interpolate the %CSVFIELD references), or a default o generate a hledger transaction (journal entry) from these values. - This is all part of the CSV reader, one of several readers hledger can - use to parse input files. When all files have been read successfully, - the transactions are passed as input to whichever hledger command the + This is all part of the CSV reader, one of several readers hledger can + use to parse input files. When all files have been read successfully, + the transactions are passed as input to whichever hledger command the user specified. Well factored rules - Some things than can help reduce duplication and complexity in rules + Some things than can help reduce duplication and complexity in rules files: - o Extracting common rules usable with multiple CSV files into a com- + o Extracting common rules usable with multiple CSV files into a com- mon.rules, and adding include common.rules to each CSV's rules file. o Splitting if blocks into smaller if blocks, extracting the frequently @@ -3968,8 +4047,8 @@ CSV CSV rules examples Bank of Ireland - Here's a CSV with two amount fields (Debit and Credit), and a balance - field, which we can use to add balance assertions, which is not neces- + Here's a CSV with two amount fields (Debit and Credit), and a balance + field, which we can use to add balance assertions, which is not neces- sary but provides extra error checking: Date,Details,Debit,Credit,Balance @@ -4011,13 +4090,13 @@ CSV assets:bank:boi:checking EUR-5.0 = EUR126.0 expenses:unknown EUR5.0 - The balance assertions don't raise an error above, because we're read- - ing directly from CSV, but they will be checked if these entries are + The balance assertions don't raise an error above, because we're read- + ing directly from CSV, but they will be checked if these entries are imported into a journal file. Coinbase - A simple example with some CSV from Coinbase. The spot price is - recorded using cost notation. The legacy amount field name conve- + A simple example with some CSV from Coinbase. The spot price is + recorded using cost notation. The legacy amount field name conve- niently sets amount 2 (posting 2's amount) to the total cost. # Timestamp,Transaction Type,Asset,Quantity Transacted,Spot Price Currency,Spot Price at Transaction,Subtotal,Total (inclusive of fees and/or spread),Fees and/or Spread,Notes @@ -4039,7 +4118,7 @@ CSV Amazon Here we convert amazon.com order history, and use an if block to gener- - ate a third posting if there's a fee. (In practice you'd probably get + ate a third posting if there's a fee. (In practice you'd probably get this data from your bank instead, but it's an example.) "Date","Type","To/From","Name","Status","Amount","Fees","Transaction ID" @@ -4091,7 +4170,7 @@ CSV expenses:fees $1.00 Paypal - Here's a real-world rules file for (customised) Paypal CSV, with some + Here's a real-world rules file for (customised) Paypal CSV, with some Paypal-specific rules, and a second rules file included: "Date","Time","TimeZone","Name","Type","Status","Currency","Gross","Fee","Net","From Email Address","To Email Address","Transaction ID","Item Title","Item ID","Reference Txn ID","Receipt ID","Balance","Note" @@ -4242,12 +4321,12 @@ CSV Timeclock The time logging format of timeclock.el, as read by hledger. - hledger can read time logs in timeclock format. As with Ledger, these - are (a subset of) timeclock.el's format, containing clock-in and - clock-out entries as in the example below. The date is a simple date. - The time format is HH:MM[:SS][+-ZZZZ]. Seconds and timezone are op- - tional. The timezone, if present, must be four digits and is ignored - (currently the time is always interpreted as a local time). Lines be- + hledger can read time logs in timeclock format. As with Ledger, these + are (a subset of) timeclock.el's format, containing clock-in and + clock-out entries as in the example below. The date is a simple date. + The time format is HH:MM[:SS][+-ZZZZ]. Seconds and timezone are op- + tional. The timezone, if present, must be four digits and is ignored + (currently the time is always interpreted as a local time). Lines be- ginning with # or ; or *, and blank lines, are ignored. i 2015/03/30 09:00:00 some account optional description after 2 spaces ; optional comment, tags: @@ -4255,9 +4334,9 @@ Timeclock i 2015/03/31 22:21:45 another:account o 2015/04/01 02:00:34 - hledger treats each clock-in/clock-out pair as a transaction posting - some number of hours to an account. Or if the session spans more than - one day, it is split into several transactions, one for each day. For + hledger treats each clock-in/clock-out pair as a transaction posting + some number of hours to an account. Or if the session spans more than + one day, it is split into several transactions, one for each day. For the above time log, hledger print generates these journal entries: $ hledger -f t.timeclock print @@ -4287,13 +4366,13 @@ Timeclock perhaps the extras in ledgerutils.el o or use the old ti and to scripts in the ledger 2.x repository. These - rely on a "timeclock" executable which I think is just the ledger 2 + rely on a "timeclock" executable which I think is just the ledger 2 executable renamed. Timedot - timedot format is hledger's human-friendly time logging format. Com- - pared to timeclock format, it is more convenient for quick, approxi- - mate, and retroactive time logging, and more human-readable (you can + timedot format is hledger's human-friendly time logging format. Com- + pared to timeclock format, it is more convenient for quick, approxi- + mate, and retroactive time logging, and more human-readable (you can see at a glance where time was spent). A quick example: 2023-05-01 @@ -4312,59 +4391,59 @@ Timedot (per:admin:finance) 0 A timedot file contains a series of transactions (usually one per day). - Each begins with a simple date (Y-M-D, Y/M/D, or Y.M.D), optionally be + Each begins with a simple date (Y-M-D, Y/M/D, or Y.M.D), optionally be followed on the same line by a transaction description, and/or a trans- action comment following a semicolon. After the date line are zero or more time postings, consisting of: - o An account name - any hledger-style account name, optionally in- + o An account name - any hledger-style account name, optionally in- dented. - o Two or more spaces - required if there is an amount (as in journal + o Two or more spaces - required if there is an amount (as in journal format). o A timedot amount, which can be o empty (representing zero) - o a number, optionally followed by a unit s, m, h, d, w, mo, or y, - representing a precise number of seconds, minutes, hours, days + o a number, optionally followed by a unit s, m, h, d, w, mo, or y, + representing a precise number of seconds, minutes, hours, days weeks, months or years (hours is assumed by default), which will be - converted to hours according to 60s = 1m, 60m = 1h, 24h = 1d, 7d = + converted to hours according to 60s = 1m, 60m = 1h, 24h = 1d, 7d = 1w, 30d = 1mo, 365d = 1y. - o one or more dots (period characters), each representing 0.25. - These are the dots in "timedot". Spaces are ignored and can be + o one or more dots (period characters), each representing 0.25. + These are the dots in "timedot". Spaces are ignored and can be used for grouping/alignment. - o Added in 1.32 one or more letters. These are like dots but they - also generate a tag t: (short for "type") with the letter as its - value, and a separate posting for each of the values. This pro- - vides a second dimension of categorisation, viewable in reports + o Added in 1.32 one or more letters. These are like dots but they + also generate a tag t: (short for "type") with the letter as its + value, and a separate posting for each of the values. This pro- + vides a second dimension of categorisation, viewable in reports with --pivot t. - o An optional comment following a semicolon (a hledger-style posting + o An optional comment following a semicolon (a hledger-style posting comment). - There is some flexibility to help with keeping time log data and notes + There is some flexibility to help with keeping time log data and notes in the same file: o Blank lines and lines beginning with # or ; are ignored. - o After the first date line, lines which do not contain a double space + o After the first date line, lines which do not contain a double space are parsed as postings with zero amount. (hledger's register reports will show these if you add -E). - o Before the first date line, lines beginning with * (eg org headings) - are ignored. And from the first date line onward, Emacs org mode + o Before the first date line, lines beginning with * (eg org headings) + are ignored. And from the first date line onward, Emacs org mode heading prefixes at the start of lines (one or more *'s followed by a - space) will be ignored. This means the time log can also be a org + space) will be ignored. This means the time log can also be a org outline. Timedot files don't support directives like journal files. So a common - pattern is to have a main journal file (eg time.journal) that contains - any needed directives, and then includes the timedot file (include + pattern is to have a main journal file (eg time.journal) that contains + any needed directives, and then includes the timedot file (include time.timedot). Timedot examples @@ -4472,21 +4551,21 @@ Timedot PART 3: REPORTING CONCEPTS Time periods Report start & end date - Most hledger reports will by default show the full time period 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 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. + 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. End dates are exclusive; specify the day after the last day you want to see in the report. When dates are specified by multiple options, the last (right-most) op- - tion wins. And when date: queries and date options are combined, the + tion wins. And when date: queries and date options are combined, the report period will be their intersection. Examples: @@ -4514,17 +4593,17 @@ Time periods -b and -e) Smart dates - 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 + 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. Examples: 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 + 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. 2004-10 @@ -4557,7 +4636,7 @@ Time periods 201812 6 digit YYYYMM with valid year and month - Dates with no separators are allowed but might give surprising results + 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 @@ -4565,20 +4644,20 @@ Time periods o 20181232 (YYYYMMDD with an invalid day) gives a parse error - o 201801012 (a valid YYYYMMDD followed by additional digits) gives a + 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- + 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- + A report interval can be specified so that reports like register, bal- ance or activity become multi-period, showing each subperiod as a sepa- rate row or column. - The following standard intervals can be enabled with command-line + The following standard intervals can be enabled with command-line flags: o -D/--daily @@ -4591,7 +4670,7 @@ Time periods o -Y/--yearly - More complex intervals can be specified using -p/--period, described + More complex intervals can be specified using -p/--period, described below. Date adjustments @@ -4602,17 +4681,17 @@ Time periods For example, if the journal's first transaction is on january 10th, - o hledger register (no report interval) will start the report on janu- + o hledger register (no report interval) will start the report on janu- ary 10th. - o hledger register --monthly will start the report on the previous + o hledger register --monthly will start the report on the previous month boundary, january 1st. o hledger register --monthly --begin 1/5 will start the report on janu- ary 5th [1]. - Also if you are generating transactions or budget goals with periodic - transaction rules, their start date may be adjusted in a similar way + Also if you are generating transactions or budget goals with periodic + transaction rules, their start date may be adjusted in a similar way (in certain situations). End date adjustment @@ -4623,7 +4702,7 @@ Time periods o hledger register will end the report on february 20th. - o hledger register --monthly will end the report at the end of febru- + o hledger register --monthly will end the report at the end of febru- ary. o hledger register --monthly --end 2/14 also will end the report at the @@ -4635,40 +4714,40 @@ Time periods [1] Since hledger 1.29. Period headings - With non-standard subperiods, hledger will show "STARTDATE..ENDDATE" + With non-standard subperiods, hledger will show "STARTDATE..ENDDATE" headings. With standard subperiods (ie, starting on a natural interval - boundary), you'll see more compact headings, which are usually prefer- + boundary), you'll see more compact headings, which are usually prefer- able. (Though month names will be in english, currently.) - So if you are specifying a start date and you want compact headings: + So if you are specifying a start date and you want compact headings: choose a start of year for yearly reports, a start of quarter for quar- - terly reports, a start of month for monthly reports, etc. (Remember, - you can write eg -b 2024 or 1/1 as a shortcut for a start of year, or + terly reports, a start of month for monthly reports, etc. (Remember, + you can write eg -b 2024 or 1/1 as a shortcut for a start of year, or 2024-04 or 202404 or Apr for a start of month or quarter.) - For weekly reports, choose a date that's a Monday. (You can try dif- - ferent dates until you see the short headings, or write eg -b '3 weeks + For weekly reports, choose a date that's a Monday. (You can try dif- + ferent dates until you see the short headings, or write eg -b '3 weeks ago'.) Period expressions - The -p/--period option specifies a period expression, which is a com- + The -p/--period option specifies a period expression, which is a com- pact way of expressing a start date, end date, and/or report interval. - Here's a period expression with a start and end date (specifying the + Here's a period expression with a start and end date (specifying the first quarter of 2009): -p "from 2009/1/1 to 2009/4/1" - Several keywords like "from" and "to" are supported for readability; - these are optional. "to" can also be written as ".." or "-". The - spaces are also optional, as long as you don't run two dates together. + Several keywords like "from" and "to" are supported for readability; + these are optional. "to" can also be written as ".." or "-". The + spaces are also optional, as long as you don't run two dates together. So the following are equivalent to the above: -p "2009/1/1 2009/4/1" -p2009/1/1to2009/4/1 -p2009/1/1..2009/4/1 - Dates are smart dates, so if the current year is 2009, these are also + Dates are smart dates, so if the current year is 2009, these are also equivalent to the above: -p "1/1 4/1" @@ -4680,28 +4759,28 @@ Time periods -p "from 2009/1/1" everything after january 1, 2009 - -p "since 2009/1" the same, since is a syn- + -p "since 2009/1" the same, since is a syn- onym -p "from 2009" the same - -p "to 2009" everything before january + -p "to 2009" everything before january 1, 2009 You can also specify a period by writing a single partial or full date: -p "2009" the year 2009; equivalent to "2009/1/1 to 2010/1/1" - -p "2009/1" the month of january 2009; equivalent to "2009/1/1 to + -p "2009/1" the month of january 2009; equivalent to "2009/1/1 to 2009/2/1" - -p "2009/1/1" the first day of 2009; equivalent to "2009/1/1 to + -p "2009/1/1" the first day of 2009; equivalent to "2009/1/1 to 2009/1/2" or by using the "Q" quarter-year syntax (case insensitive): - -p "2009Q1" first quarter of 2009, equivalent to "2009/1/1 to + -p "2009Q1" first quarter of 2009, equivalent to "2009/1/1 to 2009/4/1" -p "q4" fourth quarter of the current year Period expressions with a report interval - A period expression can also begin with a report interval, separated + A period expression can also begin with a report interval, separated from the start/end dates (if any) by a space or the word in: -p "weekly from 2009/1/1 to 2009/4/1" @@ -4724,15 +4803,15 @@ Time periods Weekly on a custom day: - o every Nth day of week (th, nd, rd, or st are all accepted after the + o every Nth day of week (th, nd, rd, or st are all accepted after the number) - o every WEEKDAYNAME (full or three-letter english weekday name, case + o every WEEKDAYNAME (full or three-letter english weekday name, case insensitive) Monthly on a custom day: - o every Nth day [of month] (31st day will be adjusted to each month's + o every Nth day [of month] (31st day will be adjusted to each month's last day) o every Nth WEEKDAYNAME [of month] @@ -4741,7 +4820,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) @@ -4754,21 +4833,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" @@ -4779,10 +4858,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) @@ -4791,35 +4870,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' @@ -4840,15 +4919,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 @@ -4856,15 +4935,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 @@ -4872,10 +4951,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:\\$. @@ -4883,21 +4962,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 @@ -4905,7 +4984,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 @@ -4915,11 +4994,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] @@ -4935,11 +5014,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 @@ -4960,8 +5039,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: @@ -4974,45 +5053,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: @@ -5044,7 +5123,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:. @@ -5060,78 +5139,78 @@ Pivoting -2 EUR Generating data - hledger can enrich the data provided to it, or generate new data, in a + hledger can enrich the data provided to it, or generate new data, in a number of ways. Mostly, this is done only if you request it: - o Missing amounts or missing costs in transactions are inferred auto- + o Missing amounts or missing costs in transactions are inferred auto- matically when possible. - o The --infer-equity flag infers missing conversion equity postings + o The --infer-equity flag infers missing conversion equity postings from @/@@ costs. - o The --infer-costs flag infers missing costs from conversion equity + o The --infer-costs flag infers missing costs from conversion equity postings. o The --infer-market-prices flag infers P price directives from costs. - o The --auto flag adds extra postings to transactions matched by auto + o The --auto flag adds extra postings to transactions matched by auto posting rules. - o The --forecast option generates transactions from periodic transac- + o The --forecast option generates transactions from periodic transac- tion rules. - o The balance --budget report infers budget goals from periodic trans- + o The balance --budget report infers budget goals from periodic trans- action rules. - o Commands like close, rewrite, and hledger-interest generate transac- + o Commands like close, rewrite, and hledger-interest generate transac- tions or postings. - o CSV data is converted to transactions by applying CSV conversion + o CSV data is converted to transactions by applying CSV conversion rules.. etc. - Such generated data is temporary, existing only at report time. You - can convert it to permanent recorded data by, eg, capturing the output - of hledger print and saving it in your journal file. This can some- + Such generated data is temporary, existing only at report time. You + can convert it to permanent recorded data by, eg, capturing the output + of hledger print and saving it in your journal file. This can some- times be useful as a data entry aid. - If you are curious what data is being generated and why, run hledger - print -x --verbose-tags. -x/--explicit shows inferred amounts and - --verbose-tags adds tags like generated-transaction (from periodic + If you are curious what data is being generated and why, run hledger + print -x --verbose-tags. -x/--explicit shows inferred amounts and + --verbose-tags adds tags like generated-transaction (from periodic rules) and generated-posting, modified (from auto posting rules). Sim- - ilar hidden tags (with an underscore prefix) are always present, also, - so you can always match such data with queries like tag:generated or + ilar hidden tags (with an underscore prefix) are always present, also, + so you can always match such data with queries like tag:generated or tag:modified. 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 @@ -5165,7 +5244,7 @@ Forecasting expenses:rent $1000 Here there are no ordinary transactions, so the forecasted transactions - begin on the first occurrence after today's date. (You won't normally + begin on the first occurrence after today's date. (You won't normally use --today; it's just to make these examples reproducible.) Forecast reports @@ -5189,19 +5268,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: @@ -5233,7 +5312,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. @@ -5243,22 +5322,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. @@ -5266,13 +5345,13 @@ 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. @@ -5280,17 +5359,17 @@ Budgeting 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 + 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 + 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 + 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 + 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) @@ -5300,9 +5379,9 @@ Amount formatting 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 + 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 @@ -5311,7 +5390,7 @@ Amount formatting 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- + 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). @@ -5320,16 +5399,16 @@ Amount formatting 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 + 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 + 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 + 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: @@ -5343,7 +5422,7 @@ Amount formatting (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 + disabling digit group marks, eg with -c/--commodity (for each affected commodity): $ hledger print -c '$1000.00' @@ -5360,19 +5439,19 @@ Amount formatting 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 + 1. "hledger-readable output" - should be readable by hledger (and by humans) - o This is produced by reports that show full journal entries: print, + 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 + 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- + 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, + o It can be parsed reliably (by hledger and ledger2beancount at least, but perhaps not by Ledger..) 2. "human-readable output" - usually for humans @@ -5384,13 +5463,13 @@ Amount formatting o It shows ambiguous amounts unmodified. - o It can be parsed reliably in the context of a known report (when you + 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, + 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. @@ -5400,17 +5479,17 @@ Amount formatting 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 @@ -5425,11 +5504,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 @@ -5438,49 +5517,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 @@ -5491,10 +5570,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 @@ -5516,14 +5595,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 @@ -5537,11 +5616,14 @@ 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. + Note you will need to add account declarations for these to your jour- + nal, if you use check accounts or check --strict. + 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- @@ -8336,12 +8418,12 @@ Advanced report commands DESCPAT 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 + The --layout option affects how balance and the other balance-like com- + mands show multi-commodity amounts and commodity symbols. It can im- + prove readability, for humans and/or machines (other software). 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 @@ -8349,8 +8431,9 @@ Advanced report 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, - with one row per data value + o --layout=tidy: data is normalised to easily-consumed "tidy" form, + with one row per data value. (This one is currently supported only + by the balance command.) Here are the --layout modes supported by each output format Only CSV output supports all of them: @@ -8488,33 +8571,33 @@ Advanced report commands host:5000. You can also produce relative links, like --base-url="some/path" or --base-url="".) - The balance reports' HTML output currently does not display tree mode - reports properly (#1846). For now, if generating HTML you should prob- - abBly use the default --flat mode. + The balance reports' HTML output currently does not indent tree mode + reports properly (#1846). So in HTML balance reports, use list mode + for now (it is the default). Some useful balance reports 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 @@ -8528,7 +8611,7 @@ Advanced report commands Show top gainers [or losers] last week roi - Shows the time-weighted (TWR) and money-weighted (IRR) rate of return + Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on your investments. Flags: @@ -8538,38 +8621,38 @@ Advanced report commands --profit-loss=QUERY --pnl query to select profit-and-loss or appreciation/valuation transactions - 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 + 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 + 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 + 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 + 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- + 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 + o Error (SearchFailed): Failed to find solution for Internal Rate of Return (IRR). Either search does not converge to a solution, or con- verges too slowly. Examples: - o Using roi to compute total return of investment in stocks: + o Using roi to compute total return of investment in stocks: https://github.com/simonmichael/hledger/blob/master/examples/invest- ing/roi-unrealised.ledger @@ -8579,28 +8662,28 @@ Advanced report commands 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, + 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 + 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 + 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 + "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 + sets, or otherwise converting between your investment commodity and any other commodity. Example: 2019-01-01 Investing in Snake Oil @@ -8617,12 +8700,12 @@ Advanced report commands 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- + 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 + 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 @@ -8639,58 +8722,58 @@ Advanced report commands 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- + "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 + 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 + 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, + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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: @@ -8703,7 +8786,7 @@ Advanced report commands o IRR vs TWR - o Examples of computing IRR and TWR and discussion of the limitations + o Examples of computing IRR and TWR and discussion of the limitations of both metrics Chart commands @@ -8713,8 +8796,8 @@ Chart commands Flags: no command-specific flags - The activity command displays an ascii histogram showing transaction - counts by day, week, month or other reporting interval (by day is the + The activity command displays an ascii histogram showing transaction + counts by day, week, month or other reporting interval (by day is the default). With query arguments, it counts only matched transactions. Examples: @@ -8729,10 +8812,10 @@ Data generation commands close (equity) - close generates several kinds of "closing" and/or "opening" transac- - tions, useful in certain situations, including migrating balances to a - new journal file, retaining earnings into equity, consolidating bal- - ances, or viewing lots. Like print, it prints valid journal entries. + close generates several kinds of "closing" and/or "opening" transac- + tions, useful in certain situations, including migrating balances to a + new journal file, retaining earnings into equity, consolidating bal- + ances, 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. @@ -8769,77 +8852,77 @@ Data generation commands close currently has six modes, selected by a single mode flag: close --migrate - This is the most common mode. It prints a "closing balances" transac- + This is the most common mode. It prints a "closing balances" transac- tion 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 an- + an opposite "opening balances" transaction that restores them again. + The balancing account will be equity:opening/closing balances (or an- other 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 --mi- - grate=NEWYEAR -e NEWYEAR and then copy the closing transaction to the + This is useful when migrating balances to a new journal file at the + start of a new year. Essentially, you run hledger close --mi- + grate=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 bal- - ances correct when you use both old and new files together, by can- + file. The opening transaction sets correct starting balances in the + new file when it is used alone, and the closing transaction keeps bal- + ances correct when you use both old and new files together, by can- celling out the following opening transaction and preventing buildup of - duplicated opening balances. Think of the closing/opening pair as + 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.) Rev- + 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.) Rev- enues 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 incre- - menting a number (eg a year number) within the default journal's main + 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 incre- + menting a number (eg a year number) within the default journal's main file name. The other modes behave similarly. close --close - This prints just the closing balances transaction of --migrate. It is - the default behaviour if you specify no mode flag. Using the customi- + This prints just the closing balances transaction of --migrate. It is + the default behaviour if you specify no mode flag. Using the customi- sation options below, you can move balances from any set of accounts to a different account. close --open - This prints just the opening balances transaction of --migrate. It is + This prints just the opening balances transaction of --migrate. It is similar to Ledger's equity command. 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 + just declares balance assertions for the current balances without + changing them. It could be useful as documention and to guard against changes. close --assign This prints an "opening balances" transaction that restores the account - balances using balance assignments. Balance assignments work regard- - less of any previous balance, so a preceding closing balances transac- + balances using balance assignments. Balance assignments work regard- + less of any previous balance, so a preceding closing balances transac- tion is not needed. - However, omitting the closing balances transaction would unbalance eq- - uity. This is relatively harmless for personal reports, but it dis- - turbs the accounting equation, removing a source of error detection. - So --migrate is generally the best way to set to set balances in new + However, omitting the closing balances transaction would unbalance eq- + uity. This is relatively harmless for personal reports, but it dis- + turbs 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. close --retain This is like --close with different defaults: it prints a "retain earn- - ings" transaction (with retain: tag), that transfers revenue and ex- + ings" transaction (with retain: tag), that transfers revenue and ex- pense balances to equity:retained earnings. - This is a different kind of closing, called "retaining earnings" or + 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 pur- + 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 pur- poses.) - In personal accounting you generally don't need to do this, unless you - want the balancesheetequity report to show a zero total, demonstrating + 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. close customisation @@ -8849,57 +8932,57 @@ Data generation commands o the balancing account, with --close-acct=ACCT and/or --open-acct=ACCT - o the transaction descriptions, with --close-desc=DESC and + o the transaction descriptions, with --close-desc=DESC and --open-desc=DESC o the transaction's tag value, with a --MODE=NEW option argument o 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; + 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 gener- + if it involves multiple commodities, a separate posting will be gener- ated 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 trou- + With --interleaved, each individual transfer is shown with source and + destination postings next to each other (perhaps useful for trou- bleshooting). 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 + 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.) close and balance assertions close adds balance assertions verifying that the accounts have been re- set to zero in a closing transaction or restored to their previous bal- - ances in an opening transaction. These provide useful error checking, + ances in an opening transaction. These provide useful error checking, but you can ignore them temporarily with -I, or remove them if you pre- fer. - Single-commodity, subaccount-exclusive balance assertions (=) are gen- - erated by default. This can be changed with --assertion-type='==*' + Single-commodity, subaccount-exclusive balance assertions (=) are gen- + erated 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), + 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 + 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 ac- + To solve this you can transfer the money to and from a temporary ac- count, splitting the multi-day transaction into two single-day transac- tions: @@ -8920,7 +9003,7 @@ Data generation commands $ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal - After this, to see 2022's revenues and expenses you must exclude the + 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' @@ -8932,13 +9015,13 @@ Data generation commands # 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 + 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 exclud- + For more flexibility, it helps to tag closing and opening transactions + with eg start:NEWYEAR, then you can ensure correct balances by exclud- ing 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' @@ -8953,7 +9036,7 @@ Data generation commands rewrite Print all transactions, rewriting the postings of matched transactions. - For now the only rewrite available is adding new postings, like print + For now the only rewrite available is adding new postings, like print --auto. Flags: @@ -8967,9 +9050,9 @@ Data generation commands patch tool This is a start at a generic rewriter of transaction entries. It reads - the default journal and prints the transactions, like print, but adds + the default journal and prints the transactions, like print, but adds one or more specified postings to any transactions matching QUERY. The - posting amounts can be fixed, or a multiplier of the existing transac- + posting amounts can be fixed, or a multiplier of the existing transac- tion's first posting amount. Examples: @@ -8985,7 +9068,7 @@ Data generation commands (reserve:grocery) *0.25 ; reserve 25% for grocery (reserve:) *0.25 ; reserve 25% for grocery - Note the single quotes to protect the dollar sign from bash, and the + Note the single quotes to protect the dollar sign from bash, and the two spaces between account and amount. More: @@ -8995,16 +9078,16 @@ Data generation commands $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"' $ hledger rewrite -- ^income --add-posting '(budget:foreign currency) *0.25 JPY; diversify' - Argument for --add-posting option is a usual posting of transaction - with an exception for amount specification. More precisely, you can + Argument for --add-posting option is a usual posting of transaction + with an exception for amount specification. More precisely, you can use '*' (star symbol) before the amount to indicate that that this is a - factor for an amount of original matched posting. If the amount in- + 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- + 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- + 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. @@ -9019,7 +9102,7 @@ Data generation commands budget:gifts *-1 assets:budget *1 - Note that '=' (equality symbol) that is used instead of date in trans- + Note that '=' (equality symbol) that is used instead of date in trans- actions you usually write. It indicates the query by which you want to match the posting to add new ones. @@ -9032,12 +9115,12 @@ Data generation commands --add-posting 'assets:budget *1' \ > rewritten-tidy-output.journal - It is important to understand that relative order of such entries in - journal is important. You can re-use result of previously added post- + It is important to understand that relative order of such entries in + journal is important. You can re-use result of previously added post- ings. Diff output format - To use this tool for batch modification of your journal files you may + To use this tool for batch modification of your journal files you may find useful output in form of unified diff. $ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax) *.33' @@ -9061,10 +9144,10 @@ Data generation commands If you'll pass this through patch tool you'll get transactions contain- ing the posting that matches your query be updated. Note that multiple - files might be update according to list of input files specified via + files might be update according to list of input files specified via --file options and include directives inside of these files. - Be careful. Whole transaction being re-formatted in a style of output + Be careful. Whole transaction being re-formatted in a style of output from hledger print. See also: @@ -9072,17 +9155,17 @@ Data generation commands https://github.com/simonmichael/hledger/issues/99 rewrite vs. print --auto - This command predates print --auto, and currently does much the same + This command predates print --auto, and currently does much the same thing, but with these differences: - o with multiple files, rewrite lets rules in any file affect all other - files. print --auto uses standard directive scoping; rules affect + o with multiple files, rewrite lets rules in any file affect all other + files. print --auto uses standard directive scoping; rules affect only child files. - o rewrite's query limits which transactions can be rewritten; all are + o rewrite's query limits which transactions can be rewritten; all are printed. print --auto's query limits which transactions are printed. - o rewrite applies rules specified on command line or in the journal. + o rewrite applies rules specified on command line or in the journal. print --auto applies rules specified in the journal. Maintenance commands @@ -9092,103 +9175,103 @@ Maintenance commands Flags: no command-specific flags - 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 + 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 + 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- + 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 + 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 + 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 + 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 + 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 + 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 + 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- + 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 + 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 + 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- + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + o hledger-check-tagfiles - all tag values containing / (a forward slash) exist as file paths - o hledger-check-fancyassertions - more complex balance assertions are + o hledger-check-fancyassertions - more complex balance assertions are passing diff - Compares a particular account's transactions in two input files. It + Compares a particular account's transactions in two input files. It shows any transactions to this account which are in one file but not in the other. @@ -9196,16 +9279,16 @@ Maintenance commands no command-specific flags More precisely: for each posting affecting this account in either file, - this command looks for a corresponding posting in the other file which - posts the same amount to the same account (ignoring date, description, + this command looks for a corresponding posting in the other file which + posts the same amount to the same account (ignoring date, description, etc). Since it compares postings, not transactions, this also works when mul- tiple bank transactions have been combined into a single journal entry. - This command is useful eg if you have downloaded an account's transac- - tions from your bank (eg as CSV data): when hledger and your bank dis- - agree about the account balance, you can compare the bank data with + This command is useful eg if you have downloaded an account's transac- + tions from your bank (eg as CSV data): when hledger and your bank dis- + agree about the account balance, you can compare the bank data with your journal to find out the cause. Examples: @@ -9226,13 +9309,13 @@ Maintenance commands Flags: no command-specific flags - This command runs the unit tests built in to hledger and hledger-lib, - printing the results on stdout. If any test fails, the exit code will + This command runs the unit tests built in to hledger and hledger-lib, + printing the results on stdout. If any test fails, the exit code will be non-zero. - This is mainly used by hledger developers, but you can also use it to - sanity-check the installed hledger executable on your platform. All - tests are expected to pass - if you ever see a failure, please report + This is mainly used by hledger developers, but you can also use it to + sanity-check the installed hledger executable on your platform. All + tests are expected to pass - if you ever see a failure, please report as a bug! This command also accepts tasty test runner options, written after a -- @@ -9241,11 +9324,11 @@ Maintenance commands $ hledger test -- -pData.Amount --color=never - For help on these, see https://github.com/feuerbach/tasty#options (-- + For help on these, see https://github.com/feuerbach/tasty#options (-- --help currently doesn't show them). PART 5: COMMON TASKS - Here are some quick examples of how to do some basic tasks with + Here are some quick examples of how to do some basic tasks with hledger. Getting help @@ -9255,37 +9338,37 @@ Getting help $ hledger --help # show common options $ hledger CMD --help # show CMD's options, common options and CMD's documentation - You can also view your hledger version's manual in several formats by + You can also view your hledger version's manual in several formats by using the help command. Eg: $ hledger help # show the hledger manual with info, man or $PAGER (best available) $ hledger help journal # show the journal topic in the hledger manual $ hledger help --help # find out more about the help command - To view manuals and introductory docs on the web, visit - https://hledger.org. Chat and mail list support and discussion + 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. 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- + 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: - o command-specific options must go after the command (it's fine to put + o command-specific options must go after the command (it's fine to put common options there too: hledger CMD OPTS ARGS) - o running add-on executables directly simplifies command line parsing + o running add-on executables directly simplifies command line parsing (hledger-ui OPTS ARGS) o enclose "problematic" args in single quotes - o if needed, also add a backslash to hide regular expression metachar- + o if needed, also add a backslash to hide regular expression metachar- acters from the shell o to see how a misbehaving command line is being parsed, add --debug=2. Starting a journal file - hledger looks for your accounting data in a journal file, + hledger looks for your accounting data in a journal file, $HOME/.hledger.journal by default: $ hledger stats @@ -9293,9 +9376,9 @@ Starting a journal file Please create it first, eg with "hledger add" or a text editor. Or, specify an existing journal file with -f or LEDGER_FILE. - You can override this by setting the LEDGER_FILE environment variable - (see below). It's a good practice to keep this important file under - version control, and to start a new file each year. So you could do + You can override this by setting the LEDGER_FILE environment variable + (see below). It's a good practice to keep this important file under + version control, and to start a new file each year. So you could do something like this: $ mkdir ~/finance @@ -9321,28 +9404,28 @@ Starting a journal 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 + On unix and mac, running these commands in the terminal will work for many people; adapt as needed: $ echo 'export LEDGER_FILE=~/finance/2023.journal' >> ~/.profile $ source ~/.profile - When correctly configured, in a new terminal window env | grep + When correctly configured, in a new terminal window env | grep LEDGER_FILE will show your file, and so will hledger files. - On mac, this additional step might be helpful for GUI applications - (like Emacs started from the dock): add an entry to ~/.MacOSX/environ- + On mac, this additional step might be helpful for GUI applications + (like Emacs started from the dock): add an entry to ~/.MacOSX/environ- ment.plist like { "LEDGER_FILE" : "~/finance/2023.journal" } - and then run killall Dock in a terminal window (or restart the ma- + and then run killall Dock in a terminal window (or restart the ma- chine). On Windows, see https://www.java.com/en/download/help/path.html, or try - running these commands in a powershell window (let us know if it per- + running these commands in a powershell window (let us know if it per- sists across a reboot, and if you need to be an Administrator): > CD @@ -9350,20 +9433,20 @@ Setting LEDGER_FILE > SETX LEDGER_FILE "C:\Users\USERNAME\finance\2023.journal" 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 + Pick a starting date for which you can look up the balances of some + real-world assets (bank accounts, wallet..) and liabilities (credit cards..). - To avoid a lot of data entry, you may want to start with just one or + To avoid a lot of data entry, you may want to start with just one or two accounts, like your checking account or cash wallet; and pick a re- - cent starting date, like today or the start of the week. You can al- - ways come back later and add more accounts and older transactions, eg + cent starting date, like today or the start of the week. You can al- + ways come back later and add more accounts and older transactions, eg going back to january 1st. - Add an opening balances transaction to the journal, declaring the bal- + Add an opening balances transaction to the journal, declaring the bal- ances on this date. Here are two ways to do it: - o The first way: open the journal in any text editor and save an entry + o The first way: open the journal in any text editor and save an entry like this: 2023-01-01 * opening balances @@ -9373,19 +9456,19 @@ Setting opening balances liabilities:creditcard $-50 = $-50 equity:opening/closing balances - These are start-of-day balances, ie whatever was in the account at + These are start-of-day balances, ie whatever was in the account at the end of the previous day. - The * after the date is an optional status flag. Here it means + The * after the date is an optional status flag. Here it means "cleared & confirmed". - The currency symbols are optional, but usually a good idea as you'll + The currency symbols are optional, but usually a good idea as you'll be dealing with multiple currencies sooner or later. - The = amounts are optional balance assertions, providing extra error + The = amounts are optional balance assertions, providing extra error checking. - o The second way: run hledger add and follow the prompts to record a + o The second way: run hledger add and follow the prompts to record a similar transaction: $ hledger add @@ -9422,18 +9505,18 @@ Setting opening balances Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2023-01-01]: . - If you're using version control, this could be a good time to commit + If you're using version control, this could be a good time to commit the journal. Eg: $ git commit -m 'initial balances' 2023.journal 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 + 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 convert CSV data downloaded from your bank. - Here are some simple transactions, see the hledger_journal(5) manual + Here are some simple transactions, see the hledger_journal(5) manual and hledger.org for more ideas: 2023/1/10 * gift received @@ -9449,22 +9532,22 @@ Recording transactions assets:bank:checking $1000 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 - real-world balances (and, that the real-world institutions have not - made a mistake!). This gets easy and fast with (1) practice and (2) - frequency. If you do it daily, it can take 2-10 minutes. If you let - it pile up, expect it to take longer as you hunt down errors and dis- + 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 + real-world balances (and, that the real-world institutions have not + made a mistake!). This gets easy and fast with (1) practice and (2) + frequency. If you do it daily, it can take 2-10 minutes. If you let + it pile up, expect it to take longer as you hunt down errors and dis- crepancies. A typical workflow: - 1. Reconcile cash. Count what's in your wallet. Compare with what - hledger reports (hledger bal cash). If they are different, try to - remember the missing transaction, or look for the error in the al- - ready-recorded transactions. A register report can be helpful - (hledger reg cash). If you can't find the error, add an adjustment + 1. Reconcile cash. Count what's in your wallet. Compare with what + hledger reports (hledger bal cash). If they are different, try to + remember the missing transaction, or look for the error in the al- + ready-recorded transactions. A register report can be helpful + (hledger reg cash). If you can't find the error, add an adjustment transaction. Eg if you have $105 after the above, and can't explain the missing $2, it could be: @@ -9474,26 +9557,26 @@ Reconciling 2. Reconcile checking. Log in to your bank's website. Compare today's (cleared) balance with hledger's cleared balance (hledger bal check- - ing -C). If they are different, track down the error or record the - missing transaction(s) or add an adjustment transaction, similar to + ing -C). If they are different, track down the error or record the + missing transaction(s) or add an adjustment transaction, similar to the above. Unlike the cash case, you can usually compare the trans- - action history and running balance from your bank with the one re- - ported by hledger reg checking -C. This will be easier if you gen- - erally record transaction dates quite similar to your bank's clear- + action history and running balance from your bank with the one re- + ported by hledger reg checking -C. This will be easier if you gen- + erally record transaction dates quite similar to your bank's clear- ing dates. 3. Repeat for other asset/liability accounts. - Tip: instead of the register command, use hledger-ui to see a live-up- + Tip: instead of the register command, use hledger-ui to see a live-up- dating register while you edit the journal: hledger-ui --watch --regis- ter checking -C - After reconciling, it could be a good time to mark the reconciled - transactions' status as "cleared and confirmed", if you want to track - that, by adding the * marker. Eg in the paycheck transaction above, + After reconciling, it could be a good time to mark the reconciled + transactions' status as "cleared and confirmed", if you want to track + that, by adding the * marker. Eg in the paycheck transaction above, insert * between 2023-01-15 and paycheck - If you're using version control, this can be another good time to com- + If you're using version control, this can be another good time to com- mit: $ git commit -m 'txns' 2023.journal @@ -9565,7 +9648,7 @@ Reporting -------------------- 0 - Show only asset and liability balances, as a flat list, limited to + Show only asset and liability balances, as a flat list, limited to depth 2: $ hledger bal assets liabilities -2 @@ -9575,7 +9658,7 @@ Reporting -------------------- $4055 - Show the same thing without negative numbers, formatted as a simple + Show the same thing without negative numbers, formatted as a simple balance sheet: $ hledger bs -2 @@ -9642,70 +9725,70 @@ Reporting 2023-01-13 **** Migrating to a new file - At the end of the year, you may want to continue your journal in a new + 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 + and to help ensure the integrity of your accounting history. See the close command. If using version control, don't forget to git add the new file. BUGS We welcome bug reports in the hledger issue tracker (shortcut: - http://bugs.hledger.org), or on the #hledger chat or hledger mail list + http://bugs.hledger.org), or on the #hledger chat or hledger mail list (https://hledger.org/support). Some known issues and limitations: - The need to precede add-on command options with -- when invoked from + The need to precede add-on command options with -- when invoked from hledger is awkward. (See Command options, Constructing command lines.) - A UTF-8-aware system locale must be configured to work with non-ascii + A UTF-8-aware system locale must be configured to work with non-ascii data. (See Unicode characters, Troubleshooting.) On Microsoft Windows, depending whether you are running in a CMD window or a Cygwin/MSYS/Mintty window and how you installed hledger, non-ascii characters and colours may not be supported, and the tab key may not be - supported by hledger add. (Running in a WSL window should resolve + supported by hledger add. (Running in a WSL window should resolve these.) When processing large data files, hledger uses more memory than Ledger. Troubleshooting - Here are some common issues you might encounter when you run hledger, - and how to resolve them (and remember also you can usually get quick + Here are some common issues you might encounter when you run hledger, + and how to resolve them (and remember also you can usually get quick Support): PATH issues: I get an error like "No command 'hledger' found" Depending how you installed hledger, the executables may not be in your - shell's PATH. Eg on unix systems, stack installs hledger in ~/.lo- + shell's PATH. Eg on unix systems, stack installs hledger in ~/.lo- cal/bin and cabal installs it in ~/.cabal/bin. You may need to add one - of these directories to your shell's PATH, and/or open a new terminal + of these directories to your shell's PATH, and/or open a new terminal window. - LEDGER_FILE issues: I configured LEDGER_FILE but hledger is not using + LEDGER_FILE issues: I configured LEDGER_FILE but hledger is not using it - o LEDGER_FILE should be a real environment variable, not just a shell + o LEDGER_FILE should be a real environment variable, not just a shell variable. Eg on unix, the command env | grep LEDGER_FILE should show - it. You may need to use export (see https://stackover- + it. You may need to use export (see https://stackover- flow.com/a/7411509). - o You may need to force your shell to see the new configuration. A + o You may need to force your shell to see the new configuration. A simple way is to close your terminal window and open a new one. - LANG issues: I get errors like "Illegal byte sequence" or "Invalid or + LANG issues: I get errors like "Illegal byte sequence" or "Invalid or incomplete multibyte or wide character" or "commitAndReleaseBuffer: in- valid argument (invalid character)" - Programs compiled with GHC (hledger, haskell build tools, etc.) need - the system locale to be UTF-8-aware, or they will fail when they en- - counter non-ascii characters. To fix it, set the LANG environment - variable to a locale which supports UTF-8 and which is installed on + Programs compiled with GHC (hledger, haskell build tools, etc.) need + the system locale to be UTF-8-aware, or they will fail when they en- + counter non-ascii characters. To fix it, set the LANG environment + variable to a locale which supports UTF-8 and which is installed on your system. - On unix, locale -a lists the installed locales. Look for one which - mentions utf8, UTF-8 or similar. Some examples: C.UTF-8, en_US.utf-8, - fr_FR.utf8. If necessary, use your system package manager to install - one. Then select it by setting the LANG environment variable. Note, - exact spelling and capitalisation of the locale name may be important: + On unix, locale -a lists the installed locales. Look for one which + mentions utf8, UTF-8 or similar. Some examples: C.UTF-8, en_US.utf-8, + fr_FR.utf8. If necessary, use your system package manager to install + one. Then select it by setting the LANG environment variable. Note, + exact spelling and capitalisation of the locale name may be important: Here's one common way to configure this permanently for your shell: $ echo "export LANG=en_US.utf8" >>~/.profile @@ -9718,7 +9801,7 @@ BUGS # close and re-open terminal window COMPATIBILITY ISSUES: hledger gives an error with my Ledger file - Not all of Ledger's journal file syntax or feature set is supported. + Not all of Ledger's journal file syntax or feature set is supported. See hledger and Ledger for full details. @@ -9739,4 +9822,4 @@ LICENSE SEE ALSO hledger(1), hledger-ui(1), hledger-web(1), ledger(1) -hledger-1.40.99 September 2024 HLEDGER(1) +hledger-1.40.99 October 2024 HLEDGER(1)