diff --git a/hledger-lib/.date.m4 b/hledger-lib/.date.m4 index 8ea9dad02..eaa70f8fc 100644 --- a/hledger-lib/.date.m4 +++ b/hledger-lib/.date.m4 @@ -1,2 +1,2 @@ m4_dnl Date to show in man pages. Updated by "Shake manuals" -m4_define({{_monthyear_}}, {{April 2023}})m4_dnl +m4_define({{_monthyear_}}, {{May 2023}})m4_dnl diff --git a/hledger-ui/.date.m4 b/hledger-ui/.date.m4 index 8ea9dad02..eaa70f8fc 100644 --- a/hledger-ui/.date.m4 +++ b/hledger-ui/.date.m4 @@ -1,2 +1,2 @@ m4_dnl Date to show in man pages. Updated by "Shake manuals" -m4_define({{_monthyear_}}, {{April 2023}})m4_dnl +m4_define({{_monthyear_}}, {{May 2023}})m4_dnl diff --git a/hledger-ui/hledger-ui.1 b/hledger-ui/hledger-ui.1 index f502e4d4c..03ad884b2 100644 --- a/hledger-ui/hledger-ui.1 +++ b/hledger-ui/hledger-ui.1 @@ -1,5 +1,5 @@ -.TH "HLEDGER-UI" "1" "April 2023" "hledger-ui-1.29.99 " "hledger User Manuals" +.TH "HLEDGER-UI" "1" "May 2023" "hledger-ui-1.29.99 " "hledger User Manuals" @@ -30,12 +30,13 @@ limited data entry capability. It is easier than hledger\[aq]s command-line interface, and sometimes quicker and more convenient than the web interface. .PP -Like hledger, it reads data from one or more files in journal, -timeclock, timedot, or CSV format. -The default file is \f[V].hledger.journal\f[R] in your home directory; -this can be overridden with one or more \f[V]-f FILE\f[R] options, or -the \f[V]LEDGER_FILE\f[R] environment variable. -For more about this see hledger(1), hledger_journal(5) etc. +Like hledger, it reads from (and appends to) a journal file specified by +the \f[V]LEDGER_FILE\f[R] environment variable (defaulting to +\f[V]$HOME/.hledger.journal\f[R]); or you can specify files with +\f[V]-f\f[R] options. +It can also read timeclock files, timedot files, or any CSV/SSV/TSV file +with a date field. +(See hledger(1) -> Input for details.) .PP Unlike hledger, hledger-ui hides all future-dated transactions by default. @@ -179,17 +180,29 @@ convert amounts to their market value in commodity COMM \f[V]--value\f[R] convert amounts to cost or market value, more flexibly than -B/-V/-X .TP -\f[V]--infer-market-prices\f[R] -use transaction prices (recorded with \[at] or \[at]\[at]) as additional -market prices, as if they were P directives +\f[V]--infer-equity\f[R] +infer conversion equity postings from costs .TP -\f[V]--auto\f[R] -apply automated posting rules to modify transactions. +\f[V]--infer-costs\f[R] +infer costs from conversion equity postings +.TP +\f[V]--infer-market-prices\f[R] +use costs as additional market prices, as if they were P directives .TP \f[V]--forecast\f[R] -generate future transactions from periodic transaction rules, for the -next 6 months or till report end date. -In hledger-ui, also make ordinary future transactions visible. +generate transactions from periodic rules, +between the latest recorded txn and 6 months from today, +or during the specified PERIOD (= is required). +Auto posting rules will be applied to these transactions as well. +Also, in hledger-ui make future-dated transactions visible. +.TP +\f[V]--auto\f[R] +generate extra postings by applying auto posting rules to all txns (not +just forecast txns) +.TP +\f[V]--verbose-tags\f[R] +add visible tags indicating transactions or postings which have been +generated/modified .TP \f[V]--commodity-style\f[R] Override the commodity style in the output for the specified commodity. @@ -515,23 +528,25 @@ This leaves more mental bandwidth for your accounting. Of course you can still interact with hledger-ui when needed, eg to toggle cleared mode, or to explore the history. .PP -Here are some current limitations to be aware of: +There are currently some limitations with \f[V]--watch\f[R]: .PP -Changes might not be detected with certain editors, possibly including -Jetbrains IDEs, \f[V]gedit\f[R], other Gnome applications; or on certain -unusual filesystems. -(#1617, #911). -To work around, reload manually by pressing \f[V]g\f[R] in the -hledger-ui window. -(Or see #1617 for another workaround, and let us know if it works for -you.) +It may not work correctly for you, depending on platform or system +configuration. +(Eg #836.) .PP -CPU and memory usage can sometimes gradually increase, if -\f[V]hledger-ui --watch\f[R] is left running for days. -(Possibly correlated with certain platforms, many transactions, and/or -large numbers of other files present). -To work around, \f[V]q\f[R]uit and restart it, or (where supported) -suspend (\f[V]CTRL-z\f[R]) and restart it (\f[V]fg\f[R]). +At least on mac, there can be a slow build-up of CPU usage over time, +until the program is restarted (or, suspending and restarting with +\f[V]CTRL-z\f[R] \f[V]fg\f[R] may be enough). +.PP +It will not detect file changes made by certain editors, such as +Jetbrains IDEs or \f[V]gedit\f[R], or on certain less common +filesystems. +(To work around, press \f[V]g\f[R] to reload manually, or try +#1617\[aq]s \f[V]fs.inotify.max_user_watches\f[R] workaround and let us +know.) +.PP +If you are viewing files mounted from another machine, the system clocks +on both machines should be roughly in agreement. .SS Debug output .PP You can add \f[V]--debug[=N]\f[R] to the command line to log debug @@ -544,92 +559,29 @@ N ranges from 1 (least output, the default) to 9 (maximum output). \f[B]COLUMNS\f[R] The screen width to use. Default: the full terminal width. .PP -\f[B]LEDGER_FILE\f[R] The journal file path when not specified with -\f[V]-f\f[R]. -.PP -On unix computers, the default value is: -\f[V]\[ti]/.hledger.journal\f[R]. -.PP -A more typical value is something like -\f[V]\[ti]/finance/YYYY.journal\f[R], where \f[V]\[ti]/finance\f[R] is a -version-controlled finance directory and YYYY is the current year. -Or, \f[V]\[ti]/finance/current.journal\f[R], where current.journal is a -symbolic link to YYYY.journal. -.PP -The usual way to set this permanently is to add a command to one of your -shell\[aq]s startup files (eg \f[V]\[ti]/.profile\f[R]): -.IP -.nf -\f[C] -export LEDGER_FILE=\[ti]/finance/current.journal\[ga] -\f[R] -.fi -.PP -On some Mac computers, there is a more thorough way to set environment -variables, that will also affect applications started from the GUI (eg, -Emacs started from a dock icon): In -\f[V]\[ti]/.MacOSX/environment.plist\f[R], add an entry like: -.IP -.nf -\f[C] -{ - \[dq]LEDGER_FILE\[dq] : \[dq]\[ti]/finance/current.journal\[dq] -} -\f[R] -.fi -.PP -For this to take effect you might need to \f[V]killall Dock\f[R], or -reboot. -.PP -On Windows computers, the default value is probably -\f[V]C:\[rs]Users\[rs]YOURNAME\[rs].hledger.journal\f[R]. -You can change this by running a command like this in a powershell -window (let us know if you need to be an Administrator, and if this -persists across a reboot): -.IP -.nf -\f[C] -> setx LEDGER_FILE \[dq]C:\[rs]Users\[rs]MyUserName\[rs]finance\[rs]2021.journal\[dq] -\f[R] -.fi -.PP -Or, change it in settings: see -https://www.java.com/en/download/help/path.html. -.SH FILES -.PP -Reads data from one or more files in journal, timeclock, timedot, or CSV -format. -The default file is \f[V].hledger.journal\f[R] in your home directory; -this can be overridden with one or more \f[V]-f FILE\f[R] options, or -the \f[V]LEDGER_FILE\f[R] environment variable. +\f[B]LEDGER_FILE\f[R] The main journal file to use when not specified +with \f[V]-f/--file\f[R]. +Default: \f[V]$HOME/.hledger.journal\f[R]. .SH BUGS .PP +We welcome bug reports in the hledger issue tracker (shortcut: +http://bugs.hledger.org), or on the #hledger chat or hledger mail list +(https://hledger.org/support). +.PP +Some known issues: +.PP \f[V]-f-\f[R] doesn\[aq]t work (hledger-ui can\[aq]t read from stdin). .PP -\f[V]-V\f[R] affects only the accounts screen. +If you press \f[V]g\f[R] with large files, there could be a noticeable +pause. .PP -When you press \f[V]g\f[R], the current and all previous screens are -regenerated, which may cause a noticeable pause with large files. -Also there is no visual indication that this is in progress. +The Transaction screen does not update from file changes until you exit +and re-endter it (see SCREENS > Transaction above). .PP -\f[V]--watch\f[R] is not yet fully robust. -It works well for normal usage, but many file changes in a short time -(eg saving the file thousands of times with an editor macro) can cause -problems at least on OSX. -Symptoms include: unresponsive UI, periodic resetting of the cursor -position, momentary display of parse errors, high CPU usage eventually -subsiding, and possibly a small but persistent build-up of CPU usage -until the program is restarted. -.PP -Also, if you are viewing files mounted from another machine, -\f[V]-w/--watch\f[R] requires that both machine clocks are roughly in -step. +\f[V]--watch\f[R] is not yet fully robust on all platforms (see Watch +mode above). -.SH "REPORTING BUGS" -Report bugs at http://bugs.hledger.org -(or on the #hledger chat or hledger mail list) - .SH AUTHORS Simon Michael and contributors. .br diff --git a/hledger-ui/hledger-ui.info b/hledger-ui/hledger-ui.info index cda82b1b4..4e1fbe133 100644 --- a/hledger-ui/hledger-ui.info +++ b/hledger-ui/hledger-ui.info @@ -31,11 +31,11 @@ limited data entry capability. It is easier than hledger's command-line interface, and sometimes quicker and more convenient than the web interface. - Like hledger, it reads data from one or more files in journal, -timeclock, timedot, or CSV format. The default file is -'.hledger.journal' in your home directory; this can be overridden with -one or more '-f FILE' options, or the 'LEDGER_FILE' environment -variable. For more about this see hledger(1), hledger_journal(5) etc. + Like hledger, it reads from (and appends to) a journal file specified +by the 'LEDGER_FILE' environment variable (defaulting to +'$HOME/.hledger.journal'); or you can specify files with '-f' options. +It can also read timeclock files, timedot files, or any CSV/SSV/TSV file +with a date field. (See hledger(1) -> Input for details.) Unlike hledger, hledger-ui hides all future-dated transactions by default. They can be revealed, along with any rule-generated periodic @@ -50,7 +50,6 @@ enable "forecast mode". * SCREENS:: * TIPS:: * ENVIRONMENT:: -* FILES:: * BUGS::  @@ -200,18 +199,30 @@ the data. convert amounts to cost or market value, more flexibly than -B/-V/-X +'--infer-equity' + + infer conversion equity postings from costs +'--infer-costs' + + infer costs from conversion equity postings '--infer-market-prices' - use transaction prices (recorded with @ or @@) as additional market - prices, as if they were P directives -'--auto' - - apply automated posting rules to modify transactions. + use costs as additional market prices, as if they were P directives '--forecast' - generate future transactions from periodic transaction rules, for - the next 6 months or till report end date. In hledger-ui, also - make ordinary future transactions visible. + generate transactions from periodic rules, between the latest + recorded txn and 6 months from today, or during the specified + PERIOD (= is required). Auto posting rules will be applied to + these transactions as well. Also, in hledger-ui make future-dated + transactions visible. +'--auto' + + generate extra postings by applying auto posting rules to all txns + (not just forecast txns) +'--verbose-tags' + + add visible tags indicating transactions or postings which have + been generated/modified '--commodity-style' Override the commodity style in the output for the specified @@ -575,19 +586,22 @@ bandwidth for your accounting. Of course you can still interact with hledger-ui when needed, eg to toggle cleared mode, or to explore the history. - Here are some current limitations to be aware of: + There are currently some limitations with '--watch': - Changes might not be detected with certain editors, possibly -including Jetbrains IDEs, 'gedit', other Gnome applications; or on -certain unusual filesystems. (#1617, #911). To work around, reload -manually by pressing 'g' in the hledger-ui window. (Or see #1617 for -another workaround, and let us know if it works for you.) + It may not work correctly for you, depending on platform or system +configuration. (Eg #836.) - CPU and memory usage can sometimes gradually increase, if 'hledger-ui ---watch' is left running for days. (Possibly correlated with certain -platforms, many transactions, and/or large numbers of other files -present). To work around, 'q'uit and restart it, or (where supported) -suspend ('CTRL-z') and restart it ('fg'). + At least on mac, there can be a slow build-up of CPU usage over time, +until the program is restarted (or, suspending and restarting with +'CTRL-z' 'fg' may be enough). + + It will not detect file changes made by certain editors, such as +Jetbrains IDEs or 'gedit', or on certain less common filesystems. (To +work around, press 'g' to reload manually, or try #1617's +'fs.inotify.max_user_watches' workaround and let us know.) + + If you are viewing files mounted from another machine, the system +clocks on both machines should be roughly in agreement.  File: hledger-ui.info, Node: Debug output, Prev: Watch mode, Up: TIPS @@ -600,123 +614,75 @@ will be logged to the file 'hledger-ui.log' in the current directory. N ranges from 1 (least output, the default) to 9 (maximum output).  -File: hledger-ui.info, Node: ENVIRONMENT, Next: FILES, Prev: TIPS, Up: Top +File: hledger-ui.info, Node: ENVIRONMENT, Next: BUGS, Prev: TIPS, Up: Top 6 ENVIRONMENT ************* *COLUMNS* The screen width to use. Default: the full terminal width. - *LEDGER_FILE* The journal file path when not specified with '-f'. - - On unix computers, the default value is: '~/.hledger.journal'. - - A more typical value is something like '~/finance/YYYY.journal', -where '~/finance' is a version-controlled finance directory and YYYY is -the current year. Or, '~/finance/current.journal', where -current.journal is a symbolic link to YYYY.journal. - - The usual way to set this permanently is to add a command to one of -your shell's startup files (eg '~/.profile'): - -export LEDGER_FILE=~/finance/current.journal` - - On some Mac computers, there is a more thorough way to set -environment variables, that will also affect applications started from -the GUI (eg, Emacs started from a dock icon): In -'~/.MacOSX/environment.plist', add an entry like: - -{ - "LEDGER_FILE" : "~/finance/current.journal" -} - - For this to take effect you might need to 'killall Dock', or reboot. - - On Windows computers, the default value is probably -'C:\Users\YOURNAME\.hledger.journal'. You can change this by running a -command like this in a powershell window (let us know if you need to be -an Administrator, and if this persists across a reboot): - -> setx LEDGER_FILE "C:\Users\MyUserName\finance\2021.journal" - - Or, change it in settings: see -https://www.java.com/en/download/help/path.html. + *LEDGER_FILE* The main journal file to use when not specified with +'-f/--file'. Default: '$HOME/.hledger.journal'.  -File: hledger-ui.info, Node: FILES, Next: BUGS, Prev: ENVIRONMENT, Up: Top +File: hledger-ui.info, Node: BUGS, Prev: ENVIRONMENT, Up: Top -7 FILES -******* - -Reads data from one or more files in journal, timeclock, timedot, or CSV -format. The default file is '.hledger.journal' in your home directory; -this can be overridden with one or more '-f FILE' options, or the -'LEDGER_FILE' environment variable. - - -File: hledger-ui.info, Node: BUGS, Prev: FILES, Up: Top - -8 BUGS +7 BUGS ****** -'-f-' doesn't work (hledger-ui can't read from stdin). +We welcome bug reports in the hledger issue tracker (shortcut: +http://bugs.hledger.org), or on the #hledger chat or hledger mail list +(https://hledger.org/support). - '-V' affects only the accounts screen. + Some known issues: - When you press 'g', the current and all previous screens are -regenerated, which may cause a noticeable pause with large files. Also -there is no visual indication that this is in progress. + '-f-' doesn't work (hledger-ui can't read from stdin). - '--watch' is not yet fully robust. It works well for normal usage, -but many file changes in a short time (eg saving the file thousands of -times with an editor macro) can cause problems at least on OSX. Symptoms -include: unresponsive UI, periodic resetting of the cursor position, -momentary display of parse errors, high CPU usage eventually subsiding, -and possibly a small but persistent build-up of CPU usage until the -program is restarted. + If you press 'g' with large files, there could be a noticeable pause. - Also, if you are viewing files mounted from another machine, -'-w/--watch' requires that both machine clocks are roughly in step. + The Transaction screen does not update from file changes until you +exit and re-endter it (see SCREENS > Transaction above). + + '--watch' is not yet fully robust on all platforms (see Watch mode +above).  Tag Table: Node: Top223 -Node: OPTIONS1843 -Ref: #options1941 -Node: MOUSE7074 -Ref: #mouse7169 -Node: KEYS7406 -Ref: #keys7499 -Node: SCREENS12012 -Ref: #screens12110 -Node: Menu12690 -Ref: #menu12783 -Node: Cash accounts12978 -Ref: #cash-accounts13120 -Node: Balance sheet accounts13304 -Ref: #balance-sheet-accounts13485 -Node: Income statement accounts13605 -Ref: #income-statement-accounts13791 -Node: All accounts13955 -Ref: #all-accounts14101 -Node: Register14283 -Ref: #register14407 -Node: Transaction16369 -Ref: #transaction16492 -Node: Error17909 -Ref: #error18003 -Node: TIPS18247 -Ref: #tips18346 -Node: Watch mode18388 -Ref: #watch-mode18495 -Node: Debug output19951 -Ref: #debug-output20062 -Node: ENVIRONMENT20274 -Ref: #environment20385 -Node: FILES21770 -Ref: #files21869 -Node: BUGS22117 -Ref: #bugs22194 +Node: OPTIONS1838 +Ref: #options1936 +Node: MOUSE7432 +Ref: #mouse7527 +Node: KEYS7764 +Ref: #keys7857 +Node: SCREENS12370 +Ref: #screens12468 +Node: Menu13048 +Ref: #menu13141 +Node: Cash accounts13336 +Ref: #cash-accounts13478 +Node: Balance sheet accounts13662 +Ref: #balance-sheet-accounts13843 +Node: Income statement accounts13963 +Ref: #income-statement-accounts14149 +Node: All accounts14313 +Ref: #all-accounts14459 +Node: Register14641 +Ref: #register14765 +Node: Transaction16727 +Ref: #transaction16850 +Node: Error18267 +Ref: #error18361 +Node: TIPS18605 +Ref: #tips18704 +Node: Watch mode18746 +Ref: #watch-mode18853 +Node: Debug output20312 +Ref: #debug-output20423 +Node: ENVIRONMENT20635 +Ref: #environment20745 +Node: BUGS20936 +Ref: #bugs21019  End Tag Table diff --git a/hledger-ui/hledger-ui.txt b/hledger-ui/hledger-ui.txt index 7f36f0ec2..a37e58bba 100644 --- a/hledger-ui/hledger-ui.txt +++ b/hledger-ui/hledger-ui.txt @@ -15,8 +15,8 @@ DESCRIPTION also the hledger manual for common concepts and file formats. hledger is a robust, user-friendly, cross-platform set of programs for - tracking money, time, or any other commodity, using double-entry - accounting and a simple, editable file format. hledger is inspired by + tracking money, time, or any other commodity, using double-entry ac- + counting and a simple, editable file format. hledger is inspired by and largely compatible with ledger(1), and largely interconvertible with beancount(1). @@ -26,14 +26,14 @@ DESCRIPTION line interface, and sometimes quicker and more convenient than the web interface. - Like hledger, it reads data from one or more files in journal, time- - clock, timedot, or CSV format. The default file is .hledger.journal in - your home directory; this can be overridden with one or more -f FILE - options, or the LEDGER_FILE environment variable. For more about this - see hledger(1), hledger_journal(5) etc. + Like hledger, it reads from (and appends to) a journal file specified + by the LEDGER_FILE environment variable (defaulting to + $HOME/.hledger.journal); or you can specify files with -f options. It + can also read timeclock files, timedot files, or any CSV/SSV/TSV file + with a date field. (See hledger(1) -> Input for details.) - Unlike hledger, hledger-ui hides all future-dated transactions by - default. They can be revealed, along with any rule-generated periodic + Unlike hledger, hledger-ui hides all future-dated transactions by de- + fault. They can be revealed, along with any rule-generated periodic transactions, by pressing the F key (or starting with --forecast) to enable "forecast mode". @@ -99,8 +99,8 @@ OPTIONS assignments) -s --strict - do extra error checking (check that all posted accounts are - declared) + do extra error checking (check that all posted accounts are de- + clared) hledger reporting options: @@ -132,8 +132,8 @@ OPTIONS using period expressions syntax --date2 - match the secondary date instead (see command help for other - effects) + match the secondary date instead (see command help for other ef- + fects) --today=DATE override today's date (affects relative smart dates, for @@ -162,42 +162,55 @@ OPTIONS convert amounts to their cost/selling amount at transaction time -V --market - convert amounts to their market value in default valuation com- + convert amounts to their market value in default valuation com- modities -X --exchange=COMM convert amounts to their market value in commodity COMM --value - convert amounts to cost or market value, more flexibly than + convert amounts to cost or market value, more flexibly than -B/-V/-X - --infer-market-prices - use transaction prices (recorded with @ or @@) as additional - market prices, as if they were P directives + --infer-equity + infer conversion equity postings from costs - --auto apply automated posting rules to modify transactions. + --infer-costs + infer costs from conversion equity postings + + --infer-market-prices + use costs as additional market prices, as if they were P direc- + tives --forecast - generate future transactions from periodic transaction rules, - for the next 6 months or till report end date. In hledger-ui, - also make ordinary future transactions visible. + generate transactions from periodic rules, between the latest + recorded txn and 6 months from today, or during the specified + PERIOD (= is required). Auto posting rules will be applied to + these transactions as well. Also, in hledger-ui make future- + dated transactions visible. + + --auto generate extra postings by applying auto posting rules to all + txns (not just forecast txns) + + --verbose-tags + add visible tags indicating transactions or postings which have + been generated/modified --commodity-style - Override the commodity style in the output for the specified + Override the commodity style in the output for the specified commodity. For example 'EUR1.000,00'. --color=WHEN (or --colour=WHEN) - Should color-supporting commands use ANSI color codes in text - output. 'auto' (default): whenever stdout seems to be a color- - supporting terminal. 'always' or 'yes': always, useful eg when - piping output into 'less -R'. 'never' or 'no': never. A + Should color-supporting commands use ANSI color codes in text + output. 'auto' (default): whenever stdout seems to be a color- + supporting terminal. 'always' or 'yes': always, useful eg when + piping output into 'less -R'. 'never' or 'no': never. A NO_COLOR environment variable overrides this. --pretty[=WHEN] - Show prettier output, e.g. using unicode box-drawing charac- - ters. Accepts 'yes' (the default) or 'no' ('y', 'n', 'always', - 'never' also work). If you provide an argument you must use + Show prettier output, e.g. using unicode box-drawing charac- + ters. Accepts 'yes' (the default) or 'no' ('y', 'n', 'always', + 'never' also work). If you provide an argument you must use '=', e.g. '--pretty=yes'. When a reporting option appears more than once in the command line, the @@ -221,11 +234,11 @@ OPTIONS show debug output (levels 1-9, default: 1) A @FILE argument will be expanded to the contents of FILE, which should - contain one command line option/argument per line. (To prevent this, + contain one command line option/argument per line. (To prevent this, insert a -- argument before.) MOUSE - In most modern terminals, you can navigate through the screens with a + In most modern terminals, you can navigate through the screens with a mouse or touchpad: o Use mouse wheel or trackpad to scroll up and down @@ -237,91 +250,91 @@ MOUSE KEYS Keyboard gives more control. - ? shows a help dialog listing all keys. (Some of these also appear in - the quick help at the bottom of each screen.) Press ? again (or - ESCAPE, or LEFT, or q) to close it. The following keys work on most + ? shows a help dialog listing all keys. (Some of these also appear in + the quick help at the bottom of each screen.) Press ? again (or ES- + CAPE, or LEFT, or q) to close it. The following keys work on most screens: - The cursor keys navigate: RIGHT or ENTER goes deeper, LEFT returns to + The cursor keys navigate: RIGHT or ENTER goes deeper, LEFT returns to the previous screen, UP/DOWN/PGUP/PGDN/HOME/END move up and down - through lists. Emacs-style (CTRL-p/CTRL-n/CTRL-f/CTRL-b) and VI-style - (k,j,l,h) movement keys are also supported. A tip: movement speed is - limited by your keyboard repeat rate, to move faster you may want to - adjust it. (If you're on a mac, the karabiner app is one way to do + through lists. Emacs-style (CTRL-p/CTRL-n/CTRL-f/CTRL-b) and VI-style + (k,j,l,h) movement keys are also supported. A tip: movement speed is + limited by your keyboard repeat rate, to move faster you may want to + adjust it. (If you're on a mac, the karabiner app is one way to do that.) - With shift pressed, the cursor keys adjust the report period, limiting - the transactions to be shown (by default, all are shown). SHIFT- - DOWN/UP steps downward and upward through these standard report period - durations: year, quarter, month, week, day. Then, SHIFT-LEFT/RIGHT - moves to the previous/next period. T sets the report period to today. - With the -w/--watch option, when viewing a "current" period (the cur- + With shift pressed, the cursor keys adjust the report period, limiting + the transactions to be shown (by default, all are shown). SHIFT- + DOWN/UP steps downward and upward through these standard report period + durations: year, quarter, month, week, day. Then, SHIFT-LEFT/RIGHT + moves to the previous/next period. T sets the report period to today. + With the -w/--watch option, when viewing a "current" period (the cur- rent day, week, month, quarter, or year), the period will move automat- - ically to track the current date. To set a non-standard period, you + ically to track the current date. To set a non-standard period, you can use / and a date: query. - (Mac users: SHIFT-DOWN/UP keys do not work by default in Terminal, as - of MacOS Monterey. You can configure them as follows: open Terminal, - press CMD-comma to open preferences, click Profiles, select your cur- + (Mac users: SHIFT-DOWN/UP keys do not work by default in Terminal, as + of MacOS Monterey. You can configure them as follows: open Terminal, + press CMD-comma to open preferences, click Profiles, select your cur- rent terminal profile on the left, click Keyboard on the right, click + and add this for Shift-Down: \033[1;2B, click + and add this for Shift- - Up: \033[1;2A. Press the Escape key to enter the \033 part, you can't + Up: \033[1;2A. Press the Escape key to enter the \033 part, you can't type it directly.) - / lets you set a general filter query limiting the data shown, using - the same query terms as in hledger and hledger-web. While editing the - query, you can use CTRL-a/e/d/k, BS, cursor keys; press ENTER to set + / lets you set a general filter query limiting the data shown, using + the same query terms as in hledger and hledger-web. While editing the + query, you can use CTRL-a/e/d/k, BS, cursor keys; press ENTER to set it, or ESCAPEto cancel. There are also keys for quickly adjusting some - common filters like account depth and transaction status (see below). + common filters like account depth and transaction status (see below). BACKSPACE or DELETE removes all filters, showing all transactions. - As mentioned above, by default hledger-ui hides future transactions - + As mentioned above, by default hledger-ui hides future transactions - both ordinary transactions recorded in the journal, and periodic trans- - actions generated by rule. F toggles forecast mode, in which - future/forecasted transactions are shown. + actions generated by rule. F toggles forecast mode, in which fu- + ture/forecasted transactions are shown. - ESCAPE resets the UI state and jumps back to the top screen, restoring - the app's initial state at startup. Or, it cancels minibuffer data - entry or the help dialog. + ESCAPE resets the UI state and jumps back to the top screen, restoring + the app's initial state at startup. Or, it cancels minibuffer data en- + try or the help dialog. CTRL-l redraws the screen and centers the selection if possible (selec- - tions near the top won't be centered, since we don't scroll above the + tions near the top won't be centered, since we don't scroll above the top). - g reloads from the data file(s) and updates the current screen and any - previous screens. (With large files, this could cause a noticeable + g reloads from the data file(s) and updates the current screen and any + previous screens. (With large files, this could cause a noticeable pause.) - I toggles balance assertion checking. Disabling balance assertions + I toggles balance assertion checking. Disabling balance assertions temporarily can be useful for troubleshooting. - a runs command-line hledger's add command, and reloads the updated + a runs command-line hledger's add command, and reloads the updated file. This allows some basic data entry. - A is like a, but runs the hledger-iadd tool, which provides a terminal - interface. This key will be available if hledger-iadd is installed in + A is like a, but runs the hledger-iadd tool, which provides a terminal + interface. This key will be available if hledger-iadd is installed in $path. - E runs $HLEDGER_UI_EDITOR, or $EDITOR, or a default (emacsclient -a "" - -nw) on the journal file. With some editors (emacs, vi), the cursor - will be positioned at the current transaction when invoked from the - register and transaction screens, and at the error location (if possi- + E runs $HLEDGER_UI_EDITOR, or $EDITOR, or a default (emacsclient -a "" + -nw) on the journal file. With some editors (emacs, vi), the cursor + will be positioned at the current transaction when invoked from the + register and transaction screens, and at the error location (if possi- ble) when invoked from the error screen. - B toggles cost mode, showing amounts in their cost's commodity (like + B toggles cost mode, showing amounts in their cost's commodity (like toggling the -B/--cost flag). - V toggles value mode, showing amounts' current market value in their - default valuation commodity (like toggling the -V/--market flag). - Note, "current market value" means the value on the report end date if - specified, otherwise today. To see the value on another date, you can - temporarily set that as the report end date. Eg: to see a transaction - as it was valued on july 30, go to the accounts or register screen, + V toggles value mode, showing amounts' current market value in their + default valuation commodity (like toggling the -V/--market flag). + Note, "current market value" means the value on the report end date if + specified, otherwise today. To see the value on another date, you can + temporarily set that as the report end date. Eg: to see a transaction + as it was valued on july 30, go to the accounts or register screen, press /, and add date:-7/30 to the query. At most one of cost or value mode can be active at once. - There's not yet any visual reminder when cost or value mode is active; + There's not yet any visual reminder when cost or value mode is active; for now pressing b b v should reliably reset to normal mode. q quits the application. @@ -329,10 +342,10 @@ KEYS Additional screen-specific keys are described below. SCREENS - At startup, hledger-ui shows a menu screen by default. From here you + At startup, hledger-ui shows a menu screen by default. From here you can navigate to other screens using the cursor keys: UP/DOWN to select, - RIGHT to move to the selected screen, LEFT to return to the previous - screen. Or you can use ESC to return directly to the top menu screen. + RIGHT to move to the selected screen, LEFT to return to the previous + screen. Or you can use ESC to return directly to the top menu screen. You can also use a command line flag to specific a different startup screen (--cs, --bs, --is, --all, or --register=ACCT). @@ -398,79 +411,82 @@ SCREENS R toggles real mode, in which virtual postings are ignored. - z toggles nonzero mode, in which only transactions posting a nonzero - change are shown (hledger-ui shows zero items by default, unlike com- + z toggles nonzero mode, in which only transactions posting a nonzero + change are shown (hledger-ui shows zero items by default, unlike com- mand-line hledger). Press RIGHT to view the selected transaction in detail. Transaction - This screen shows a single transaction, as a general journal entry, - similar to hledger's print command and journal format (hledger_jour- + This screen shows a single transaction, as a general journal entry, + similar to hledger's print command and journal format (hledger_jour- nal(5)). - The transaction's date(s) and any cleared flag, transaction code, - description, comments, along with all of its account postings are - shown. Simple transactions have two postings, but there can be more - (or in certain cases, fewer). + The transaction's date(s) and any cleared flag, transaction code, de- + scription, comments, along with all of its account postings are shown. + Simple transactions have two postings, but there can be more (or in + certain cases, fewer). - UP and DOWN will step through all transactions listed in the previous - account register screen. In the title bar, the numbers in parentheses - show your position within that account register. They will vary - depending on which account register you came from (remember most trans- - actions appear in multiple account registers). The #N number preceding + UP and DOWN will step through all transactions listed in the previous + account register screen. In the title bar, the numbers in parentheses + show your position within that account register. They will vary de- + pending on which account register you came from (remember most transac- + tions appear in multiple account registers). The #N number preceding them is the transaction's position within the complete unfiltered jour- nal, which is a more stable id (at least until the next reload). On this screen (and the register screen), the E key will open your text - editor with the cursor positioned at the current transaction if possi- + editor with the cursor positioned at the current transaction if possi- ble. - This screen has a limitation with showing file updates: it will not - show them until you exit and re-enter it. So eg to see the effect of + This screen has a limitation with showing file updates: it will not + show them until you exit and re-enter it. So eg to see the effect of using the E key, currently you must: - press E, edit and save the file, - then exit the editor, returning to hledger-ui - press g to reload the - file (or use -w/--watch mode) - press LEFT then RIGHT to exit and re- + then exit the editor, returning to hledger-ui - press g to reload the + file (or use -w/--watch mode) - press LEFT then RIGHT to exit and re- enter the transaction screen. Error - This screen will appear if there is a problem, such as a parse error, - when you press g to reload. Once you have fixed the problem, press g + This screen will appear if there is a problem, such as a parse error, + when you press g to reload. Once you have fixed the problem, press g again to reload and resume normal operation. (Or, you can press escape to cancel the reload attempt.) TIPS Watch mode - One of hledger-ui's best features is the auto-reloading -w/--watch - mode. With this flag, it will update the display automatically when- + One of hledger-ui's best features is the auto-reloading -w/--watch + mode. With this flag, it will update the display automatically when- ever changes are saved to the data files. - This is very useful when reconciling. A good workflow is to have your - bank's online register open in a browser window, for reference; the - journal file open in an editor window; and hledger-ui in watch mode in + This is very useful when reconciling. A good workflow is to have your + bank's online register open in a browser window, for reference; the + journal file open in an editor window; and hledger-ui in watch mode in a terminal window, eg: $ hledger-ui --watch --register checking -C - As you mark things cleared in the editor, you can see the effect imme- - diately without having to context switch. This leaves more mental - bandwidth for your accounting. Of course you can still interact with - hledger-ui when needed, eg to toggle cleared mode, or to explore the + As you mark things cleared in the editor, you can see the effect imme- + diately without having to context switch. This leaves more mental + bandwidth for your accounting. Of course you can still interact with + hledger-ui when needed, eg to toggle cleared mode, or to explore the history. - Here are some current limitations to be aware of: + There are currently some limitations with --watch: - Changes might not be detected with certain editors, possibly including - Jetbrains IDEs, gedit, other Gnome applications; or on certain unusual - filesystems. (#1617, #911). To work around, reload manually by press- - ing g in the hledger-ui window. (Or see #1617 for another workaround, - and let us know if it works for you.) + It may not work correctly for you, depending on platform or system con- + figuration. (Eg #836.) - CPU and memory usage can sometimes gradually increase, if hledger-ui - --watch is left running for days. (Possibly correlated with certain - platforms, many transactions, and/or large numbers of other files - present). To work around, quit and restart it, or (where supported) - suspend (CTRL-z) and restart it (fg). + At least on mac, there can be a slow build-up of CPU usage over time, + until the program is restarted (or, suspending and restarting with + CTRL-z fg may be enough). + + It will not detect file changes made by certain editors, such as Jet- + brains IDEs or gedit, or on certain less common filesystems. (To work + around, press g to reload manually, or try #1617's fs.ino- + tify.max_user_watches workaround and let us know.) + + If you are viewing files mounted from another machine, the system + clocks on both machines should be roughly in agreement. Debug output You can add --debug[=N] to the command line to log debug output. This @@ -480,72 +496,26 @@ TIPS ENVIRONMENT COLUMNS The screen width to use. Default: the full terminal width. - LEDGER_FILE The journal file path when not specified with -f. - - On unix computers, the default value is: ~/.hledger.journal. - - A more typical value is something like ~/finance/YYYY.journal, where - ~/finance is a version-controlled finance directory and YYYY is the - current year. Or, ~/finance/current.journal, where current.journal is - a symbolic link to YYYY.journal. - - The usual way to set this permanently is to add a command to one of - your shell's startup files (eg ~/.profile): - - export LEDGER_FILE=~/finance/current.journal` - - On some Mac computers, there is a more thorough way to set environment - variables, that will also affect applications started from the GUI (eg, - Emacs started from a dock icon): In ~/.MacOSX/environment.plist, add an - entry like: - - { - "LEDGER_FILE" : "~/finance/current.journal" - } - - For this to take effect you might need to killall Dock, or reboot. - - On Windows computers, the default value is probably C:\Users\YOUR- - NAME\.hledger.journal. You can change this by running a command like - this in a powershell window (let us know if you need to be an Adminis- - trator, and if this persists across a reboot): - - > setx LEDGER_FILE "C:\Users\MyUserName\finance\2021.journal" - - Or, change it in settings: see https://www.java.com/en/down- - load/help/path.html. - -FILES - Reads data from one or more files in journal, timeclock, timedot, or - CSV format. The default file is .hledger.journal in your home direc- - tory; this can be overridden with one or more -f FILE options, or the - LEDGER_FILE environment variable. + LEDGER_FILE The main journal file to use when not specified with + -f/--file. Default: $HOME/.hledger.journal. BUGS + We welcome bug reports in the hledger issue tracker (shortcut: + http://bugs.hledger.org), or on the #hledger chat or hledger mail list + (https://hledger.org/support). + + Some known issues: + -f- doesn't work (hledger-ui can't read from stdin). - -V affects only the accounts screen. + If you press g with large files, there could be a noticeable pause. - When you press g, the current and all previous screens are regenerated, - which may cause a noticeable pause with large files. Also there is no - visual indication that this is in progress. + The Transaction screen does not update from file changes until you exit + and re-endter it (see SCREENS > Transaction above). - --watch is not yet fully robust. It works well for normal usage, but - many file changes in a short time (eg saving the file thousands of - times with an editor macro) can cause problems at least on OSX. Symp- - toms include: unresponsive UI, periodic resetting of the cursor posi- - tion, momentary display of parse errors, high CPU usage eventually sub- - siding, and possibly a small but persistent build-up of CPU usage until - the program is restarted. + --watch is not yet fully robust on all platforms (see Watch mode + above). - Also, if you are viewing files mounted from another machine, -w/--watch - requires that both machine clocks are roughly in step. - - - -REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger chat or - hledger mail list) AUTHORS @@ -566,4 +536,4 @@ SEE ALSO -hledger-ui-1.29.99 April 2023 HLEDGER-UI(1) +hledger-ui-1.29.99 May 2023 HLEDGER-UI(1) diff --git a/hledger-web/.date.m4 b/hledger-web/.date.m4 index 8ea9dad02..eaa70f8fc 100644 --- a/hledger-web/.date.m4 +++ b/hledger-web/.date.m4 @@ -1,2 +1,2 @@ m4_dnl Date to show in man pages. Updated by "Shake manuals" -m4_define({{_monthyear_}}, {{April 2023}})m4_dnl +m4_define({{_monthyear_}}, {{May 2023}})m4_dnl diff --git a/hledger-web/hledger-web.1 b/hledger-web/hledger-web.1 index 8df5d8f41..e52950275 100644 --- a/hledger-web/hledger-web.1 +++ b/hledger-web/hledger-web.1 @@ -1,5 +1,5 @@ -.TH "HLEDGER-WEB" "1" "April 2023" "hledger-web-1.29.99 " "hledger User Manuals" +.TH "HLEDGER-WEB" "1" "May 2023" "hledger-web-1.29.99 " "hledger User Manuals" @@ -47,12 +47,13 @@ As a small protection against data loss when running an unprotected instance, it writes a numbered backup of the main journal file (only) on every edit. .PP -Like hledger, it reads data from one or more files in journal, -timeclock, timedot, or CSV format. -The default file is \f[V].hledger.journal\f[R] in your home directory; -this can be overridden with one or more \f[V]-f FILE\f[R] options, or -the \f[V]LEDGER_FILE\f[R] environment variable. -For more about this see hledger(1). +Like hledger, it reads from (and appends to) a journal file specified by +the \f[V]LEDGER_FILE\f[R] environment variable (defaulting to +\f[V]$HOME/.hledger.journal\f[R]); or you can specify files with +\f[V]-f\f[R] options. +It can also read timeclock files, timedot files, or any CSV/SSV/TSV file +with a date field. +(See hledger(1) -> Input for details.) .PP hledger-web can be run in three modes: .IP \[bu] 2 @@ -217,17 +218,29 @@ convert amounts to their market value in commodity COMM \f[V]--value\f[R] convert amounts to cost or market value, more flexibly than -B/-V/-X .TP -\f[V]--infer-market-prices\f[R] -use transaction prices (recorded with \[at] or \[at]\[at]) as additional -market prices, as if they were P directives +\f[V]--infer-equity\f[R] +infer conversion equity postings from costs .TP -\f[V]--auto\f[R] -apply automated posting rules to modify transactions. +\f[V]--infer-costs\f[R] +infer costs from conversion equity postings +.TP +\f[V]--infer-market-prices\f[R] +use costs as additional market prices, as if they were P directives .TP \f[V]--forecast\f[R] -generate future transactions from periodic transaction rules, for the -next 6 months or till report end date. -In hledger-ui, also make ordinary future transactions visible. +generate transactions from periodic rules, +between the latest recorded txn and 6 months from today, +or during the specified PERIOD (= is required). +Auto posting rules will be applied to these transactions as well. +Also, in hledger-ui make future-dated transactions visible. +.TP +\f[V]--auto\f[R] +generate extra postings by applying auto posting rules to all txns (not +just forecast txns) +.TP +\f[V]--verbose-tags\f[R] +add visible tags indicating transactions or postings which have been +generated/modified .TP \f[V]--commodity-style\f[R] Override the commodity style in the output for the specified commodity. @@ -611,79 +624,20 @@ stderr, eg: \f[V]hledger-web --debug=3 2>hledger-web.log\f[R]. .SH ENVIRONMENT .PP -\f[B]LEDGER_FILE\f[R] The journal file path when not specified with -\f[V]-f\f[R]. -.PP -On unix computers, the default value is: -\f[V]\[ti]/.hledger.journal\f[R]. -.PP -A more typical value is something like -\f[V]\[ti]/finance/YYYY.journal\f[R], where \f[V]\[ti]/finance\f[R] is a -version-controlled finance directory and YYYY is the current year. -Or, \f[V]\[ti]/finance/current.journal\f[R], where current.journal is a -symbolic link to YYYY.journal. -.PP -The usual way to set this permanently is to add a command to one of your -shell\[aq]s startup files (eg \f[V]\[ti]/.profile\f[R]): -.IP -.nf -\f[C] -export LEDGER_FILE=\[ti]/finance/current.journal\[ga] -\f[R] -.fi -.PP -On some Mac computers, there is a more thorough way to set environment -variables, that will also affect applications started from the GUI (eg, -Emacs started from a dock icon): In -\f[V]\[ti]/.MacOSX/environment.plist\f[R], add an entry like: -.IP -.nf -\f[C] -{ - \[dq]LEDGER_FILE\[dq] : \[dq]\[ti]/finance/current.journal\[dq] -} -\f[R] -.fi -.PP -For this to take effect you might need to \f[V]killall Dock\f[R], or -reboot. -.PP -On Windows computers, the default value is probably -\f[V]C:\[rs]Users\[rs]YOURNAME\[rs].hledger.journal\f[R]. -You can change this by running a command like this in a powershell -window (let us know if you need to be an Administrator, and if this -persists across a reboot): -.IP -.nf -\f[C] -> setx LEDGER_FILE \[dq]C:\[rs]Users\[rs]MyUserName\[rs]finance\[rs]2021.journal\[dq] -\f[R] -.fi -.PP -Or, change it in settings: see -https://www.java.com/en/download/help/path.html. -.SH FILES -.PP -Reads data from one or more files in journal, timeclock, timedot, or CSV -format. -The default file is \f[V].hledger.journal\f[R] in your home directory; -this can be overridden with one or more \f[V]-f FILE\f[R] options, or -the \f[V]LEDGER_FILE\f[R] environment variable. +\f[B]LEDGER_FILE\f[R] The main journal file to use when not specified +with \f[V]-f/--file\f[R]. +Default: \f[V]$HOME/.hledger.journal\f[R]. .SH BUGS .PP -\f[V]-f-\f[R] doesn\[aq]t work (hledger-web can\[aq]t read from stdin). +We welcome bug reports in the hledger issue tracker (shortcut: +http://bugs.hledger.org), or on the #hledger chat or hledger mail list +(https://hledger.org/support). .PP -Query arguments and some hledger options are ignored. +Some known issues: .PP -Does not work in text-mode browsers. -.PP -Does not work well on small screens. +Does not work well on small screens, or in text-mode browsers. -.SH "REPORTING BUGS" -Report bugs at http://bugs.hledger.org -(or on the #hledger chat or hledger mail list) - .SH AUTHORS Simon Michael and contributors. .br diff --git a/hledger-web/hledger-web.info b/hledger-web/hledger-web.info index a2a15be31..3ed4083d9 100644 --- a/hledger-web/hledger-web.info +++ b/hledger-web/hledger-web.info @@ -39,11 +39,11 @@ you should put it behind a suitable web proxy. As a small protection against data loss when running an unprotected instance, it writes a numbered backup of the main journal file (only) on every edit. - Like hledger, it reads data from one or more files in journal, -timeclock, timedot, or CSV format. The default file is -'.hledger.journal' in your home directory; this can be overridden with -one or more '-f FILE' options, or the 'LEDGER_FILE' environment -variable. For more about this see hledger(1). + Like hledger, it reads from (and appends to) a journal file specified +by the 'LEDGER_FILE' environment variable (defaulting to +'$HOME/.hledger.journal'); or you can specify files with '-f' options. +It can also read timeclock files, timedot files, or any CSV/SSV/TSV file +with a date field. (See hledger(1) -> Input for details.) hledger-web can be run in three modes: @@ -69,7 +69,6 @@ requests to stdout. * JSON API:: * DEBUG OUTPUT:: * ENVIRONMENT:: -* FILES:: * BUGS::  @@ -227,18 +226,30 @@ before options, as shown in the synopsis above. convert amounts to cost or market value, more flexibly than -B/-V/-X +'--infer-equity' + + infer conversion equity postings from costs +'--infer-costs' + + infer costs from conversion equity postings '--infer-market-prices' - use transaction prices (recorded with @ or @@) as additional market - prices, as if they were P directives -'--auto' - - apply automated posting rules to modify transactions. + use costs as additional market prices, as if they were P directives '--forecast' - generate future transactions from periodic transaction rules, for - the next 6 months or till report end date. In hledger-ui, also - make ordinary future transactions visible. + generate transactions from periodic rules, between the latest + recorded txn and 6 months from today, or during the specified + PERIOD (= is required). Auto posting rules will be applied to + these transactions as well. Also, in hledger-ui make future-dated + transactions visible. +'--auto' + + generate extra postings by applying auto posting rules to all txns + (not just forecast txns) +'--verbose-tags' + + add visible tags indicating transactions or postings which have + been generated/modified '--commodity-style' Override the commodity style in the output for the specified @@ -596,94 +607,49 @@ can usually redirect stderr, eg: 'hledger-web --debug=3 2>hledger-web.log'.  -File: hledger-web.info, Node: ENVIRONMENT, Next: FILES, Prev: DEBUG OUTPUT, Up: Top +File: hledger-web.info, Node: ENVIRONMENT, Next: BUGS, Prev: DEBUG OUTPUT, Up: Top 7 ENVIRONMENT ************* -*LEDGER_FILE* The journal file path when not specified with '-f'. - - On unix computers, the default value is: '~/.hledger.journal'. - - A more typical value is something like '~/finance/YYYY.journal', -where '~/finance' is a version-controlled finance directory and YYYY is -the current year. Or, '~/finance/current.journal', where -current.journal is a symbolic link to YYYY.journal. - - The usual way to set this permanently is to add a command to one of -your shell's startup files (eg '~/.profile'): - -export LEDGER_FILE=~/finance/current.journal` - - On some Mac computers, there is a more thorough way to set -environment variables, that will also affect applications started from -the GUI (eg, Emacs started from a dock icon): In -'~/.MacOSX/environment.plist', add an entry like: - -{ - "LEDGER_FILE" : "~/finance/current.journal" -} - - For this to take effect you might need to 'killall Dock', or reboot. - - On Windows computers, the default value is probably -'C:\Users\YOURNAME\.hledger.journal'. You can change this by running a -command like this in a powershell window (let us know if you need to be -an Administrator, and if this persists across a reboot): - -> setx LEDGER_FILE "C:\Users\MyUserName\finance\2021.journal" - - Or, change it in settings: see -https://www.java.com/en/download/help/path.html. +*LEDGER_FILE* The main journal file to use when not specified with +'-f/--file'. Default: '$HOME/.hledger.journal'.  -File: hledger-web.info, Node: FILES, Next: BUGS, Prev: ENVIRONMENT, Up: Top +File: hledger-web.info, Node: BUGS, Prev: ENVIRONMENT, Up: Top -8 FILES -******* - -Reads data from one or more files in journal, timeclock, timedot, or CSV -format. The default file is '.hledger.journal' in your home directory; -this can be overridden with one or more '-f FILE' options, or the -'LEDGER_FILE' environment variable. - - -File: hledger-web.info, Node: BUGS, Prev: FILES, Up: Top - -9 BUGS +8 BUGS ****** -'-f-' doesn't work (hledger-web can't read from stdin). +We welcome bug reports in the hledger issue tracker (shortcut: +http://bugs.hledger.org), or on the #hledger chat or hledger mail list +(https://hledger.org/support). - Query arguments and some hledger options are ignored. + Some known issues: - Does not work in text-mode browsers. - - Does not work well on small screens. + Does not work well on small screens, or in text-mode browsers.  Tag Table: Node: Top225 -Node: OPTIONS2683 -Ref: #options2788 -Node: PERMISSIONS10225 -Ref: #permissions10364 -Node: EDITING UPLOADING DOWNLOADING11576 -Ref: #editing-uploading-downloading11757 -Node: RELOADING12591 -Ref: #reloading12725 -Node: JSON API13158 -Ref: #json-api13273 -Node: DEBUG OUTPUT18761 -Ref: #debug-output18886 -Node: Debug output18913 -Ref: #debug-output-119014 -Node: ENVIRONMENT19431 -Ref: #environment19551 -Node: FILES20862 -Ref: #files20962 -Node: BUGS21210 -Ref: #bugs21288 +Node: OPTIONS2702 +Ref: #options2807 +Node: PERMISSIONS10607 +Ref: #permissions10746 +Node: EDITING UPLOADING DOWNLOADING11958 +Ref: #editing-uploading-downloading12139 +Node: RELOADING12973 +Ref: #reloading13107 +Node: JSON API13540 +Ref: #json-api13655 +Node: DEBUG OUTPUT19143 +Ref: #debug-output19268 +Node: Debug output19295 +Ref: #debug-output-119396 +Node: ENVIRONMENT19813 +Ref: #environment19932 +Node: BUGS20049 +Ref: #bugs20133  End Tag Table diff --git a/hledger-web/hledger-web.txt b/hledger-web/hledger-web.txt index 6c5220667..2fcb6fa40 100644 --- a/hledger-web/hledger-web.txt +++ b/hledger-web/hledger-web.txt @@ -17,8 +17,8 @@ DESCRIPTION the hledger manual for common concepts and file formats. hledger is a robust, user-friendly, cross-platform set of programs for - tracking money, time, or any other commodity, using double-entry - accounting and a simple, editable file format. hledger is inspired by + tracking money, time, or any other commodity, using double-entry ac- + counting and a simple, editable file format. hledger is inspired by and largely compatible with ledger(1), and largely interconvertible with beancount(1). @@ -34,11 +34,11 @@ DESCRIPTION against data loss when running an unprotected instance, it writes a numbered backup of the main journal file (only) on every edit. - Like hledger, it reads data from one or more files in journal, time- - clock, timedot, or CSV format. The default file is .hledger.journal in - your home directory; this can be overridden with one or more -f FILE - options, or the LEDGER_FILE environment variable. For more about this - see hledger(1). + Like hledger, it reads from (and appends to) a journal file specified + by the LEDGER_FILE environment variable (defaulting to + $HOME/.hledger.journal); or you can specify files with -f options. It + can also read timeclock files, timedot files, or any CSV/SSV/TSV file + with a date field. (See hledger(1) -> Input for details.) hledger-web can be run in three modes: @@ -78,8 +78,8 @@ OPTIONS --socket=SOCKETFILE use a unix domain socket file to listen for requests instead of - a TCP socket. Implies --serve. It can only be used if the - operating system can provide this type of socket. + a TCP socket. Implies --serve. It can only be used if the op- + erating system can provide this type of socket. --base-url=URL set the base url (default: http://IPADDR:PORT). Note: affects @@ -129,8 +129,8 @@ OPTIONS assignments) -s --strict - do extra error checking (check that all posted accounts are - declared) + do extra error checking (check that all posted accounts are de- + clared) hledger reporting options: @@ -162,8 +162,8 @@ OPTIONS using period expressions syntax --date2 - match the secondary date instead (see command help for other - effects) + match the secondary date instead (see command help for other ef- + fects) --today=DATE override today's date (affects relative smart dates, for @@ -192,42 +192,55 @@ OPTIONS convert amounts to their cost/selling amount at transaction time -V --market - convert amounts to their market value in default valuation com- + convert amounts to their market value in default valuation com- modities -X --exchange=COMM convert amounts to their market value in commodity COMM --value - convert amounts to cost or market value, more flexibly than + convert amounts to cost or market value, more flexibly than -B/-V/-X - --infer-market-prices - use transaction prices (recorded with @ or @@) as additional - market prices, as if they were P directives + --infer-equity + infer conversion equity postings from costs - --auto apply automated posting rules to modify transactions. + --infer-costs + infer costs from conversion equity postings + + --infer-market-prices + use costs as additional market prices, as if they were P direc- + tives --forecast - generate future transactions from periodic transaction rules, - for the next 6 months or till report end date. In hledger-ui, - also make ordinary future transactions visible. + generate transactions from periodic rules, between the latest + recorded txn and 6 months from today, or during the specified + PERIOD (= is required). Auto posting rules will be applied to + these transactions as well. Also, in hledger-ui make future- + dated transactions visible. + + --auto generate extra postings by applying auto posting rules to all + txns (not just forecast txns) + + --verbose-tags + add visible tags indicating transactions or postings which have + been generated/modified --commodity-style - Override the commodity style in the output for the specified + Override the commodity style in the output for the specified commodity. For example 'EUR1.000,00'. --color=WHEN (or --colour=WHEN) - Should color-supporting commands use ANSI color codes in text - output. 'auto' (default): whenever stdout seems to be a color- - supporting terminal. 'always' or 'yes': always, useful eg when - piping output into 'less -R'. 'never' or 'no': never. A + Should color-supporting commands use ANSI color codes in text + output. 'auto' (default): whenever stdout seems to be a color- + supporting terminal. 'always' or 'yes': always, useful eg when + piping output into 'less -R'. 'never' or 'no': never. A NO_COLOR environment variable overrides this. --pretty[=WHEN] - Show prettier output, e.g. using unicode box-drawing charac- - ters. Accepts 'yes' (the default) or 'no' ('y', 'n', 'always', - 'never' also work). If you provide an argument you must use + Show prettier output, e.g. using unicode box-drawing charac- + ters. Accepts 'yes' (the default) or 'no' ('y', 'n', 'always', + 'never' also work). If you provide an argument you must use '=', e.g. '--pretty=yes'. When a reporting option appears more than once in the command line, the @@ -251,35 +264,35 @@ OPTIONS show debug output (levels 1-9, default: 1) A @FILE argument will be expanded to the contents of FILE, which should - contain one command line option/argument per line. (To prevent this, + contain one command line option/argument per line. (To prevent this, insert a -- argument before.) - By default the server listens on IP address 127.0.0.1, accessible only - to local requests. You can use --host to change this, eg --host + By default the server listens on IP address 127.0.0.1, accessible only + to local requests. You can use --host to change this, eg --host 0.0.0.0 to listen on all configured addresses. - Similarly, use --port to set a TCP port other than 5000, eg if you are + Similarly, use --port to set a TCP port other than 5000, eg if you are running multiple hledger-web instances. Both of these options are ignored when --socket is used. In this case, - it creates an AF_UNIX socket file at the supplied path and uses that - for communication. This is an alternative way of running multiple - hledger-web instances behind a reverse proxy that handles authentica- - tion for different users. The path can be derived in a predictable + it creates an AF_UNIX socket file at the supplied path and uses that + for communication. This is an alternative way of running multiple + hledger-web instances behind a reverse proxy that handles authentica- + tion for different users. The path can be derived in a predictable way, eg by using the username within the path. As an example, nginx as - reverse proxy can use the variable $remote_user to derive a path from - the username used in a HTTP basic authentication. The following - proxy_pass directive allows access to all hledger-web instances that + reverse proxy can use the variable $remote_user to derive a path from + the username used in a HTTP basic authentication. The following + proxy_pass directive allows access to all hledger-web instances that created a socket in /tmp/hledger/: proxy_pass http://unix:/tmp/hledger/${remote_user}.socket; - You can use --base-url to change the protocol, hostname, port and path + You can use --base-url to change the protocol, hostname, port and path that appear in hyperlinks, useful eg for integrating hledger-web within - a larger website. The default is http://HOST:PORT/ using the server's + a larger website. The default is http://HOST:PORT/ using the server's configured host address and TCP port (or http://HOST if PORT is 80). - With --file-url you can set a different base url for static files, eg + With --file-url you can set a different base url for static files, eg for better caching or cookie-less serving on high performance websites. PERMISSIONS @@ -289,8 +302,8 @@ PERMISSIONS You can restrict who can reach it by o setting the IP address it listens on (see --host above). By default - it listens on 127.0.0.1, accessible to all users on the local - machine. + it listens on 127.0.0.1, accessible to all users on the local ma- + chine. o putting it behind an authenticating proxy, using eg apache or nginx @@ -306,8 +319,8 @@ PERMISSIONS o add - allows adding new transactions to the main journal file - o manage - allows editing, uploading or downloading the main or - included files + o manage - allows editing, uploading or downloading the main or in- + cluded files o using the --capabilities-header=HTTPHEADER flag to specify a HTTP header from which it will read capabilities to enable. hledger-web @@ -317,8 +330,8 @@ PERMISSIONS EDITING, UPLOADING, DOWNLOADING If you enable the manage capability mentioned above, you'll see a new "spanner" button to the right of the search form. Clicking this will - let you edit, upload, or download the journal file or any files it - includes. + let you edit, upload, or download the journal file or any files it in- + cludes. Note, unlike any other hledger command, in this mode you (or any visi- tor) can alter or wipe the data files. @@ -337,8 +350,8 @@ RELOADING hledger-web detects changes made to the files by other means (eg if you edit it directly, outside of hledger-web), and it will show the new data when you reload the page or navigate to a new page. If a change - makes a file unparseable, hledger-web will display an error message - until the file has been fixed. + makes a file unparseable, hledger-web will display an error message un- + til the file has been fixed. (Note: if you are viewing files mounted from another machine, make sure that both machine clocks are roughly in step.) @@ -405,15 +418,15 @@ JSON API Most of the JSON corresponds to hledger's data types; for details of what the fields mean, see the Hledger.Data.Json haddock docs and click - on the various data types, eg Transaction. And for a higher level - understanding, see the journal docs. + on the various data types, eg Transaction. And for a higher level un- + derstanding, see the journal docs. In some cases there is outer JSON corresponding to a "Report" type. To understand that, go to the Hledger.Web.Handler.MiscR haddock and look at the source for the appropriate handler to see what it returns. Eg - for /accounttransactions it's getAccounttransactionsR, returning a - "accountTransactionsReport ...". Looking up the haddock for that we - can see that /accounttransactions returns an AccountTransactionsReport, + for /accounttransactions it's getAccounttransactionsR, returning a "ac- + countTransactionsReport ...". Looking up the haddock for that we can + see that /accounttransactions returns an AccountTransactionsReport, which consists of a report title and a list of AccountTransactionsRe- portItem (etc). @@ -517,8 +530,8 @@ JSON API "tstatus": "Unmarked" } - And here's how to test adding it with curl. This should add a new - entry to your journal: + And here's how to test adding it with curl. This should add a new en- + try to your journal: $ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json @@ -533,61 +546,18 @@ DEBUG OUTPUT hledger-web --debug=3 2>hledger-web.log. ENVIRONMENT - LEDGER_FILE The journal file path when not specified with -f. - - On unix computers, the default value is: ~/.hledger.journal. - - A more typical value is something like ~/finance/YYYY.journal, where - ~/finance is a version-controlled finance directory and YYYY is the - current year. Or, ~/finance/current.journal, where current.journal is - a symbolic link to YYYY.journal. - - The usual way to set this permanently is to add a command to one of - your shell's startup files (eg ~/.profile): - - export LEDGER_FILE=~/finance/current.journal` - - On some Mac computers, there is a more thorough way to set environment - variables, that will also affect applications started from the GUI (eg, - Emacs started from a dock icon): In ~/.MacOSX/environment.plist, add an - entry like: - - { - "LEDGER_FILE" : "~/finance/current.journal" - } - - For this to take effect you might need to killall Dock, or reboot. - - On Windows computers, the default value is probably C:\Users\YOUR- - NAME\.hledger.journal. You can change this by running a command like - this in a powershell window (let us know if you need to be an Adminis- - trator, and if this persists across a reboot): - - > setx LEDGER_FILE "C:\Users\MyUserName\finance\2021.journal" - - Or, change it in settings: see https://www.java.com/en/down- - load/help/path.html. - -FILES - Reads data from one or more files in journal, timeclock, timedot, or - CSV format. The default file is .hledger.journal in your home direc- - tory; this can be overridden with one or more -f FILE options, or the - LEDGER_FILE environment variable. + LEDGER_FILE The main journal file to use when not specified with + -f/--file. Default: $HOME/.hledger.journal. BUGS - -f- doesn't work (hledger-web can't read from stdin). + We welcome bug reports in the hledger issue tracker (shortcut: + http://bugs.hledger.org), or on the #hledger chat or hledger mail list + (https://hledger.org/support). - Query arguments and some hledger options are ignored. + Some known issues: - Does not work in text-mode browsers. + Does not work well on small screens, or in text-mode browsers. - Does not work well on small screens. - - - -REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger chat or - hledger mail list) AUTHORS @@ -608,4 +578,4 @@ SEE ALSO -hledger-web-1.29.99 April 2023 HLEDGER-WEB(1) +hledger-web-1.29.99 May 2023 HLEDGER-WEB(1) diff --git a/hledger/.date.m4 b/hledger/.date.m4 index 8ea9dad02..eaa70f8fc 100644 --- a/hledger/.date.m4 +++ b/hledger/.date.m4 @@ -1,2 +1,2 @@ m4_dnl Date to show in man pages. Updated by "Shake manuals" -m4_define({{_monthyear_}}, {{April 2023}})m4_dnl +m4_define({{_monthyear_}}, {{May 2023}})m4_dnl diff --git a/hledger/hledger.1 b/hledger/hledger.1 index 074792143..a979cd2ac 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -1,6 +1,6 @@ .\"t -.TH "HLEDGER" "1" "April 2023" "hledger-1.29.99 " "hledger User Manuals" +.TH "HLEDGER" "1" "May 2023" "hledger-1.29.99 " "hledger User Manuals" @@ -51,16 +51,14 @@ Many reports are available, as subcommands. hledger will also detect other \f[V]hledger-*\f[R] executables as extra subcommands. .PP -hledger reads data from one or more files in journal, timeclock, -timedot, or CSV format. -The default file is \f[V].hledger.journal\f[R] in your home directory; -this can be overridden with one or more \f[V]-f FILE\f[R] options, or -the \f[V]LEDGER_FILE\f[R] environment variable. -hledger CLI can also read from stdin with \f[V]-f-\f[R]; more on that -below. +hledger usually reads from (and appends to) a journal file specified by +the \f[V]LEDGER_FILE\f[R] environment variable (defaulting to +\f[V]$HOME/.hledger.journal\f[R]); or you can specify files with +\f[V]-f\f[R] options. +It can also read timeclock files, timedot files, or any CSV/SSV/TSV file +with a date field. .PP -Here is a small but valid hledger journal file describing one -transaction: +Here is a small journal file describing one transaction: .IP .nf \f[C] @@ -117,7 +115,226 @@ Run \f[V]hledger\f[R] to list the commands. See also the \[dq]Starting a journal file\[dq] and \[dq]Setting opening balances\[dq] sections in PART 5: COMMON TASKS. .SH PART 1: USER INTERFACE +.SH Input +.PP +hledger reads one or more data files, each time you run it. +You can specify a file with \f[V]-f\f[R], like so +.IP +.nf +\f[C] +$ hledger -f FILE print +\f[R] +.fi +.PP +Files are most often in hledger\[aq]s journal format, with the +\f[V].journal\f[R] file extension (\f[V].hledger\f[R] or \f[V].j\f[R] +also work); these files describe transactions, like an accounting +general journal. +Some other supported file formats are discussed below. +.PP +When no \f[V]-f\f[R] option is given, hledger looks for the file +specified by the \f[V]LEDGER_FILE\f[R] environment variable; if this is +not set, it uses \f[V].hledger.journal\f[R] in your home directory. +.PP +Most people prefer to keep financial files in a dedicated folder, +perhaps with version control. +Also, starting a new journal file per year is common (it\[aq]s not +required, but helps keep things fast and organised). +So we usually set \f[V]LEDGER_FILE\f[R], to something like +\f[V]\[ti]/finance/2023.journal\f[R]. +.SS Setting LEDGER_FILE +.PP +How to set \f[V]LEDGER_FILE\f[R] permanently depends on your platform: +.PP +On unix and mac, running these commands in the terminal will work for +many people; adapt as needed: +.IP +.nf +\f[C] +$ mkdir -p \[ti]/finance +$ echo \[aq]export LEDGER_FILE=\[ti]/finance/2023.journal\[ga] >> \[ti]/.profile +$ source \[ti]/.profile +\f[R] +.fi +.PP +When correctly configured, in a new terminal window +\f[V]env | grep LEDGER_FILE\f[R] will show your file, and so will +\f[V]hledger files\f[R]. +.PP +On mac, this additional step might be helpful for GUI applications (like +Emacs started from the dock): add an entry to +\f[V]\[ti]/.MacOSX/environment.plist\f[R] like +.IP +.nf +\f[C] +{ + \[dq]LEDGER_FILE\[dq] : \[dq]\[ti]/finance/2023.journal\[dq] +} +\f[R] +.fi +.PP +and then run \f[V]killall Dock\f[R] in a terminal window (or restart the +machine). +.PP +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 +persists across a reboot, and if you need to be an Administrator): +.IP +.nf +\f[C] +> CD +> MKDIR finance +> SETX LEDGER_FILE \[dq]C:\[rs]Users\[rs]USERNAME\[rs]finance\[rs]2023.journal\[dq] +\f[R] +.fi +.SS Data formats +.PP +Usually the data file is in hledger\[aq]s journal format, but it can be +in any of the supported file formats, which currently are: +.PP +.TS +tab(@); +lw(7.8n) lw(39.5n) lw(22.7n). +T{ +Reader: +T}@T{ +Reads: +T}@T{ +Used for file extensions: +T} +_ +T{ +\f[V]journal\f[R] +T}@T{ +hledger journal files and some Ledger journals, for transactions +T}@T{ +\f[V].journal\f[R] \f[V].j\f[R] \f[V].hledger\f[R] \f[V].ledger\f[R] +T} +T{ +\f[V]timeclock\f[R] +T}@T{ +timeclock files, for precise time logging +T}@T{ +\f[V].timeclock\f[R] +T} +T{ +\f[V]timedot\f[R] +T}@T{ +timedot files, for approximate time logging +T}@T{ +\f[V].timedot\f[R] +T} +T{ +\f[V]csv\f[R] +T}@T{ +CSV/SSV/TSV/character-separated values, for data import +T}@T{ +\f[V].csv\f[R] \f[V].ssv\f[R] \f[V].tsv\f[R] \f[V].csv.rules\f[R] +\f[V].ssv.rules\f[R] \f[V].tsv.rules\f[R] +T} +.TE +.PP +These formats are described in more detail below. +.PP +hledger detects the format automatically based on the file extensions +shown above. +If it can\[aq]t recognise the file extension, it assumes +\f[V]journal\f[R] format. +So for non-journal files, it\[aq]s important to use a recognised file +extension, so as to either read successfully or to show relevant error +messages. +.PP +You can also force a specific reader/format by prefixing the file path +with the format and a colon. +Eg, to read a .dat file as csv format: +.IP +.nf +\f[C] +$ hledger -f csv:/some/csv-file.dat stats +\f[R] +.fi +.SS Standard input +.PP +The file name \f[V]-\f[R] means standard input: +.IP +.nf +\f[C] +$ cat FILE | hledger -f- print +\f[R] +.fi +.PP +If reading non-journal data in this way, you\[aq]ll need to add a file +format prefix, like: +.IP +.nf +\f[C] +$ echo \[aq]i 2009/13/1 08:00:00\[aq] | hledger print -f timeclock:- +\f[R] +.fi +.SS Multiple files +.PP +You can specify multiple \f[V]-f\f[R] options, to read multiple files as +one big journal. +When doing this, note that certain features (described below) will be +affected: +.IP \[bu] 2 +Balance assertions will not see the effect of transactions in previous +files. +(Usually this doesn\[aq]t matter as each file will set the corresponding +opening balances.) +.IP \[bu] 2 +Some directives will not affect previous or subsequent files. +.PP +If needed, you can work around these by using a single parent file which +includes the others, or concatenating the files into one, eg: +\f[V]cat a.journal b.journal | hledger -f- CMD\f[R]. +.SS Strict mode +.PP +hledger checks input files for valid data. +By default, the most important errors are detected, while still +accepting easy journal files without a lot of declarations: +.IP \[bu] 2 +Are the input files parseable, with valid syntax ? +.IP \[bu] 2 +Are all transactions balanced ? +.IP \[bu] 2 +Do all balance assertions pass ? +.PP +With the \f[V]-s\f[R]/\f[V]--strict\f[R] flag, additional checks are +performed: +.IP \[bu] 2 +Are all accounts posted to, declared with an \f[V]account\f[R] directive +? +(Account error checking) +.IP \[bu] 2 +Are all commodities declared with a \f[V]commodity\f[R] directive ? +(Commodity error checking) +.IP \[bu] 2 +Are all commodity conversions declared explicitly ? +.PP +You can use the check command to run individual checks -- the ones +listed above and some more. +.SH Environment +.PP +Environment variables which affect hledger: +.PP +\f[B]COLUMNS\f[R] This is normally set by your terminal; some hledger +commands (\f[V]register\f[R]) will format their output to this width. +If not set, they will try to use the available terminal width. +.PP +\f[B]LEDGER_FILE\f[R] The main journal file to use when not specified +with \f[V]-f/--file\f[R]. +Default: \f[V]$HOME/.hledger.journal\f[R]. +.PP +\f[B]NO_COLOR\f[R] If this environment variable is set (with any value), +hledger will not use ANSI color codes in terminal output, unless +overridden by an explicit \f[V]--color/--colour\f[R] option. .SH Options +.PP +Here is a list of flags and options common to most hledger commands, and +some useful details about hledger command line parsing. +But if you are new to hledger, feel free to skim/skip ahead to the +Commands. .SS General options .PP To see general usage help, including general options which are supported @@ -236,17 +453,29 @@ convert amounts to their market value in commodity COMM \f[V]--value\f[R] convert amounts to cost or market value, more flexibly than -B/-V/-X .TP -\f[V]--infer-market-prices\f[R] -use transaction prices (recorded with \[at] or \[at]\[at]) as additional -market prices, as if they were P directives +\f[V]--infer-equity\f[R] +infer conversion equity postings from costs .TP -\f[V]--auto\f[R] -apply automated posting rules to modify transactions. +\f[V]--infer-costs\f[R] +infer costs from conversion equity postings +.TP +\f[V]--infer-market-prices\f[R] +use costs as additional market prices, as if they were P directives .TP \f[V]--forecast\f[R] -generate future transactions from periodic transaction rules, for the -next 6 months or till report end date. -In hledger-ui, also make ordinary future transactions visible. +generate transactions from periodic rules, +between the latest recorded txn and 6 months from today, +or during the specified PERIOD (= is required). +Auto posting rules will be applied to these transactions as well. +Also, in hledger-ui make future-dated transactions visible. +.TP +\f[V]--auto\f[R] +generate extra postings by applying auto posting rules to all txns (not +just forecast txns) +.TP +\f[V]--verbose-tags\f[R] +add visible tags indicating transactions or postings which have been +generated/modified .TP \f[V]--commodity-style\f[R] Override the commodity style in the output for the specified commodity. @@ -273,6 +502,15 @@ When a reporting option appears more than once in the command line, the last one takes precedence. .PP Some reporting options can also be written as query arguments. +.SS Option repetition +.PP +If options are repeated in a command line, hledger will generally use +the last (right-most) occurence. +Some of the boolean flags will toggle if repeated; these include: +\f[V]--invert\f[R], \f[V]--transpose\f[R], \f[V]-r/--related\f[R], +\f[V]-%/--percent\f[R], \f[V]-E/--empty\f[R], \f[V]-N/--no-total\f[R], +\f[V]-T/--row-total\f[R], \f[V]-A/--average\f[R], and +\f[V]-S/--sort-amount\f[R]. .SS Command options .PP To see options for a particular command, including command-specific @@ -556,213 +794,6 @@ Eg to search for amounts with the dollar sign in hledger-web, write On the command line, some metacharacters like \f[V]$\f[R] have a special meaning to the shell and so must be escaped at least once more. See Special characters. -.SH Environment -.PP -\f[B]LEDGER_FILE\f[R] The journal file path when not specified with -\f[V]-f\f[R]. -.PP -On unix computers, the default value is: -\f[V]\[ti]/.hledger.journal\f[R]. -.PP -A more typical value is something like -\f[V]\[ti]/finance/YYYY.journal\f[R], where \f[V]\[ti]/finance\f[R] is a -version-controlled finance directory and YYYY is the current year. -Or, \f[V]\[ti]/finance/current.journal\f[R], where current.journal is a -symbolic link to YYYY.journal. -.PP -The usual way to set this permanently is to add a command to one of your -shell\[aq]s startup files (eg \f[V]\[ti]/.profile\f[R]): -.IP -.nf -\f[C] -export LEDGER_FILE=\[ti]/finance/current.journal\[ga] -\f[R] -.fi -.PP -On some Mac computers, there is a more thorough way to set environment -variables, that will also affect applications started from the GUI (eg, -Emacs started from a dock icon): In -\f[V]\[ti]/.MacOSX/environment.plist\f[R], add an entry like: -.IP -.nf -\f[C] -{ - \[dq]LEDGER_FILE\[dq] : \[dq]\[ti]/finance/current.journal\[dq] -} -\f[R] -.fi -.PP -For this to take effect you might need to \f[V]killall Dock\f[R], or -reboot. -.PP -On Windows computers, the default value is probably -\f[V]C:\[rs]Users\[rs]YOURNAME\[rs].hledger.journal\f[R]. -You can change this by running a command like this in a powershell -window (let us know if you need to be an Administrator, and if this -persists across a reboot): -.IP -.nf -\f[C] -> setx LEDGER_FILE \[dq]C:\[rs]Users\[rs]MyUserName\[rs]finance\[rs]2021.journal\[dq] -\f[R] -.fi -.PP -Or, change it in settings: see -https://www.java.com/en/download/help/path.html. -.PP -\f[B]COLUMNS\f[R] The screen width used by the register command. -Default: the full terminal width. -.PP -\f[B]NO_COLOR\f[R] If this variable exists with any value, hledger will -not use ANSI color codes in terminal output. -This is overriden by the --color/--colour option. -.SH Input -.PP -hledger reads transactions from one or more data files. -The default data file is \f[V]$HOME/.hledger.journal\f[R] (or on -Windows, something like -\f[V]C:\[rs]Users\[rs]YOURNAME\[rs].hledger.journal\f[R]). -.PP -You can override this with the \f[V]$LEDGER_FILE\f[R] environment -variable: -.IP -.nf -\f[C] -$ setenv LEDGER_FILE \[ti]/finance/2016.journal -$ hledger stats -\f[R] -.fi -.PP -or with one or more \f[V]-f/--file\f[R] options: -.IP -.nf -\f[C] -$ hledger -f /some/file -f another_file stats -\f[R] -.fi -.PP -The file name \f[V]-\f[R] means standard input: -.IP -.nf -\f[C] -$ cat some.journal | hledger -f- -\f[R] -.fi -.SS Data formats -.PP -Usually the data file is in hledger\[aq]s journal format, but it can be -in any of the supported file formats, which currently are: -.PP -.TS -tab(@); -lw(7.8n) lw(39.5n) lw(22.7n). -T{ -Reader: -T}@T{ -Reads: -T}@T{ -Used for file extensions: -T} -_ -T{ -\f[V]journal\f[R] -T}@T{ -hledger journal files and some Ledger journals, for transactions -T}@T{ -\f[V].journal\f[R] \f[V].j\f[R] \f[V].hledger\f[R] \f[V].ledger\f[R] -T} -T{ -\f[V]timeclock\f[R] -T}@T{ -timeclock files, for precise time logging -T}@T{ -\f[V].timeclock\f[R] -T} -T{ -\f[V]timedot\f[R] -T}@T{ -timedot files, for approximate time logging -T}@T{ -\f[V].timedot\f[R] -T} -T{ -\f[V]csv\f[R] -T}@T{ -comma/semicolon/tab/other-separated values, for data import -T}@T{ -\f[V].csv\f[R] \f[V].ssv\f[R] \f[V].tsv\f[R] -T} -.TE -.PP -These formats are described in more detail below. -.PP -hledger detects the format automatically based on the file extensions -shown above. -If it can\[aq]t recognise the file extension, it assumes -\f[V]journal\f[R] format. -So for non-journal files, it\[aq]s important to use a recognised file -extension, so as to either read successfully or to show relevant error -messages. -.PP -You can also force a specific reader/format by prefixing the file path -with the format and a colon. -Eg, to read a .dat file as csv format: -.IP -.nf -\f[C] -$ hledger -f csv:/some/csv-file.dat stats -\f[R] -.fi -.PP -Or to read stdin (\f[V]-\f[R]) as timeclock format: -.IP -.nf -\f[C] -$ echo \[aq]i 2009/13/1 08:00:00\[aq] | hledger print -ftimeclock:- -\f[R] -.fi -.SS Multiple files -.PP -You can specify multiple \f[V]-f\f[R] options, to read multiple files as -one big journal. -There are some limitations with this: -.IP \[bu] 2 -most directives do not affect sibling files -.IP \[bu] 2 -balance assertions will not see any account balances from previous files -.PP -If you need either of those things, you can -.IP \[bu] 2 -use a single parent file which includes the others -.IP \[bu] 2 -or concatenate the files into one before reading, eg: -\f[V]cat a.journal b.journal | hledger -f- CMD\f[R]. -.SS Strict mode -.PP -hledger checks input files for valid data. -By default, the most important errors are detected, while still -accepting easy journal files without a lot of declarations: -.IP \[bu] 2 -Are the input files parseable, with valid syntax ? -.IP \[bu] 2 -Are all transactions balanced ? -.IP \[bu] 2 -Do all balance assertions pass ? -.PP -With the \f[V]-s\f[R]/\f[V]--strict\f[R] flag, additional checks are -performed: -.IP \[bu] 2 -Are all accounts posted to, declared with an \f[V]account\f[R] directive -? -(Account error checking) -.IP \[bu] 2 -Are all commodities declared with a \f[V]commodity\f[R] directive ? -(Commodity error checking) -.IP \[bu] 2 -Are all commodity conversions declared explicitly ? -.PP -You can use the check command to run individual checks -- the ones -listed above and some more. .SH Commands .PP hledger provides a number of built-in subcommands (described below). @@ -1151,129 +1182,6 @@ stderr, eg: hledger bal --debug=3 2>hledger.log \f[R] .fi -.SH Limitations -.PP -The need to precede add-on command options with \f[V]--\f[R] when -invoked from hledger is awkward. -.PP -When input data contains non-ascii characters, a suitable system locale -must be configured (or there will be an unhelpful error). -Eg on POSIX, set LANG to something other than C. -.PP -In a Microsoft Windows CMD window, non-ascii characters and colours are -not supported. -.PP -On Windows, non-ascii characters may not display correctly when running -a hledger built in CMD in MSYS/CYGWIN, or vice-versa. -.PP -In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger -add. -.PP -Not all of Ledger\[aq]s journal file syntax is supported. -See hledger and Ledger > Differences > journal format. -.PP -On large data files, hledger is slower and uses more memory than Ledger. -.SH Troubleshooting -.PP -Here are some issues you might encounter when you run hledger (and -remember you can also seek help from the IRC channel, mail list or bug -tracker): -.PP -\f[B]Successfully installed, but \[dq]No command \[aq]hledger\[aq] -found\[dq]\f[R] -.PD 0 -.P -.PD -stack and cabal install binaries into a special directory, which should -be added to your PATH environment variable. -Eg on unix-like systems, that is \[ti]/.local/bin and \[ti]/.cabal/bin -respectively. -.PP -\f[B]I set a custom LEDGER_FILE, but hledger is still using the default -file\f[R] -.PD 0 -.P -.PD -\f[V]LEDGER_FILE\f[R] should be a real environment variable, not just a -shell variable. -The command \f[V]env | grep LEDGER_FILE\f[R] should show it. -You may need to use \f[V]export\f[R]. -Here\[aq]s an explanation. -.PP -\f[B]Getting errors like \[dq]Illegal byte sequence\[dq] or \[dq]Invalid -or incomplete multibyte or wide character\[dq] or -\[dq]commitAndReleaseBuffer: invalid argument (invalid -character)\[dq]\f[R] -.PD 0 -.P -.PD -Programs compiled with GHC (hledger, haskell build tools, etc.) -need to have a UTF-8-aware locale configured in the environment, -otherwise they will fail with these kinds of errors when they encounter -non-ascii characters. -.PP -To fix it, set the LANG environment variable to some locale which -supports UTF-8. -The locale you choose must be installed on your system. -.PP -Here\[aq]s an example of setting LANG temporarily, on Ubuntu GNU/Linux: -.IP -.nf -\f[C] -$ file my.journal -my.journal: UTF-8 Unicode text # the file is UTF8-encoded -$ echo $LANG -C # LANG is set to the default locale, which does not support UTF8 -$ locale -a # which locales are installed ? -C -en_US.utf8 # here\[aq]s a UTF8-aware one we can use -POSIX -$ LANG=en_US.utf8 hledger -f my.journal print # ensure it is used for this command -\f[R] -.fi -.PP -If available, \f[V]C.UTF-8\f[R] will also work. -If your preferred locale isn\[aq]t listed by \f[V]locale -a\f[R], you -might need to install it. -Eg on Ubuntu/Debian: -.IP -.nf -\f[C] -$ apt-get install language-pack-fr -$ locale -a -C -en_US.utf8 -fr_BE.utf8 -fr_CA.utf8 -fr_CH.utf8 -fr_FR.utf8 -fr_LU.utf8 -POSIX -$ LANG=fr_FR.utf8 hledger -f my.journal print -\f[R] -.fi -.PP -Here\[aq]s how you could set it permanently, if you use a bash shell: -.IP -.nf -\f[C] -$ echo \[dq]export LANG=en_US.utf8\[dq] >>\[ti]/.bash_profile -$ bash --login -\f[R] -.fi -.PP -Exact spelling and capitalisation may be important. -Note the difference on MacOS (\f[V]UTF-8\f[R], not \f[V]utf8\f[R]). -Some platforms (eg ubuntu) allow variant spellings, but others (eg -macos) require it to be exact: -.IP -.nf -\f[C] -$ locale -a | grep -iE en_us.*utf -en_US.UTF-8 -$ LANG=en_US.UTF-8 hledger -f my.journal print -\f[R] -.fi .SH PART 2: DATA FORMATS .PP .SH Journal @@ -1346,7 +1254,6 @@ P 2022-01-01 AAAA $1.40 expenses:tax:us:2021 $500 ; plus means added to this account (debit) ; revenue/expense categories are also \[dq]accounts\[dq] -Kv 2022-01-01 ; The description is optional. ; Any currency/commodity symbols are allowed, on either side. assets:cash:wallet GBP -10 @@ -1386,11 +1293,14 @@ The journal file contains a number of transaction entries, each describing a transfer of money (or any commodity) between two or more named accounts, in a simple format readable by both hledger and humans. .PP -hledger\[aq]s journal format is a compatible subset, mostly, of -ledger\[aq]s journal format, so hledger can work with compatible ledger -journal files as well. -It\[aq]s safe, and encouraged, to run both hledger and ledger on the -same journal file, eg to validate the results you\[aq]re getting. +hledger\[aq]s journal format is compatible with most of Ledger\[aq]s +journal format, but not all of it. +The differences and interoperation tips are described at hledger and +Ledger. +With some care, and by avoiding incompatible features, you can keep your +hledger journal readable by Ledger and vice versa. +This can useful eg for comparing the behaviour of one app against the +other. .PP You can use hledger without learning any more about this file; just use the add or web or import commands to create and update it. @@ -1985,7 +1895,7 @@ Write the price per unit, as \f[V]\[at] UNITPRICE\f[R] after the amount: .nf \f[C] 2009/1/1 - assets:euros \[Eu]100 \[at] $1.35 ; one hundred euros purchased at $1.35 each + assets:euros €100 \[at] $1.35 ; one hundred euros purchased at $1.35 each assets:dollars ; balancing amount is -$135.00 \f[R] .fi @@ -1998,7 +1908,7 @@ amount: .nf \f[C] 2009/1/1 - assets:euros \[Eu]100 \[at]\[at] $135 ; one hundred euros purchased at $135 for the lot + assets:euros €100 \[at]\[at] $135 ; one hundred euros purchased at $135 for the lot assets:dollars \f[R] .fi @@ -2007,21 +1917,21 @@ amount: Specify amounts for all postings, using exactly two commodities, and let hledger infer the price that balances the transaction. Note the effect of posting order: the price is added to first posting, -making it \f[V]\[Eu]100 \[at]\[at] $135\f[R], as in example 2: +making it \f[V]€100 \[at]\[at] $135\f[R], as in example 2: .RS 4 .IP .nf \f[C] 2009/1/1 - assets:euros \[Eu]100 ; one hundred euros purchased + assets:euros €100 ; one hundred euros purchased assets:dollars $-135 ; for $135 \f[R] .fi .RE .PP Amounts can be converted to cost at report time using the -\f[V]-B/--cost\f[R] flag; this is discussed more in the \[u02DC]COST -REPORTING section. +\f[V]-B/--cost\f[R] flag; this is discussed more in the ˜COST REPORTING +section. .PP Note that the cost normally should be a positive amount, though it\[aq]s not required to be. @@ -2214,17 +2124,17 @@ the asserted one (or at least, that their balance is 0). \f[C] 2013/1/1 a $1 - a 1\[Eu] + a 1€ b $-1 - c -1\[Eu] + c -1€ 2013/1/2 ; These assertions succeed a 0 = $1 - a 0 = 1\[Eu] + a 0 = 1€ b 0 == $-1 - c 0 == -1\[Eu] + c 0 == -1€ -2013/1/3 ; This assertion fails as \[aq]a\[aq] also contains 1\[Eu] +2013/1/3 ; This assertion fails as \[aq]a\[aq] also contains 1€ a 0 == $1 \f[R] .fi @@ -2237,13 +2147,13 @@ One workaround is to isolate each commodity into its own subaccount: \f[C] 2013/1/1 a:usd $1 - a:euro 1\[Eu] + a:euro 1€ b 2013/1/2 a 0 == 0 a:usd 0 == $1 - a:euro 0 == 1\[Eu] + a:euro 0 == 1€ \f[R] .fi .SS Assertions and prices @@ -2254,7 +2164,7 @@ one: .nf \f[C] 2019/1/1 - (a) $1 \[at] \[Eu]1 = $1 + (a) $1 \[at] €1 = $1 \f[R] .fi .PP @@ -2382,35 +2292,24 @@ You can list a tag\[aq]s values with \f[V]tag:NAMEREGEX=VALUEREGEX\f[R] query. .SS Directives .PP -A directive is a line in the journal beginning with a special keyword, -that influences how the journal is processed, how things are displayed, -and so on. -hledger\[aq]s directives are based on (a subset of) Ledger\[aq]s, but -there are many differences, and also some differences between hledger -versions. -Here are some more definitions: -.IP \[bu] 2 -\f[I]subdirective\f[R] - Some directives support subdirectives, written -indented below the parent directive. -.IP \[bu] 2 -\f[I]decimal mark\f[R] - The character to interpret as a decimal mark -(period or comma) when parsing amounts of a commodity. -.IP \[bu] 2 -\f[I]display style\f[R] - How to display amounts of a commodity in -output: symbol side and spacing, digit groups, decimal mark, and number -of decimal places. -.PP -Directives are not required when starting out with hledger, but you will -probably want to add some as your needs grow. -Here some key directives for particular needs: +Besides transactions, there is something else you can put in a +\f[V]journal\f[R] file: directives. +These are declarations, beginning with a keyword, that modify +hledger\[aq]s behaviour. +Some directives can have more specific subdirectives, indented below +them. +hledger\[aq]s directives are similar to Ledger\[aq]s in many cases, but +there are also many differences. +Directives are not required, but can be useful. +Here are the main directives: .PP .TS tab(@); -lw(43.0n) lw(27.0n). +lw(39.7n) lw(30.3n). T{ purpose T}@T{ -directives +directive T} _ T{ @@ -2418,22 +2317,22 @@ T{ T}@T{ T} T{ -Declare file\[aq]s decimal mark to help parse amounts accurately -T}@T{ -\f[V]decimal-mark\f[R] -T} -T{ Rewrite account names T}@T{ \f[V]alias\f[R] T} T{ -Comment out sections of the data +Comment out sections of the file T}@T{ \f[V]comment\f[R] T} T{ -Include extra data files +Declare file\[aq]s decimal mark, to help parse amounts accurately +T}@T{ +\f[V]decimal-mark\f[R] +T} +T{ +Include other data files T}@T{ \f[V]include\f[R] T} @@ -2447,7 +2346,7 @@ T}@T{ \f[V]\[ti]\f[R] T} T{ -Generate extra postings on transactions +Generate extra postings on existing transactions T}@T{ \f[V]=\f[R] T} @@ -2458,7 +2357,7 @@ T} T{ Define valid entities to provide more error checking T}@T{ -\f[V]account\f[R], \f[V]commodity\f[R], \f[V]payee\f[R] +\f[V]account\f[R], \f[V]commodity\f[R], \f[V]payee\f[R], \f[V]tag\f[R] T} T{ \f[B]REPORTING:\f[R] @@ -2480,10 +2379,28 @@ T}@T{ \f[V]P\f[R] T} .TE +.SS Directives and multiple files +.PP +Directives vary in their scope, ie which journal entries and which input +files they affect. +Most often, a directive will affect the following entries and included +files if any, until the end of the current file - and no further. +You might find this inconvenient! +For example, \f[V]alias\f[R] directives do not affect parent or sibling +files. +But there are usually workarounds; for example, put \f[V]alias\f[R] +directives in your top-most file, before including other files. +.PP +The restriction, though it may be annoying at first, is in a good cause; +it allows reports to be stable and deterministic, independent of the +order of input. +Without it, reports could show different numbers depending on the order +of -f options, or the positions of include directives in your files. .SS Directive effects .PP -And here is what each directive does, and which files and journal -entries (transactions) it affects: +Here are all hledger\[aq]s directives, with their effects and scope +summarised - nine main directives, plus four others which we consider +non-essential: .PP .TS tab(@); @@ -2629,22 +2546,6 @@ Other directives from Ledger\[aq]s file format are accepted but ignored. T}@T{ T} .TE -.SS Directives and multiple files -.PP -If you use multiple \f[V]-f\f[R]/\f[V]--file\f[R] options, or the -\f[V]include\f[R] directive, hledger will process multiple input files. -But directives which affect input typically have effect only until the -end of the file in which they occur (and on any included files in that -region). -.PP -This may seem inconvenient, but it\[aq]s intentional; it makes reports -stable and deterministic, independent of the order of input. -Otherwise you could see different numbers if you happened to write -f -options in a different order, or if you moved includes around while -cleaning up your files. -.PP -It can be surprising though; for example, it means that \f[V]alias\f[R] -directives do not affect parent or sibling files (see below). .SS \f[V]account\f[R] directive .PP \f[V]account\f[R] directives can be used to declare accounts (ie, the @@ -3339,10 +3240,10 @@ Examples: .nf \f[C] # one euro was worth $1.35 from 2009-01-01 onward: -P 2009-01-01 \[Eu] $1.35 +P 2009-01-01 € $1.35 # and $1.40 from 2010-01-01 onward: -P 2010-01-01 \[Eu] $1.40 +P 2010-01-01 € $1.40 \f[R] .fi .PP @@ -3496,26 +3397,20 @@ description, if any. .IP \[bu] 2 Don\[aq]t accidentally write two spaces in the middle of your period expression. -.SS Other syntax -.PP -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. .SS Auto postings .PP -The \f[V]=\f[R] directive declares a rule for automatically adding -temporary extra postings (visible in reports, not in the journal file) -to all transactions matched by a certain query, when you use the -\f[V]--auto\f[R] flag. +The \f[V]=\f[R] directive declares a rule for generating temporary extra +postings on transactions. +Wherever the rule matches an existing posting, it can add one or more +companion postings below that one, optionally influenced by the matched +posting\[aq]s amount. +This can be useful for generating tax postings with a standard +percentage, for example. .PP -Downsides: depending on generated data for your reports makes your -financial data less portable, less future-proof, and less trustworthy in -an audit. -Also, because the feature is optional, other features like balance -assertions can break depending on whether it is on or off. +Note that depending on generated data is not ideal for financial records +(it\[aq]s less portable, less future-proof, less auditable by others, +and less robust, since other features like balance assertions will +depend on using or not using \f[V]--auto\f[R]). .PP An auto posting rule looks a bit like a transaction: .IP @@ -3644,6 +3539,21 @@ have these tags added: .IP \[bu] 2 \f[V]_modified:\f[R] - a hidden tag not appearing in the comment; this transaction was modified \[dq]just now\[dq]. +.SS Auto postings on forecast transactions only +.PP +Tip: you can can make auto postings that will apply to forecast +transactions but not recorded transactions, by adding +\f[V]tag:_generated-transaction\f[R] to their QUERY. +This can be useful when generating new journal entries to be saved in +the journal. +.SS Other syntax +.PP +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. .SS Balance assignments .PP Ledger-style balance assignments are also supported. @@ -3694,7 +3604,7 @@ that price attached: .nf \f[C] 2019/1/1 - (a) = $1 \[at] \[Eu]2 + (a) = $1 \[at] €2 \f[R] .fi .IP @@ -3702,7 +3612,7 @@ that price attached: \f[C] $ hledger print --explicit 2019-01-01 - (a) $1 \[at] \[Eu]2 = $1 \[at] \[Eu]2 + (a) $1 \[at] €2 = $1 \[at] €2 \f[R] .fi .SS Bracketed posting dates @@ -4034,6 +3944,11 @@ The following kinds of rule can appear in the rules file, in any order. tab(@); lw(23.7n) lw(46.3n). T{ +\f[B]\f[VB]source\f[B]\f[R] +T}@T{ +optionally declare which file to read data from +T} +T{ \f[B]\f[VB]separator\f[B]\f[R] T}@T{ declare the field separator, instead of relying on file extension @@ -4106,6 +4021,47 @@ T} .PP Working with CSV tips can be found below, including How CSV rules are evaluated. +.SS \f[V]source\f[R] +.PP +If you tell hledger to read a csv file with \f[V]-f foo.csv\f[R], it +will look for rules in \f[V]foo.csv.rules\f[R]. +Or, you can tell it to read the rules file, with +\f[V]-f foo.csv.rules\f[R], and it will look for data in +\f[V]foo.csv\f[R] (since 1.30). +.PP +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 \[dq]source\[dq] +rule: +.IP +.nf +\f[C] +source ./Checking1.csv +\f[R] +.fi +.PP +If you specify just a file name with no path, hledger will look for it +in your system\[aq]s downloads directory (\f[V]\[ti]/Downloads\f[R], +currently): +.IP +.nf +\f[C] +source Checking1.csv +\f[R] +.fi +.PP +And if you specify a glob pattern, hledger will read the most recent of +the matched files (useful with repeated downloads): +.IP +.nf +\f[C] +source Checking1*.csv +\f[R] +.fi +.PP +See also \[dq]Working with CSV > Reading files specified by rule\[dq]. .SS \f[V]separator\f[R] .PP You can use the \f[V]separator\f[R] rule to read other kinds of @@ -4151,15 +4107,15 @@ skip N The word \f[V]skip\f[R] 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. -(Empty/blank lines are skipped automatically, so you don\[aq]t need to -count those.) You\[aq]ll need this whenever your CSV data contains header lines. -Header lines skipped in this way are ignored, and not parsed as CSV. +Note, empty and blank lines are skipped automatically, so you don\[aq]t +need to count those. .PP -\f[V]skip\f[R] can also be used inside if blocks (described below), to -skip individual data records. -Note records skipped in this way are still required to be valid CSV, -even though otherwise ignored. +\f[V]skip\f[R] 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. .SS \f[V]date-format\f[R] .IP .nf @@ -4497,59 +4453,103 @@ below), a default account name will be chosen (like \[dq]expenses:unknown\[dq] or \[dq]income:unknown\[dq]). .SS amount field .PP -There are several \[dq]amount\[dq] field name variants, useful for -different situations: +Amount setting can get a bit complex. +Assigning to \f[V]amount\f[R] is sufficient for simple transactions, but +there are four field name variants you can use for different situations: .IP \[bu] 2 -\f[V]amountN\f[R] sets the amount of the Nth posting, and causes that -posting to be generated. -By assigning to \f[V]amount1\f[R], \f[V]amount2\f[R], ... -etc. -you can generate up to 99 postings. -Posting numbers don\[aq]t have to be consecutive; in certain situations -using a high number might be helpful to influence the layout of -postings. +\f[B]\f[VB]amountN\f[B] sets a specific posting\[aq]s amount from one +CSV field or arbitrary value.\f[R] +.PD 0 +.P +.PD +Assigning to \f[V]amountN\f[R] sets the amount of the Nth posting - and +also causes that posting to be generated. +N is most often 1 or 2 but can go up to 99, potentially generating a +99-posting transaction. +(Posting numbers don\[aq]t have to be consecutive; higher posting +numbers can sometimes be useful with conditional rules, to ensure a +certain ordering of postings.) .IP \[bu] 2 -\f[V]amountN-in\f[R] and \f[V]amountN-out\f[R] should be used instead, -as a pair, when and only when the amount must be obtained from two CSV -fields. -Eg when the CSV has separate Debit and Credit fields instead of a single -Amount field. -Note: +\f[B]\f[VB]amountN-in/-out\f[B] sets a specific posting\[aq]s amount +from two CSV fields.\f[R] +.PD 0 +.P +.PD +When the amount is provided as two CSV fields - +\[dq]Debit\[dq]/\[dq]Credit\[dq], +\[dq]Deposit\[dq]/\[dq]Withdrawal\[dq], \[dq]Money In\[dq]/\[dq]Money +Out\[dq] or similar - assign those fields to \f[V]amountN-in\f[R] and +\f[V]amountN-out\f[R] respectively (or possibly the other way round, +depending on signs). +This will set the Nth posting\[aq]s amount to whichever of the two CSV +field values is non-zero. +Some notes: .RS 2 .IP \[bu] 2 -Don\[aq]t think \[dq]-in is for the first posting and -out is for the -second posting\[dq] - that\[aq]s not correct. -Think: \[dq]\f[V]amountN-in\f[R] and \f[V]amountN-out\f[R] together -detect the amount for posting N, by inspecting two CSV fields at -once.\[dq] +Don\[aq]t mix \f[V]amountN\f[R] and \f[V]amountN-in\f[R]/\f[V]-out\f[R]. +When you have one CSV amount field, use \f[V]amountN\f[R]. +When you have two CSV amount fields, use +\f[V]amountN-in\f[R]/\f[V]amountN-out\f[R]. .IP \[bu] 2 -hledger assumes both CSV fields are unsigned, and will automatically -negate the -out value. +\f[V]amountN-in\f[R] and \f[V]amountN-out\f[R] are always used together, +as a pair. +Assign to both of them. .IP \[bu] 2 -It also expects that at least one of the values is empty or zero, so it -knows which one to ignore. -If that\[aq]s not the case you\[aq]ll need an if rule (see Setting -amounts below). -.RE +They do not generate two separate postings; rather, they generate the +Nth posting\[aq]s single amount, from the value found in one or other of +the two CSV fields. .IP \[bu] 2 -\f[V]amount\f[R], with no posting number (and similarly, -\f[V]amount-in\f[R] and \f[V]amount-out\f[R] with no number) are an -older syntax. -We keep them for backwards compatibility, and because they have special -behaviour that is sometimes convenient: -.RS 2 +In each record, at least one of the two CSV fields must contain a zero +amount or be empty. .IP \[bu] 2 -They set the amount of posting 1 and (negated) the amount of posting 2. +hledger assumes the two CSV fields contain unsigned numbers, and it will +automatically negate the -out amount. .IP \[bu] 2 -Posting 2\[aq]s amount will be converted to cost if it has a cost price. -.IP \[bu] 2 -Any of the newer rules for posting 1 or 2 (like \f[V]amount1\f[R], or -\f[V]amount2-in\f[R] and \f[V]amount2-out\f[R]) will take precedence. -This allows incrementally migrating old rules files to the new syntax. +This variant can be convenient, but it doesn\[aq]t handle every +two-amount-field situation; if you need more flexibility, use an +\f[V]if\f[R] rule (see \[dq]Setting amounts\[dq] below). .RE .PP -There\[aq]s more to say about amount-setting that doesn\[aq]t fit here; -please see also \[dq]Setting amounts\[dq] below. +The other two variants are older and considered legacy syntax, but can +still be convenient sometimes: +.IP \[bu] 2 +\f[B]\f[VB]amount\f[B] sets posting 1 and 2\[aq]s amounts from one CSV +field or value.\f[R] +.PD 0 +.P +.PD +Assigning to \f[V]amount\f[R], with no posting number, +.RS 2 +.IP \[bu] 2 +sets posting 1\[aq]s amount (like \f[V]amount1\f[R]) +.IP \[bu] 2 +sets posting 2\[aq]s amount to the same amount but with opposite sign; +and also converts it to cost if it has a cost price +.IP \[bu] 2 +can be overridden by \f[V]amount1\f[R] and/or \f[V]amount2\f[R] +assignments. +(This helps with incremental migration of old rules files to the newer +syntax.) +.RE +.IP \[bu] 2 +\f[B]\f[VB]amount-in/-out\f[B] sets posting 1 and 2\[aq]s amounts from +two CSV fields.\f[R] +.PD 0 +.P +.PD +Assigning \f[V]amount-in\f[R] and \f[V]amount-out\f[R], with no posting +numbers, to two CSV fields reads whichever of the two values is non-zero +as the amount, and then sets the first two posting amounts as above. +.PP +We recommend using only one of these variants within a rules file, +rather than mixing them. +And remember that a \f[V]fields\f[R] list can also do assignments, so eg +naming a CSV field \[dq]amount\[dq] counts as an assignment to +\f[V]amount\f[R]; if you don\[aq]t want that, call it something else, +like \[dq]amount_\[dq]. +.PP +In addition to this section, please see also the tips beginning at +\[dq]Working with CSV > Setting amounts\[dq] below. .SS currency field .PP \f[V]currency\f[R] sets a currency symbol, to be prepended to all @@ -4896,6 +4896,32 @@ once, hledger will look for a correspondingly-named rules file for each CSV file. But if you use the \f[V]--rules-file\f[R] option, that rules file will be used for all the CSV files. +.SS Reading files specified by rule +.PP +Instead of specifying a CSV file in the command line, you can specify a +rules file, as in \f[V]hledger -f foo.csv.rules CMD\f[R]. +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\[aq]s download directory. +.PP +This feature was added in hledger 1.30, so you won\[aq]t see it in most +CSV rules examples. +But it helps remove some of the busywork of managing CSV downloads. +Most of your financial institutions\[aq]s default CSV filenames are +different and can be recognised by a glob pattern. +So you can put a rule like \f[V]source Checking1*.csv\f[R] in +foo-checking.csv.rules, and then periodically follow a workflow like: +.IP "1." 3 +Download CSV from Foo\[aq]s website, using your browser\[aq]s defaults +.IP "2." 3 +Run \f[V]hledger import foo-checking.csv.rules\f[R] to import any new +transactions +.PP +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 nothing, next time your browser will save something like +Checking1-2.csv, and hledger will use that because of the \f[V]*\f[R] +wild card and because it is the most recent. .SS Valid transactions .PP After reading a CSV file, hledger post-processes and validates the @@ -5059,8 +5085,10 @@ In this situation hledger is more likely to guess the wrong default account name, so you may need to set that explicitly. .SS Amount signs .PP -There is some special handling for amount signs, to simplify parsing and -sign-flipping: +There is some special handling making it easier to parse and to reverse +amount signs. +(This only works for whole amounts, not for cost amounts such as COST in +\f[V]amount1 AMT \[at] COST\f[R]): .IP \[bu] 2 \f[B]If an amount value begins with a plus sign:\f[R] .PD 0 @@ -5091,6 +5119,9 @@ parentheses):\f[R] that is removed, making it an empty value. \f[V]\[dq]+\[dq]\f[R] or \f[V]\[dq]-\[dq]\f[R] or \f[V]\[dq]()\[dq]\f[R] becomes \f[V]\[dq]\[dq]\f[R]. +.PP +It\[aq]s not possible (without preprocessing the CSV) to set an amount +to its absolute value, ie discard its sign. .SS Setting currency/commodity .PP If the currency/commodity symbol is included in the CSV\[aq]s amount @@ -5623,9 +5654,9 @@ blank lines, are ignored. .IP .nf \f[C] -i 2015/03/30 09:00:00 some:account name optional description after two spaces +i 2015/03/30 09:00:00 some account optional description after 2 spaces ; optional comment, tags: o 2015/03/30 09:20:00 -i 2015/03/31 22:21:45 another account +i 2015/03/31 22:21:45 another:account o 2015/04/01 02:00:34 \f[R] .fi @@ -5640,14 +5671,14 @@ entries: .nf \f[C] $ hledger -f t.timeclock print -2015-03-30 * optional description after two spaces - (some:account name) 0.33h +2015-03-30 * optional description after 2 spaces ; optional comment, tags: + (some account) 0.33h 2015-03-31 * 22:21-23:59 - (another account) 1.64h + (another:account) 1.64h 2015-04-01 * 00:00-02:00 - (another account) 2.01h + (another:account) 2.01h \f[R] .fi .PP @@ -5689,80 +5720,72 @@ this: .IP .nf \f[C] -2021-08-04 -hom:errands .... .... -fos:hledger:timedot .. ; docs -per:admin:finance +2023-05-01 +hom:errands .... .... ; two hours +fos:hledger:timedot .. ; half an hour +per:admin:finance \f[R] .fi .PP -hledger reads this as three time transactions on this day, with each dot -representing a quarter-hour spent: +hledger reads this as a transaction on this day with three (unbalanced) +postings, where each dot represents \[dq]0.25\[dq]. +No commodity is assumed, but normally we interpret it as hours, with +each dot representing a quarter-hour. +It\[aq]s convenient, though not required, to group the dots in fours for +easy reading. .IP .nf \f[C] -$ hledger -f a.timedot print # .timedot file extension activates the timedot reader -2021-08-04 * - (hom:errands) 2.00 - -2021-08-04 * - (fos:hledger:timedot) 0.50 - -2021-08-04 * - (per:admin:finance) 0 +$ hledger -f a.timedot print # .timedot file extension (or timedot: prefix) is required +2023-05-01 * + (hom:errands) 2.00 ; two hours + (fos:hledger:timedot) 0.50 ; half an hour + (per:admin:finance) 0 \f[R] .fi .PP -A day entry begins with a date line: -.IP \[bu] 2 -a non-indented \f[B]simple date\f[R] (Y-M-D, Y/M/D, or Y.M.D). +A transaction begins with a non-indented \f[B]simple date\f[R] (Y-M-D, +Y/M/D, or Y.M.D). +It can optionally be preceded by one or more stars and a space, for +Emacs org mode compatibility. +It can optionally be followed on the same line by a transaction +description, and/or a transaction comment following a semicolon. .PP -Optionally this can be followed on the same line by +After the date line are zero or more time postings, consisting of: .IP \[bu] 2 -a common \f[B]transaction description\f[R] for this day -.IP \[bu] 2 -a common \f[B]transaction comment\f[R] for this day, after a semicolon -(\f[V];\f[R]). -.PP -After the date line are zero or more optionally-indented time -transaction lines, consisting of: -.IP \[bu] 2 -an \f[B]account name\f[R] - any word or phrase, usually a hledger-style -account name. +an \f[B]account name\f[R] - any hledger-style account name, optionally +hierarchical, optionally indented. .IP \[bu] 2 \f[B]two or more spaces\f[R] - a field separator, required if there is an amount (as in journal format). .IP \[bu] 2 -a \f[B]timedot amount\f[R] - dots representing quarter hours, or a -number representing hours. +an optional \f[B]timedot amount\f[R] - dots representing quarter hours, +or a number representing hours, optionally with a unit suffix. .IP \[bu] 2 -an optional \f[B]comment\f[R] beginning with semicolon. -This is ignored. +an optional \f[B]posting comment\f[R] following a semicolon. .PP -In more detail, timedot amounts can be: +Timedot amounts can be: .IP \[bu] 2 -\f[B]dots\f[R]: zero or more period characters, each representing one -quarter-hour. +\f[B]dots\f[R]: zero or more period characters (\f[V].\f[R]), each +representing 0.25. Spaces are ignored and can be used for grouping. Eg: \f[V].... ..\f[R] .IP \[bu] 2 -a \f[B]number\f[R], representing hours. +or a \f[B]number\f[R]. Eg: \f[V]1.5\f[R] .IP \[bu] 2 -a \f[B]number immediately followed by a unit symbol\f[R] \f[V]s\f[R], +or a \f[B]number immediately followed by a unit symbol\f[R] \f[V]s\f[R], \f[V]m\f[R], \f[V]h\f[R], \f[V]d\f[R], \f[V]w\f[R], \f[V]mo\f[R], or -\f[V]y\f[R], representing seconds, minutes, hours, days weeks, months or -years. -Eg \f[V]1.5h\f[R] or \f[V]90m\f[R]. -The following equivalencies are assumed: +\f[V]y\f[R]. +These are interpreted as seconds, minutes, hours, days weeks, months or +years, and converted to hours, assuming: .PD 0 .P .PD \f[V]60s\f[R] = \f[V]1m\f[R], \f[V]60m\f[R] = \f[V]1h\f[R], \f[V]24h\f[R] = \f[V]1d\f[R], \f[V]7d\f[R] = \f[V]1w\f[R], \f[V]30d\f[R] = \f[V]1mo\f[R], \f[V]365d\f[R] = \f[V]1y\f[R]. -(This unit will not be visible in the generated transaction amount, -which is always in hours.) +Eg \f[V]90m\f[R] is parsed as \f[V]1.5\f[R]. .PP There is some added flexibility to help with keeping time log data in the same file as your notes, todo lists, etc.: @@ -5772,15 +5795,17 @@ ignored. .IP \[bu] 2 Before the first date line, lines beginning with \f[V]*\f[R] are ignored. -From the first date line onward, a sequence of \f[V]*\f[R]\[aq]s -followed by a space at beginning of lines (ie, the headline prefix used -by Emacs Org mode) is ignored. +.IP \[bu] 2 +From the first date line onward, one or more \f[V]*\f[R]\[aq]s followed +by a space at beginning of lines (ie, the headline prefix used by Emacs +Org mode) is ignored. This means the time log can be kept under an Org headline, and date lines or time transaction lines can be Org headlines. .IP \[bu] 2 -Lines not ending with a double-space and amount are parsed as -transactions with zero amount. -(Most hledger reports hide these by default; add -E to see them.) +Lines not ending with a double-space and amount are parsed as postings +with zero amount. +Note hledger\[aq]s register reports hide these by default (add -E to see +them). .PP More examples: .IP @@ -6752,97 +6777,235 @@ $ hledger balance --pivot member acct:. .fi .SH Generating data .PP -Two features for generating transient data (visible only at report time) -are built in to hledger\[aq]s journal format: +hledger has several features for generating data, such as: .IP \[bu] 2 -Auto posting rules can generate extra postings on certain transactions. -They are activated by the \f[V]--auto\f[R] flag. +Periodic transaction rules can generate single or repeating transactions +following a template. +These are usually dated in the future, eg to help with forecasting. +They are activated by the \f[V]--forecast\f[R] option. .IP \[bu] 2 -Periodic transaction rules can generate repeating transactions, usually -dated in the future, to help with forecasting or budgeting. -They are activated by the \f[V]--forecast\f[R] or -\f[V]balance --budget\f[R] options, described next. +The balance command\[aq]s \f[V]--budget\f[R] option uses these same +periodic rules to generate goals for the budget report. +.IP \[bu] 2 +Auto posting rules can generate extra postings on certain matched +transactions. +They are always applied to forecast transactions; with the +\f[V]--auto\f[R] flag they are applied to transactions recorded in the +journal as well. +.IP \[bu] 2 +The \f[V]--infer-equity\f[R] flag infers missing conversion equity +postings from \[at]/\[at]\[at] costs. +And the inverse \f[V]--infer-costs\f[R] flag infers missing +\[at]/\[at]\[at] costs from conversion equity postings. +.PP +Generated data of this kind is temporary, existing only at report time. +But you can see it in the output of \f[V]hledger print\f[R], and you can +save that to your journal, in effect converting it from temporary +generated data to permanent recorded data. +This could be useful as a data entry aid. +.PP +If you are wondering what data is being generated and why, add the +\f[V]--verbose-tags\f[R] flag. +In \f[V]hledger print\f[R] output you will see extra tags like +\f[V]generated-transaction\f[R], \f[V]generated-posting\f[R], and +\f[V]modified\f[R] on generated/modified data. +Also, even without \f[V]--verbose-tags\f[R], generated data always has +equivalen hidden tags (with an underscore prefix), so eg you could match +generated transactions with \f[V]tag:_generated-transaction\f[R]. .SH Forecasting .PP -The \f[V]--forecast\f[R] flag activates any periodic transaction rules -in the journal. -These will generate temporary additional transactions, usually recurring -and in the future, which will appear in all reports. -\f[V]hledger print --forecast\f[R] is a good way to see them. +Forecasting, or speculative future reporting, can be useful for +estimating future balances, or for exploring different future scenarios. .PP -This can be useful for estimating balances into the future, perhaps -experimenting with different 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 \f[V]future.journal\f[R] and include +that with \f[V]-f\f[R] only when you want to see them. +.SS --forecast .PP -It could also be useful for scripted data entry: you could describe -recurring transactions, and every so often copy the output of -\f[V]print --forecast\f[R] into the journal. +There is another way: with the \f[V]--forecast\f[R] option, hledger can +generate temporary \[dq]forecast transactions\[dq] for reporting +purposes, according to periodic transaction rules defined in the +journal. +Each rule can generate multiple recurring transactions, so by changing +one rule you can change many forecasted transactions. +(These same rules can also generate budget goals, described in +Budgeting.) .PP -The generated transactions will have an extra tag, like -\f[V]generated-transaction:\[ti] PERIODICEXPR\f[R], indicating which -periodic rule generated them. -There is also a similar, hidden tag, named -\f[V]_generated-transaction:\f[R], which you can use to reliably match -transactions generated \[dq]just now\[dq] (rather than \f[V]print\f[R]ed -in the past). +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 exact rules are a little more complicated, and are given below.) .PP -The forecast transactions are generated within a \f[I]forecast -period\f[R], which is independent of the report period. -(Forecast period sets the bounds for generated transactions, report -period controls which transactions are reported.) -The forecast period begins on: +This is the \[dq]forecast period\[dq], which need not be the same as the +report 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 +\f[V]--forecast=..2099\f[R] or \f[V]--forecast=2023-02-15..\f[R]. +Note that the \f[V]=\f[R] is required. +.SS Inspecting forecast transactions +.PP +\f[V]print\f[R] is the best command for inspecting and troubleshooting +forecast transactions. +Eg: +.IP +.nf +\f[C] +\[ti] monthly from 2022-12-20 rent + assets:bank:checking + expenses:rent $1000 +\f[R] +.fi +.IP +.nf +\f[C] +$ hledger print --forecast --today=2023/4/21 +2023-05-20 rent + ; generated-transaction: \[ti] monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 + +2023-06-20 rent + ; generated-transaction: \[ti] monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 + +2023-07-20 rent + ; generated-transaction: \[ti] monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 + +2023-08-20 rent + ; generated-transaction: \[ti] monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 + +2023-09-20 rent + ; generated-transaction: \[ti] monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 +\f[R] +.fi +.PP +Here there are no ordinary transactions, so the forecasted transactions +begin on the first occurence after today\[aq]s date. +(You won\[aq]t normally use \f[V]--today\f[R]; it\[aq]s just to make +these examples reproducible.) +.SS Forecast reports +.PP +Forecast transactions affect all reports, as you would expect. +Eg: +.IP +.nf +\f[C] +$ hledger areg rent --forecast --today=2023/4/21 +Transactions in expenses:rent and subaccounts: +2023-05-20 rent as:ba:checking $1000 $1000 +2023-06-20 rent as:ba:checking $1000 $2000 +2023-07-20 rent as:ba:checking $1000 $3000 +2023-08-20 rent as:ba:checking $1000 $4000 +2023-09-20 rent as:ba:checking $1000 $5000 +\f[R] +.fi +.IP +.nf +\f[C] +$ hledger bal -M expenses --forecast --today=2023/4/21 +Balance changes in 2023-05-01..2023-09-30: + + || May Jun Jul Aug Sep +===============++=================================== + expenses:rent || $1000 $1000 $1000 $1000 $1000 +---------------++----------------------------------- + || $1000 $1000 $1000 $1000 $1000 +\f[R] +.fi +.SS Forecast tags +.PP +Forecast transactions generated by --forecast have a hidden tag, +\f[V]_generated-transaction\f[R]. +So if you ever need to match forecast transactions, you could use +\f[V]tag:_generated-transaction\f[R] (or just \f[V]tag:generated\f[R]) +in a query. +.PP +For troubleshooting, you can add the \f[V]--verbose-tags\f[R] flag. +Then, visible \f[V]generated-transaction\f[R] tags will be added also, +so you can view them with the \f[V]print\f[R] command. +Their value indicates which periodic rule was responsible. +.SS Forecast period, in detail +.PP +Forecast start/end dates are chosen so as to do something useful by +default in almost all situations, while also being flexible. +Here are (with luck) the exact rules, to help with troubleshooting: +.PP +The forecast period starts on: .IP \[bu] 2 -the start date provided within \f[V]--forecast\f[R]\[aq]s argument, if -any -.IP \[bu] 2 -otherwise, the later of +the later of .RS 2 .IP \[bu] 2 -the report start date, if specified (with -\f[V]-b\f[R]/\f[V]-p\f[R]/\f[V]date:\f[R]) +the start date in the periodic transaction rule .IP \[bu] 2 -the day after the latest ordinary transaction in the journal, if any +the start date in \f[V]--forecast\f[R]\[aq]s argument .RE .IP \[bu] 2 -otherwise today. -.PP -It ends on: -.IP \[bu] 2 -the end date provided within \f[V]--forecast\f[R]\[aq]s argument, if any -.IP \[bu] 2 -otherwise, the report end date, if specified (with -\f[V]-e\f[R]/\f[V]-p\f[R]/\f[V]date:\f[R]) -.IP \[bu] 2 -otherwise 180 days (6 months) from today. -.PP -Note, this means that ordinary transactions will suppress periodic -transactions, by default; the periodic transactions will not start until -after the last ordinary transaction. -This is usually convenient, but you can get around it in two ways: -.IP \[bu] 2 -If you need to record some transactions in the future, make them -periodic transactions (with a single occurrence, eg: -\f[V]\[ti] YYYY-MM-DD\f[R]) rather than ordinary transactions. -That way they won\[aq]t suppress other periodic transactions. -.IP \[bu] 2 -Or give \f[V]--forecast\f[R] a period expression argument. -A forecast period specified this way can overlap ordinary transactions, -and need not be in the future. -Some things to note: +otherwise (if those are not available): the later of .RS 2 .IP \[bu] 2 -You must use \f[V]=\f[R] between flag and argument; a space won\[aq]t -work. +the report start date specified with +\f[V]-b\f[R]/\f[V]-p\f[R]/\f[V]date:\f[R] .IP \[bu] 2 -The period expression can specify the forecast period\[aq]s start date, -end date, or both. -See also Report start & end date. -.IP \[bu] 2 -The period expression should not specify a report interval. -(Each periodic transaction rule specifies its own interval.) +the day after the latest ordinary transaction in the journal .RE +.IP \[bu] 2 +otherwise (if none of these are available): today. .PP -Some examples: \f[V]--forecast=202001-202004\f[R], -\f[V]--forecast=jan-\f[R], \f[V]--forecast=2021\f[R]. +The forecast period ends on: +.IP \[bu] 2 +the earlier of +.RS 2 +.IP \[bu] 2 +the end date in the periodic transaction rule +.IP \[bu] 2 +the end date in \f[V]--forecast\f[R]\[aq]s argument +.RE +.IP \[bu] 2 +otherwise: the report end date specified with +\f[V]-e\f[R]/\f[V]-p\f[R]/\f[V]date:\f[R] +.IP \[bu] 2 +otherwise: 180 days (\[ti]6 months) from today. +.SS Forecast troubleshooting +.PP +When --forecast is not doing what you expect, one of these tips should +help: +.IP \[bu] 2 +Remember to use the \f[V]--forecast\f[R] option. +.IP \[bu] 2 +Remember to have at least one periodic transaction rule in your journal. +.IP \[bu] 2 +Test with \f[V]print --forecast\f[R]. +.IP \[bu] 2 +Check for typos or too-restrictive start/end dates in your periodic +transaction rule. +.IP \[bu] 2 +Leave at least 2 spaces between the rule\[aq]s period expression and +description fields. +.IP \[bu] 2 +Check for future-dated ordinary transactions suppressing forecasted +transactions. +.IP \[bu] 2 +Try setting explicit report start and/or end dates with \f[V]-b\f[R], +\f[V]-e\f[R], \f[V]-p\f[R] or \f[V]date:\f[R] +.IP \[bu] 2 +Try adding the \f[V]-E\f[R] flag to encourage display of empty +periods/zero transactions. +.IP \[bu] 2 +Try setting explicit forecast start and/or end dates with +\f[V]--forecast=START..END\f[R] +.IP \[bu] 2 +Consult Forecast period, in detail, above. +.IP \[bu] 2 +Check inside the engine: add \f[V]--debug=2\f[R] (eg). .SH Budgeting .PP With the balance command\[aq]s \f[V]--budget\f[R] report, each periodic @@ -6850,6 +7013,10 @@ transaction rule generates recurring budget goals in specified accounts, and goals and actual performance can be compared. See the balance command\[aq]s doc below. .PP +You can generate budget goals and forecast transactions at the same +time, from the same or different periodic transaction rules: +\f[V]hledger bal -M --budget --forecast ...\f[R] +.PP See also: Budgeting and Forecasting. .SH Cost reporting .PP @@ -6889,7 +7056,7 @@ Eg: \f[C] 2022-01-01 assets:dollars $-135 ; 135 dollars is exchanged for.. - assets:euros \[Eu]100 \[at] $1.35 ; one hundred euros purchased at $1.35 each + assets:euros €100 \[at] $1.35 ; one hundred euros purchased at $1.35 each \f[R] .fi .IP @@ -6897,7 +7064,7 @@ Eg: \f[C] $ hledger bal -N $-135 assets:dollars - \[Eu]100 assets:euros + €100 assets:euros $ hledger bal -N -B $-135 assets:dollars $135 assets:euros # <- the euros\[aq] cost @@ -6915,15 +7082,15 @@ equivalent, -B shows something different: \f[C] 2022-01-01 assets:dollars $-135 ; 135 dollars sold - assets:euros \[Eu]100 ; for 100 euros + assets:euros €100 ; for 100 euros \f[R] .fi .IP .nf \f[C] $ hledger bal -N -B - \[Eu]-100 assets:dollars # <- the dollars\[aq] selling price - \[Eu]100 assets:euros + €-100 assets:dollars # <- the dollars\[aq] selling price + €100 assets:euros \f[R] .fi .PP @@ -6943,8 +7110,8 @@ In this style, the above entry might be written: 2022-01-01 one hundred euros purchased at $1.35 each assets:dollars $-135 equity:conversion $135 - equity:conversion \[Eu]-100 - assets:euros \[Eu]100 + equity:conversion €-100 + assets:euros €100 \f[R] .fi .PP @@ -6968,7 +7135,7 @@ PTA cost notation and adds equity conversion postings to them: \f[C] 2022-01-01 assets:dollars -$135 - assets:euros \[Eu]100 \[at] $1.35 + assets:euros €100 \[at] $1.35 \f[R] .fi .IP @@ -6977,9 +7144,9 @@ PTA cost notation and adds equity conversion postings to them: $ hledger print --infer-equity 2022-01-01 assets:dollars $-135 - assets:euros \[Eu]100 \[at] $1.35 - equity:conversion:$-\[Eu]:\[Eu] \[Eu]-100 ; generated-posting: - equity:conversion:$-\[Eu]:$ $135.00 ; generated-posting: + assets:euros €100 \[at] $1.35 + equity:conversion:$-€:€ €-100 ; generated-posting: + equity:conversion:$-€:$ $135.00 ; generated-posting: \f[R] .fi .PP @@ -7001,8 +7168,8 @@ cost notation to them: 2022-01-01 assets:dollars $-135 equity:conversion $135 - equity:conversion \[Eu]-100 - assets:euros \[Eu]100 + equity:conversion €-100 + assets:euros €100 \f[R] .fi .IP @@ -7010,10 +7177,10 @@ cost notation to them: \f[C] $ hledger print --infer-costs 2022-01-01 - assets:dollars $-135 \[at]\[at] \[Eu]100 + assets:dollars $-135 \[at]\[at] €100 equity:conversion $135 - equity:conversion \[Eu]-100 - assets:euros \[Eu]100 + equity:conversion €-100 + assets:euros €100 \f[R] .fi .PP @@ -7025,8 +7192,8 @@ postings: \f[C] $ hledger print --infer-costs -B 2009-01-01 - assets:dollars \[Eu]-100 - assets:euros \[Eu]100 + assets:dollars €-100 + assets:euros €100 \f[R] .fi .PP @@ -7426,15 +7593,15 @@ Here are some quick examples of \f[V]-V\f[R]: .nf \f[C] ; one euro is worth this many dollars from nov 1 -P 2016/11/01 \[Eu] $1.10 +P 2016/11/01 € $1.10 ; purchase some euros on nov 3 2016/11/3 - assets:euros \[Eu]100 + assets:euros €100 assets:checking ; the euro is worth fewer dollars by dec 21 -P 2016/12/21 \[Eu] $1.03 +P 2016/12/21 € $1.03 \f[R] .fi .PP @@ -7443,7 +7610,7 @@ How many euros do I have ? .nf \f[C] $ hledger -f t.j bal -N euros - \[Eu]100 assets:euros + €100 assets:euros \f[R] .fi .PP @@ -8414,6 +8581,8 @@ or value of balance changes (\f[V]-V\f[R]) or change of balance values (\f[V]--valuechange\f[R]) .IP \[bu] 2 or unrealised capital gain/loss (\f[V]--gain\f[R]) +.IP \[bu] 2 +or postings count (\f[V]--count\f[R]) .PP \&..in.. .IP \[bu] 2 @@ -8743,7 +8912,7 @@ them to one commodity with \f[V]-B\f[R], \f[V]-V\f[R], \f[V]-X\f[R] or .nf \f[C] $ hledger bal -% cur:\[rs]\[rs]$ -$ hledger bal -% cur:\[Eu] +$ hledger bal -% cur:€ \f[R] .fi .SS Multi-period balance report @@ -8859,8 +9028,8 @@ postings.) The balance command is quite flexible; here is the full detail on how to control what it reports. If the following seems complicated, don\[aq]t worry - this is for -advanced reporting, and it does typically take some time and -experimentation to get clear on all these report modes. +advanced reporting, and it does take time and experimentation to get +familiar with all the report modes. .PP There are three important option groups: .PP @@ -8881,6 +9050,8 @@ fluctuations) .IP \[bu] 2 \f[V]--gain\f[R] : show the unrealised capital gain/loss, (the current valued balance minus each amount\[aq]s original cost) +.IP \[bu] 2 +\f[V]--count\f[R] : show the count of postings .SS Accumulation type .PP How amounts should accumulate across report periods. @@ -9070,21 +9241,21 @@ Budget performance in 2017/11/01-2017/12/31: \f[R] .fi .PP -This is different from a normal balance report in several ways: +This is different from a normal balance report in several ways. +Currently: .IP \[bu] 2 -Only accounts with budget goals during the report period are shown, by -default. +Accounts with budget goals during the report period, and their parents, +are shown. .IP \[bu] 2 -In each column, in square brackets after the actual amount, budget goal -amounts are shown, and the actual/goal percentage. -(Note: budget goals should be in the same commodity as the actual -amount.) +Their subaccounts are not shown (regardless of the depth setting). .IP \[bu] 2 -All parent accounts are always shown, even in list mode. -Eg assets, assets:bank, and expenses above. +Accounts without budget goals, if any, are aggregated and shown as +\[dq]\[dq]. .IP \[bu] 2 -Amounts always include all subaccounts, budgeted or unbudgeted, even in -list mode. +Amounts are always inclusive (subaccount-including), even in list mode. +.IP \[bu] 2 +After each actual amount, the corresponding goal amount and percentage +of goal reached are also shown, in square brackets. .PP This means that the numbers displayed will not always add up! Eg above, the \f[V]expenses\f[R] actual amount includes the gifts and @@ -11836,12 +12007,101 @@ See the close command. .PP If using version control, don\[aq]t forget to \f[V]git add\f[R] the new file. +.SH BUGS +.PP +We welcome bug reports in the hledger issue tracker (shortcut: +http://bugs.hledger.org), or on the #hledger chat or hledger mail list +(https://hledger.org/support). +.PP +Some known issues and limitations: +.PP +The need to precede add-on command options with \f[V]--\f[R] when +invoked from hledger is awkward. +(See Command options, Constructing command lines.) +.PP +A UTF-8-aware system locale must be configured to work with non-ascii +data. +(See Unicode characters, Troubleshooting.) +.PP +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 \f[V]hledger add\f[R]. +(Running in a WSL window should resolve these.) +.PP +When processing large data files, hledger uses more memory than Ledger. +.SS Troubleshooting +.PP +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): +.PP +\f[B]PATH issues: I get an error like \[dq]No command \[aq]hledger\[aq] +found\[dq]\f[R] +.PD 0 +.P +.PD +Depending how you installed hledger, the executables may not be in your +shell\[aq]s PATH. +Eg on unix systems, stack installs hledger in \f[V]\[ti]/.local/bin\f[R] +and cabal installs it in \f[V]\[ti]/.cabal/bin\f[R]. +You may need to add one of these directories to your shell\[aq]s PATH, +and/or open a new terminal window. +.PP +\f[B]LEDGER_FILE issues: I configured LEDGER_FILE but hledger is not +using it\f[R] +.PD 0 +.P +.PD +.IP \[bu] 2 +\f[V]LEDGER_FILE\f[R] should be a real environment variable, not just a +shell variable. +Eg on unix, the command \f[V]env | grep LEDGER_FILE\f[R] should show it. +You may need to use \f[V]export\f[R] (see +https://stackoverflow.com/a/7411509). +.IP \[bu] 2 +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. +.PP +\f[B]LANG issues: I get errors like \[dq]Illegal byte sequence\[dq] or +\[dq]Invalid or incomplete multibyte or wide character\[dq] or +\[dq]commitAndReleaseBuffer: invalid argument (invalid +character)\[dq]\f[R] +.PD 0 +.P +.PD +Programs compiled with GHC (hledger, haskell build tools, etc.) +need the system locale to be UTF-8-aware, or they will fail when they +encounter 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. +.PP +On unix, \f[V]locale -a\f[R] lists the installed locales. +Look for one which mentions \f[V]utf8\f[R], \f[V]UTF-8\f[R] or similar. +Some examples: \f[V]C.UTF-8\f[R], \f[V]en_US.utf-8\f[R], +\f[V]fr_FR.utf8\f[R]. +If necessary, use your system package manager to install one. +Then select it by setting the \f[V]LANG\f[R] environment variable. +Note, exact spelling and capitalisation of the locale name may be +important: Here\[aq]s one common way to configure this permanently for +your shell: +.IP +.nf +\f[C] +$ echo \[dq]export LANG=en_US.utf8\[dq] >>\[ti]/.profile +# close and re-open terminal window +\f[R] +.fi +.PP +\f[B]COMPATIBILITY ISSUES: hledger gives an error with my Ledger +file\f[R] +.PD 0 +.P +.PD +Not all of Ledger\[aq]s journal file syntax or feature set is supported. +See hledger and Ledger for full details. -.SH "REPORTING BUGS" -Report bugs at http://bugs.hledger.org -(or on the #hledger chat or hledger mail list) - .SH AUTHORS Simon Michael and contributors. .br diff --git a/hledger/hledger.info b/hledger/hledger.info index 344b502fe..fd27f4459 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -40,14 +40,13 @@ useful report on the terminal (or save it as HTML, CSV, JSON or SQL). Many reports are available, as subcommands. hledger will also detect other 'hledger-*' executables as extra subcommands. - hledger reads data from one or more files in journal, timeclock, -timedot, or CSV format. The default file is '.hledger.journal' in your -home directory; this can be overridden with one or more '-f FILE' -options, or the 'LEDGER_FILE' environment variable. hledger CLI can -also read from stdin with '-f-'; more on that below. + hledger usually reads from (and appends to) a journal file specified +by the 'LEDGER_FILE' environment variable (defaulting to +'$HOME/.hledger.journal'); or you can specify files with '-f' options. +It can also read timeclock files, timedot files, or any CSV/SSV/TSV file +with a date field. - Here is a small but valid hledger journal file describing one -transaction: + Here is a small journal file describing one transaction: 2015-10-16 bought food expenses:food $10 @@ -82,13 +81,11 @@ file" and "Setting opening balances" sections in PART 5: COMMON TASKS. * Menu: * PART 1 USER INTERFACE:: -* Options:: -* Environment:: * Input:: +* Environment:: +* Options:: * Commands:: * Output:: -* Limitations:: -* Troubleshooting:: * PART 2 DATA FORMATS:: * Journal:: * CSV:: @@ -106,22 +103,214 @@ file" and "Setting opening balances" sections in PART 5: COMMON TASKS. * Valuation:: * PART 4 COMMANDS:: * PART 5 COMMON TASKS:: +* BUGS::  -File: hledger.info, Node: PART 1 USER INTERFACE, Next: Options, Prev: Top, Up: Top +File: hledger.info, Node: PART 1 USER INTERFACE, Next: Input, Prev: Top, Up: Top 1 PART 1: USER INTERFACE ************************  -File: hledger.info, Node: Options, Next: Environment, Prev: PART 1 USER INTERFACE, Up: Top +File: hledger.info, Node: Input, Next: Environment, Prev: PART 1 USER INTERFACE, Up: Top -2 Options +2 Input +******* + +hledger reads one or more data files, each time you run it. You can +specify a file with '-f', like so + +$ hledger -f FILE print + + Files are most often in hledger's journal format, with the '.journal' +file extension ('.hledger' or '.j' also work); these files describe +transactions, like an accounting general journal. Some other supported +file formats are discussed below. + + When no '-f' option is given, hledger looks for the file specified by +the 'LEDGER_FILE' environment variable; if this is not set, it uses +'.hledger.journal' in your home directory. + + Most people prefer to keep financial files in a dedicated folder, +perhaps with version control. Also, starting a new journal file per +year is common (it's not required, but helps keep things fast and +organised). So we usually set 'LEDGER_FILE', to something like +'~/finance/2023.journal'. + +* Menu: + +* Setting LEDGER_FILE:: +* Data formats:: +* Standard input:: +* Multiple files:: +* Strict mode:: + + +File: hledger.info, Node: Setting LEDGER_FILE, Next: Data formats, Up: Input + +2.1 Setting LEDGER_FILE +======================= + +How to set 'LEDGER_FILE' permanently depends on your platform: + + On unix and mac, running these commands in the terminal will work for +many people; adapt as needed: + +$ mkdir -p ~/finance +$ echo 'export LEDGER_FILE=~/finance/2023.journal` >> ~/.profile +$ source ~/.profile + + 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/environment.plist' like + +{ + "LEDGER_FILE" : "~/finance/2023.journal" +} + + and then run 'killall Dock' in a terminal window (or restart the +machine). + + 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 +persists across a reboot, and if you need to be an Administrator): + +> CD +> MKDIR finance +> SETX LEDGER_FILE "C:\Users\USERNAME\finance\2023.journal" + + +File: hledger.info, Node: Data formats, Next: Standard input, Prev: Setting LEDGER_FILE, Up: Input + +2.2 Data formats +================ + +Usually the data file is in hledger's journal format, but it can be in +any of the supported file formats, which currently are: + +Reader: Reads: Used for file + extensions: +-------------------------------------------------------------------------- +'journal'hledger journal files and some Ledger '.journal' '.j' + journals, for transactions '.hledger' '.ledger' +'timeclock'timeclock files, for precise time '.timeclock' + logging +'timedot'timedot files, for approximate time '.timedot' + logging +'csv' CSV/SSV/TSV/character-separated '.csv' '.ssv' '.tsv' + values, for data import '.csv.rules' + '.ssv.rules' + '.tsv.rules' + + These formats are described in more detail below. + + hledger detects the format automatically based on the file extensions +shown above. If it can't recognise the file extension, it assumes +'journal' format. So for non-journal files, it's important to use a +recognised file extension, so as to either read successfully or to show +relevant error messages. + + You can also force a specific reader/format by prefixing the file +path with the format and a colon. Eg, to read a .dat file as csv +format: + +$ hledger -f csv:/some/csv-file.dat stats + + +File: hledger.info, Node: Standard input, Next: Multiple files, Prev: Data formats, Up: Input + +2.3 Standard input +================== + +The file name '-' means standard input: + +$ cat FILE | hledger -f- print + + If reading non-journal data in this way, you'll need to add a file +format prefix, like: + +$ echo 'i 2009/13/1 08:00:00' | hledger print -f timeclock:- + + +File: hledger.info, Node: Multiple files, Next: Strict mode, Prev: Standard input, Up: Input + +2.4 Multiple files +================== + +You can specify multiple '-f' options, to read multiple files as one big +journal. When doing this, note that certain features (described below) +will be affected: + + * Balance assertions will not see the effect of transactions in + previous files. (Usually this doesn't matter as each file will set + the corresponding opening balances.) + * Some directives will not affect previous or subsequent files. + + If needed, you can work around these by using a single parent file +which includes the others, or concatenating the files into one, eg: 'cat +a.journal b.journal | hledger -f- CMD'. + + +File: hledger.info, Node: Strict mode, Prev: Multiple files, Up: Input + +2.5 Strict mode +=============== + +hledger checks input files for valid data. By default, the most +important errors are detected, while still accepting easy journal files +without a lot of declarations: + + * Are the input files parseable, with valid syntax ? + * Are all transactions balanced ? + * Do all balance assertions pass ? + + With the '-s'/'--strict' flag, additional checks are performed: + + * Are all accounts posted to, declared with an 'account' directive ? + (Account error checking) + * Are all commodities declared with a 'commodity' directive ? + (Commodity error checking) + * Are all commodity conversions declared explicitly ? + + You can use the check command to run individual checks - the ones +listed above and some more. + + +File: hledger.info, Node: Environment, Next: Options, Prev: Input, Up: Top + +3 Environment +************* + +Environment variables which affect hledger: + + *COLUMNS* This is normally set by your terminal; some hledger +commands ('register') will format their output to this width. If not +set, they will try to use the available terminal width. + + *LEDGER_FILE* The main journal file to use when not specified with +'-f/--file'. Default: '$HOME/.hledger.journal'. + + *NO_COLOR* If this environment variable is set (with any value), +hledger will not use ANSI color codes in terminal output, unless +overridden by an explicit '--color/--colour' option. + + +File: hledger.info, Node: Options, Next: Commands, Prev: Environment, Up: Top + +4 Options ********* +Here is a list of flags and options common to most hledger commands, and +some useful details about hledger command line parsing. But if you are +new to hledger, feel free to skim/skip ahead to the Commands. + * Menu: * General options:: +* Option repetition:: * Command options:: * Command arguments:: * Special characters:: @@ -129,9 +318,9 @@ File: hledger.info, Node: Options, Next: Environment, Prev: PART 1 USER INTER * Regular expressions::  -File: hledger.info, Node: General options, Next: Command options, Up: Options +File: hledger.info, Node: General options, Next: Option repetition, Up: Options -2.1 General options +4.1 General options =================== To see general usage help, including general options which are supported @@ -255,18 +444,30 @@ by most hledger commands, run 'hledger -h'. convert amounts to cost or market value, more flexibly than -B/-V/-X +'--infer-equity' + + infer conversion equity postings from costs +'--infer-costs' + + infer costs from conversion equity postings '--infer-market-prices' - use transaction prices (recorded with @ or @@) as additional market - prices, as if they were P directives -'--auto' - - apply automated posting rules to modify transactions. + use costs as additional market prices, as if they were P directives '--forecast' - generate future transactions from periodic transaction rules, for - the next 6 months or till report end date. In hledger-ui, also - make ordinary future transactions visible. + generate transactions from periodic rules, between the latest + recorded txn and 6 months from today, or during the specified + PERIOD (= is required). Auto posting rules will be applied to + these transactions as well. Also, in hledger-ui make future-dated + transactions visible. +'--auto' + + generate extra postings by applying auto posting rules to all txns + (not just forecast txns) +'--verbose-tags' + + add visible tags indicating transactions or postings which have + been generated/modified '--commodity-style' Override the commodity style in the output for the specified @@ -291,9 +492,21 @@ the last one takes precedence. Some reporting options can also be written as query arguments.  -File: hledger.info, Node: Command options, Next: Command arguments, Prev: General options, Up: Options +File: hledger.info, Node: Option repetition, Next: Command options, Prev: General options, Up: Options -2.2 Command options +4.2 Option repetition +===================== + +If options are repeated in a command line, hledger will generally use +the last (right-most) occurence. Some of the boolean flags will toggle +if repeated; these include: '--invert', '--transpose', '-r/--related', +'-%/--percent', '-E/--empty', '-N/--no-total', '-T/--row-total', +'-A/--average', and '-S/--sort-amount'. + + +File: hledger.info, Node: Command options, Next: Command arguments, Prev: Option repetition, Up: Options + +4.3 Command options =================== To see options for a particular command, including command-specific @@ -309,7 +522,7 @@ run the add-on executable directly: 'hledger-ui --watch'.  File: hledger.info, Node: Command arguments, Next: Special characters, Prev: Command options, Up: Options -2.3 Command arguments +4.4 Command arguments ===================== Most hledger commands accept arguments after the command name, which are @@ -349,7 +562,7 @@ than you would at the command prompt. Bad:  File: hledger.info, Node: Special characters, Next: Unicode characters, Prev: Command arguments, Up: Options -2.4 Special characters +4.5 Special characters ====================== * Menu: @@ -362,7 +575,7 @@ File: hledger.info, Node: Special characters, Next: Unicode characters, Prev:  File: hledger.info, Node: Single escaping shell metacharacters, Next: Double escaping regular expression metacharacters, Up: Special characters -2.4.1 Single escaping (shell metacharacters) +4.5.1 Single escaping (shell metacharacters) -------------------------------------------- In shell command lines, characters significant to your shell - such as @@ -384,7 +597,7 @@ PowerShell treats both single and double quotes as quotes.  File: hledger.info, Node: Double escaping regular expression metacharacters, Next: Triple escaping for add-on commands, Prev: Single escaping shell metacharacters, Up: Special characters -2.4.2 Double escaping (regular expression metacharacters) +4.5.2 Double escaping (regular expression metacharacters) --------------------------------------------------------- Characters significant in regular expressions (described below) - such @@ -404,7 +617,7 @@ $ hledger balance cur:\\$  File: hledger.info, Node: Triple escaping for add-on commands, Next: Less escaping, Prev: Double escaping regular expression metacharacters, Up: Special characters -2.4.3 Triple escaping (for add-on commands) +4.5.3 Triple escaping (for add-on commands) ------------------------------------------- When you use hledger to run an external add-on command (described @@ -434,7 +647,7 @@ $ hledger-ui cur:\\$  File: hledger.info, Node: Less escaping, Prev: Triple escaping for add-on commands, Up: Special characters -2.4.4 Less escaping +4.5.4 Less escaping ------------------- Options and arguments are sometimes used in places other than the shell @@ -449,7 +662,7 @@ use one less level of escaping. Those places include:  File: hledger.info, Node: Unicode characters, Next: Regular expressions, Prev: Special characters, Up: Options -2.5 Unicode characters +4.6 Unicode characters ====================== hledger is expected to handle non-ascii characters correctly: @@ -488,7 +701,7 @@ hledger is expected to handle non-ascii characters correctly:  File: hledger.info, Node: Regular expressions, Prev: Unicode characters, Up: Options -2.6 Regular expressions +4.7 Regular expressions ======================= hledger uses regular expressions in a number of places: @@ -531,167 +744,7 @@ they support: See Special characters.  -File: hledger.info, Node: Environment, Next: Input, Prev: Options, Up: Top - -3 Environment -************* - -*LEDGER_FILE* The journal file path when not specified with '-f'. - - On unix computers, the default value is: '~/.hledger.journal'. - - A more typical value is something like '~/finance/YYYY.journal', -where '~/finance' is a version-controlled finance directory and YYYY is -the current year. Or, '~/finance/current.journal', where -current.journal is a symbolic link to YYYY.journal. - - The usual way to set this permanently is to add a command to one of -your shell's startup files (eg '~/.profile'): - -export LEDGER_FILE=~/finance/current.journal` - - On some Mac computers, there is a more thorough way to set -environment variables, that will also affect applications started from -the GUI (eg, Emacs started from a dock icon): In -'~/.MacOSX/environment.plist', add an entry like: - -{ - "LEDGER_FILE" : "~/finance/current.journal" -} - - For this to take effect you might need to 'killall Dock', or reboot. - - On Windows computers, the default value is probably -'C:\Users\YOURNAME\.hledger.journal'. You can change this by running a -command like this in a powershell window (let us know if you need to be -an Administrator, and if this persists across a reboot): - -> setx LEDGER_FILE "C:\Users\MyUserName\finance\2021.journal" - - Or, change it in settings: see -https://www.java.com/en/download/help/path.html. - - *COLUMNS* The screen width used by the register command. Default: -the full terminal width. - - *NO_COLOR* If this variable exists with any value, hledger will not -use ANSI color codes in terminal output. This is overriden by the --color/-colour option. - - -File: hledger.info, Node: Input, Next: Commands, Prev: Environment, Up: Top - -4 Input -******* - -hledger reads transactions from one or more data files. The default -data file is '$HOME/.hledger.journal' (or on Windows, something like -'C:\Users\YOURNAME\.hledger.journal'). - - You can override this with the '$LEDGER_FILE' environment variable: - -$ setenv LEDGER_FILE ~/finance/2016.journal -$ hledger stats - - or with one or more '-f/--file' options: - -$ hledger -f /some/file -f another_file stats - - The file name '-' means standard input: - -$ cat some.journal | hledger -f- - -* Menu: - -* Data formats:: -* Multiple files:: -* Strict mode:: - - -File: hledger.info, Node: Data formats, Next: Multiple files, Up: Input - -4.1 Data formats -================ - -Usually the data file is in hledger's journal format, but it can be in -any of the supported file formats, which currently are: - -Reader: Reads: Used for file - extensions: --------------------------------------------------------------------------- -'journal'hledger journal files and some Ledger '.journal' '.j' - journals, for transactions '.hledger' '.ledger' -'timeclock'timeclock files, for precise time '.timeclock' - logging -'timedot'timedot files, for approximate time '.timedot' - logging -'csv' comma/semicolon/tab/other-separated '.csv' '.ssv' '.tsv' - values, for data import - - These formats are described in more detail below. - - hledger detects the format automatically based on the file extensions -shown above. If it can't recognise the file extension, it assumes -'journal' format. So for non-journal files, it's important to use a -recognised file extension, so as to either read successfully or to show -relevant error messages. - - You can also force a specific reader/format by prefixing the file -path with the format and a colon. Eg, to read a .dat file as csv -format: - -$ hledger -f csv:/some/csv-file.dat stats - - Or to read stdin ('-') as timeclock format: - -$ echo 'i 2009/13/1 08:00:00' | hledger print -ftimeclock:- - - -File: hledger.info, Node: Multiple files, Next: Strict mode, Prev: Data formats, Up: Input - -4.2 Multiple files -================== - -You can specify multiple '-f' options, to read multiple files as one big -journal. There are some limitations with this: - - * most directives do not affect sibling files - * balance assertions will not see any account balances from previous - files - - If you need either of those things, you can - - * use a single parent file which includes the others - * or concatenate the files into one before reading, eg: 'cat - a.journal b.journal | hledger -f- CMD'. - - -File: hledger.info, Node: Strict mode, Prev: Multiple files, Up: Input - -4.3 Strict mode -=============== - -hledger checks input files for valid data. By default, the most -important errors are detected, while still accepting easy journal files -without a lot of declarations: - - * Are the input files parseable, with valid syntax ? - * Are all transactions balanced ? - * Do all balance assertions pass ? - - With the '-s'/'--strict' flag, additional checks are performed: - - * Are all accounts posted to, declared with an 'account' directive ? - (Account error checking) - * Are all commodities declared with a 'commodity' directive ? - (Commodity error checking) - * Are all commodity conversions declared explicitly ? - - You can use the check command to run individual checks - the ones -listed above and some more. - - -File: hledger.info, Node: Commands, Next: Output, Prev: Input, Up: Top +File: hledger.info, Node: Commands, Next: Output, Prev: Options, Up: Top 5 Commands ********** @@ -750,7 +803,7 @@ add-on program directly, eg: $ hledger-web --serve  -File: hledger.info, Node: Output, Next: Limitations, Prev: Commands, Up: Top +File: hledger.info, Node: Output, Next: PART 2 DATA FORMATS, Prev: Commands, Up: Top 6 Output ******** @@ -985,117 +1038,16 @@ a log file instead, you can usually redirect stderr, eg: hledger bal --debug=3 2>hledger.log  -File: hledger.info, Node: Limitations, Next: Troubleshooting, Prev: Output, Up: Top +File: hledger.info, Node: PART 2 DATA FORMATS, Next: Journal, Prev: Output, Up: Top -7 Limitations -************* - -The need to precede add-on command options with '--' when invoked from -hledger is awkward. - - When input data contains non-ascii characters, a suitable system -locale must be configured (or there will be an unhelpful error). Eg on -POSIX, set LANG to something other than C. - - In a Microsoft Windows CMD window, non-ascii characters and colours -are not supported. - - On Windows, non-ascii characters may not display correctly when -running a hledger built in CMD in MSYS/CYGWIN, or vice-versa. - - In a Cygwin/MSYS/Mintty window, the tab key is not supported in -hledger add. - - Not all of Ledger's journal file syntax is supported. See hledger -and Ledger > Differences > journal format. - - On large data files, hledger is slower and uses more memory than -Ledger. - - -File: hledger.info, Node: Troubleshooting, Next: PART 2 DATA FORMATS, Prev: Limitations, Up: Top - -8 Troubleshooting -***************** - -Here are some issues you might encounter when you run hledger (and -remember you can also seek help from the IRC channel, mail list or bug -tracker): - - *Successfully installed, but "No command 'hledger' found"* -stack and cabal install binaries into a special directory, which should -be added to your PATH environment variable. Eg on unix-like systems, -that is ~/.local/bin and ~/.cabal/bin respectively. - - *I set a custom LEDGER_FILE, but hledger is still using the default -file* -'LEDGER_FILE' should be a real environment variable, not just a shell -variable. The command 'env | grep LEDGER_FILE' should show it. You may -need to use 'export'. Here's an explanation. - - *Getting errors like "Illegal byte sequence" or "Invalid or -incomplete multibyte or wide character" or "commitAndReleaseBuffer: -invalid argument (invalid character)"* -Programs compiled with GHC (hledger, haskell build tools, etc.) need to -have a UTF-8-aware locale configured in the environment, otherwise they -will fail with these kinds of errors when they encounter non-ascii -characters. - - To fix it, set the LANG environment variable to some locale which -supports UTF-8. The locale you choose must be installed on your system. - - Here's an example of setting LANG temporarily, on Ubuntu GNU/Linux: - -$ file my.journal -my.journal: UTF-8 Unicode text # the file is UTF8-encoded -$ echo $LANG -C # LANG is set to the default locale, which does not support UTF8 -$ locale -a # which locales are installed ? -C -en_US.utf8 # here's a UTF8-aware one we can use -POSIX -$ LANG=en_US.utf8 hledger -f my.journal print # ensure it is used for this command - - If available, 'C.UTF-8' will also work. If your preferred locale -isn't listed by 'locale -a', you might need to install it. Eg on -Ubuntu/Debian: - -$ apt-get install language-pack-fr -$ locale -a -C -en_US.utf8 -fr_BE.utf8 -fr_CA.utf8 -fr_CH.utf8 -fr_FR.utf8 -fr_LU.utf8 -POSIX -$ LANG=fr_FR.utf8 hledger -f my.journal print - - Here's how you could set it permanently, if you use a bash shell: - -$ echo "export LANG=en_US.utf8" >>~/.bash_profile -$ bash --login - - Exact spelling and capitalisation may be important. Note the -difference on MacOS ('UTF-8', not 'utf8'). Some platforms (eg ubuntu) -allow variant spellings, but others (eg macos) require it to be exact: - -$ locale -a | grep -iE en_us.*utf -en_US.UTF-8 -$ LANG=en_US.UTF-8 hledger -f my.journal print - - -File: hledger.info, Node: PART 2 DATA FORMATS, Next: Journal, Prev: Troubleshooting, Up: Top - -9 PART 2: DATA FORMATS +7 PART 2: DATA FORMATS **********************  File: hledger.info, Node: Journal, Next: CSV, Prev: PART 2 DATA FORMATS, Up: Top -10 Journal -********** +8 Journal +********* hledger's default file format, representing a General Journal. Here's a cheatsheet/mini-tutorial, or you can skip ahead to About journal format. @@ -1128,13 +1080,14 @@ cheatsheet/mini-tutorial, or you can skip ahead to About journal format. * payee directive:: * tag directive:: * Periodic transactions:: +* Auto postings:: * Other syntax::  File: hledger.info, Node: Journal cheatsheet, Next: About journal format, Up: Journal -10.1 Journal cheatsheet -======================= +8.1 Journal cheatsheet +====================== # Here is the main syntax of hledger's journal format # (omitting extra Ledger compatibility syntax). @@ -1197,7 +1150,6 @@ P 2022-01-01 AAAA $1.40 expenses:tax:us:2021 $500 ; plus means added to this account (debit) ; revenue/expense categories are also "accounts" -Kv 2022-01-01 ; The description is optional. ; Any currency/commodity symbols are allowed, on either side. assets:cash:wallet GBP -10 @@ -1228,8 +1180,8 @@ Kv  File: hledger.info, Node: About journal format, Next: Comments, Prev: Journal cheatsheet, Up: Journal -10.2 About journal format -========================= +8.2 About journal format +======================== hledger's usual data source is a plain text file containing journal entries in hledger journal format. This file represents a standard @@ -1239,10 +1191,12 @@ entries, each describing a transfer of money (or any commodity) between two or more named accounts, in a simple format readable by both hledger and humans. - hledger's journal format is a compatible subset, mostly, of ledger's -journal format, so hledger can work with compatible ledger journal files -as well. It's safe, and encouraged, to run both hledger and ledger on -the same journal file, eg to validate the results you're getting. + hledger's journal format is compatible with most of Ledger's journal +format, but not all of it. The differences and interoperation tips are +described at hledger and Ledger. With some care, and by avoiding +incompatible features, you can keep your hledger journal readable by +Ledger and vice versa. This can useful eg for comparing the behaviour +of one app against the other. You can use hledger without learning any more about this file; just use the add or web or import commands to create and update it. @@ -1264,8 +1218,8 @@ rules and auto posting rules as directives).  File: hledger.info, Node: Comments, Next: Transactions, Prev: About journal format, Up: Journal -10.3 Comments -============= +8.3 Comments +============ Lines in the journal will be ignored if they begin with a hash ('#') or a semicolon (';'). (See also Other syntax.) hledger will also ignore @@ -1294,8 +1248,8 @@ comments, and Account comments below.  File: hledger.info, Node: Transactions, Next: Dates, Prev: Comments, Up: Journal -10.4 Transactions -================= +8.4 Transactions +================ Transactions are the main unit of information in a journal file. They represent events, typically a movement of some quantity of commodities @@ -1323,8 +1277,8 @@ optional fields, separated by spaces:  File: hledger.info, Node: Dates, Next: Status, Prev: Transactions, Up: Journal -10.5 Dates -========== +8.5 Dates +========= * Menu: @@ -1334,8 +1288,8 @@ File: hledger.info, Node: Dates, Next: Status, Prev: Transactions, Up: Journ  File: hledger.info, Node: Simple dates, Next: Posting dates, Up: Dates -10.5.1 Simple dates -------------------- +8.5.1 Simple dates +------------------ Dates in the journal file use _simple dates_ format: 'YYYY-MM-DD' or 'YYYY/MM/DD' or 'YYYY.MM.DD', with leading zeros optional. The year may @@ -1350,8 +1304,8 @@ dates documented in the hledger manual.)  File: hledger.info, Node: Posting dates, Prev: Simple dates, Up: Dates -10.5.2 Posting dates --------------------- +8.5.2 Posting dates +------------------- You can give individual postings a different date from their parent transaction, by adding a posting comment containing a tag (see below) @@ -1378,8 +1332,8 @@ a 'date:' tag with no value is not allowed.  File: hledger.info, Node: Status, Next: Code, Prev: Dates, Up: Journal -10.6 Status -=========== +8.6 Status +========== Transactions, or individual postings within a transaction, can have a status mark, which is a single character before the transaction @@ -1428,8 +1382,8 @@ your finances.  File: hledger.info, Node: Code, Next: Description, Prev: Status, Up: Journal -10.7 Code -========= +8.7 Code +======== After the status mark, but before the description, you can optionally write a transaction "code", enclosed in parentheses. This is a good @@ -1439,8 +1393,8 @@ or reference number.  File: hledger.info, Node: Description, Next: Transaction comments, Prev: Code, Up: Journal -10.8 Description -================ +8.8 Description +=============== A transaction's description is the rest of the line following the date and status mark (or until a comment begins). Sometimes called the @@ -1455,8 +1409,8 @@ comments.  File: hledger.info, Node: Payee and note, Up: Description -10.8.1 Payee and note ---------------------- +8.8.1 Payee and note +-------------------- You can optionally include a '|' (pipe) character in descriptions to subdivide the description into separate fields for payee/payer name on @@ -1467,8 +1421,8 @@ precise querying and pivoting by payee or by note.  File: hledger.info, Node: Transaction comments, Next: Postings, Prev: Description, Up: Journal -10.9 Transaction comments -========================= +8.9 Transaction comments +======================== Text following ';', after a transaction description, and/or on indented lines immediately below it, form comments for that transaction. They @@ -1483,8 +1437,8 @@ tags, which are not ignored.  File: hledger.info, Node: Postings, Next: Account names, Prev: Transaction comments, Up: Journal -10.10 Postings -============== +8.10 Postings +============= A posting is an addition of some amount to, or removal of some amount from, an account. Each posting line begins with at least one space or @@ -1511,8 +1465,8 @@ the amount, the amount will be considered part of the account name.  File: hledger.info, Node: Account names, Next: Amounts, Prev: Postings, Up: Journal -10.11 Account names -=================== +8.11 Account names +================== Accounts are the main way of categorising things in hledger. As in Double Entry Bookkeeping, they can represent real world accounts (such @@ -1562,8 +1516,8 @@ aliases.  File: hledger.info, Node: Amounts, Next: Costs, Prev: Account names, Up: Journal -10.12 Amounts -============= +8.12 Amounts +============ After the account name, there is usually an amount. (Important: between account name and amount, there must be *two or more spaces*.) @@ -1611,8 +1565,8 @@ EUR 1E3  File: hledger.info, Node: Decimal marks digit group marks, Next: Commodity, Up: Amounts -10.12.1 Decimal marks, digit group marks ----------------------------------------- +8.12.1 Decimal marks, digit group marks +--------------------------------------- A _decimal mark_ can be written as a period or a comma: @@ -1647,8 +1601,8 @@ directives will also work. These are described below.  File: hledger.info, Node: Commodity, Next: Directives influencing number parsing and display, Prev: Decimal marks digit group marks, Up: Amounts -10.12.2 Commodity ------------------ +8.12.2 Commodity +---------------- Amounts in hledger have both a "quantity", which is a signed decimal number, and a "commodity", which is a currency symbol, stock ticker, or @@ -1673,8 +1627,8 @@ these are the 'Amount' and 'MixedAmount' types.)  File: hledger.info, Node: Directives influencing number parsing and display, Next: Commodity display style, Prev: Commodity, Up: Amounts -10.12.3 Directives influencing number parsing and display ---------------------------------------------------------- +8.12.3 Directives influencing number parsing and display +-------------------------------------------------------- You can add 'decimal-mark' and 'commodity' directives to the journal, to declare and control these things more explicitly and precisely. These @@ -1692,8 +1646,8 @@ commodity 1 000 000.9455  File: hledger.info, Node: Commodity display style, Next: Rounding, Prev: Directives influencing number parsing and display, Up: Amounts -10.12.4 Commodity display style -------------------------------- +8.12.4 Commodity display style +------------------------------ For the amounts in each commodity, hledger chooses a consistent display style to use in most reports. (Exceptions: price amounts, and all @@ -1749,8 +1703,8 @@ line option.  File: hledger.info, Node: Rounding, Prev: Commodity display style, Up: Amounts -10.12.5 Rounding ----------------- +8.12.5 Rounding +--------------- Amounts are stored internally as decimal numbers with up to 255 decimal places, and displayed with the number of decimal places specified by the @@ -1761,8 +1715,8 @@ places is "0").  File: hledger.info, Node: Costs, Next: Balance assertions, Prev: Amounts, Up: Journal -10.13 Costs -=========== +8.13 Costs +========== After a posting amount, you can note its cost (when buying) or selling price (when selling) in another commodity, by writing either '@ @@ -1819,8 +1773,8 @@ not required to be. This can be a little confusing, see discussion at  File: hledger.info, Node: Other cost/lot notations, Up: Costs -10.13.1 Other cost/lot notations --------------------------------- +8.13.1 Other cost/lot notations +------------------------------- A slight digression for Ledger and Beancount users. Ledger has a number of cost/lot-related notations: @@ -1889,8 +1843,8 @@ but ignores it.  File: hledger.info, Node: Balance assertions, Next: Posting comments, Prev: Costs, Up: Journal -10.14 Balance assertions -======================== +8.14 Balance assertions +======================= hledger supports Ledger-style balance assertions in journal files. These look like, for example, '= EXPECTEDBALANCE' following a posting's @@ -1928,8 +1882,8 @@ does not disable balance assignments, described below).  File: hledger.info, Node: Assertions and ordering, Next: Assertions and multiple included files, Up: Balance assertions -10.14.1 Assertions and ordering -------------------------------- +8.14.1 Assertions and ordering +------------------------------ hledger sorts an account's postings and assertions first by date and then (for postings on the same day) by parse order. Note this is @@ -1947,8 +1901,8 @@ can assert intra-day balances.  File: hledger.info, Node: Assertions and multiple included files, Next: Assertions and multiple -f files, Prev: Assertions and ordering, Up: Balance assertions -10.14.2 Assertions and multiple included files ----------------------------------------------- +8.14.2 Assertions and multiple included files +--------------------------------------------- Multiple files included with the 'include' directive are processed as if concatenated into one file, preserving their order and the posting order @@ -1963,8 +1917,8 @@ balance on that day, you'll need to put the assertion in the right file  File: hledger.info, Node: Assertions and multiple -f files, Next: Assertions and commodities, Prev: Assertions and multiple included files, Up: Balance assertions -10.14.3 Assertions and multiple -f files ----------------------------------------- +8.14.3 Assertions and multiple -f files +--------------------------------------- Unlike 'include', when multiple files are specified on the command line with multiple '-f/--file' options, balance assertions will not see @@ -1977,8 +1931,8 @@ problems in earlier files to disrupt valid assertions in later files.  File: hledger.info, Node: Assertions and commodities, Next: Assertions and prices, Prev: Assertions and multiple -f files, Up: Balance assertions -10.14.4 Assertions and commodities ----------------------------------- +8.14.4 Assertions and commodities +--------------------------------- The asserted balance must be a simple single-commodity amount, and in fact the assertion checks only this commodity's balance within the @@ -2025,8 +1979,8 @@ commodity into its own subaccount:  File: hledger.info, Node: Assertions and prices, Next: Assertions and subaccounts, Prev: Assertions and commodities, Up: Balance assertions -10.14.5 Assertions and prices ------------------------------ +8.14.5 Assertions and prices +---------------------------- Balance assertions ignore costs, and should normally be written without one: @@ -2043,8 +1997,8 @@ _assignments_ do use them (see below).  File: hledger.info, Node: Assertions and subaccounts, Next: Assertions and virtual postings, Prev: Assertions and prices, Up: Balance assertions -10.14.6 Assertions and subaccounts ----------------------------------- +8.14.6 Assertions and subaccounts +--------------------------------- The balance assertions above ('=' and '==') do not count the balance from subaccounts; they check the account's exclusive balance only. You @@ -2060,8 +2014,8 @@ eg:  File: hledger.info, Node: Assertions and virtual postings, Next: Assertions and auto postings, Prev: Assertions and subaccounts, Up: Balance assertions -10.14.7 Assertions and virtual postings ---------------------------------------- +8.14.7 Assertions and virtual postings +-------------------------------------- Balance assertions always consider both real and virtual postings; they are not affected by the '--real/-R' flag or 'real:' query. @@ -2069,8 +2023,8 @@ are not affected by the '--real/-R' flag or 'real:' query.  File: hledger.info, Node: Assertions and auto postings, Next: Assertions and precision, Prev: Assertions and virtual postings, Up: Balance assertions -10.14.8 Assertions and auto postings ------------------------------------- +8.14.8 Assertions and auto postings +----------------------------------- Balance assertions _are_ affected by the '--auto' flag, which generates auto postings, which can alter account balances. Because auto postings @@ -2088,8 +2042,8 @@ these. So to avoid making fragile assertions, either:  File: hledger.info, Node: Assertions and precision, Prev: Assertions and auto postings, Up: Balance assertions -10.14.9 Assertions and precision --------------------------------- +8.14.9 Assertions and precision +------------------------------- Balance assertions compare the exactly calculated amounts, which are not always what is shown by reports. Eg a commodity directive may limit the @@ -2099,8 +2053,8 @@ assertion failure messages show exact amounts.  File: hledger.info, Node: Posting comments, Next: Tags, Prev: Balance assertions, Up: Journal -10.15 Posting comments -====================== +8.15 Posting comments +===================== Text following ';', at the end of a posting line, and/or on indented lines immediately below it, form comments for that posting. They are @@ -2116,8 +2070,8 @@ tags, which are not ignored.  File: hledger.info, Node: Tags, Next: Directives, Prev: Posting comments, Up: Journal -10.16 Tags -========== +8.16 Tags +========= Tags are a way to add extra labels or labelled data to transactions, postings, or accounts, which you can then search or pivot on. @@ -2153,8 +2107,8 @@ tag name with a 'tag:NAMEREGEX' query.  File: hledger.info, Node: Tag values, Up: Tags -10.16.1 Tag values ------------------- +8.16.1 Tag values +----------------- Tags can have a value, which is any text after the colon up until a comma or end of line (with surrounding whitespace removed). Note this @@ -2175,62 +2129,72 @@ match by tag value with a 'tag:NAMEREGEX=VALUEREGEX' query.  File: hledger.info, Node: Directives, Next: account directive, Prev: Tags, Up: Journal -10.17 Directives -================ +8.17 Directives +=============== -A directive is a line in the journal beginning with a special keyword, -that influences how the journal is processed, how things are displayed, -and so on. hledger's directives are based on (a subset of) Ledger's, -but there are many differences, and also some differences between -hledger versions. Here are some more definitions: +Besides transactions, there is something else you can put in a 'journal' +file: directives. These are declarations, beginning with a keyword, +that modify hledger's behaviour. Some directives can have more specific +subdirectives, indented below them. hledger's directives are similar to +Ledger's in many cases, but there are also many differences. Directives +are not required, but can be useful. Here are the main directives: - * _subdirective_ - Some directives support subdirectives, written - indented below the parent directive. - - * _decimal mark_ - The character to interpret as a decimal mark - (period or comma) when parsing amounts of a commodity. - - * _display style_ - How to display amounts of a commodity in output: - symbol side and spacing, digit groups, decimal mark, and number of - decimal places. - - Directives are not required when starting out with hledger, but you -will probably want to add some as your needs grow. Here some key -directives for particular needs: - -purpose directives +purpose directive -------------------------------------------------------------------------- *READING DATA:* -Declare file's decimal mark to help parse 'decimal-mark' -amounts accurately -Rewrite account names 'alias' -Comment out sections of the data 'comment' -Include extra data files 'include' +Rewrite account names 'alias' +Comment out sections of the file 'comment' +Declare file's decimal mark, to help 'decimal-mark' +parse amounts accurately +Include other data files 'include' *GENERATING DATA:* -Generate recurring transactions or budget '~' -goals -Generate extra postings on transactions '=' +Generate recurring transactions or '~' +budget goals +Generate extra postings on existing '=' +transactions *CHECKING FOR ERRORS:* -Define valid entities to provide more 'account', 'commodity', -error checking 'payee' +Define valid entities to provide more 'account', 'commodity', +error checking 'payee', 'tag' *REPORTING:* -Declare accounts' type and display order 'account' -Declare commodity display styles 'commodity' -Declare market prices 'P' +Declare accounts' type and display 'account' +order +Declare commodity display styles 'commodity' +Declare market prices 'P' * Menu: -* Directive effects:: * Directives and multiple files:: +* Directive effects::  -File: hledger.info, Node: Directive effects, Next: Directives and multiple files, Up: Directives +File: hledger.info, Node: Directives and multiple files, Next: Directive effects, Up: Directives -10.17.1 Directive effects -------------------------- +8.17.1 Directives and multiple files +------------------------------------ -And here is what each directive does, and which files and journal -entries (transactions) it affects: +Directives vary in their scope, ie which journal entries and which input +files they affect. Most often, a directive will affect the following +entries and included files if any, until the end of the current file - +and no further. You might find this inconvenient! For example, 'alias' +directives do not affect parent or sibling files. But there are usually +workarounds; for example, put 'alias' directives in your top-most file, +before including other files. + + The restriction, though it may be annoying at first, is in a good +cause; it allows reports to be stable and deterministic, independent of +the order of input. Without it, reports could show different numbers +depending on the order of -f options, or the positions of include +directives in your files. + + +File: hledger.info, Node: Directive effects, Prev: Directives and multiple files, Up: Directives + +8.17.2 Directive effects +------------------------ + +Here are all hledger's directives, with their effects and scope +summarised - nine main directives, plus four others which we consider +non-essential: directivewhat it does ends at @@ -2283,31 +2247,11 @@ account'*following entries until end of current file or 'end apply Ledgerignored. directives* - -File: hledger.info, Node: Directives and multiple files, Prev: Directive effects, Up: Directives - -10.17.2 Directives and multiple files -------------------------------------- - -If you use multiple '-f'/'--file' options, or the 'include' directive, -hledger will process multiple input files. But directives which affect -input typically have effect only until the end of the file in which they -occur (and on any included files in that region). - - This may seem inconvenient, but it's intentional; it makes reports -stable and deterministic, independent of the order of input. Otherwise -you could see different numbers if you happened to write -f options in a -different order, or if you moved includes around while cleaning up your -files. - - It can be surprising though; for example, it means that 'alias' -directives do not affect parent or sibling files (see below). -  File: hledger.info, Node: account directive, Next: alias directive, Prev: Directives, Up: Journal -10.18 'account' directive -========================= +8.18 'account' directive +======================== 'account' directives can be used to declare accounts (ie, the places that amounts are transferred from and to). Though not required, these @@ -2349,8 +2293,8 @@ account (assets:bank:checking)  File: hledger.info, Node: Account comments, Next: Account subdirectives, Up: account directive -10.18.1 Account comments ------------------------- +8.18.1 Account comments +----------------------- Text following *two or more spaces* and ';' at the end of an account directive line, and/or following ';' on indented lines immediately below @@ -2367,8 +2311,8 @@ account assets:bank:checking ; same-line comment, at least 2 spaces before th  File: hledger.info, Node: Account subdirectives, Next: Account error checking, Prev: Account comments, Up: account directive -10.18.2 Account subdirectives ------------------------------ +8.18.2 Account subdirectives +---------------------------- Ledger-style indented subdirectives are also accepted, but currently ignored: @@ -2379,8 +2323,8 @@ account assets:bank:checking  File: hledger.info, Node: Account error checking, Next: Account display order, Prev: Account subdirectives, Up: account directive -10.18.3 Account error checking ------------------------------- +8.18.3 Account error checking +----------------------------- By default, accounts need not be declared; they come into existence when a posting references them. This is convenient, but it means hledger @@ -2407,8 +2351,8 @@ been declared by an account directive. Some notes:  File: hledger.info, Node: Account display order, Next: Account types, Prev: Account error checking, Up: account directive -10.18.4 Account display order ------------------------------ +8.18.4 Account display order +---------------------------- The order in which account directives are written influences the order in which accounts appear in reports, hledger-ui, hledger-web etc. By @@ -2451,8 +2395,8 @@ means:  File: hledger.info, Node: Account types, Prev: Account display order, Up: account directive -10.18.5 Account types ---------------------- +8.18.5 Account types +-------------------- hledger knows that accounts come in several types: assets, liabilities, expenses and so on. This enables easy reports like balancesheet and @@ -2537,8 +2481,8 @@ account equity:conversion ; type: V  File: hledger.info, Node: alias directive, Next: commodity directive, Prev: account directive, Up: Journal -10.19 'alias' directive -======================= +8.19 'alias' directive +====================== You can define account alias rules which rewrite your account names, or parts of them, before generating reports. This can be useful for: @@ -2574,8 +2518,8 @@ more on this below.  File: hledger.info, Node: Basic aliases, Next: Regex aliases, Up: alias directive -10.19.1 Basic aliases ---------------------- +8.19.1 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 @@ -2598,8 +2542,8 @@ alias checking = assets:bank:wells fargo:checking  File: hledger.info, Node: Regex aliases, Next: Combining aliases, Prev: Basic aliases, Up: alias directive -10.19.2 Regex aliases ---------------------- +8.19.2 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 @@ -2632,8 +2576,8 @@ of option argument), so it can contain trailing whitespace.  File: hledger.info, Node: Combining aliases, Next: Aliases and multiple files, Prev: Regex aliases, Up: alias directive -10.19.3 Combining aliases -------------------------- +8.19.3 Combining aliases +------------------------ You can define as many aliases as you like, using journal directives and/or command line options. @@ -2669,8 +2613,8 @@ which aliases are being applied when.  File: hledger.info, Node: Aliases and multiple files, Next: end aliases directive, Prev: Combining aliases, Up: alias directive -10.19.4 Aliases and multiple files ----------------------------------- +8.19.4 Aliases and multiple files +--------------------------------- As explained at Directives and multiple files, 'alias' directives do not affect parent or sibling files. Eg in this command, @@ -2701,8 +2645,8 @@ include c.journal ; also affected  File: hledger.info, Node: end aliases directive, Next: Aliases can generate bad account names, Prev: Aliases and multiple files, Up: alias directive -10.19.5 'end aliases' directive -------------------------------- +8.19.5 'end aliases' directive +------------------------------ You can clear (forget) all currently defined aliases (seen in the journal so far, or defined on the command line) with this directive: @@ -2712,8 +2656,8 @@ end aliases  File: hledger.info, Node: Aliases can generate bad account names, Next: Aliases and account types, Prev: end aliases directive, Up: alias directive -10.19.6 Aliases can generate bad account names ----------------------------------------------- +8.19.6 Aliases can generate bad account names +--------------------------------------------- Be aware that account aliases can produce malformed account names, which could cause confusing reports or invalid 'print' output. For example, @@ -2743,8 +2687,8 @@ $ hledger print --alias old="new USD" | hledger -f- print  File: hledger.info, Node: Aliases and account types, Prev: Aliases can generate bad account names, Up: alias directive -10.19.7 Aliases and account types ---------------------------------- +8.19.7 Aliases and account types +-------------------------------- If an account with a type declaration (see Declaring accounts > Account types) is renamed by an alias, normally the account type remains in @@ -2767,8 +2711,8 @@ $ hledger accounts --alias assets=bassetts type:a  File: hledger.info, Node: commodity directive, Next: decimal-mark directive, Prev: alias directive, Up: Journal -10.20 'commodity' directive -=========================== +8.20 'commodity' directive +========================== You can use 'commodity' directives to declare your commodities. In fact the 'commodity' directive performs several functions at once: @@ -2845,8 +2789,8 @@ style can still be overridden by supplying a command line option.  File: hledger.info, Node: Commodity error checking, Up: commodity directive -10.20.1 Commodity error checking --------------------------------- +8.20.1 Commodity error checking +------------------------------- In strict mode, enabled with the '-s'/'--strict' flag, hledger will report an error if a commodity symbol is used that has not been declared @@ -2861,8 +2805,8 @@ are always allowed to have no commodity symbol.  File: hledger.info, Node: decimal-mark directive, Next: include directive, Prev: commodity directive, Up: Journal -10.21 'decimal-mark' directive -============================== +8.21 'decimal-mark' directive +============================= You can use a 'decimal-mark' directive - usually one per file, at the top of the file - to declare which character represents a decimal mark @@ -2881,8 +2825,8 @@ thousands separators).  File: hledger.info, Node: include directive, Next: P directive, Prev: decimal-mark directive, Up: Journal -10.22 'include' directive -========================= +8.22 'include' directive +======================== You can pull in the content of additional files by writing an include directive, like this: @@ -2912,8 +2856,8 @@ files): 'include timedot:~/notes/2020*.md'.  File: hledger.info, Node: P directive, Next: payee directive, Prev: include directive, Up: Journal -10.23 'P' directive -=================== +8.23 'P' directive +================== The 'P' directive declares a market price, which is a conversion rate between two commodities on a certain date. This allows value reports to @@ -2942,8 +2886,8 @@ amount values in another commodity. See Valuation.  File: hledger.info, Node: payee directive, Next: tag directive, Prev: P directive, Up: Journal -10.24 'payee' directive -======================= +8.24 'payee' directive +====================== 'payee PAYEE NAME' @@ -2959,8 +2903,8 @@ payee Whole Foods  File: hledger.info, Node: tag directive, Next: Periodic transactions, Prev: payee directive, Up: Journal -10.25 'tag' directive -===================== +8.25 'tag' directive +==================== 'tag TAGNAME' @@ -2977,10 +2921,10 @@ of colons in comments(#comments]; if you want to prevent this, you can declare and check your tags .  -File: hledger.info, Node: Periodic transactions, Next: Other syntax, Prev: tag directive, Up: Journal +File: hledger.info, Node: Periodic transactions, Next: Auto postings, Prev: tag directive, Up: Journal -10.26 Periodic transactions -=========================== +8.26 Periodic transactions +========================== The '~' directive declares recurring transactions. Such directives allow hledger to generate temporary future transactions (visible in @@ -3021,8 +2965,8 @@ read this whole section, or at least these tips:  File: hledger.info, Node: Periodic rule syntax, Next: Periodic rules and relative dates, Up: Periodic transactions -10.26.1 Periodic rule syntax ----------------------------- +8.26.1 Periodic rule syntax +--------------------------- A periodic transaction rule looks like a normal journal entry, with the date replaced by a tilde ('~') followed by a period expression @@ -3046,8 +2990,8 @@ dates).  File: hledger.info, Node: Periodic rules and relative dates, Next: Two spaces between period expression and description!, Prev: Periodic rule syntax, Up: Periodic transactions -10.26.2 Periodic rules and relative dates ------------------------------------------ +8.26.2 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 @@ -3065,8 +3009,8 @@ dates.  File: hledger.info, Node: Two spaces between period expression and description!, Prev: Periodic rules and relative dates, Up: Periodic transactions -10.26.3 Two spaces between period expression and description! -------------------------------------------------------------- +8.26.3 Two spaces between period expression and description! +------------------------------------------------------------ If the period expression is followed by a transaction description, these must be separated by *two or more spaces*. This helps hledger know @@ -3088,46 +3032,22 @@ accidentally alter their meaning, as in this example: expression.  -File: hledger.info, Node: Other syntax, Prev: Periodic transactions, Up: Journal +File: hledger.info, Node: Auto postings, Next: Other syntax, Prev: Periodic transactions, Up: Journal -10.27 Other syntax +8.27 Auto postings ================== -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. +The '=' directive declares a rule for generating temporary extra +postings on transactions. Wherever the rule matches an existing +posting, it can add one or more companion postings below that one, +optionally influenced by the matched posting's amount. This can be +useful for generating tax postings with a standard percentage, for +example. -* Menu: - -* Auto postings:: -* Balance assignments:: -* Bracketed posting dates:: -* D directive:: -* apply account directive:: -* Y directive:: -* Secondary dates:: -* Star comments:: -* Valuation expressions:: -* Virtual postings:: -* Other Ledger directives:: - - -File: hledger.info, Node: Auto postings, Next: Balance assignments, Up: Other syntax - -10.27.1 Auto postings ---------------------- - -The '=' directive declares a rule for automatically adding temporary -extra postings (visible in reports, not in the journal file) to all -transactions matched by a certain query, when you use the '--auto' flag. - - Downsides: depending on generated data for your reports makes your -financial data less portable, less future-proof, and less trustworthy in -an audit. Also, because the feature is optional, other features like -balance assertions can break depending on whether it is on or off. + Note that depending on generated data is not ideal for financial +records (it's less portable, less future-proof, less auditable by +others, and less robust, since other features like balance assertions +will depend on using or not using '--auto'). An auto posting rule looks a bit like a transaction: @@ -3193,35 +3113,39 @@ $ hledger print --auto * Menu: * Auto postings and multiple files:: -* Auto postings and dates:: -* Auto postings and transaction balancing / inferred amounts / balance assertions:: -* Auto posting tags::  -File: hledger.info, Node: Auto postings and multiple files, Next: Auto postings and dates, Up: Auto postings +File: hledger.info, Node: Auto postings and multiple files, Up: Auto postings -10.27.1.1 Auto postings and multiple files -.......................................... +8.27.1 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 sibling files (when multiple '-f'/'--file' are used - see #1212). - -File: hledger.info, Node: Auto postings and dates, Next: Auto postings and transaction balancing / inferred amounts / balance assertions, Prev: Auto postings and multiple files, Up: Auto postings +* Menu: -10.27.1.2 Auto postings and dates -................................. +* Auto postings and dates:: +* Auto postings and transaction balancing / inferred amounts / balance assertions:: +* Auto posting tags:: +* Auto postings on forecast transactions only:: + + +File: hledger.info, Node: Auto postings and dates, Next: Auto postings and transaction balancing / inferred amounts / balance assertions, Up: Auto postings and multiple files + +8.27.1.1 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 be used in the generated posting.  -File: hledger.info, Node: Auto postings and transaction balancing / inferred amounts / balance assertions, Next: Auto posting tags, Prev: Auto postings and dates, Up: Auto postings +File: hledger.info, Node: Auto postings and transaction balancing / inferred amounts / balance assertions, Next: Auto posting tags, Prev: Auto postings and dates, Up: Auto postings and multiple files -10.27.1.3 Auto postings and transaction balancing / inferred -............................................................ +8.27.1.2 Auto postings and transaction balancing / inferred +........................................................... amounts / balance assertions Currently, auto postings are added: @@ -3238,10 +3162,10 @@ a missing amount applied to a given transaction, as it will be unable to infer amounts.  -File: hledger.info, Node: Auto posting tags, Prev: Auto postings and transaction balancing / inferred amounts / balance assertions, Up: Auto postings +File: hledger.info, Node: Auto posting tags, Next: Auto postings on forecast transactions only, Prev: Auto postings and transaction balancing / inferred amounts / balance assertions, Up: Auto postings and multiple files -10.27.1.4 Auto posting tags -........................... +8.27.1.3 Auto posting tags +.......................... Automated postings will have some extra tags: @@ -3260,10 +3184,47 @@ will have these tags added: transaction was modified "just now".  -File: hledger.info, Node: Balance assignments, Next: Bracketed posting dates, Prev: Auto postings, Up: Other syntax +File: hledger.info, Node: Auto postings on forecast transactions only, Prev: Auto posting tags, Up: Auto postings and multiple files -10.27.2 Balance assignments ---------------------------- +8.27.1.4 Auto postings on forecast transactions only +.................................................... + +Tip: you can can make auto postings that will apply to forecast +transactions but not recorded transactions, by adding +'tag:_generated-transaction' to their QUERY. This can be useful when +generating new journal entries to be saved in the journal. + + +File: hledger.info, Node: Other syntax, Prev: Auto postings, Up: Journal + +8.28 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 help +you decide if you want to use them. + +* Menu: + +* Balance assignments:: +* Bracketed posting dates:: +* D directive:: +* apply account directive:: +* Y directive:: +* Secondary dates:: +* Star comments:: +* Valuation expressions:: +* Virtual postings:: +* Other Ledger directives:: + + +File: hledger.info, Node: Balance assignments, Next: Bracketed posting dates, Up: Other syntax + +8.28.1 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 @@ -3304,8 +3265,8 @@ trustworthy in an audit.  File: hledger.info, Node: Balance assignments and prices, Up: Balance assignments -10.27.2.1 Balance assignments and prices -........................................ +8.28.1.1 Balance assignments and prices +....................................... A cost in a balance assignment will cause the calculated amount to have that price attached: @@ -3320,8 +3281,8 @@ $ hledger print --explicit  File: hledger.info, Node: Bracketed posting dates, Next: D directive, Prev: Balance assignments, Up: Other syntax -10.27.3 Bracketed posting dates -------------------------------- +8.28.2 Bracketed posting dates +------------------------------ For setting posting dates and secondary posting dates, Ledger's bracketed date syntax is also supported: '[DATE]', '[DATE=DATE2]' or @@ -3337,8 +3298,8 @@ syntax.  File: hledger.info, Node: D directive, Next: apply account directive, Prev: Bracketed posting dates, Up: Other syntax -10.27.4 'D' directive ---------------------- +8.28.3 'D' directive +-------------------- 'D AMOUNT' @@ -3383,8 +3344,8 @@ Ledger's 'D'.  File: hledger.info, Node: apply account directive, Next: Y directive, Prev: D directive, Up: Other syntax -10.27.5 'apply account' directive ---------------------------------- +8.28.4 'apply account' directive +-------------------------------- This directive sets a default parent account, which will be prepended to all accounts in following entries, until an 'end apply account' @@ -3419,8 +3380,8 @@ portable, and less trustworthy in an audit.  File: hledger.info, Node: Y directive, Next: Secondary dates, Prev: apply account directive, Up: Other syntax -10.27.6 'Y' directive ---------------------- +8.28.5 'Y' directive +-------------------- 'Y YEAR' @@ -3457,8 +3418,8 @@ date.  File: hledger.info, Node: Secondary dates, Next: Star comments, Prev: Y directive, Up: Other syntax -10.27.7 Secondary dates ------------------------ +8.28.6 Secondary dates +---------------------- A secondary date is written after the primary date, following an equals sign. If the year is omitted, the primary date's year is assumed. When @@ -3479,8 +3440,8 @@ better.  File: hledger.info, Node: Star comments, Next: Valuation expressions, Prev: Secondary dates, Up: Other syntax -10.27.8 Star comments ---------------------- +8.28.7 Star comments +-------------------- Lines beginning with '*' (star/asterisk) are also comment lines. This feature allows Emacs users to insert org headings in their journal, @@ -3496,8 +3457,8 @@ losing ledger mode's features.  File: hledger.info, Node: Valuation expressions, Next: Virtual postings, Prev: Star comments, Up: Other syntax -10.27.9 Valuation expressions ------------------------------ +8.28.8 Valuation expressions +---------------------------- Ledger allows a valuation function or value to be written in double parentheses after an amount. hledger ignores these. @@ -3505,8 +3466,8 @@ parentheses after an amount. hledger ignores these.  File: hledger.info, Node: Virtual postings, Next: Other Ledger directives, Prev: Valuation expressions, Up: Other syntax -10.27.10 Virtual postings -------------------------- +8.28.9 Virtual postings +----------------------- A posting with parentheses around the account name is called a _virtual posting_ or _unbalanced posting_, which means it is exempt from the @@ -3544,8 +3505,8 @@ and less trustworthy in an audit.  File: hledger.info, Node: Other Ledger directives, Prev: Virtual postings, Up: Other syntax -10.27.11 Other Ledger directives --------------------------------- +8.28.10 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 @@ -3575,8 +3536,8 @@ hledger/Ledger syntax comparison.  File: hledger.info, Node: CSV, Next: Timeclock, Prev: Journal, Up: Top -11 CSV -****** +9 CSV +***** hledger can read CSV files (Character Separated Value - usually comma, semicolon, or tab) containing dated records, automatically converting @@ -3624,6 +3585,7 @@ https://github.com/simonmichael/hledger/tree/master/examples/csv. * Menu: * CSV rules cheatsheet:: +* source:: * separator:: * skip:: * date-format:: @@ -3643,14 +3605,16 @@ https://github.com/simonmichael/hledger/tree/master/examples/csv. * CSV rules examples::  -File: hledger.info, Node: CSV rules cheatsheet, Next: separator, Up: CSV +File: hledger.info, Node: CSV rules cheatsheet, Next: source, Up: CSV -11.1 CSV rules cheatsheet -========================= +9.1 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 + from *'separator'* declare the field separator, instead of relying on file extension *'skip'* skip one or more header lines at start of file @@ -3681,10 +3645,40 @@ The following kinds of rule can appear in the rules file, in any order. evaluated.  -File: hledger.info, Node: separator, Next: skip, Prev: CSV rules cheatsheet, Up: CSV +File: hledger.info, Node: source, Next: separator, Prev: CSV rules cheatsheet, Up: CSV -11.2 'separator' -================ +9.2 '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' +(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 +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 in your system's downloads directory ('~/Downloads', currently): + +source Checking1.csv + + And if you specify a glob pattern, hledger will read the most recent +of the matched files (useful with repeated downloads): + +source Checking1*.csv + + See also "Working with CSV > Reading files specified by rule". + + +File: hledger.info, Node: separator, Next: skip, Prev: source, Up: CSV + +9.3 'separator' +=============== You can use the 'separator' rule to read other kinds of character-separated data. The argument is any single separator @@ -3708,27 +3702,27 @@ inferred automatically, and you won't need this rule.  File: hledger.info, Node: skip, Next: date-format, Prev: separator, Up: CSV -11.3 'skip' -=========== +9.4 '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. (Empty/blank lines are skipped automatically, so you don't need -to count those.) You'll need this whenever your CSV data contains -header lines. Header lines skipped in this way are ignored, and not -parsed as CSV. +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' can also be used inside if blocks (described below), to skip -individual data records. Note records skipped in this way are still -required to be valid CSV, even though otherwise ignored. + '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.  File: hledger.info, Node: date-format, Next: timezone, Prev: skip, Up: CSV -11.4 'date-format' -================== +9.5 'date-format' +================= date-format DATEFMT @@ -3756,8 +3750,8 @@ date-format %-m/%-d/%Y %l:%M %p some other junk  File: hledger.info, Node: timezone, Next: newest-first, Prev: date-format, Up: CSV -11.5 'timezone' -=============== +9.6 'timezone' +============== timezone TIMEZONE @@ -3785,8 +3779,8 @@ For others, use numeric format: +HHMM or -HHMM.  File: hledger.info, Node: newest-first, Next: intra-day-reversed, Prev: timezone, Up: CSV -11.6 'newest-first' -=================== +9.7 'newest-first' +================== hledger tries to ensure that the generated transactions will be ordered chronologically, including intra-day transactions. Usually it can @@ -3808,8 +3802,8 @@ newest-first  File: hledger.info, Node: intra-day-reversed, Next: decimal-mark, Prev: newest-first, Up: CSV -11.7 'intra-day-reversed' -========================= +9.8 'intra-day-reversed' +======================== CSV records for each day are sometimes ordered in reverse compared to the overall date order. Eg, here dates are newest first, but the @@ -3829,8 +3823,8 @@ intra-day-reversed  File: hledger.info, Node: decimal-mark, Next: fields list, Prev: intra-day-reversed, Up: CSV -11.8 'decimal-mark' -=================== +9.9 'decimal-mark' +================== decimal-mark . @@ -3847,7 +3841,7 @@ misparsed numbers.  File: hledger.info, Node: fields list, Next: Field assignment, Prev: decimal-mark, Up: CSV -11.9 'fields' list +9.10 'fields' list ================== fields FIELDNAME1, FIELDNAME2, ... @@ -3892,8 +3886,8 @@ field (and generating a balance assertion).  File: hledger.info, Node: Field assignment, Next: Field names, Prev: fields list, Up: CSV -11.10 Field assignment -====================== +9.11 Field assignment +===================== HLEDGERFIELD FIELDVALUE @@ -3926,8 +3920,8 @@ comment note: %somefield - %anotherfield, date: %1  File: hledger.info, Node: Field names, Next: if block, Prev: Field assignment, Up: CSV -11.11 Field names -================= +9.12 Field names +================ Note the two kinds of field names mentioned here, and used only in hledger CSV rules files: @@ -3975,48 +3969,48 @@ happens when you assign values to them:  File: hledger.info, Node: date field, Next: date2 field, Up: Field names -11.11.1 date field ------------------- +9.12.1 date field +----------------- Assigning to 'date' sets the transaction date.  File: hledger.info, Node: date2 field, Next: status field, Prev: date field, Up: Field names -11.11.2 date2 field -------------------- +9.12.2 date2 field +------------------ 'date2' sets the transaction's secondary date, if any.  File: hledger.info, Node: status field, Next: code field, Prev: date2 field, Up: Field names -11.11.3 status field --------------------- +9.12.3 status field +------------------- 'status' sets the transaction's status, if any.  File: hledger.info, Node: code field, Next: description field, Prev: status field, Up: Field names -11.11.4 code field ------------------- +9.12.4 code field +----------------- 'code' sets the transaction's code, if any.  File: hledger.info, Node: description field, Next: comment field, Prev: code field, Up: Field names -11.11.5 description field -------------------------- +9.12.5 description field +------------------------ 'description' sets the transaction's description, if any.  File: hledger.info, Node: comment field, Next: account field, Prev: description field, Up: Field names -11.11.6 comment field ---------------------- +9.12.6 comment field +-------------------- 'comment' sets the transaction's comment, if any. @@ -4030,8 +4024,8 @@ code. A comment starting with '\n' will begin on a new line.  File: hledger.info, Node: account field, Next: amount field, Prev: comment field, Up: Field names -11.11.7 account field ---------------------- +9.12.7 account field +-------------------- Assigning to 'accountN', where N is 1 to 99, sets the account name of the Nth posting, and causes that posting to be generated. @@ -4048,55 +4042,81 @@ or "income:unknown").  File: hledger.info, Node: amount field, Next: currency field, Prev: account field, Up: Field names -11.11.8 amount field --------------------- +9.12.8 amount field +------------------- -There are several "amount" field name variants, useful for different -situations: +Amount setting can get a bit complex. Assigning to 'amount' is +sufficient for simple transactions, but there are four field name +variants you can use for different situations: - * 'amountN' sets the amount of the Nth posting, and causes that - posting to be generated. By assigning to 'amount1', 'amount2', ... - etc. you can generate up to 99 postings. Posting numbers don't - have to be consecutive; in certain situations using a high number - might be helpful to influence the layout of postings. + * *'amountN' sets a specific posting's amount from one CSV field or + arbitrary value.* + Assigning to 'amountN' sets the amount of the Nth posting - and + also causes that posting to be generated. N is most often 1 or 2 + but can go up to 99, potentially generating a 99-posting + transaction. (Posting numbers don't have to be consecutive; higher + posting numbers can sometimes be useful with conditional rules, to + ensure a certain ordering of postings.) - * 'amountN-in' and 'amountN-out' should be used instead, as a pair, - when and only when the amount must be obtained from two CSV fields. - Eg when the CSV has separate Debit and Credit fields instead of a - single Amount field. Note: + * *'amountN-in/-out' sets a specific posting's amount from two CSV + fields.* + When the amount is provided as two CSV fields - "Debit"/"Credit", + "Deposit"/"Withdrawal", "Money In"/"Money Out" or similar - assign + those fields to 'amountN-in' and 'amountN-out' respectively (or + possibly the other way round, depending on signs). This will set + the Nth posting's amount to whichever of the two CSV field values + is non-zero. Some notes: - * Don't think "-in is for the first posting and -out is for the - second posting" - that's not correct. Think: "'amountN-in' - and 'amountN-out' together detect the amount for posting N, by - inspecting two CSV fields at once." - * hledger assumes both CSV fields are unsigned, and will - automatically negate the -out value. - * It also expects that at least one of the values is empty or - zero, so it knows which one to ignore. If that's not the case - you'll need an if rule (see Setting amounts below). + * Don't mix 'amountN' and 'amountN-in'/'-out'. When you have + one CSV amount field, use 'amountN'. When you have two CSV + amount fields, use 'amountN-in'/'amountN-out'. + * 'amountN-in' and 'amountN-out' are always used together, as a + pair. Assign to both of them. + * They do not generate two separate postings; rather, they + generate the Nth posting's single amount, from the value found + in one or other of the two CSV fields. + * In each record, at least one of the two CSV fields must + contain a zero amount or be empty. + * hledger assumes the two CSV fields contain unsigned numbers, + and it will automatically negate the -out amount. + * This variant can be convenient, but it doesn't handle every + two-amount-field situation; if you need more flexibility, use + an 'if' rule (see "Setting amounts" below). - * 'amount', with no posting number (and similarly, 'amount-in' and - 'amount-out' with no number) are an older syntax. We keep them for - backwards compatibility, and because they have special behaviour - that is sometimes convenient: + The other two variants are older and considered legacy syntax, but +can still be convenient sometimes: - * They set the amount of posting 1 and (negated) the amount of - posting 2. - * Posting 2's amount will be converted to cost if it has a cost - price. - * Any of the newer rules for posting 1 or 2 (like 'amount1', or - 'amount2-in' and 'amount2-out') will take precedence. This - allows incrementally migrating old rules files to the new - syntax. + * *'amount' sets posting 1 and 2's amounts from one CSV field or + value.* + Assigning to 'amount', with no posting number, - There's more to say about amount-setting that doesn't fit here; -please see also "Setting amounts" below. + * sets posting 1's amount (like 'amount1') + * sets posting 2's amount to the same amount but with opposite + sign; and also converts it to cost if it has a cost price + * can be overridden by 'amount1' and/or 'amount2' assignments. + (This helps with incremental migration of old rules files to + the newer syntax.) + + * *'amount-in/-out' sets posting 1 and 2's amounts from two CSV + fields.* + Assigning 'amount-in' and 'amount-out', with no posting numbers, to + two CSV fields reads whichever of the two values is non-zero as the + amount, and then sets the first two posting amounts as above. + + We recommend using only one of these variants within a rules file, +rather than mixing them. And remember that a 'fields' list can also do +assignments, so eg naming a CSV field "amount" counts as an assignment +to 'amount'; if you don't want that, call it something else, like +"amount_". + + In addition to this section, please see also the tips beginning at +"Working with CSV > Setting amounts" below.  File: hledger.info, Node: currency field, Next: balance field, Prev: amount field, Up: Field names -11.11.9 currency field ----------------------- +9.12.9 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 @@ -4108,8 +4128,8 @@ amount.  File: hledger.info, Node: balance field, Prev: currency field, Up: Field names -11.11.10 balance field ----------------------- +9.12.10 balance field +--------------------- 'balanceN' sets a balance assertion amount (or if the posting amount is left empty, a balance assignment) on posting N. @@ -4125,8 +4145,8 @@ equivalent to 'balance1'.  File: hledger.info, Node: if block, Next: Matchers, Prev: Field names, Up: CSV -11.12 'if' block -================ +9.13 'if' block +=============== Rules can be applied conditionally, depending on patterns in the CSV data. This allows flexibility; in particular, it is how you can @@ -4180,8 +4200,8 @@ if ,,,,  File: hledger.info, Node: Matchers, Next: if table, Prev: if block, Up: CSV -11.13 Matchers -============== +9.14 Matchers +============= There are two kinds: @@ -4224,8 +4244,8 @@ the original record was:  File: hledger.info, Node: if table, Next: balance-type, Prev: Matchers, Up: CSV -11.14 'if' table -================ +9.15 '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 @@ -4275,8 +4295,8 @@ atm transaction fee,expenses:business:banking,deductible? check it  File: hledger.info, Node: balance-type, Next: include, Prev: if table, Up: CSV -11.15 'balance-type' -==================== +9.16 'balance-type' +=================== Balance assertions generated by assigning to balanceN are of the simple '=' type by default, which is a single-commodity, subaccount-excluding @@ -4298,8 +4318,8 @@ balance-type ==*  File: hledger.info, Node: include, Next: Working with CSV, Prev: balance-type, Up: CSV -11.16 'include' -=============== +9.17 'include' +============== include RULESFILE @@ -4321,8 +4341,8 @@ include categorisation.rules  File: hledger.info, Node: Working with CSV, Next: CSV rules examples, Prev: include, Up: CSV -11.17 Working with CSV -====================== +9.18 Working with CSV +===================== Some tips: @@ -4333,6 +4353,7 @@ Some tips: * File Extension:: * Reading CSV from standard input:: * Reading multiple CSV files:: +* Reading files specified by rule:: * Valid transactions:: * Deduplicating importing:: * Setting amounts:: @@ -4346,8 +4367,8 @@ Some tips:  File: hledger.info, Node: Rapid feedback, Next: Valid CSV, Up: Working with CSV -11.17.1 Rapid feedback ----------------------- +9.18.1 Rapid feedback +--------------------- 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: @@ -4362,8 +4383,8 @@ output.  File: hledger.info, Node: Valid CSV, Next: File Extension, Prev: Rapid feedback, Up: Working with CSV -11.17.2 Valid CSV ------------------ +9.18.2 Valid CSV +---------------- 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 @@ -4383,8 +4404,8 @@ permissive CSV parser like python's csv lib.  File: hledger.info, Node: File Extension, Next: Reading CSV from standard input, Prev: Valid CSV, Up: Working with CSV -11.17.3 File Extension ----------------------- +9.18.3 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), @@ -4403,8 +4424,8 @@ rule if needed.  File: hledger.info, Node: Reading CSV from standard input, Next: Reading multiple CSV files, Prev: File Extension, Up: Working with CSV -11.17.4 Reading CSV from standard input ---------------------------------------- +9.18.4 Reading CSV from standard input +-------------------------------------- You'll need the file format prefix when reading CSV from stdin also, since hledger assumes journal format by default. Eg: @@ -4412,10 +4433,10 @@ since hledger assumes journal format by default. Eg: $ cat foo.dat | hledger -f ssv:- print  -File: hledger.info, Node: Reading multiple CSV files, Next: Valid transactions, Prev: Reading CSV from standard input, Up: Working with CSV +File: hledger.info, Node: Reading multiple CSV files, Next: Reading files specified by rule, Prev: Reading CSV from standard input, Up: Working with CSV -11.17.5 Reading multiple CSV files ----------------------------------- +9.18.5 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 @@ -4423,10 +4444,39 @@ file. But if you use the '--rules-file' option, that rules file will be used for all the CSV files.  -File: hledger.info, Node: Valid transactions, Next: Deduplicating importing, Prev: Reading multiple CSV files, Up: Working with CSV +File: hledger.info, Node: Reading files specified by rule, Next: Valid transactions, Prev: Reading multiple CSV files, Up: Working with CSV -11.17.6 Valid transactions --------------------------- +9.18.6 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 +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 CSV downloads. Most of your financial institutions's default +CSV filenames 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 + 2. Run 'hledger import foo-checking.csv.rules' to import any new + transactions + + 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 nothing, +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. + + +File: hledger.info, Node: Valid transactions, Next: Deduplicating importing, Prev: Reading files specified by rule, Up: Working with CSV + +9.18.7 Valid transactions +------------------------- After reading a CSV file, hledger post-processes and validates the generated journal entries as it would for a journal file - balancing @@ -4444,8 +4494,8 @@ $ hledger -f file.csv print | hledger -f- print  File: hledger.info, Node: Deduplicating importing, Next: Setting amounts, Prev: Valid transactions, Up: Working with CSV -11.17.7 Deduplicating, importing --------------------------------- +9.18.8 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 some @@ -4474,8 +4524,8 @@ CSV data. See:  File: hledger.info, Node: Setting amounts, Next: Amount signs, Prev: Deduplicating importing, Up: Working with CSV -11.17.8 Setting amounts ------------------------ +9.18.9 Setting amounts +---------------------- Continuing from amount field above, here are more tips on handling various amount-setting situations: @@ -4541,11 +4591,12 @@ various amount-setting situations:  File: hledger.info, Node: Amount signs, Next: Setting currency/commodity, Prev: Setting amounts, Up: Working with CSV -11.17.9 Amount signs +9.18.10 Amount signs -------------------- -There is some special handling for amount signs, to simplify parsing and -sign-flipping: +There is some special handling making it easier to parse and to reverse +amount signs. (This only works for whole amounts, not for cost amounts +such as COST in 'amount1 AMT @ COST'): * *If an amount value begins with a plus sign:* that will be removed: '+AMT' becomes 'AMT' @@ -4564,11 +4615,14 @@ sign-flipping: that is removed, making it an empty value. '"+"' or '"-"' or '"()"' becomes '""'. + It's not possible (without preprocessing the CSV) to set an amount to +its absolute value, ie discard its sign. +  File: hledger.info, Node: Setting currency/commodity, Next: Amount decimal places, Prev: Amount signs, Up: Working with CSV -11.17.10 Setting currency/commodity ------------------------------------ +9.18.11 Setting currency/commodity +---------------------------------- If the currency/commodity symbol is included in the CSV's amount field(s): @@ -4615,8 +4669,8 @@ that would trigger the prepending effect, which we don't want here.  File: hledger.info, Node: Amount decimal places, Next: Referencing other fields, Prev: Setting currency/commodity, Up: Working with CSV -11.17.11 Amount decimal places ------------------------------- +9.18.12 Amount decimal places +----------------------------- Like amounts in a journal file, the amounts generated by CSV rules like 'amount1' influence commodity display styles, such as the number of @@ -4628,8 +4682,8 @@ style (because we don't yet reliably know their commodity).  File: hledger.info, Node: Referencing other fields, Next: How CSV rules are evaluated, Prev: Amount decimal places, Up: Working with CSV -11.17.12 Referencing other fields ---------------------------------- +9.18.13 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 @@ -4665,8 +4719,8 @@ if something  File: hledger.info, Node: How CSV rules are evaluated, Next: Well factored rules, Prev: Referencing other fields, Up: Working with CSV -11.17.13 How CSV rules are evaluated ------------------------------------- +9.18.14 How CSV rules are evaluated +----------------------------------- Here's how to think of CSV rules being evaluated (if you really need to). First, @@ -4706,8 +4760,8 @@ command the user specified.  File: hledger.info, Node: Well factored rules, Prev: How CSV rules are evaluated, Up: Working with CSV -11.17.14 Well factored rules ----------------------------- +9.18.15 Well factored rules +--------------------------- Some things than can help reduce duplication and complexity in rules files: @@ -4722,8 +4776,8 @@ files:  File: hledger.info, Node: CSV rules examples, Prev: Working with CSV, Up: CSV -11.18 CSV rules examples -======================== +9.19 CSV rules examples +======================= * Menu: @@ -4735,8 +4789,8 @@ File: hledger.info, Node: CSV rules examples, Prev: Working with CSV, Up: CSV  File: hledger.info, Node: Bank of Ireland, Next: Coinbase, Up: CSV rules examples -11.18.1 Bank of Ireland ------------------------ +9.19.1 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 @@ -4788,8 +4842,8 @@ imported into a journal file.  File: hledger.info, Node: Coinbase, Next: Amazon, Prev: Bank of Ireland, Up: CSV rules examples -11.18.2 Coinbase ----------------- +9.19.2 Coinbase +--------------- A simple example with some CSV from Coinbase. The spot price is recorded using cost notation. The legacy 'amount' field name @@ -4815,8 +4869,8 @@ $ hledger print -f coinbase.csv  File: hledger.info, Node: Amazon, Next: Paypal, Prev: Coinbase, Up: CSV rules examples -11.18.3 Amazon --------------- +9.19.3 Amazon +------------- Here we convert amazon.com order history, and use an if block to generate a third posting if there's a fee. (In practice you'd probably @@ -4873,8 +4927,8 @@ $ hledger -f amazon-orders.csv print  File: hledger.info, Node: Paypal, Prev: Amazon, Up: CSV rules examples -11.18.4 Paypal --------------- +9.19.4 Paypal +------------- Here's a real-world rules file for (customised) Paypal CSV, with some Paypal-specific rules, and a second rules file included: @@ -5027,7 +5081,7 @@ $ hledger -f paypal-custom.csv print  File: hledger.info, Node: Timeclock, Next: Timedot, Prev: CSV, Up: Top -12 Timeclock +10 Timeclock ************ The time logging format of timeclock.el, as read by hledger. @@ -5040,9 +5094,9 @@ optional. The timezone, if present, must be four digits and is ignored (currently the time is always interpreted as a local time). Lines beginning with '#' or ';' or '*', and blank lines, are ignored. -i 2015/03/30 09:00:00 some:account name optional description after two spaces +i 2015/03/30 09:00:00 some account optional description after 2 spaces ; optional comment, tags: o 2015/03/30 09:20:00 -i 2015/03/31 22:21:45 another account +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 @@ -5051,14 +5105,14 @@ 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 -2015-03-30 * optional description after two spaces - (some:account name) 0.33h +2015-03-30 * optional description after 2 spaces ; optional comment, tags: + (some account) 0.33h 2015-03-31 * 22:21-23:59 - (another account) 1.64h + (another:account) 1.64h 2015-04-01 * 00:00-02:00 - (another account) 2.01h + (another:account) 2.01h Here is a sample.timeclock to download and some queries to try: @@ -5082,7 +5136,7 @@ $ hledger -f sample.timeclock register -p weekly --depth 1 --empty # time summa  File: hledger.info, Node: Timedot, Next: PART 3 REPORTING CONCEPTS, Prev: Timeclock, Up: Top -13 Timedot +11 Timedot ********** 'timedot' format is hledger's human-friendly time logging format. @@ -5094,60 +5148,53 @@ Compared to 'timeclock' format, it is A timedot file contains a series of day entries, which might look like this: -2021-08-04 -hom:errands .... .... -fos:hledger:timedot .. ; docs -per:admin:finance +2023-05-01 +hom:errands .... .... ; two hours +fos:hledger:timedot .. ; half an hour +per:admin:finance - hledger reads this as three time transactions on this day, with each -dot representing a quarter-hour spent: + hledger reads this as a transaction on this day with three +(unbalanced) postings, where each dot represents "0.25". No commodity +is assumed, but normally we interpret it as hours, with each dot +representing a quarter-hour. It's convenient, though not required, to +group the dots in fours for easy reading. -$ hledger -f a.timedot print # .timedot file extension activates the timedot reader -2021-08-04 * - (hom:errands) 2.00 +$ hledger -f a.timedot print # .timedot file extension (or timedot: prefix) is required +2023-05-01 * + (hom:errands) 2.00 ; two hours + (fos:hledger:timedot) 0.50 ; half an hour + (per:admin:finance) 0 -2021-08-04 * - (fos:hledger:timedot) 0.50 + A transaction begins with a non-indented *simple date* (Y-M-D, Y/M/D, +or Y.M.D). It can optionally be preceded by one or more stars and a +space, for Emacs org mode compatibility. It can optionally be followed +on the same line by a transaction description, and/or a transaction +comment following a semicolon. -2021-08-04 * - (per:admin:finance) 0 + After the date line are zero or more time postings, consisting of: - A day entry begins with a date line: - - * a non-indented *simple date* (Y-M-D, Y/M/D, or Y.M.D). - - Optionally this can be followed on the same line by - - * a common *transaction description* for this day - * a common *transaction comment* for this day, after a semicolon - (';'). - - After the date line are zero or more optionally-indented time -transaction lines, consisting of: - - * an *account name* - any word or phrase, usually a hledger-style - account name. + * an *account name* - any hledger-style account name, optionally + hierarchical, optionally indented. * *two or more spaces* - a field separator, required if there is an amount (as in journal format). - * a *timedot amount* - dots representing quarter hours, or a number - representing hours. - * an optional *comment* beginning with semicolon. This is ignored. + * an optional *timedot amount* - dots representing quarter hours, or + a number representing hours, optionally with a unit suffix. + * an optional *posting comment* following a semicolon. - In more detail, timedot amounts can be: + Timedot amounts can be: - * *dots*: zero or more period characters, each representing one - quarter-hour. Spaces are ignored and can be used for grouping. - Eg: '.... ..' + * *dots*: zero or more period characters ('.'), each representing + 0.25. Spaces are ignored and can be used for grouping. Eg: '.... + ..' - * a *number*, representing hours. Eg: '1.5' + * or a *number*. Eg: '1.5' - * a *number immediately followed by a unit symbol* 's', 'm', 'h', - 'd', 'w', 'mo', or 'y', representing seconds, minutes, hours, days - weeks, months or years. Eg '1.5h' or '90m'. The following - equivalencies are assumed: + * or a *number immediately followed by a unit symbol* 's', 'm', 'h', + 'd', 'w', 'mo', or 'y'. These are interpreted as seconds, minutes, + hours, days weeks, months or years, and converted to hours, + assuming: '60s' = '1m', '60m' = '1h', '24h' = '1d', '7d' = '1w', '30d' = - '1mo', '365d' = '1y'. (This unit will not be visible in the - generated transaction amount, which is always in hours.) + '1mo', '365d' = '1y'. Eg '90m' is parsed as '1.5'. There is some added flexibility to help with keeping time log data in the same file as your notes, todo lists, etc.: @@ -5155,15 +5202,16 @@ the same file as your notes, todo lists, etc.: * Blank lines and lines beginning with '#' or ';' are ignored. * Before the first date line, lines beginning with '*' are ignored. - From the first date line onward, a sequence of '*''s followed by a + + * From the first date line onward, one or more '*''s followed by a space at beginning of lines (ie, the headline prefix used by Emacs Org mode) is ignored. This means the time log can be kept under an Org headline, and date lines or time transaction lines can be Org headlines. * Lines not ending with a double-space and amount are parsed as - transactions with zero amount. (Most hledger reports hide these by - default; add -E to see them.) + postings with zero amount. Note hledger's register reports hide + these by default (add -E to see them). More examples: @@ -5245,13 +5293,13 @@ $ hledger -f a.timedot --alias /\\./=: bal --tree  File: hledger.info, Node: PART 3 REPORTING CONCEPTS, Next: Time periods, Prev: Timedot, Up: Top -14 PART 3: REPORTING CONCEPTS +12 PART 3: REPORTING CONCEPTS *****************************  File: hledger.info, Node: Time periods, Next: Depth, Prev: PART 3 REPORTING CONCEPTS, Up: Top -15 Time periods +13 Time periods *************** * Menu: @@ -5265,7 +5313,7 @@ File: hledger.info, Node: Time periods, Next: Depth, Prev: PART 3 REPORTING C  File: hledger.info, Node: Report start & end date, Next: Smart dates, Up: Time periods -15.1 Report start & end date +13.1 Report start & end date ============================ By default, most hledger reports will show the full span of time @@ -5310,7 +5358,7 @@ thismonth'  File: hledger.info, Node: Smart dates, Next: Report intervals, Prev: Report start & end date, Up: Time periods -15.2 Smart dates +13.2 Smart dates ================ hledger's user interfaces accept a "smart date" syntax for added @@ -5359,7 +5407,7 @@ periodic transaction rules, which are not affected by '--today'.)  File: hledger.info, Node: Report intervals, Next: Date adjustment, Prev: Smart dates, Up: Time periods -15.3 Report intervals +13.3 Report intervals ===================== A report interval can be specified so that reports like register, @@ -5381,7 +5429,7 @@ described below.  File: hledger.info, Node: Date adjustment, Next: Period expressions, Prev: Report intervals, Up: Time periods -15.4 Date adjustment +13.4 Date adjustment ==================== When there is a report interval (other than daily), report start/end @@ -5405,7 +5453,7 @@ period headings.  File: hledger.info, Node: Period expressions, Prev: Date adjustment, Up: Time periods -15.5 Period expressions +13.5 Period expressions ======================= The '-p/--period' option specifies a period expression, which is a @@ -5465,7 +5513,7 @@ date:  File: hledger.info, Node: Period expressions with a report interval, Next: More complex report intervals, Up: Period expressions -15.5.1 Period expressions with a report interval +13.5.1 Period expressions with a report interval ------------------------------------------------ A period expression can also begin with a report interval, separated @@ -5478,7 +5526,7 @@ from the start/end dates (if any) by a space or the word 'in':  File: hledger.info, Node: More complex report intervals, Next: Multiple weekday intervals, Prev: Period expressions with a report interval, Up: Period expressions -15.5.2 More complex report intervals +13.5.2 More complex report intervals ------------------------------------ Some more complex intervals can be specified within period expressions, @@ -5541,7 +5589,7 @@ $ hledger register checking -p "every 3rd day of week"  File: hledger.info, Node: Multiple weekday intervals, Prev: More complex report intervals, Up: Period expressions -15.5.3 Multiple weekday intervals +13.5.3 Multiple weekday intervals --------------------------------- This special form is also supported: @@ -5569,7 +5617,7 @@ weekendday"'  File: hledger.info, Node: Depth, Next: Queries, Prev: Time periods, Up: Top -16 Depth +14 Depth ******** With the '--depth NUM' option (short form: '-NUM'), reports will show @@ -5581,7 +5629,7 @@ equivalent.  File: hledger.info, Node: Queries, Next: Pivoting, Prev: Depth, Up: Top -17 Queries +15 Queries ********** One of hledger's strengths is being able to quickly report on a precise @@ -5622,7 +5670,7 @@ arguments to restrict their scope. The syntax is as follows:  File: hledger.info, Node: Query types, Next: Combining query terms, Up: Queries -17.1 Query types +15.1 Query types ================ Here are the types of query term available. Remember these can also be @@ -5711,7 +5759,7 @@ hledger-web to show the transaction register for an account.)  File: hledger.info, Node: Combining query terms, Next: Queries and command options, Prev: Query types, Up: Queries -17.2 Combining query terms +15.2 Combining query terms ========================== When given multiple space-separated query terms, most commands select @@ -5755,7 +5803,7 @@ OR, and NOT, where NOT is different syntax for 'not:'.  File: hledger.info, Node: Queries and command options, Next: Queries and valuation, Prev: Combining query terms, Up: Queries -17.3 Queries and command options +15.3 Queries and command options ================================ Some queries can also be expressed as command-line options: 'depth:2' is @@ -5766,7 +5814,7 @@ resulting query is their intersection.  File: hledger.info, Node: Queries and valuation, Next: Querying with account aliases, Prev: Queries and command options, Up: Queries -17.4 Queries and valuation +15.4 Queries and valuation ========================== When amounts are converted to other commodities in cost or value @@ -5777,7 +5825,7 @@ reversed, see #1625).  File: hledger.info, Node: Querying with account aliases, Next: Querying with cost or value, Prev: Queries and valuation, Up: Queries -17.5 Querying with account aliases +15.5 Querying with account aliases ================================== When account names are rewritten with '--alias' or 'alias', note that @@ -5786,7 +5834,7 @@ When account names are rewritten with '--alias' or 'alias', note that  File: hledger.info, Node: Querying with cost or value, Prev: Querying with account aliases, Up: Queries -17.6 Querying with cost or value +15.6 Querying with cost or value ================================ When amounts are converted to other commodities in cost or value @@ -5798,7 +5846,7 @@ the discussion at #1625.  File: hledger.info, Node: Pivoting, Next: Generating data, Prev: Queries, Up: Top -18 Pivoting +16 Pivoting *********** Normally, hledger groups and sums amounts within each account. The @@ -5850,92 +5898,238 @@ $ hledger balance --pivot member acct:.  File: hledger.info, Node: Generating data, Next: Forecasting, Prev: Pivoting, Up: Top -19 Generating data +17 Generating data ****************** -Two features for generating transient data (visible only at report time) -are built in to hledger's journal format: +hledger has several features for generating data, such as: - * Auto posting rules can generate extra postings on certain - transactions. They are activated by the '--auto' flag. + * Periodic transaction rules can generate single or repeating + transactions following a template. These are usually dated in the + future, eg to help with forecasting. They are activated by the + '--forecast' option. - * Periodic transaction rules can generate repeating transactions, - usually dated in the future, to help with forecasting or budgeting. - They are activated by the '--forecast' or 'balance --budget' - options, described next. + * The balance command's '--budget' option uses these same periodic + rules to generate goals for the budget report. + + * Auto posting rules can generate extra postings on certain matched + transactions. They are always applied to forecast transactions; + with the '--auto' flag they are applied to transactions recorded in + the journal as well. + + * The '--infer-equity' flag infers missing conversion equity postings + from @/@@ costs. And the inverse '--infer-costs' flag infers + missing @/@@ costs from conversion equity postings. + + Generated data of this kind is temporary, existing only at report +time. But you can see it in the output of 'hledger print', and you can +save that to your journal, in effect converting it from temporary +generated data to permanent recorded data. This could be useful as a +data entry aid. + + If you are wondering what data is being generated and why, add the +'--verbose-tags' flag. In 'hledger print' output you will see extra +tags like 'generated-transaction', 'generated-posting', and 'modified' +on generated/modified data. Also, even without '--verbose-tags', +generated data always has equivalen hidden tags (with an underscore +prefix), so eg you could match generated transactions with +'tag:_generated-transaction'.  File: hledger.info, Node: Forecasting, Next: Budgeting, Prev: Generating data, Up: Top -20 Forecasting +18 Forecasting ************** -The '--forecast' flag activates any periodic transaction rules in the -journal. These will generate temporary additional transactions, usually -recurring and in the future, which will appear in all reports. 'hledger -print --forecast' is a good way to see them. +Forecasting, or speculative future reporting, can be useful for +estimating future balances, or for exploring different future scenarios. - This can be useful for estimating balances into the future, perhaps -experimenting with different 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 see them. - It could also be useful for scripted data entry: you could describe -recurring transactions, and every so often copy the output of 'print ---forecast' into the journal. +* Menu: - The generated transactions will have an extra tag, like -'generated-transaction:~ PERIODICEXPR', indicating which periodic rule -generated them. There is also a similar, hidden tag, named -'_generated-transaction:', which you can use to reliably match -transactions generated "just now" (rather than 'print'ed in the past). +* --forecast:: +* Inspecting forecast transactions:: +* Forecast reports:: +* Forecast tags:: +* Forecast period in detail:: +* Forecast troubleshooting:: - The forecast transactions are generated within a _forecast period_, -which is independent of the report period. (Forecast period sets the -bounds for generated transactions, report period controls which -transactions are reported.) The forecast period begins on: + +File: hledger.info, Node: --forecast, Next: Inspecting forecast transactions, Up: Forecasting - * the start date provided within '--forecast''s argument, if any - * otherwise, the later of - * the report start date, if specified (with '-b'/'-p'/'date:') - * the day after the latest ordinary transaction in the journal, - if any +18.1 -forecast +============== - * otherwise today. +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 +generate multiple recurring transactions, so by changing one rule you +can change many forecasted transactions. (These same rules can also +generate budget goals, described in Budgeting.) - It ends on: + 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 +exact rules are a little more complicated, and are given below.) - * the end date provided within '--forecast''s argument, if any - * otherwise, the report end date, if specified (with - '-e'/'-p'/'date:') - * otherwise 180 days (6 months) from today. + 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, 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 required. - Note, this means that ordinary transactions will suppress periodic -transactions, by default; the periodic transactions will not start until -after the last ordinary transaction. This is usually convenient, but -you can get around it in two ways: + +File: hledger.info, Node: Inspecting forecast transactions, Next: Forecast reports, Prev: --forecast, Up: Forecasting - * If you need to record some transactions in the future, make them - periodic transactions (with a single occurrence, eg: '~ - YYYY-MM-DD') rather than ordinary transactions. That way they - won't suppress other periodic transactions. +18.2 Inspecting forecast transactions +===================================== - * Or give '--forecast' a period expression argument. A forecast - period specified this way can overlap ordinary transactions, and - need not be in the future. Some things to note: +'print' is the best command for inspecting and troubleshooting forecast +transactions. Eg: - * You must use '=' between flag and argument; a space won't - work. - * The period expression can specify the forecast period's start - date, end date, or both. See also Report start & end date. - * The period expression should not specify a report interval. - (Each periodic transaction rule specifies its own interval.) +~ monthly from 2022-12-20 rent + assets:bank:checking + expenses:rent $1000 - Some examples: '--forecast=202001-202004', '--forecast=jan-', -'--forecast=2021'. +$ hledger print --forecast --today=2023/4/21 +2023-05-20 rent + ; generated-transaction: ~ monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 + +2023-06-20 rent + ; generated-transaction: ~ monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 + +2023-07-20 rent + ; generated-transaction: ~ monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 + +2023-08-20 rent + ; generated-transaction: ~ monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 + +2023-09-20 rent + ; generated-transaction: ~ monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 + + Here there are no ordinary transactions, so the forecasted +transactions begin on the first occurence after today's date. (You +won't normally use '--today'; it's just to make these examples +reproducible.) + + +File: hledger.info, Node: Forecast reports, Next: Forecast tags, Prev: Inspecting forecast transactions, Up: Forecasting + +18.3 Forecast reports +===================== + +Forecast transactions affect all reports, as you would expect. Eg: + +$ hledger areg rent --forecast --today=2023/4/21 +Transactions in expenses:rent and subaccounts: +2023-05-20 rent as:ba:checking $1000 $1000 +2023-06-20 rent as:ba:checking $1000 $2000 +2023-07-20 rent as:ba:checking $1000 $3000 +2023-08-20 rent as:ba:checking $1000 $4000 +2023-09-20 rent as:ba:checking $1000 $5000 + +$ hledger bal -M expenses --forecast --today=2023/4/21 +Balance changes in 2023-05-01..2023-09-30: + + || May Jun Jul Aug Sep +===============++=================================== + expenses:rent || $1000 $1000 $1000 $1000 $1000 +---------------++----------------------------------- + || $1000 $1000 $1000 $1000 $1000 + + +File: hledger.info, Node: Forecast tags, Next: Forecast period in detail, Prev: Forecast reports, Up: Forecasting + +18.4 Forecast tags +================== + +Forecast transactions generated by -forecast have a hidden tag, +'_generated-transaction'. So if you ever need to match forecast +transactions, you could use 'tag:_generated-transaction' (or just +'tag:generated') in a query. + + For troubleshooting, you can add the '--verbose-tags' flag. Then, +visible 'generated-transaction' tags will be added also, so you can view +them with the 'print' command. Their value indicates which periodic +rule was responsible. + + +File: hledger.info, Node: Forecast period in detail, Next: Forecast troubleshooting, Prev: Forecast tags, Up: Forecasting + +18.5 Forecast period, in detail +=============================== + +Forecast start/end dates are chosen so as to do something useful by +default in almost all situations, while also being flexible. Here are +(with luck) the exact rules, to help with troubleshooting: + + The forecast period starts on: + + * the later of + * the start date in the periodic transaction rule + * the start date in '--forecast''s argument + + * otherwise (if those are not available): the later of + * the report start date specified with '-b'/'-p'/'date:' + * the day after the latest ordinary transaction in the journal + + * otherwise (if none of these are available): today. + + The forecast period ends on: + + * the earlier of + * the end date in the periodic transaction rule + * the end date in '--forecast''s argument + + * otherwise: the report end date specified with '-e'/'-p'/'date:' + * otherwise: 180 days (~6 months) from today. + + +File: hledger.info, Node: Forecast troubleshooting, Prev: Forecast period in detail, Up: Forecasting + +18.6 Forecast troubleshooting +============================= + +When -forecast is not doing what you expect, one of these tips should +help: + + * Remember to use the '--forecast' option. + * Remember to have at least one periodic transaction rule in your + journal. + * Test with 'print --forecast'. + * Check for typos or too-restrictive start/end dates in your periodic + transaction rule. + * Leave at least 2 spaces between the rule's period expression and + description fields. + * Check for future-dated ordinary transactions suppressing forecasted + transactions. + * Try setting explicit report start and/or end dates with '-b', '-e', + '-p' or 'date:' + * Try adding the '-E' flag to encourage display of empty periods/zero + transactions. + * Try setting explicit forecast start and/or end dates with + '--forecast=START..END' + * Consult Forecast period, in detail, above. + * Check inside the engine: add '--debug=2' (eg).  File: hledger.info, Node: Budgeting, Next: Cost reporting, Prev: Forecasting, Up: Top -21 Budgeting +19 Budgeting ************ With the balance command's '--budget' report, each periodic transaction @@ -5943,12 +6137,16 @@ 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 +bal -M --budget --forecast ...' + See also: Budgeting and Forecasting.  File: hledger.info, Node: Cost reporting, Next: Valuation, Prev: Budgeting, Up: Top -22 Cost reporting +20 Cost reporting ***************** This section is about recording the cost of things, in transactions @@ -5984,7 +6182,7 @@ currency, or a stock purchase or sale. First, a quick glossary:  File: hledger.info, Node: -B Convert to cost, Next: Equity conversion postings, Up: Cost reporting -22.1 -B: Convert to cost +20.1 -B: Convert to cost ======================== As discussed in JOURNAL > Costs, when recording a transaction you can @@ -6028,7 +6226,7 @@ equation and tends to causes a non-zero total in balance reports.  File: hledger.info, Node: Equity conversion postings, Next: Inferring equity postings from cost, Prev: -B Convert to cost, Up: Cost reporting -22.2 Equity conversion postings +20.2 Equity conversion postings =============================== By contrast, conventional double entry bookkeeping (DEB) uses a @@ -6056,7 +6254,7 @@ not-so-clear transaction balancing error message.  File: hledger.info, Node: Inferring equity postings from cost, Next: Inferring cost from equity postings, Prev: Equity conversion postings, Up: Cost reporting -22.3 Inferring equity postings from cost +20.3 Inferring equity postings from cost ======================================== With '--infer-equity', hledger detects transactions written with PTA @@ -6084,7 +6282,7 @@ entries for sharing with non-PTA-users.  File: hledger.info, Node: Inferring cost from equity postings, Next: When to infer cost/equity, Prev: Inferring equity postings from cost, Up: Cost reporting -22.4 Inferring cost from equity postings +20.4 Inferring cost from equity postings ======================================== The reverse operation is possible using '--infer-costs', which detects @@ -6141,7 +6339,7 @@ mixture of both notations in your journal.  File: hledger.info, Node: When to infer cost/equity, Next: How to record conversions, Prev: Inferring cost from equity postings, Up: Cost reporting -22.5 When to infer cost/equity +20.5 When to infer cost/equity ============================== Inferring equity postings or costs is still fairly new, so not enabled @@ -6157,7 +6355,7 @@ suggestions to try, experience reports welcome:  File: hledger.info, Node: How to record conversions, Next: Cost tips, Prev: When to infer cost/equity, Up: Cost reporting -22.6 How to record conversions +20.6 How to record conversions ============================== Essentially there are four ways to record a conversion transaction in @@ -6173,7 +6371,7 @@ hledger. Here are all of them, with pros and cons.  File: hledger.info, Node: Conversion with implicit cost, Next: Conversion with explicit cost, Up: How to record conversions -22.6.1 Conversion with implicit cost +20.6.1 Conversion with implicit cost ------------------------------------ Let's assume 100 EUR is converted to 120 USD. You can just record the @@ -6208,7 +6406,7 @@ check balancednoautoconversion', or '-s/--strict'.  File: hledger.info, Node: Conversion with explicit cost, Next: Conversion with equity postings, Prev: Conversion with implicit cost, Up: How to record conversions -22.6.2 Conversion with explicit cost +20.6.2 Conversion with explicit cost ------------------------------------ You can add the conversion rate using @ notation: @@ -6234,7 +6432,7 @@ error otherwise.  File: hledger.info, Node: Conversion with equity postings, Next: Conversion with equity postings and explicit cost, Prev: Conversion with explicit cost, Up: How to record conversions -22.6.3 Conversion with equity postings +20.6.3 Conversion with equity postings -------------------------------------- In strict double entry bookkeeping, the above transaction is not @@ -6266,7 +6464,7 @@ each commodity, using an equity account:  File: hledger.info, Node: Conversion with equity postings and explicit cost, Prev: Conversion with equity postings, Up: How to record conversions -22.6.4 Conversion with equity postings and explicit cost +20.6.4 Conversion with equity postings and explicit cost -------------------------------------------------------- Here both equity postings and @ notation are used together. @@ -6292,7 +6490,7 @@ Here both equity postings and @ notation are used together.  File: hledger.info, Node: Cost tips, Prev: How to record conversions, Up: Cost reporting -22.7 Cost tips +20.7 Cost tips ============== * Recording the cost/conversion rate explicitly is good because it @@ -6312,7 +6510,7 @@ File: hledger.info, Node: Cost tips, Prev: How to record conversions, Up: Cos  File: hledger.info, Node: Valuation, Next: PART 4 COMMANDS, Prev: Cost reporting, Up: Top -23 Valuation +21 Valuation ************ Instead of reporting amounts in their original commodity, hledger can @@ -6339,7 +6537,7 @@ and '-X COMMODITY' options, and often one of these is all you need:  File: hledger.info, Node: -V Value, Next: -X Value in specified commodity, Up: Valuation -23.1 -V: Value +21.1 -V: Value ============== The '-V/--market' flag converts amounts to market value in their default @@ -6349,7 +6547,7 @@ _valuation date(s)_, if any. More on these in a minute.  File: hledger.info, Node: -X Value in specified commodity, Next: Valuation date, Prev: -V Value, Up: Valuation -23.2 -X: Value in specified commodity +21.2 -X: Value in specified commodity ===================================== The '-X/--exchange=COMM' option is like '-V', except you tell it which @@ -6359,7 +6557,7 @@ that.  File: hledger.info, Node: Valuation date, Next: Finding market price, Prev: -X Value in specified commodity, Up: Valuation -23.3 Valuation date +21.3 Valuation date =================== Since market prices can change from day to day, market value reports @@ -6376,7 +6574,7 @@ of the period, by default.  File: hledger.info, Node: Finding market price, Next: --infer-market-prices market prices from transactions, Prev: Valuation date, Up: Valuation -23.4 Finding market price +21.4 Finding market price ========================= To convert a commodity A to its market value in another commodity B, @@ -6410,7 +6608,7 @@ converted.  File: hledger.info, Node: --infer-market-prices market prices from transactions, Next: Valuation commodity, Prev: Finding market price, Up: Valuation -23.5 -infer-market-prices: market prices from transactions +21.5 -infer-market-prices: market prices from transactions ========================================================== Normally, market value in hledger is fully controlled by, and requires, @@ -6496,7 +6694,7 @@ P 2022-01-03 B A -1.0  File: hledger.info, Node: Valuation commodity, Next: Simple valuation examples, Prev: --infer-market-prices market prices from transactions, Up: Valuation -23.6 Valuation commodity +21.6 Valuation commodity ======================== *When you specify a valuation commodity ('-X COMM' or '--value @@ -6535,7 +6733,7 @@ converted.  File: hledger.info, Node: Simple valuation examples, Next: --value Flexible valuation, Prev: Valuation commodity, Up: Valuation -23.7 Simple valuation examples +21.7 Simple valuation examples ============================== Here are some quick examples of '-V': @@ -6570,7 +6768,7 @@ $ hledger -f t.j bal -N euros -V  File: hledger.info, Node: --value Flexible valuation, Next: More valuation examples, Prev: Simple valuation examples, Up: Valuation -23.8 -value: Flexible valuation +21.8 -value: Flexible valuation =============================== '-V' and '-X' are special cases of the more general '--value' option: @@ -6612,7 +6810,7 @@ this commodity, deducing market prices as described above.  File: hledger.info, Node: More valuation examples, Next: Interaction of valuation and queries, Prev: --value Flexible valuation, Up: Valuation -23.9 More valuation examples +21.9 More valuation examples ============================ Here are some examples showing the effect of '--value', as seen with @@ -6726,7 +6924,7 @@ $ hledger print -X A  File: hledger.info, Node: Interaction of valuation and queries, Next: Effect of valuation on reports, Prev: More valuation examples, Up: Valuation -23.10 Interaction of valuation and queries +21.10 Interaction of valuation and queries ========================================== When matching postings based on queries in the presence of valuation, @@ -6747,7 +6945,7 @@ the following happens.  File: hledger.info, Node: Effect of valuation on reports, Prev: Interaction of valuation and queries, Up: Valuation -23.11 Effect of valuation on reports +21.11 Effect of valuation on reports ==================================== Here is a reference for how valuation is supposed to affect each part of @@ -6896,7 +7094,7 @@ _report interval_  File: hledger.info, Node: PART 4 COMMANDS, Next: PART 5 COMMON TASKS, Prev: Valuation, Up: Top -24 PART 4: COMMANDS +22 PART 4: COMMANDS ******************* * Menu: @@ -6935,7 +7133,7 @@ File: hledger.info, Node: PART 4 COMMANDS, Next: PART 5 COMMON TASKS, Prev: V  File: hledger.info, Node: Commands overview, Next: accounts, Up: PART 4 COMMANDS -24.1 Commands overview +22.1 Commands overview ====================== Here are the built-in commands: @@ -6954,7 +7152,7 @@ Here are the built-in commands:  File: hledger.info, Node: DATA ENTRY, Next: DATA CREATION, Up: Commands overview -24.1.1 DATA ENTRY +22.1.1 DATA ENTRY ----------------- These data entry commands are the only ones which can modify your @@ -6966,7 +7164,7 @@ journal file.  File: hledger.info, Node: DATA CREATION, Next: DATA MANAGEMENT, Prev: DATA ENTRY, Up: Commands overview -24.1.2 DATA CREATION +22.1.2 DATA CREATION -------------------- * close - generate balance-zeroing/restoring transactions @@ -6975,7 +7173,7 @@ File: hledger.info, Node: DATA CREATION, Next: DATA MANAGEMENT, Prev: DATA EN  File: hledger.info, Node: DATA MANAGEMENT, Next: REPORTS FINANCIAL, Prev: DATA CREATION, Up: Commands overview -24.1.3 DATA MANAGEMENT +22.1.3 DATA MANAGEMENT ---------------------- * check - check for various kinds of error in the data @@ -6984,7 +7182,7 @@ File: hledger.info, Node: DATA MANAGEMENT, Next: REPORTS FINANCIAL, Prev: DAT  File: hledger.info, Node: REPORTS FINANCIAL, Next: REPORTS VERSATILE, Prev: DATA MANAGEMENT, Up: Commands overview -24.1.4 REPORTS, FINANCIAL +22.1.4 REPORTS, FINANCIAL ------------------------- * aregister (areg) - show transactions in a particular account @@ -6996,7 +7194,7 @@ File: hledger.info, Node: REPORTS FINANCIAL, Next: REPORTS VERSATILE, Prev: D  File: hledger.info, Node: REPORTS VERSATILE, Next: REPORTS BASIC, Prev: REPORTS FINANCIAL, Up: Commands overview -24.1.5 REPORTS, VERSATILE +22.1.5 REPORTS, VERSATILE ------------------------- * balance (bal) - show balance changes, end balances, budgets, @@ -7009,7 +7207,7 @@ File: hledger.info, Node: REPORTS VERSATILE, Next: REPORTS BASIC, Prev: REPOR  File: hledger.info, Node: REPORTS BASIC, Next: HELP, Prev: REPORTS VERSATILE, Up: Commands overview -24.1.6 REPORTS, BASIC +22.1.6 REPORTS, BASIC --------------------- * accounts - show account names @@ -7028,7 +7226,7 @@ File: hledger.info, Node: REPORTS BASIC, Next: HELP, Prev: REPORTS VERSATILE,  File: hledger.info, Node: HELP, Next: ADD-ONS, Prev: REPORTS BASIC, Up: Commands overview -24.1.7 HELP +22.1.7 HELP ----------- * help - show the hledger manual with info/man/pager @@ -7037,7 +7235,7 @@ File: hledger.info, Node: HELP, Next: ADD-ONS, Prev: REPORTS BASIC, Up: Comm  File: hledger.info, Node: ADD-ONS, Prev: HELP, Up: Commands overview -24.1.8 ADD-ONS +22.1.8 ADD-ONS -------------- And here are some typical add-on commands. Some of these are installed @@ -7057,7 +7255,7 @@ hledger's commands list:  File: hledger.info, Node: accounts, Next: activity, Prev: Commands overview, Up: PART 4 COMMANDS -24.2 accounts +22.2 accounts ============= Show account names. @@ -7114,7 +7312,7 @@ $ hledger check accounts  File: hledger.info, Node: activity, Next: add, Prev: accounts, Up: PART 4 COMMANDS -24.3 activity +22.3 activity ============= Show an ascii barchart of posting counts per interval. @@ -7134,7 +7332,7 @@ $ hledger activity --quarterly  File: hledger.info, Node: add, Next: aregister, Prev: activity, Up: PART 4 COMMANDS -24.4 add +22.4 add ======== Prompt for transactions and add them to the journal. Any arguments will @@ -7204,7 +7402,7 @@ file path ends with a period, as that would cause problems (#1056).  File: hledger.info, Node: aregister, Next: balance, Prev: add, Up: PART 4 COMMANDS -24.5 aregister +22.5 aregister ============== (areg) @@ -7279,7 +7477,7 @@ options. The output formats supported are 'txt', 'csv', and 'json'.  File: hledger.info, Node: aregister and custom posting dates, Up: aregister -24.5.1 aregister and custom posting dates +22.5.1 aregister and custom posting dates ----------------------------------------- Transactions whose date is outside the report period can still be shown, @@ -7295,7 +7493,7 @@ it's probably best to assume the running balance is wrong.  File: hledger.info, Node: balance, Next: balancesheet, Prev: aregister, Up: PART 4 COMMANDS -24.6 balance +22.6 balance ============ (bal) @@ -7334,7 +7532,7 @@ more control, then use 'balance'.  File: hledger.info, Node: balance features, Next: Simple balance report, Up: balance -24.6.1 balance features +22.6.1 balance features ----------------------- Here's a quick overview of the 'balance' command's features, followed by @@ -7354,6 +7552,7 @@ higher-level commands as well. * or value of balance changes ('-V') * or change of balance values ('--valuechange') * or unrealised capital gain/loss ('--gain') + * or postings count ('--count') ..in.. @@ -7396,7 +7595,7 @@ in the transactions of the postings which would normally be shown.  File: hledger.info, Node: Simple balance report, Next: Balance report line format, Prev: balance features, Up: balance -24.6.2 Simple balance report +22.6.2 Simple balance report ---------------------------- With no arguments, 'balance' shows a list of all accounts and their @@ -7445,7 +7644,7 @@ $ hledger -f examples/sample.journal bal -E  File: hledger.info, Node: Balance report line format, Next: Filtered balance report, Prev: Simple balance report, Up: balance -24.6.3 Balance report line format +22.6.3 Balance report line format --------------------------------- For single-period balance reports displayed in the terminal (only), you @@ -7508,7 +7707,7 @@ may be needed to get pleasing results.  File: hledger.info, Node: Filtered balance report, Next: List or tree mode, Prev: Balance report line format, Up: balance -24.6.4 Filtered balance report +22.6.4 Filtered balance report ------------------------------ You can show fewer accounts, a different time period, totals from @@ -7523,7 +7722,7 @@ $ hledger -f examples/sample.journal bal --cleared assets date:200806  File: hledger.info, Node: List or tree mode, Next: Depth limiting, Prev: Filtered balance report, Up: balance -24.6.5 List or tree mode +22.6.5 List or tree mode ------------------------ By default, or with '-l/--flat', accounts are shown as a flat list with @@ -7566,7 +7765,7 @@ $ hledger -f examples/sample.journal balance  File: hledger.info, Node: Depth limiting, Next: Dropping top-level accounts, Prev: List or tree mode, Up: balance -24.6.6 Depth limiting +22.6.6 Depth limiting --------------------- With a 'depth:NUM' query, or '--depth NUM' option, or just '-NUM' (eg: @@ -7588,7 +7787,7 @@ $ hledger -f examples/sample.journal balance -1  File: hledger.info, Node: Dropping top-level accounts, Next: Showing declared accounts, Prev: Depth limiting, Up: balance -24.6.7 Dropping top-level accounts +22.6.7 Dropping top-level accounts ---------------------------------- You can also hide one or more top-level account name parts, using @@ -7604,7 +7803,7 @@ $ hledger -f examples/sample.journal bal expenses --drop 1  File: hledger.info, Node: Showing declared accounts, Next: Sorting by amount, Prev: Dropping top-level accounts, Up: balance -24.6.8 Showing declared accounts +22.6.8 Showing declared accounts -------------------------------- With '--declared', accounts which have been declared with an account @@ -7622,7 +7821,7 @@ accounts yet.  File: hledger.info, Node: Sorting by amount, Next: Percentages, Prev: Showing declared accounts, Up: balance -24.6.9 Sorting by amount +22.6.9 Sorting by amount ------------------------ With '-S/--sort-amount', accounts with the largest (most positive) @@ -7640,7 +7839,7 @@ which flip the sign automatically. Eg: 'hledger incomestatement -MAS').  File: hledger.info, Node: Percentages, Next: Multi-period balance report, Prev: Sorting by amount, Up: balance -24.6.10 Percentages +22.6.10 Percentages ------------------- With '-%/--percent', balance reports show each account's value expressed @@ -7663,7 +7862,7 @@ $ hledger bal -% cur:€  File: hledger.info, Node: Multi-period balance report, Next: Balance change end balance, Prev: Percentages, Up: balance -24.6.11 Multi-period balance report +22.6.11 Multi-period balance report ----------------------------------- With a report interval (set by the '-D/--daily', '-W/--weekly', @@ -7718,7 +7917,7 @@ viewing in the terminal. Here are some ways to handle that:  File: hledger.info, Node: Balance change end balance, Next: Balance report types, Prev: Multi-period balance report, Up: balance -24.6.12 Balance change, end balance +22.6.12 Balance change, end balance ----------------------------------- It's important to be clear on the meaning of the numbers shown in @@ -7755,13 +7954,13 @@ historical end balances:  File: hledger.info, Node: Balance report types, Next: Budget report, Prev: Balance change end balance, Up: balance -24.6.13 Balance report types +22.6.13 Balance report types ---------------------------- The balance command is quite flexible; here is the full detail on how to control what it reports. If the following seems complicated, don't -worry - this is for advanced reporting, and it does typically take some -time and experimentation to get clear on all these report modes. +worry - this is for advanced reporting, and it does take time and +experimentation to get familiar with all the report modes. There are three important option groups: @@ -7778,7 +7977,7 @@ time and experimentation to get clear on all these report modes.  File: hledger.info, Node: Calculation type, Next: Accumulation type, Up: Balance report types -24.6.13.1 Calculation type +22.6.13.1 Calculation type .......................... The basic calculation to perform for each table cell. It is one of: @@ -7791,11 +7990,12 @@ The basic calculation to perform for each table cell. It is one of: fluctuations) * '--gain' : show the unrealised capital gain/loss, (the current valued balance minus each amount's original cost) + * '--count' : show the count of postings  File: hledger.info, Node: Accumulation type, Next: Valuation type, Prev: Calculation type, Up: Balance report types -24.6.13.2 Accumulation type +22.6.13.2 Accumulation type ........................... How amounts should accumulate across report periods. Another way to say @@ -7820,7 +8020,7 @@ calculation. It is one of:  File: hledger.info, Node: Valuation type, Next: Combining balance report types, Prev: Accumulation type, Up: Balance report types -24.6.13.3 Valuation type +22.6.13.3 Valuation type ........................ Which kind of value or cost conversion should be applied, if any, before @@ -7851,7 +8051,7 @@ displaying the report. It is one of:  File: hledger.info, Node: Combining balance report types, Prev: Valuation type, Up: Balance report types -24.6.13.4 Combining balance report types +22.6.13.4 Combining balance report types ........................................ Most combinations of these options should produce reasonable reports, @@ -7890,7 +8090,7 @@ Accumulation:v YYYY-MM-DD  File: hledger.info, Node: Budget report, Next: Data layout, Prev: Balance report types, Up: balance -24.6.14 Budget report +22.6.14 Budget report --------------------- The '--budget' report type activates extra columns showing any budget @@ -7943,20 +8143,18 @@ Budget performance in 2017/11/01-2017/12/31: ----------------------++---------------------------------------------------- || 0 [ 0] 0 [ 0] - This is different from a normal balance report in several ways: + This is different from a normal balance report in several ways. +Currently: - * Only accounts with budget goals during the report period are shown, - by default. - - * In each column, in square brackets after the actual amount, budget - goal amounts are shown, and the actual/goal percentage. (Note: - budget goals should be in the same commodity as the actual amount.) - - * All parent accounts are always shown, even in list mode. Eg - assets, assets:bank, and expenses above. - - * Amounts always include all subaccounts, budgeted or unbudgeted, - even in list mode. + * Accounts with budget goals during the report period, and their + parents, are shown. + * Their subaccounts are not shown (regardless of the depth setting). + * Accounts without budget goals, if any, are aggregated and shown as + "". + * Amounts are always inclusive (subaccount-including), even in list + mode. + * After each actual amount, the corresponding goal amount and + percentage of goal reached are also shown, in square brackets. This means that the numbers displayed will not always add up! Eg above, the 'expenses' actual amount includes the gifts and supplies @@ -8027,7 +8225,7 @@ currencies, '--layout bare' or '--layout tall' can help.  File: hledger.info, Node: Budget report start date, Next: Budgets and subaccounts, Up: Budget report -24.6.14.1 Budget report start date +22.6.14.1 Budget report start date .................................. This might be a bug, but for now: when making budget reports, it's a @@ -8071,7 +8269,7 @@ Budget performance in 2020-01-01..2020-01-15:  File: hledger.info, Node: Budgets and subaccounts, Next: Selecting budget goals, Prev: Budget report start date, Up: Budget report -24.6.14.2 Budgets and subaccounts +22.6.14.2 Budgets and subaccounts ................................. You can add budgets to any account in your account hierarchy. If you @@ -8159,7 +8357,7 @@ Budget performance in 2019/01:  File: hledger.info, Node: Selecting budget goals, Next: Budget vs forecast, Prev: Budgets and subaccounts, Up: Budget report -24.6.14.3 Selecting budget goals +22.6.14.3 Selecting budget goals ................................ The budget report evaluates periodic transaction rules to generate @@ -8185,7 +8383,7 @@ select from multiple budgets defined in your journal.  File: hledger.info, Node: Budget vs forecast, Prev: Selecting budget goals, Up: Budget report -24.6.14.4 Budget vs forecast +22.6.14.4 Budget vs forecast ............................ 'hledger --forecast ...' and 'hledger balance --budget ...' are separate @@ -8233,7 +8431,7 @@ time if you want. Here are some differences between them, as of hledger  File: hledger.info, Node: Data layout, Next: Useful balance reports, Prev: Budget report, Up: balance -24.6.15 Data layout +22.6.15 Data layout ------------------- The '--layout' option affects how balance reports show multi-commodity @@ -8368,7 +8566,7 @@ tidy Y  File: hledger.info, Node: Useful balance reports, Prev: Data layout, Up: balance -24.6.16 Useful balance reports +22.6.16 Useful balance reports ------------------------------ Some frequently used 'balance' options/reports are: @@ -8408,7 +8606,7 @@ Some frequently used 'balance' options/reports are:  File: hledger.info, Node: balancesheet, Next: balancesheetequity, Prev: balance, Up: PART 4 COMMANDS -24.7 balancesheet +22.7 balancesheet ================= (bs) @@ -8457,7 +8655,7 @@ options The output formats supported are 'txt', 'csv', 'html', and  File: hledger.info, Node: balancesheetequity, Next: cashflow, Prev: balancesheet, Up: PART 4 COMMANDS -24.8 balancesheetequity +22.8 balancesheetequity ======================= (bse) @@ -8511,7 +8709,7 @@ options The output formats supported are 'txt', 'csv', 'html', and  File: hledger.info, Node: cashflow, Next: check, Prev: balancesheetequity, Up: PART 4 COMMANDS -24.9 cashflow +22.9 cashflow ============= (cf) @@ -8564,7 +8762,7 @@ options The output formats supported are 'txt', 'csv', 'html', and  File: hledger.info, Node: check, Next: close, Prev: cashflow, Up: PART 4 COMMANDS -24.10 check +22.10 check =========== Check for various kinds of errors in your data. @@ -8597,7 +8795,7 @@ run these checks, providing instant feedback as you edit the journal.  File: hledger.info, Node: Basic checks, Next: Strict checks, Up: check -24.10.1 Basic checks +22.10.1 Basic checks -------------------- These checks are always run automatically, by (almost) all hledger @@ -8616,7 +8814,7 @@ commands, including 'check':  File: hledger.info, Node: Strict checks, Next: Other checks, Prev: Basic checks, Up: check -24.10.2 Strict checks +22.10.2 Strict checks --------------------- These additional checks are run when the '-s'/'--strict' (strict mode) @@ -8634,7 +8832,7 @@ flag is used. Or, they can be run by giving their names as arguments to  File: hledger.info, Node: Other checks, Next: Custom checks, Prev: Strict checks, Up: check -24.10.3 Other checks +22.10.3 Other checks -------------------- These checks can be run only by giving their names as arguments to @@ -8655,7 +8853,7 @@ therefore optional:  File: hledger.info, Node: Custom checks, Next: More about specific checks, Prev: Other checks, Up: check -24.10.4 Custom checks +22.10.4 Custom checks --------------------- A few more checks are are available as separate add-on commands, in @@ -8673,7 +8871,7 @@ See: Cookbook -> Scripting.  File: hledger.info, Node: More about specific checks, Prev: Custom checks, Up: check -24.10.5 More about specific checks +22.10.5 More about specific checks ---------------------------------- 'hledger check recentassertions' will complain if any balance-asserted @@ -8691,7 +8889,7 @@ assertions against real-world balances.  File: hledger.info, Node: close, Next: codes, Prev: check, Up: PART 4 COMMANDS -24.11 close +22.11 close =========== (equity) @@ -8774,7 +8972,7 @@ report period will be the closing date; eg '-e 2022' means "close on  File: hledger.info, Node: close and balance assertions, Next: Example retain earnings, Up: close -24.11.1 close and balance assertions +22.11.1 close and balance assertions ------------------------------------ Balance assertions will be generated, verifying that the accounts have @@ -8812,7 +9010,7 @@ single-day transactions:  File: hledger.info, Node: Example retain earnings, Next: Example migrate balances to a new file, Prev: close and balance assertions, Up: close -24.11.2 Example: retain earnings +22.11.2 Example: retain earnings -------------------------------- Record 2022's revenues/expenses as retained earnings on 2022-12-31, @@ -8829,7 +9027,7 @@ $ hledger -f 2022.journal is not:desc:'retain earnings'  File: hledger.info, Node: Example migrate balances to a new file, Next: Example excluding closing/opening transactions, Prev: Example retain earnings, Up: close -24.11.3 Example: migrate balances to a new file +22.11.3 Example: migrate balances to a new file ----------------------------------------------- Close assets/liabilities/equity on 2022-12-31 and re-open them on @@ -8849,7 +9047,7 @@ $ hledger -f 2022.journal bs not:desc:'closing balances'  File: hledger.info, Node: Example excluding closing/opening transactions, Prev: Example migrate balances to a new file, Up: close -24.11.4 Example: excluding closing/opening transactions +22.11.4 Example: excluding closing/opening transactions ------------------------------------------------------- When combining many files for multi-year reports, the closing/opening @@ -8899,7 +9097,7 @@ $ hledger -f all.journal bs -e2023 not:tag:clopen=2023  File: hledger.info, Node: codes, Next: commodities, Prev: close, Up: PART 4 COMMANDS -24.12 codes +22.12 codes =========== List the codes seen in transactions, in the order parsed. @@ -8947,7 +9145,7 @@ $ hledger codes -E  File: hledger.info, Node: commodities, Next: demo, Prev: codes, Up: PART 4 COMMANDS -24.13 commodities +22.13 commodities ================= List all commodity/currency symbols used or declared in the journal. @@ -8955,7 +9153,7 @@ List all commodity/currency symbols used or declared in the journal.  File: hledger.info, Node: demo, Next: descriptions, Prev: commodities, Up: PART 4 COMMANDS -24.14 demo +22.14 demo ========== Play demos of hledger usage in the terminal, if asciinema is installed. @@ -8982,7 +9180,7 @@ $ hledger demo install -- -s5 -i.5 # play the install demo at 5x speed,  File: hledger.info, Node: descriptions, Next: diff, Prev: demo, Up: PART 4 COMMANDS -24.15 descriptions +22.15 descriptions ================== List the unique descriptions that appear in transactions. @@ -9001,7 +9199,7 @@ Person A  File: hledger.info, Node: diff, Next: files, Prev: descriptions, Up: PART 4 COMMANDS -24.16 diff +22.16 diff ========== Compares a particular account's transactions in two input files. It @@ -9035,7 +9233,7 @@ These transactions are in the second file only:  File: hledger.info, Node: files, Next: help, Prev: diff, Up: PART 4 COMMANDS -24.17 files +22.17 files =========== List all files included in the journal. With a REGEX argument, only @@ -9044,7 +9242,7 @@ file names matching the regular expression (case sensitive) are shown.  File: hledger.info, Node: help, Next: import, Prev: files, Up: PART 4 COMMANDS -24.18 help +22.18 help ========== Show the hledger user manual in the terminal, with 'info', 'man', or a @@ -9079,7 +9277,7 @@ $ hledger help -m journal # show it with man, even if info is installed  File: hledger.info, Node: import, Next: incomestatement, Prev: help, Up: PART 4 COMMANDS -24.19 import +22.19 import ============ Read new transactions added to each FILE since last run, and add them to @@ -9111,7 +9309,7 @@ most common import source, and these docs focus on that case.  File: hledger.info, Node: Deduplication, Next: Import testing, Up: import -24.19.1 Deduplication +22.19.1 Deduplication --------------------- As a convenience 'import' does _deduplication_ while reading @@ -9155,7 +9353,7 @@ certain date.  File: hledger.info, Node: Import testing, Next: Importing balance assignments, Prev: Deduplication, Up: import -24.19.2 Import testing +22.19.2 Import testing ---------------------- With '--dry-run', the transactions that will be imported are printed to @@ -9180,7 +9378,7 @@ import.  File: hledger.info, Node: Importing balance assignments, Next: Commodity display styles, Prev: Import testing, Up: import -24.19.3 Importing balance assignments +22.19.3 Importing balance assignments ------------------------------------- Entries added by import will have their posting amounts made explicit @@ -9199,7 +9397,7 @@ please test it and send a pull request.)  File: hledger.info, Node: Commodity display styles, Prev: Importing balance assignments, Up: import -24.19.4 Commodity display styles +22.19.4 Commodity display styles -------------------------------- Imported amounts will be formatted according to the canonical commodity @@ -9208,7 +9406,7 @@ styles (declared or inferred) in the main journal file.  File: hledger.info, Node: incomestatement, Next: notes, Prev: import, Up: PART 4 COMMANDS -24.20 incomestatement +22.20 incomestatement ===================== (is) @@ -9258,7 +9456,7 @@ options The output formats supported are 'txt', 'csv', 'html', and  File: hledger.info, Node: notes, Next: payees, Prev: incomestatement, Up: PART 4 COMMANDS -24.21 notes +22.21 notes =========== List the unique notes that appear in transactions. @@ -9277,7 +9475,7 @@ Snacks  File: hledger.info, Node: payees, Next: prices, Prev: notes, Up: PART 4 COMMANDS -24.22 payees +22.22 payees ============ List the unique payee/payer names that appear in transactions. @@ -9302,7 +9500,7 @@ Person A  File: hledger.info, Node: prices, Next: print, Prev: payees, Up: PART 4 COMMANDS -24.23 prices +22.23 prices ============ Print market price directives from the journal. With @@ -9314,7 +9512,7 @@ displayed with their full precision.  File: hledger.info, Node: print, Next: register, Prev: prices, Up: PART 4 COMMANDS -24.24 print +22.24 print =========== Show transaction journal entries, sorted by date. @@ -9438,7 +9636,7 @@ $ hledger print -Ocsv  File: hledger.info, Node: register, Next: rewrite, Prev: print, Up: PART 4 COMMANDS -24.25 register +22.25 register ============== (reg) @@ -9548,7 +9746,7 @@ no posting will be shown and the program exit code will be non-zero.  File: hledger.info, Node: Custom register output, Up: register -24.25.1 Custom register output +22.25.1 Custom register output ------------------------------ register uses the full terminal width by default, except on windows. @@ -9580,7 +9778,7 @@ options The output formats supported are 'txt', 'csv', and  File: hledger.info, Node: rewrite, Next: roi, Prev: register, Up: PART 4 COMMANDS -24.26 rewrite +22.26 rewrite ============= Print all transactions, rewriting the postings of matched transactions. @@ -9633,7 +9831,7 @@ commodity.  File: hledger.info, Node: Re-write rules in a file, Next: Diff output format, Up: rewrite -24.26.1 Re-write rules in a file +22.26.1 Re-write rules in a file -------------------------------- During the run this tool will execute so called "Automated Transactions" @@ -9671,7 +9869,7 @@ postings.  File: hledger.info, Node: Diff output format, Next: rewrite vs print --auto, Prev: Re-write rules in a file, Up: rewrite -24.26.2 Diff output format +22.26.2 Diff output format -------------------------- To use this tool for batch modification of your journal files you may @@ -9712,7 +9910,7 @@ output from 'hledger print'.  File: hledger.info, Node: rewrite vs print --auto, Prev: Diff output format, Up: rewrite -24.26.3 rewrite vs. print -auto +22.26.3 rewrite vs. print -auto ------------------------------- This command predates print -auto, and currently does much the same @@ -9732,7 +9930,7 @@ thing, but with these differences:  File: hledger.info, Node: roi, Next: stats, Prev: rewrite, Up: PART 4 COMMANDS -24.27 roi +22.27 roi ========= Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on @@ -9780,7 +9978,7 @@ display, regardless of the length of reporting interval.  File: hledger.info, Node: Spaces and special characters in --inv and --pnl, Next: Semantics of --inv and --pnl, Up: roi -24.27.1 Spaces and special characters in '--inv' and +22.27.1 Spaces and special characters in '--inv' and ---------------------------------------------------- '--pnl' Note that '--inv' and '--pnl''s argument is a query, and queries @@ -9799,7 +9997,7 @@ $ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'  File: hledger.info, Node: Semantics of --inv and --pnl, Next: IRR and TWR explained, Prev: Spaces and special characters in --inv and --pnl, Up: roi -24.27.2 Semantics of '--inv' and '--pnl' +22.27.2 Semantics of '--inv' and '--pnl' ---------------------------------------- Query supplied to '--inv' has to match all transactions that are related @@ -9853,7 +10051,7 @@ postings in the example below would be classifed as:  File: hledger.info, Node: IRR and TWR explained, Prev: Semantics of --inv and --pnl, Up: roi -24.27.3 IRR and TWR explained +22.27.3 IRR and TWR explained ----------------------------- "ROI" stands for "return on investment". Traditionally this was @@ -9920,7 +10118,7 @@ your investment.  File: hledger.info, Node: stats, Next: tags, Prev: roi, Up: PART 4 COMMANDS -24.28 stats +22.28 stats =========== Show journal and performance statistics. @@ -9960,7 +10158,7 @@ Throughput : 8342 txns/s  File: hledger.info, Node: tags, Next: test, Prev: stats, Up: PART 4 COMMANDS -24.29 tags +22.29 tags ========== List the tags used in the journal, or their values. @@ -9990,7 +10188,7 @@ transactions also acquire tags from their postings.  File: hledger.info, Node: test, Prev: tags, Up: PART 4 COMMANDS -24.30 test +22.30 test ========== Run built-in unit tests. @@ -10014,9 +10212,9 @@ $ hledger test -- -pData.Amount --color=never ('-- --help' currently doesn't show them).  -File: hledger.info, Node: PART 5 COMMON TASKS, Prev: PART 4 COMMANDS, Up: Top +File: hledger.info, Node: PART 5 COMMON TASKS, Next: BUGS, Prev: PART 4 COMMANDS, Up: Top -25 PART 5: COMMON TASKS +23 PART 5: COMMON TASKS *********************** Here are some quick examples of how to do some basic tasks with hledger. @@ -10035,7 +10233,7 @@ Here are some quick examples of how to do some basic tasks with hledger.  File: hledger.info, Node: Getting help, Next: Constructing command lines, Up: PART 5 COMMON TASKS -25.1 Getting help +23.1 Getting help ================= Here's how to list commands and view options and command docs: @@ -10058,7 +10256,7 @@ can be found at https://hledger.org/support.  File: hledger.info, Node: Constructing command lines, Next: Starting a journal file, Prev: Getting help, Up: PART 5 COMMON TASKS -25.2 Constructing command lines +23.2 Constructing command lines =============================== hledger has a flexible command line interface. We strive to keep it @@ -10078,7 +10276,7 @@ described in OPTIONS, here are some tips that might help:  File: hledger.info, Node: Starting a journal file, Next: Setting opening balances, Prev: Constructing command lines, Up: PART 5 COMMON TASKS -25.3 Starting a journal file +23.3 Starting a journal file ============================ hledger looks for your accounting data in a journal file, @@ -10117,7 +10315,7 @@ Market prices : 0 ()  File: hledger.info, Node: Setting opening balances, Next: Recording transactions, Prev: Starting a journal file, Up: PART 5 COMMON TASKS -25.4 Setting opening balances +23.4 Setting opening balances ============================= Pick a starting date for which you can look up the balances of some @@ -10200,7 +10398,7 @@ $ git commit -m 'initial balances' 2020.journal  File: hledger.info, Node: Recording transactions, Next: Reconciling, Prev: Setting opening balances, Up: PART 5 COMMON TASKS -25.5 Recording transactions +23.5 Recording transactions =========================== As you spend or receive money, you can record these transactions using @@ -10226,7 +10424,7 @@ and hledger.org for more ideas:  File: hledger.info, Node: Reconciling, Next: Reporting, Prev: Recording transactions, Up: PART 5 COMMON TASKS -25.6 Reconciling +23.6 Reconciling ================ Periodically you should reconcile - compare your hledger-reported @@ -10281,7 +10479,7 @@ $ git commit -m 'txns' 2020.journal  File: hledger.info, Node: Reporting, Next: Migrating to a new file, Prev: Reconciling, Up: PART 5 COMMON TASKS -25.7 Reporting +23.7 Reporting ============== Here are some basic reports. @@ -10429,7 +10627,7 @@ $ hledger activity -W  File: hledger.info, Node: Migrating to a new file, Prev: Reporting, Up: PART 5 COMMON TASKS -25.8 Migrating to a new file +23.8 Migrating to a new file ============================ At the end of the year, you may want to continue your journal in a new @@ -10439,615 +10637,722 @@ close command. If using version control, don't forget to 'git add' the new file. + +File: hledger.info, Node: BUGS, Prev: PART 5 COMMON TASKS, Up: Top + +24 BUGS +******* + +We welcome bug reports in the hledger issue tracker (shortcut: +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 hledger is awkward. (See Command options, Constructing command +lines.) + + 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 these.) + + When processing large data files, hledger uses more memory than +Ledger. + +* Menu: + +* Troubleshooting:: + + +File: hledger.info, Node: Troubleshooting, Up: BUGS + +24.1 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 +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 +'~/.local/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 window. + + *LEDGER_FILE issues: I configured LEDGER_FILE but hledger is not +using it* + + * '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://stackoverflow.com/a/7411509). + * 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 incomplete multibyte or wide character" or "commitAndReleaseBuffer: +invalid 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 +encounter 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: Here's one common way to configure this +permanently for your shell: + +$ echo "export LANG=en_US.utf8" >>~/.profile +# 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. +See hledger and Ledger for full details. +  Tag Table: Node: Top210 -Node: PART 1 USER INTERFACE3861 -Ref: #part-1-user-interface4002 -Node: Options4002 -Ref: #options4121 -Node: General options4263 -Ref: #general-options4388 -Node: Command options8601 -Ref: #command-options8752 -Node: Command arguments9152 -Ref: #command-arguments9310 -Node: Special characters10190 -Ref: #special-characters10353 -Node: Single escaping shell metacharacters10516 -Ref: #single-escaping-shell-metacharacters10757 -Node: Double escaping regular expression metacharacters11360 -Ref: #double-escaping-regular-expression-metacharacters11671 -Node: Triple escaping for add-on commands12197 -Ref: #triple-escaping-for-add-on-commands12457 -Node: Less escaping13101 -Ref: #less-escaping13255 -Node: Unicode characters13579 -Ref: #unicode-characters13744 -Node: Regular expressions15156 -Ref: #regular-expressions15296 -Node: Environment17040 -Ref: #environment17151 -Node: Input18720 -Ref: #input18820 -Node: Data formats19363 -Ref: #data-formats19476 -Node: Multiple files20862 -Ref: #multiple-files20999 -Node: Strict mode21468 -Ref: #strict-mode21578 -Node: Commands22302 -Ref: #commands22403 -Node: Add-on commands22875 -Ref: #add-on-commands22977 -Node: Output24062 -Ref: #output24165 -Node: Output destination24292 -Ref: #output-destination24423 -Node: Output format24848 -Ref: #output-format24994 -Node: CSV output26532 -Ref: #csv-output26648 -Node: HTML output26751 -Ref: #html-output26889 -Node: JSON output26983 -Ref: #json-output27121 -Node: SQL output28043 -Ref: #sql-output28159 -Node: Commodity styles28894 -Ref: #commodity-styles29034 -Node: Colour29633 -Ref: #colour29751 -Node: Box-drawing30155 -Ref: #box-drawing30273 -Node: Paging30563 -Ref: #paging30677 -Node: Debug output31630 -Ref: #debug-output31736 -Node: Limitations32399 -Ref: #limitations32519 -Node: Troubleshooting33288 -Ref: #troubleshooting33429 -Node: PART 2 DATA FORMATS35911 -Ref: #part-2-data-formats36058 -Node: Journal36058 -Ref: #journal36169 -Node: Journal cheatsheet36808 -Ref: #journal-cheatsheet36949 -Node: About journal format40937 -Ref: #about-journal-format41099 -Node: Comments42617 -Ref: #comments42749 -Node: Transactions43565 -Ref: #transactions43690 -Node: Dates44704 -Ref: #dates44813 -Node: Simple dates44858 -Ref: #simple-dates44976 -Node: Posting dates45476 -Ref: #posting-dates45596 -Node: Status46565 -Ref: #status46668 -Node: Code48376 -Ref: #code48481 -Node: Description48713 -Ref: #description48846 -Node: Payee and note49166 -Ref: #payee-and-note49274 -Node: Transaction comments49609 -Ref: #transaction-comments49764 -Node: Postings50127 -Ref: #postings50262 -Node: Account names51257 -Ref: #account-names51389 -Node: Amounts53063 -Ref: #amounts53180 -Node: Decimal marks digit group marks54165 -Ref: #decimal-marks-digit-group-marks54342 -Node: Commodity55356 -Ref: #commodity55545 -Node: Directives influencing number parsing and display56497 -Ref: #directives-influencing-number-parsing-and-display56758 -Node: Commodity display style57210 -Ref: #commodity-display-style57418 -Node: Rounding59587 -Ref: #rounding59707 -Node: Costs60006 -Ref: #costs60124 -Node: Other cost/lot notations62322 -Ref: #other-costlot-notations62456 -Node: Balance assertions65045 -Ref: #balance-assertions65198 -Node: Assertions and ordering66281 -Ref: #assertions-and-ordering66472 -Node: Assertions and multiple included files67172 -Ref: #assertions-and-multiple-included-files67434 -Node: Assertions and multiple -f files67934 -Ref: #assertions-and-multiple--f-files68187 -Node: Assertions and commodities68584 -Ref: #assertions-and-commodities68808 -Node: Assertions and prices69988 -Ref: #assertions-and-prices70196 -Node: Assertions and subaccounts70623 -Ref: #assertions-and-subaccounts70846 -Node: Assertions and virtual postings71170 -Ref: #assertions-and-virtual-postings71410 -Node: Assertions and auto postings71542 -Ref: #assertions-and-auto-postings71774 -Node: Assertions and precision72419 -Ref: #assertions-and-precision72603 -Node: Posting comments72870 -Ref: #posting-comments73018 -Node: Tags73395 -Ref: #tags73511 -Node: Tag values74704 -Ref: #tag-values74795 -Node: Directives75554 -Ref: #directives75683 -Node: Directive effects77489 -Ref: #directive-effects77645 -Node: Directives and multiple files80610 -Ref: #directives-and-multiple-files80790 -Node: account directive81482 -Ref: #account-directive81640 -Node: Account comments83038 -Ref: #account-comments83190 -Node: Account subdirectives83698 -Ref: #account-subdirectives83891 -Node: Account error checking84033 -Ref: #account-error-checking84233 -Node: Account display order85422 -Ref: #account-display-order85612 -Node: Account types86713 -Ref: #account-types86856 -Node: alias directive90483 -Ref: #alias-directive90646 -Node: Basic aliases91696 -Ref: #basic-aliases91829 -Node: Regex aliases92573 -Ref: #regex-aliases92732 -Node: Combining aliases93622 -Ref: #combining-aliases93802 -Node: Aliases and multiple files95078 -Ref: #aliases-and-multiple-files95284 -Node: end aliases directive95863 -Ref: #end-aliases-directive96084 -Node: Aliases can generate bad account names96233 -Ref: #aliases-can-generate-bad-account-names96483 -Node: Aliases and account types97068 -Ref: #aliases-and-account-types97262 -Node: commodity directive97958 -Ref: #commodity-directive98134 -Node: Commodity error checking100708 -Ref: #commodity-error-checking100856 -Node: decimal-mark directive101371 -Ref: #decimal-mark-directive101555 -Node: include directive101952 -Ref: #include-directive102118 -Node: P directive103042 -Ref: #p-directive103189 -Node: payee directive104072 -Ref: #payee-directive104223 -Node: tag directive104539 -Ref: #tag-directive104696 -Node: Periodic transactions105164 -Ref: #periodic-transactions105330 -Node: Periodic rule syntax107036 -Ref: #periodic-rule-syntax107216 -Node: Periodic rules and relative dates107861 -Ref: #periodic-rules-and-relative-dates108129 -Node: Two spaces between period expression and description!108640 -Ref: #two-spaces-between-period-expression-and-description108919 -Node: Other syntax109603 -Ref: #other-syntax109729 -Node: Auto postings110374 -Ref: #auto-postings110510 -Node: Auto postings and multiple files112981 -Ref: #auto-postings-and-multiple-files113183 -Node: Auto postings and dates113392 -Ref: #auto-postings-and-dates113664 -Node: Auto postings and transaction balancing / inferred amounts / balance assertions113839 -Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions114178 -Node: Auto posting tags114681 -Ref: #auto-posting-tags114894 -Node: Balance assignments115530 -Ref: #balance-assignments115710 -Node: Balance assignments and prices117040 -Ref: #balance-assignments-and-prices117210 -Node: Bracketed posting dates117421 -Ref: #bracketed-posting-dates117607 -Node: D directive118121 -Ref: #d-directive118291 -Node: apply account directive119891 -Ref: #apply-account-directive120073 -Node: Y directive120760 -Ref: #y-directive120922 -Node: Secondary dates121750 -Ref: #secondary-dates121906 -Node: Star comments122720 -Ref: #star-comments122882 -Node: Valuation expressions123414 -Ref: #valuation-expressions123593 -Node: Virtual postings123715 -Ref: #virtual-postings123896 -Node: Other Ledger directives125458 -Ref: #other-ledger-directives125623 -Node: CSV126189 -Ref: #csv126282 -Node: CSV rules cheatsheet128351 -Ref: #csv-rules-cheatsheet128483 -Node: separator130183 -Ref: #separator130310 -Node: skip130850 -Ref: #skip130958 -Node: date-format131529 -Ref: #date-format131650 -Node: timezone132374 -Ref: #timezone132497 -Node: newest-first133502 -Ref: #newest-first133640 -Node: intra-day-reversed134218 -Ref: #intra-day-reversed134372 -Node: decimal-mark134865 -Ref: #decimal-mark135006 -Node: fields list135345 -Ref: #fields-list135482 -Node: Field assignment137153 -Ref: #field-assignment137297 -Node: Field names138324 -Ref: #field-names138455 -Node: date field139658 -Ref: #date-field139776 -Node: date2 field139824 -Ref: #date2-field139965 -Node: status field140021 -Ref: #status-field140164 -Node: code field140213 -Ref: #code-field140358 -Node: description field140403 -Ref: #description-field140563 -Node: comment field140622 -Ref: #comment-field140777 -Node: account field141070 -Ref: #account-field141220 -Node: amount field141790 -Ref: #amount-field141939 -Node: currency field143958 -Ref: #currency-field144111 -Node: balance field144368 -Ref: #balance-field144500 -Node: if block144872 -Ref: #if-block144993 -Node: Matchers146401 -Ref: #matchers146515 -Node: if table147997 -Ref: #if-table148119 -Node: balance-type149541 -Ref: #balance-type149670 -Node: include150370 -Ref: #include150497 -Node: Working with CSV150941 -Ref: #working-with-csv151088 -Node: Rapid feedback151459 -Ref: #rapid-feedback151592 -Node: Valid CSV152044 -Ref: #valid-csv152190 -Node: File Extension152922 -Ref: #file-extension153095 -Node: Reading CSV from standard input153659 -Ref: #reading-csv-from-standard-input153883 -Node: Reading multiple CSV files154047 -Ref: #reading-multiple-csv-files154265 -Node: Valid transactions154506 -Ref: #valid-transactions154700 -Node: Deduplicating importing155328 -Ref: #deduplicating-importing155523 -Node: Setting amounts156559 -Ref: #setting-amounts156730 -Node: Amount signs159195 -Ref: #amount-signs159363 -Node: Setting currency/commodity160050 -Ref: #setting-currencycommodity160254 -Node: Amount decimal places161428 -Ref: #amount-decimal-places161634 -Node: Referencing other fields161946 -Ref: #referencing-other-fields162159 -Node: How CSV rules are evaluated163056 -Ref: #how-csv-rules-are-evaluated163273 -Node: Well factored rules164726 -Ref: #well-factored-rules164894 -Node: CSV rules examples165218 -Ref: #csv-rules-examples165353 -Node: Bank of Ireland165418 -Ref: #bank-of-ireland165555 -Node: Coinbase167017 -Ref: #coinbase167155 -Node: Amazon168202 -Ref: #amazon168327 -Node: Paypal170046 -Ref: #paypal170154 -Node: Timeclock177798 -Ref: #timeclock177903 -Node: Timedot180035 -Ref: #timedot180158 -Node: PART 3 REPORTING CONCEPTS184855 -Ref: #part-3-reporting-concepts185019 -Node: Time periods185019 -Ref: #time-periods185153 -Node: Report start & end date185271 -Ref: #report-start-end-date185423 -Node: Smart dates187082 -Ref: #smart-dates187235 -Node: Report intervals189103 -Ref: #report-intervals189258 -Node: Date adjustment189676 -Ref: #date-adjustment189836 -Node: Period expressions190687 -Ref: #period-expressions190828 -Node: Period expressions with a report interval192592 -Ref: #period-expressions-with-a-report-interval192826 -Node: More complex report intervals193040 -Ref: #more-complex-report-intervals193285 -Node: Multiple weekday intervals195086 -Ref: #multiple-weekday-intervals195275 -Node: Depth196097 -Ref: #depth196199 -Node: Queries196495 -Ref: #queries196597 -Node: Query types197506 -Ref: #query-types197627 -Node: Combining query terms200801 -Ref: #combining-query-terms200978 -Node: Queries and command options202246 -Ref: #queries-and-command-options202445 -Node: Queries and valuation202694 -Ref: #queries-and-valuation202889 -Node: Querying with account aliases203118 -Ref: #querying-with-account-aliases203329 -Node: Querying with cost or value203459 -Ref: #querying-with-cost-or-value203636 -Node: Pivoting203937 -Ref: #pivoting204051 -Node: Generating data205509 -Ref: #generating-data205641 -Node: Forecasting206121 -Ref: #forecasting206246 -Node: Budgeting209017 -Ref: #budgeting209137 -Node: Cost reporting209400 -Ref: #cost-reporting209528 -Node: -B Convert to cost210635 -Ref: #b-convert-to-cost210791 -Node: Equity conversion postings212183 -Ref: #equity-conversion-postings212397 -Node: Inferring equity postings from cost213288 -Ref: #inferring-equity-postings-from-cost213537 -Node: Inferring cost from equity postings214348 -Ref: #inferring-cost-from-equity-postings214596 -Node: When to infer cost/equity216363 -Ref: #when-to-infer-costequity216581 -Node: How to record conversions216977 -Ref: #how-to-record-conversions217169 -Node: Conversion with implicit cost217460 -Ref: #conversion-with-implicit-cost217665 -Node: Conversion with explicit cost218542 -Ref: #conversion-with-explicit-cost218787 -Node: Conversion with equity postings219204 -Ref: #conversion-with-equity-postings219473 -Node: Conversion with equity postings and explicit cost220292 -Ref: #conversion-with-equity-postings-and-explicit-cost220559 -Node: Cost tips221021 -Ref: #cost-tips221147 -Node: Valuation221853 -Ref: #valuation221977 -Node: -V Value222751 -Ref: #v-value222877 -Node: -X Value in specified commodity223072 -Ref: #x-value-in-specified-commodity223267 -Node: Valuation date223416 -Ref: #valuation-date223587 -Node: Finding market price224024 -Ref: #finding-market-price224229 -Node: --infer-market-prices market prices from transactions225399 -Ref: #infer-market-prices-market-prices-from-transactions225675 -Node: Valuation commodity228431 -Ref: #valuation-commodity228644 -Node: Simple valuation examples229857 -Ref: #simple-valuation-examples230055 -Node: --value Flexible valuation230714 -Ref: #value-flexible-valuation230918 -Node: More valuation examples232562 -Ref: #more-valuation-examples232771 -Node: Interaction of valuation and queries234770 -Ref: #interaction-of-valuation-and-queries235011 -Node: Effect of valuation on reports235483 -Ref: #effect-of-valuation-on-reports235680 -Node: PART 4 COMMANDS243377 -Ref: #part-4-commands243520 -Node: Commands overview243899 -Ref: #commands-overview244033 -Node: DATA ENTRY244212 -Ref: #data-entry244336 -Node: DATA CREATION244535 -Ref: #data-creation244689 -Node: DATA MANAGEMENT244807 -Ref: #data-management244972 -Node: REPORTS FINANCIAL245093 -Ref: #reports-financial245268 -Node: REPORTS VERSATILE245573 -Ref: #reports-versatile245746 -Node: REPORTS BASIC245999 -Ref: #reports-basic246151 -Node: HELP246660 -Ref: #help246782 -Node: ADD-ONS246892 -Ref: #add-ons246998 -Node: accounts247577 -Ref: #accounts247710 -Node: activity249597 -Ref: #activity249716 -Node: add250090 -Ref: #add250200 -Node: aregister253011 -Ref: #aregister253132 -Node: aregister and custom posting dates256020 -Ref: #aregister-and-custom-posting-dates256186 -Node: balance256738 -Ref: #balance256864 -Node: balance features257839 -Ref: #balance-features257979 -Node: Simple balance report259903 -Ref: #simple-balance-report260088 -Node: Balance report line format261713 -Ref: #balance-report-line-format261915 -Node: Filtered balance report264073 -Ref: #filtered-balance-report264265 -Node: List or tree mode264592 -Ref: #list-or-tree-mode264760 -Node: Depth limiting266105 -Ref: #depth-limiting266271 -Node: Dropping top-level accounts266872 -Ref: #dropping-top-level-accounts267072 -Node: Showing declared accounts267382 -Ref: #showing-declared-accounts267581 -Node: Sorting by amount268112 -Ref: #sorting-by-amount268279 -Node: Percentages268949 -Ref: #percentages269108 -Node: Multi-period balance report269656 -Ref: #multi-period-balance-report269856 -Node: Balance change end balance272131 -Ref: #balance-change-end-balance272340 -Node: Balance report types273768 -Ref: #balance-report-types273949 -Node: Calculation type274459 -Ref: #calculation-type274614 -Node: Accumulation type275119 -Ref: #accumulation-type275299 -Node: Valuation type276201 -Ref: #valuation-type276389 -Node: Combining balance report types277384 -Ref: #combining-balance-report-types277578 -Node: Budget report279416 -Ref: #budget-report279568 -Node: Budget report start date285250 -Ref: #budget-report-start-date285428 -Node: Budgets and subaccounts286760 -Ref: #budgets-and-subaccounts286967 -Node: Selecting budget goals290407 -Ref: #selecting-budget-goals290606 -Node: Budget vs forecast291641 -Ref: #budget-vs-forecast291800 -Node: Data layout293430 -Ref: #data-layout293580 -Node: Useful balance reports301475 -Ref: #useful-balance-reports301625 -Node: balancesheet302710 -Ref: #balancesheet302855 -Node: balancesheetequity304175 -Ref: #balancesheetequity304333 -Node: cashflow305722 -Ref: #cashflow305853 -Node: check307281 -Ref: #check307395 -Node: Basic checks308197 -Ref: #basic-checks308317 -Node: Strict checks308837 -Ref: #strict-checks308980 -Node: Other checks309403 -Ref: #other-checks309545 -Node: Custom checks310108 -Ref: #custom-checks310265 -Node: More about specific checks310682 -Ref: #more-about-specific-checks310844 -Node: close311572 -Ref: #close311683 -Node: close and balance assertions315093 -Ref: #close-and-balance-assertions315271 -Node: Example retain earnings316422 -Ref: #example-retain-earnings316639 -Node: Example migrate balances to a new file317071 -Ref: #example-migrate-balances-to-a-new-file317336 -Node: Example excluding closing/opening transactions317912 -Ref: #example-excluding-closingopening-transactions318161 -Node: codes319379 -Ref: #codes319496 -Node: commodities320360 -Ref: #commodities320488 -Node: demo320558 -Ref: #demo320679 -Node: descriptions321523 -Ref: #descriptions321653 -Node: diff321944 -Ref: #diff322059 -Node: files323101 -Ref: #files323210 -Node: help323351 -Ref: #help-1323460 -Node: import324833 -Ref: #import324956 -Node: Deduplication326042 -Ref: #deduplication326167 -Node: Import testing328061 -Ref: #import-testing328226 -Node: Importing balance assignments329069 -Ref: #importing-balance-assignments329275 -Node: Commodity display styles329924 -Ref: #commodity-display-styles330097 -Node: incomestatement330226 -Ref: #incomestatement330368 -Node: notes331689 -Ref: #notes331811 -Node: payees332173 -Ref: #payees332288 -Node: prices332807 -Ref: #prices332922 -Node: print333220 -Ref: #print333335 -Node: register338673 -Ref: #register338795 -Node: Custom register output343826 -Ref: #custom-register-output343957 -Node: rewrite345294 -Ref: #rewrite345412 -Node: Re-write rules in a file347310 -Ref: #re-write-rules-in-a-file347473 -Node: Diff output format348622 -Ref: #diff-output-format348805 -Node: rewrite vs print --auto349897 -Ref: #rewrite-vs.-print---auto350057 -Node: roi350613 -Ref: #roi350720 -Node: Spaces and special characters in --inv and --pnl352441 -Ref: #spaces-and-special-characters-in---inv-and---pnl352681 -Node: Semantics of --inv and --pnl353169 -Ref: #semantics-of---inv-and---pnl353408 -Node: IRR and TWR explained355258 -Ref: #irr-and-twr-explained355418 -Node: stats358504 -Ref: #stats358612 -Node: tags359999 -Ref: #tags-1360106 -Node: test361115 -Ref: #test361208 -Node: PART 5 COMMON TASKS361950 -Ref: #part-5-common-tasks362083 -Node: Getting help362357 -Ref: #getting-help362498 -Node: Constructing command lines363258 -Ref: #constructing-command-lines363459 -Node: Starting a journal file364116 -Ref: #starting-a-journal-file364323 -Node: Setting opening balances365511 -Ref: #setting-opening-balances365716 -Node: Recording transactions368857 -Ref: #recording-transactions369046 -Node: Reconciling369602 -Ref: #reconciling369754 -Node: Reporting372011 -Ref: #reporting372160 -Node: Migrating to a new file376145 -Ref: #migrating-to-a-new-file376302 +Node: PART 1 USER INTERFACE3780 +Ref: #part-1-user-interface3919 +Node: Input3919 +Ref: #input4032 +Node: Setting LEDGER_FILE4994 +Ref: #setting-ledger_file5126 +Node: Data formats6107 +Ref: #data-formats6248 +Node: Standard input7681 +Ref: #standard-input7821 +Node: Multiple files8048 +Ref: #multiple-files8187 +Node: Strict mode8785 +Ref: #strict-mode8895 +Node: Environment9619 +Ref: #environment9730 +Node: Options10274 +Ref: #options10380 +Node: General options10752 +Ref: #general-options10879 +Node: Option repetition15455 +Ref: #option-repetition15610 +Node: Command options15929 +Ref: #command-options16082 +Node: Command arguments16482 +Ref: #command-arguments16640 +Node: Special characters17520 +Ref: #special-characters17683 +Node: Single escaping shell metacharacters17846 +Ref: #single-escaping-shell-metacharacters18087 +Node: Double escaping regular expression metacharacters18690 +Ref: #double-escaping-regular-expression-metacharacters19001 +Node: Triple escaping for add-on commands19527 +Ref: #triple-escaping-for-add-on-commands19787 +Node: Less escaping20431 +Ref: #less-escaping20585 +Node: Unicode characters20909 +Ref: #unicode-characters21074 +Node: Regular expressions22486 +Ref: #regular-expressions22626 +Node: Commands24370 +Ref: #commands24473 +Node: Add-on commands24945 +Ref: #add-on-commands25047 +Node: Output26132 +Ref: #output26243 +Node: Output destination26370 +Ref: #output-destination26501 +Node: Output format26926 +Ref: #output-format27072 +Node: CSV output28610 +Ref: #csv-output28726 +Node: HTML output28829 +Ref: #html-output28967 +Node: JSON output29061 +Ref: #json-output29199 +Node: SQL output30121 +Ref: #sql-output30237 +Node: Commodity styles30972 +Ref: #commodity-styles31112 +Node: Colour31711 +Ref: #colour31829 +Node: Box-drawing32233 +Ref: #box-drawing32351 +Node: Paging32641 +Ref: #paging32755 +Node: Debug output33708 +Ref: #debug-output33814 +Node: PART 2 DATA FORMATS34477 +Ref: #part-2-data-formats34615 +Node: Journal34615 +Ref: #journal34724 +Node: Journal cheatsheet35381 +Ref: #journal-cheatsheet35520 +Node: About journal format39505 +Ref: #about-journal-format39665 +Node: Comments41281 +Ref: #comments41411 +Node: Transactions42227 +Ref: #transactions42350 +Node: Dates43364 +Ref: #dates43471 +Node: Simple dates43516 +Ref: #simple-dates43632 +Node: Posting dates44132 +Ref: #posting-dates44250 +Node: Status45219 +Ref: #status45320 +Node: Code47028 +Ref: #code47131 +Node: Description47363 +Ref: #description47494 +Node: Payee and note47814 +Ref: #payee-and-note47920 +Node: Transaction comments48255 +Ref: #transaction-comments48408 +Node: Postings48771 +Ref: #postings48904 +Node: Account names49899 +Ref: #account-names50029 +Node: Amounts51703 +Ref: #amounts51818 +Node: Decimal marks digit group marks52803 +Ref: #decimal-marks-digit-group-marks52978 +Node: Commodity53992 +Ref: #commodity54179 +Node: Directives influencing number parsing and display55131 +Ref: #directives-influencing-number-parsing-and-display55390 +Node: Commodity display style55842 +Ref: #commodity-display-style56048 +Node: Rounding58217 +Ref: #rounding58335 +Node: Costs58634 +Ref: #costs58750 +Node: Other cost/lot notations60948 +Ref: #other-costlot-notations61080 +Node: Balance assertions63669 +Ref: #balance-assertions63820 +Node: Assertions and ordering64903 +Ref: #assertions-and-ordering65092 +Node: Assertions and multiple included files65792 +Ref: #assertions-and-multiple-included-files66052 +Node: Assertions and multiple -f files66552 +Ref: #assertions-and-multiple--f-files66803 +Node: Assertions and commodities67200 +Ref: #assertions-and-commodities67422 +Node: Assertions and prices68602 +Ref: #assertions-and-prices68808 +Node: Assertions and subaccounts69235 +Ref: #assertions-and-subaccounts69456 +Node: Assertions and virtual postings69780 +Ref: #assertions-and-virtual-postings70018 +Node: Assertions and auto postings70150 +Ref: #assertions-and-auto-postings70380 +Node: Assertions and precision71025 +Ref: #assertions-and-precision71207 +Node: Posting comments71474 +Ref: #posting-comments71620 +Node: Tags71997 +Ref: #tags72111 +Node: Tag values73304 +Ref: #tag-values73393 +Node: Directives74152 +Ref: #directives74279 +Node: Directives and multiple files75609 +Ref: #directives-and-multiple-files75787 +Node: Directive effects76554 +Ref: #directive-effects76708 +Node: account directive79721 +Ref: #account-directive79877 +Node: Account comments81275 +Ref: #account-comments81425 +Node: Account subdirectives81933 +Ref: #account-subdirectives82124 +Node: Account error checking82266 +Ref: #account-error-checking82464 +Node: Account display order83653 +Ref: #account-display-order83841 +Node: Account types84942 +Ref: #account-types85083 +Node: alias directive88710 +Ref: #alias-directive88871 +Node: Basic aliases89921 +Ref: #basic-aliases90052 +Node: Regex aliases90796 +Ref: #regex-aliases90953 +Node: Combining aliases91843 +Ref: #combining-aliases92021 +Node: Aliases and multiple files93297 +Ref: #aliases-and-multiple-files93501 +Node: end aliases directive94080 +Ref: #end-aliases-directive94299 +Node: Aliases can generate bad account names94448 +Ref: #aliases-can-generate-bad-account-names94696 +Node: Aliases and account types95281 +Ref: #aliases-and-account-types95473 +Node: commodity directive96169 +Ref: #commodity-directive96343 +Node: Commodity error checking98917 +Ref: #commodity-error-checking99063 +Node: decimal-mark directive99578 +Ref: #decimal-mark-directive99760 +Node: include directive100157 +Ref: #include-directive100321 +Node: P directive101245 +Ref: #p-directive101390 +Node: payee directive102273 +Ref: #payee-directive102422 +Node: tag directive102738 +Ref: #tag-directive102893 +Node: Periodic transactions103361 +Ref: #periodic-transactions103526 +Node: Periodic rule syntax105232 +Ref: #periodic-rule-syntax105410 +Node: Periodic rules and relative dates106055 +Ref: #periodic-rules-and-relative-dates106321 +Node: Two spaces between period expression and description!106832 +Ref: #two-spaces-between-period-expression-and-description107109 +Node: Auto postings107793 +Ref: #auto-postings107941 +Node: Auto postings and multiple files110378 +Ref: #auto-postings-and-multiple-files110542 +Node: Auto postings and dates110943 +Ref: #auto-postings-and-dates111191 +Node: Auto postings and transaction balancing / inferred amounts / balance assertions111366 +Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions111722 +Node: Auto posting tags112225 +Ref: #auto-posting-tags112507 +Node: Auto postings on forecast transactions only113143 +Ref: #auto-postings-on-forecast-transactions-only113389 +Node: Other syntax113636 +Ref: #other-syntax113752 +Node: Balance assignments114379 +Ref: #balance-assignments114535 +Node: Balance assignments and prices115865 +Ref: #balance-assignments-and-prices116033 +Node: Bracketed posting dates116244 +Ref: #bracketed-posting-dates116428 +Node: D directive116942 +Ref: #d-directive117110 +Node: apply account directive118710 +Ref: #apply-account-directive118890 +Node: Y directive119577 +Ref: #y-directive119737 +Node: Secondary dates120565 +Ref: #secondary-dates120719 +Node: Star comments121533 +Ref: #star-comments121693 +Node: Valuation expressions122225 +Ref: #valuation-expressions122402 +Node: Virtual postings122524 +Ref: #virtual-postings122701 +Node: Other Ledger directives124263 +Ref: #other-ledger-directives124426 +Node: CSV124992 +Ref: #csv125083 +Node: CSV rules cheatsheet127163 +Ref: #csv-rules-cheatsheet127290 +Node: source129088 +Ref: #source129209 +Node: separator130089 +Ref: #separator130200 +Node: skip130740 +Ref: #skip130846 +Node: date-format131390 +Ref: #date-format131509 +Node: timezone132233 +Ref: #timezone132354 +Node: newest-first133359 +Ref: #newest-first133495 +Node: intra-day-reversed134073 +Ref: #intra-day-reversed134225 +Node: decimal-mark134718 +Ref: #decimal-mark134857 +Node: fields list135196 +Ref: #fields-list135333 +Node: Field assignment137004 +Ref: #field-assignment137146 +Node: Field names138173 +Ref: #field-names138302 +Node: date field139505 +Ref: #date-field139621 +Node: date2 field139669 +Ref: #date2-field139808 +Node: status field139864 +Ref: #status-field140005 +Node: code field140054 +Ref: #code-field140197 +Node: description field140242 +Ref: #description-field140400 +Node: comment field140459 +Ref: #comment-field140612 +Node: account field140905 +Ref: #account-field141053 +Node: amount field141623 +Ref: #amount-field141770 +Node: currency field145146 +Ref: #currency-field145297 +Node: balance field145554 +Ref: #balance-field145684 +Node: if block146056 +Ref: #if-block146175 +Node: Matchers147583 +Ref: #matchers147695 +Node: if table149177 +Ref: #if-table149297 +Node: balance-type150719 +Ref: #balance-type150846 +Node: include151546 +Ref: #include151671 +Node: Working with CSV152115 +Ref: #working-with-csv152260 +Node: Rapid feedback152667 +Ref: #rapid-feedback152798 +Node: Valid CSV153250 +Ref: #valid-csv153394 +Node: File Extension154126 +Ref: #file-extension154297 +Node: Reading CSV from standard input154861 +Ref: #reading-csv-from-standard-input155083 +Node: Reading multiple CSV files155247 +Ref: #reading-multiple-csv-files155476 +Node: Reading files specified by rule155717 +Ref: #reading-files-specified-by-rule155943 +Node: Valid transactions157114 +Ref: #valid-transactions157311 +Node: Deduplicating importing157939 +Ref: #deduplicating-importing158132 +Node: Setting amounts159168 +Ref: #setting-amounts159337 +Node: Amount signs161802 +Ref: #amount-signs161970 +Node: Setting currency/commodity162867 +Ref: #setting-currencycommodity163069 +Node: Amount decimal places164243 +Ref: #amount-decimal-places164447 +Node: Referencing other fields164759 +Ref: #referencing-other-fields164970 +Node: How CSV rules are evaluated165867 +Ref: #how-csv-rules-are-evaluated166082 +Node: Well factored rules167535 +Ref: #well-factored-rules167701 +Node: CSV rules examples168025 +Ref: #csv-rules-examples168158 +Node: Bank of Ireland168223 +Ref: #bank-of-ireland168358 +Node: Coinbase169820 +Ref: #coinbase169956 +Node: Amazon171003 +Ref: #amazon171126 +Node: Paypal172845 +Ref: #paypal172951 +Node: Timeclock180595 +Ref: #timeclock180700 +Node: Timedot182878 +Ref: #timedot183001 +Node: PART 3 REPORTING CONCEPTS187870 +Ref: #part-3-reporting-concepts188034 +Node: Time periods188034 +Ref: #time-periods188168 +Node: Report start & end date188286 +Ref: #report-start-end-date188438 +Node: Smart dates190097 +Ref: #smart-dates190250 +Node: Report intervals192118 +Ref: #report-intervals192273 +Node: Date adjustment192691 +Ref: #date-adjustment192851 +Node: Period expressions193702 +Ref: #period-expressions193843 +Node: Period expressions with a report interval195607 +Ref: #period-expressions-with-a-report-interval195841 +Node: More complex report intervals196055 +Ref: #more-complex-report-intervals196300 +Node: Multiple weekday intervals198101 +Ref: #multiple-weekday-intervals198290 +Node: Depth199112 +Ref: #depth199214 +Node: Queries199510 +Ref: #queries199612 +Node: Query types200521 +Ref: #query-types200642 +Node: Combining query terms203816 +Ref: #combining-query-terms203993 +Node: Queries and command options205261 +Ref: #queries-and-command-options205460 +Node: Queries and valuation205709 +Ref: #queries-and-valuation205904 +Node: Querying with account aliases206133 +Ref: #querying-with-account-aliases206344 +Node: Querying with cost or value206474 +Ref: #querying-with-cost-or-value206651 +Node: Pivoting206952 +Ref: #pivoting207066 +Node: Generating data208524 +Ref: #generating-data208656 +Node: Forecasting210239 +Ref: #forecasting210364 +Node: --forecast210895 +Ref: #forecast211026 +Node: Inspecting forecast transactions212072 +Ref: #inspecting-forecast-transactions212274 +Node: Forecast reports213404 +Ref: #forecast-reports213577 +Node: Forecast tags214513 +Ref: #forecast-tags214673 +Node: Forecast period in detail215133 +Ref: #forecast-period-in-detail215327 +Node: Forecast troubleshooting216221 +Ref: #forecast-troubleshooting216389 +Node: Budgeting217292 +Ref: #budgeting217412 +Node: Cost reporting217849 +Ref: #cost-reporting217977 +Node: -B Convert to cost219084 +Ref: #b-convert-to-cost219240 +Node: Equity conversion postings220632 +Ref: #equity-conversion-postings220846 +Node: Inferring equity postings from cost221737 +Ref: #inferring-equity-postings-from-cost221986 +Node: Inferring cost from equity postings222797 +Ref: #inferring-cost-from-equity-postings223045 +Node: When to infer cost/equity224812 +Ref: #when-to-infer-costequity225030 +Node: How to record conversions225426 +Ref: #how-to-record-conversions225618 +Node: Conversion with implicit cost225909 +Ref: #conversion-with-implicit-cost226114 +Node: Conversion with explicit cost226991 +Ref: #conversion-with-explicit-cost227236 +Node: Conversion with equity postings227653 +Ref: #conversion-with-equity-postings227922 +Node: Conversion with equity postings and explicit cost228741 +Ref: #conversion-with-equity-postings-and-explicit-cost229008 +Node: Cost tips229470 +Ref: #cost-tips229596 +Node: Valuation230302 +Ref: #valuation230426 +Node: -V Value231200 +Ref: #v-value231326 +Node: -X Value in specified commodity231521 +Ref: #x-value-in-specified-commodity231716 +Node: Valuation date231865 +Ref: #valuation-date232036 +Node: Finding market price232473 +Ref: #finding-market-price232678 +Node: --infer-market-prices market prices from transactions233848 +Ref: #infer-market-prices-market-prices-from-transactions234124 +Node: Valuation commodity236880 +Ref: #valuation-commodity237093 +Node: Simple valuation examples238306 +Ref: #simple-valuation-examples238504 +Node: --value Flexible valuation239163 +Ref: #value-flexible-valuation239367 +Node: More valuation examples241011 +Ref: #more-valuation-examples241220 +Node: Interaction of valuation and queries243219 +Ref: #interaction-of-valuation-and-queries243460 +Node: Effect of valuation on reports243932 +Ref: #effect-of-valuation-on-reports244129 +Node: PART 4 COMMANDS251826 +Ref: #part-4-commands251969 +Node: Commands overview252348 +Ref: #commands-overview252482 +Node: DATA ENTRY252661 +Ref: #data-entry252785 +Node: DATA CREATION252984 +Ref: #data-creation253138 +Node: DATA MANAGEMENT253256 +Ref: #data-management253421 +Node: REPORTS FINANCIAL253542 +Ref: #reports-financial253717 +Node: REPORTS VERSATILE254022 +Ref: #reports-versatile254195 +Node: REPORTS BASIC254448 +Ref: #reports-basic254600 +Node: HELP255109 +Ref: #help255231 +Node: ADD-ONS255341 +Ref: #add-ons255447 +Node: accounts256026 +Ref: #accounts256159 +Node: activity258046 +Ref: #activity258165 +Node: add258539 +Ref: #add258649 +Node: aregister261460 +Ref: #aregister261581 +Node: aregister and custom posting dates264469 +Ref: #aregister-and-custom-posting-dates264635 +Node: balance265187 +Ref: #balance265313 +Node: balance features266288 +Ref: #balance-features266428 +Node: Simple balance report268387 +Ref: #simple-balance-report268572 +Node: Balance report line format270197 +Ref: #balance-report-line-format270399 +Node: Filtered balance report272557 +Ref: #filtered-balance-report272749 +Node: List or tree mode273076 +Ref: #list-or-tree-mode273244 +Node: Depth limiting274589 +Ref: #depth-limiting274755 +Node: Dropping top-level accounts275356 +Ref: #dropping-top-level-accounts275556 +Node: Showing declared accounts275866 +Ref: #showing-declared-accounts276065 +Node: Sorting by amount276596 +Ref: #sorting-by-amount276763 +Node: Percentages277433 +Ref: #percentages277592 +Node: Multi-period balance report278140 +Ref: #multi-period-balance-report278340 +Node: Balance change end balance280615 +Ref: #balance-change-end-balance280824 +Node: Balance report types282252 +Ref: #balance-report-types282433 +Node: Calculation type282931 +Ref: #calculation-type283086 +Node: Accumulation type283635 +Ref: #accumulation-type283815 +Node: Valuation type284717 +Ref: #valuation-type284905 +Node: Combining balance report types285900 +Ref: #combining-balance-report-types286094 +Node: Budget report287932 +Ref: #budget-report288084 +Node: Budget report start date293738 +Ref: #budget-report-start-date293916 +Node: Budgets and subaccounts295248 +Ref: #budgets-and-subaccounts295455 +Node: Selecting budget goals298895 +Ref: #selecting-budget-goals299094 +Node: Budget vs forecast300129 +Ref: #budget-vs-forecast300288 +Node: Data layout301918 +Ref: #data-layout302068 +Node: Useful balance reports309963 +Ref: #useful-balance-reports310113 +Node: balancesheet311198 +Ref: #balancesheet311343 +Node: balancesheetequity312663 +Ref: #balancesheetequity312821 +Node: cashflow314210 +Ref: #cashflow314341 +Node: check315769 +Ref: #check315883 +Node: Basic checks316685 +Ref: #basic-checks316805 +Node: Strict checks317325 +Ref: #strict-checks317468 +Node: Other checks317891 +Ref: #other-checks318033 +Node: Custom checks318596 +Ref: #custom-checks318753 +Node: More about specific checks319170 +Ref: #more-about-specific-checks319332 +Node: close320060 +Ref: #close320171 +Node: close and balance assertions323581 +Ref: #close-and-balance-assertions323759 +Node: Example retain earnings324910 +Ref: #example-retain-earnings325127 +Node: Example migrate balances to a new file325559 +Ref: #example-migrate-balances-to-a-new-file325824 +Node: Example excluding closing/opening transactions326400 +Ref: #example-excluding-closingopening-transactions326649 +Node: codes327867 +Ref: #codes327984 +Node: commodities328848 +Ref: #commodities328976 +Node: demo329046 +Ref: #demo329167 +Node: descriptions330011 +Ref: #descriptions330141 +Node: diff330432 +Ref: #diff330547 +Node: files331589 +Ref: #files331698 +Node: help331839 +Ref: #help-1331948 +Node: import333321 +Ref: #import333444 +Node: Deduplication334530 +Ref: #deduplication334655 +Node: Import testing336549 +Ref: #import-testing336714 +Node: Importing balance assignments337557 +Ref: #importing-balance-assignments337763 +Node: Commodity display styles338412 +Ref: #commodity-display-styles338585 +Node: incomestatement338714 +Ref: #incomestatement338856 +Node: notes340177 +Ref: #notes340299 +Node: payees340661 +Ref: #payees340776 +Node: prices341295 +Ref: #prices341410 +Node: print341708 +Ref: #print341823 +Node: register347161 +Ref: #register347283 +Node: Custom register output352314 +Ref: #custom-register-output352445 +Node: rewrite353782 +Ref: #rewrite353900 +Node: Re-write rules in a file355798 +Ref: #re-write-rules-in-a-file355961 +Node: Diff output format357110 +Ref: #diff-output-format357293 +Node: rewrite vs print --auto358385 +Ref: #rewrite-vs.-print---auto358545 +Node: roi359101 +Ref: #roi359208 +Node: Spaces and special characters in --inv and --pnl360929 +Ref: #spaces-and-special-characters-in---inv-and---pnl361169 +Node: Semantics of --inv and --pnl361657 +Ref: #semantics-of---inv-and---pnl361896 +Node: IRR and TWR explained363746 +Ref: #irr-and-twr-explained363906 +Node: stats366992 +Ref: #stats367100 +Node: tags368487 +Ref: #tags-1368594 +Node: test369603 +Ref: #test369696 +Node: PART 5 COMMON TASKS370438 +Ref: #part-5-common-tasks370584 +Node: Getting help370858 +Ref: #getting-help370999 +Node: Constructing command lines371759 +Ref: #constructing-command-lines371960 +Node: Starting a journal file372617 +Ref: #starting-a-journal-file372824 +Node: Setting opening balances374012 +Ref: #setting-opening-balances374217 +Node: Recording transactions377358 +Ref: #recording-transactions377547 +Node: Reconciling378103 +Ref: #reconciling378255 +Node: Reporting380512 +Ref: #reporting380661 +Node: Migrating to a new file384646 +Ref: #migrating-to-a-new-file384803 +Node: BUGS385102 +Ref: #bugs385192 +Node: Troubleshooting386071 +Ref: #troubleshooting386171  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index a5df1ce6c..ba4a1b9da 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -13,8 +13,8 @@ SYNOPSIS INTRODUCTION hledger is a robust, user-friendly, cross-platform set of programs for - tracking money, time, or any other commodity, using double-entry - accounting and a simple, editable file format. hledger is inspired by + tracking money, time, or any other commodity, using double-entry ac- + counting and a simple, editable file format. hledger is inspired by and largely compatible with ledger(1), and largely interconvertible with beancount(1). @@ -29,55 +29,204 @@ INTRODUCTION with hledger --man, hledger --info or hledger help [TOPIC]. - The main function of the hledger CLI is to read plain text files - describing financial transactions, crunch the numbers, and print a use- - ful report on the terminal (or save it as HTML, CSV, JSON or SQL). - Many reports are available, as subcommands. hledger will also detect - other hledger-* executables as extra subcommands. + The main function of the hledger CLI is to read plain text files de- + scribing financial transactions, crunch the numbers, and print a useful + report on the terminal (or save it as HTML, CSV, JSON or SQL). Many + reports are available, as subcommands. hledger will also detect other + hledger-* executables as extra subcommands. - hledger reads data from one or more files in journal, timeclock, time- - dot, or CSV format. The default file is .hledger.journal in your home - directory; this can be overridden with one or more -f FILE options, or - the LEDGER_FILE environment variable. hledger CLI can also read from - stdin with -f-; more on that below. + hledger usually reads from (and appends to) a journal file specified by + the LEDGER_FILE environment variable (defaulting to + $HOME/.hledger.journal); or you can specify files with -f options. It + can also read timeclock files, timedot files, or any CSV/SSV/TSV file + with a date field. - Here is a small but valid hledger journal file describing one transac- - tion: + Here is a small journal file describing one transaction: 2015-10-16 bought food expenses:food $10 assets:cash - Transactions are dated movements of money (etc.) between two or more - accounts: bank accounts, your wallet, revenue/expense categories, peo- - ple, etc. You can choose any account names you wish, using : to indi- - cate subaccounts. There must be at least two spaces between account - name and amount. Positive amounts are inflow to that account (debit), - negatives are outflow from it (credit). (Some reports show revenue, - liability and equity account balances as negative numbers as a result; + Transactions are dated movements of money (etc.) between two or more + accounts: bank accounts, your wallet, revenue/expense categories, peo- + ple, etc. You can choose any account names you wish, using : to indi- + cate subaccounts. There must be at least two spaces between account + name and amount. Positive amounts are inflow to that account (debit), + negatives are outflow from it (credit). (Some reports show revenue, + liability and equity account balances as negative numbers as a result; this is normal.) hledger's add command can help you add transactions, or you can install other data entry UIs like hledger-web or hledger-iadd. For more exten- - sive/efficient changes, use a text editor: Emacs + ledger-mode, VIM + - vim-ledger, or VS Code + hledger-vscode are some good choices (see + sive/efficient changes, use a text editor: Emacs + ledger-mode, VIM + + vim-ledger, or VS Code + hledger-vscode are some good choices (see https://hledger.org/editors.html). - To get started, run hledger add and follow the prompts, or save some - entries like the above in $HOME/.hledger.journal, then try commands + To get started, run hledger add and follow the prompts, or save some + entries like the above in $HOME/.hledger.journal, then try commands like: hledger print -x hledger aregister assets hledger balance hledger balancesheet hledger incomestatement. - Run hledger to list the commands. See also the "Starting a journal - file" and "Setting opening balances" sections in PART 5: COMMON TASKS. + Run hledger to list the commands. See also the "Starting a journal + file" and "Setting opening balances" sections in PART 5: COMMON TASKS. PART 1: USER INTERFACE +Input + hledger reads one or more data files, each time you run it. You can + specify a file with -f, like so + + $ hledger -f FILE print + + Files are most often in hledger's journal format, with the .journal + file extension (.hledger or .j also work); these files describe trans- + actions, like an accounting general journal. Some other supported file + formats are discussed below. + + When no -f option is given, hledger looks for the file specified by the + LEDGER_FILE environment variable; if this is not set, it uses + .hledger.journal in your home directory. + + Most people prefer to keep financial files in a dedicated folder, per- + haps with version control. Also, starting a new journal file per year + is common (it's not required, but helps keep things fast and organ- + ised). So we usually set LEDGER_FILE, to something like ~/fi- + nance/2023.journal. + + Setting LEDGER_FILE + How to set LEDGER_FILE permanently depends on your platform: + + On unix and mac, running these commands in the terminal will work for + many people; adapt as needed: + + $ mkdir -p ~/finance + $ echo 'export LEDGER_FILE=~/finance/2023.journal` >> ~/.profile + $ source ~/.profile + + 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- + ment.plist like + + { + "LEDGER_FILE" : "~/finance/2023.journal" + } + + 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- + sists across a reboot, and if you need to be an Administrator): + + > CD + > MKDIR finance + > SETX LEDGER_FILE "C:\Users\USERNAME\finance\2023.journal" + + Data formats + Usually the data file is in hledger's journal format, but it can be in + any of the supported file formats, which currently are: + + Reader: Reads: Used for file exten- + sions: + ----------------------------------------------------------------------------- + journal hledger journal files and some Ledger .journal .j .hledger + journals, for transactions .ledger + time- timeclock files, for precise time log- .timeclock + clock ging + timedot timedot files, for approximate time .timedot + logging + csv CSV/SSV/TSV/character-separated values, .csv .ssv .tsv + for data import .csv.rules .ssv.rules + .tsv.rules + + These formats are described in more detail below. + + hledger detects the format automatically based on the file extensions + shown above. If it can't recognise the file extension, it assumes + journal format. So for non-journal files, it's important to use a + recognised file extension, so as to either read successfully or to show + relevant error messages. + + You can also force a specific reader/format by prefixing the file path + with the format and a colon. Eg, to read a .dat file as csv format: + + $ hledger -f csv:/some/csv-file.dat stats + + Standard input + The file name - means standard input: + + $ cat FILE | hledger -f- print + + If reading non-journal data in this way, you'll need to add a file for- + mat prefix, like: + + $ echo 'i 2009/13/1 08:00:00' | hledger print -f timeclock:- + + Multiple files + You can specify multiple -f options, to read multiple files as one big + journal. When doing this, note that certain features (described below) + will be affected: + + o Balance assertions will not see the effect of transactions in previ- + ous files. (Usually this doesn't matter as each file will set the + corresponding opening balances.) + + o Some directives will not affect previous or subsequent files. + + If needed, you can work around these by using a single parent file + which includes the others, or concatenating the files into one, eg: cat + a.journal b.journal | hledger -f- CMD. + + Strict mode + hledger checks input files for valid data. By default, the most impor- + tant errors are detected, while still accepting easy journal files + without a lot of declarations: + + o Are the input files parseable, with valid syntax ? + + o Are all transactions balanced ? + + o Do all balance assertions pass ? + + With the -s/--strict flag, additional checks are performed: + + o Are all accounts posted to, declared with an account directive ? + (Account error checking) + + o Are all commodities declared with a commodity directive ? (Commodity + error checking) + + o Are all commodity conversions declared explicitly ? + + You can use the check command to run individual checks -- the ones + listed above and some more. + +Environment + Environment variables which affect hledger: + + COLUMNS This is normally set by your terminal; some hledger commands + (register) will format their output to this width. If not set, they + will try to use the available terminal width. + + LEDGER_FILE The main journal file to use when not specified with + -f/--file. Default: $HOME/.hledger.journal. + + NO_COLOR If this environment variable is set (with any value), hledger + will not use ANSI color codes in terminal output, unless overridden by + an explicit --color/--colour option. + Options + Here is a list of flags and options common to most hledger commands, + and some useful details about hledger command line parsing. But if you + are new to hledger, feel free to skim/skip ahead to the Commands. + General options - To see general usage help, including general options which are sup- + To see general usage help, including general options which are sup- ported by most hledger commands, run hledger -h. General help options: @@ -102,7 +251,7 @@ Options $LEDGER_FILE or $HOME/.hledger.journal) --rules-file=RULESFILE - Conversion rules file to use when reading CSV (default: + Conversion rules file to use when reading CSV (default: FILE.rules) --separator=CHAR @@ -121,8 +270,8 @@ Options assignments) -s --strict - do extra error checking (check that all posted accounts are - declared) + do extra error checking (check that all posted accounts are de- + clared) General reporting options: @@ -150,15 +299,15 @@ Options multiperiod/multicolumn report by year -p --period=PERIODEXP - set start date, end date, and/or reporting interval all at once + set start date, end date, and/or reporting interval all at once using period expressions syntax --date2 - match the secondary date instead (see command help for other - effects) + match the secondary date instead (see command help for other ef- + fects) --today=DATE - override today's date (affects relative smart dates, for + override today's date (affects relative smart dates, for tests/examples) -U --unmarked @@ -177,7 +326,7 @@ Options hide/aggregate accounts or postings more than NUM levels deep -E --empty - show items with zero amount, normally hidden (and vice-versa in + show items with zero amount, normally hidden (and vice-versa in hledger-ui/hledger-web) -B --cost @@ -194,16 +343,29 @@ Options convert amounts to cost or market value, more flexibly than -B/-V/-X - --infer-market-prices - use transaction prices (recorded with @ or @@) as additional - market prices, as if they were P directives + --infer-equity + infer conversion equity postings from costs - --auto apply automated posting rules to modify transactions. + --infer-costs + infer costs from conversion equity postings + + --infer-market-prices + use costs as additional market prices, as if they were P direc- + tives --forecast - generate future transactions from periodic transaction rules, - for the next 6 months or till report end date. In hledger-ui, - also make ordinary future transactions visible. + generate transactions from periodic rules, between the latest + recorded txn and 6 months from today, or during the specified + PERIOD (= is required). Auto posting rules will be applied to + these transactions as well. Also, in hledger-ui make future- + dated transactions visible. + + --auto generate extra postings by applying auto posting rules to all + txns (not just forecast txns) + + --verbose-tags + add visible tags indicating transactions or postings which have + been generated/modified --commodity-style Override the commodity style in the output for the specified @@ -227,15 +389,22 @@ Options Some reporting options can also be written as query arguments. + Option repetition + If options are repeated in a command line, hledger will generally use + the last (right-most) occurence. Some of the boolean flags will toggle + if repeated; these include: --invert, --transpose, -r/--related, + -%/--percent, -E/--empty, -N/--no-total, -T/--row-total, -A/--average, + and -S/--sort-amount. + Command options - To see options for a particular command, including command-specific - options, run: hledger COMMAND -h. + To see options for a particular command, including command-specific op- + tions, run: hledger COMMAND -h. Command-specific options must be written after the command name, eg: hledger print -x. - Additionally, if the command is an add-on, you may need to put its - options after a double-hyphen, eg: hledger ui -- --watch. Or, you can + Additionally, if the command is an add-on, you may need to put its op- + tions after a double-hyphen, eg: hledger ui -- --watch. Or, you can run the add-on executable directly: hledger-ui --watch. Command arguments @@ -278,8 +447,8 @@ Options In shell command lines, characters significant to your shell - such as spaces, <, >, (, ), |, $ and \ - should be "shell-escaped" if you want hledger to see them. This is done by enclosing them in single or dou- - ble quotes, or by writing a backslash before them. Eg to match an - account name containing a space: + ble quotes, or by writing a backslash before them. Eg to match an ac- + count name containing a space: $ hledger register 'credit card' @@ -307,10 +476,10 @@ Options $ hledger balance cur:\\$ Triple escaping (for add-on commands) - When you use hledger to run an external add-on command (described - below), one level of shell-escaping is lost from any options or argu- - ments intended for by the add-on command, so those need an extra level - of shell-escaping. Eg to match a literal $ sign while using the bash + When you use hledger to run an external add-on command (described be- + low), one level of shell-escaping is lost from any options or arguments + intended for by the add-on command, so those need an extra level of + shell-escaping. Eg to match a literal $ sign while using the bash shell and running an add-on command (ui): $ hledger ui cur:'\\$' @@ -321,7 +490,6 @@ Options If you wondered why four backslashes, perhaps this helps: - unescaped: $ escaped: \$ double-escaped: \\$ @@ -357,8 +525,8 @@ Options This requires a well-configured environment. Here are some tips: - o A system locale must be configured, and it must be one that can - decode the characters being used. In bash, you can set a locale like + o A system locale must be configured, and it must be one that can de- + code the characters being used. In bash, you can set a locale like this: export LANG=en_US.UTF-8. There are some more details in Trou- bleshooting. This step is essential - without it, hledger will quit on encountering a non-ascii character (as with all GHC-compiled pro- @@ -425,167 +593,32 @@ Options ing to the shell and so must be escaped at least once more. See Spe- cial characters. -Environment - LEDGER_FILE The journal file path when not specified with -f. - - On unix computers, the default value is: ~/.hledger.journal. - - A more typical value is something like ~/finance/YYYY.journal, where - ~/finance is a version-controlled finance directory and YYYY is the - current year. Or, ~/finance/current.journal, where current.journal is - a symbolic link to YYYY.journal. - - The usual way to set this permanently is to add a command to one of - your shell's startup files (eg ~/.profile): - - export LEDGER_FILE=~/finance/current.journal` - - On some Mac computers, there is a more thorough way to set environment - variables, that will also affect applications started from the GUI (eg, - Emacs started from a dock icon): In ~/.MacOSX/environment.plist, add an - entry like: - - { - "LEDGER_FILE" : "~/finance/current.journal" - } - - For this to take effect you might need to killall Dock, or reboot. - - On Windows computers, the default value is probably C:\Users\YOUR- - NAME\.hledger.journal. You can change this by running a command like - this in a powershell window (let us know if you need to be an Adminis- - trator, and if this persists across a reboot): - - > setx LEDGER_FILE "C:\Users\MyUserName\finance\2021.journal" - - Or, change it in settings: see https://www.java.com/en/down- - load/help/path.html. - - COLUMNS The screen width used by the register command. Default: the - full terminal width. - - NO_COLOR If this variable exists with any value, hledger will not use - ANSI color codes in terminal output. This is overriden by the - --color/--colour option. - -Input - hledger reads transactions from one or more data files. The default - data file is $HOME/.hledger.journal (or on Windows, something like - C:\Users\YOURNAME\.hledger.journal). - - You can override this with the $LEDGER_FILE environment variable: - - $ setenv LEDGER_FILE ~/finance/2016.journal - $ hledger stats - - or with one or more -f/--file options: - - $ hledger -f /some/file -f another_file stats - - The file name - means standard input: - - $ cat some.journal | hledger -f- - - Data formats - Usually the data file is in hledger's journal format, but it can be in - any of the supported file formats, which currently are: - - - Reader: Reads: Used for file exten- - sions: - ----------------------------------------------------------------------------- - journal hledger journal files and some Ledger .journal .j .hledger - journals, for transactions .ledger - time- timeclock files, for precise time log- .timeclock - clock ging - timedot timedot files, for approximate time .timedot - logging - csv comma/semicolon/tab/other-separated .csv .ssv .tsv - values, for data import - - These formats are described in more detail below. - - hledger detects the format automatically based on the file extensions - shown above. If it can't recognise the file extension, it assumes - journal format. So for non-journal files, it's important to use a - recognised file extension, so as to either read successfully or to show - relevant error messages. - - You can also force a specific reader/format by prefixing the file path - with the format and a colon. Eg, to read a .dat file as csv format: - - $ hledger -f csv:/some/csv-file.dat stats - - Or to read stdin (-) as timeclock format: - - $ echo 'i 2009/13/1 08:00:00' | hledger print -ftimeclock:- - - Multiple files - You can specify multiple -f options, to read multiple files as one big - journal. There are some limitations with this: - - o most directives do not affect sibling files - - o balance assertions will not see any account balances from previous - files - - If you need either of those things, you can - - o use a single parent file which includes the others - - o or concatenate the files into one before reading, eg: cat a.journal - b.journal | hledger -f- CMD. - - Strict mode - hledger checks input files for valid data. By default, the most impor- - tant errors are detected, while still accepting easy journal files - without a lot of declarations: - - o Are the input files parseable, with valid syntax ? - - o Are all transactions balanced ? - - o Do all balance assertions pass ? - - With the -s/--strict flag, additional checks are performed: - - o Are all accounts posted to, declared with an account directive ? - (Account error checking) - - o Are all commodities declared with a commodity directive ? (Commodity - error checking) - - o Are all commodity conversions declared explicitly ? - - You can use the check command to run individual checks -- the ones - listed above and some more. - Commands - hledger provides a number of built-in subcommands (described below). + hledger provides a number of built-in subcommands (described below). Most of these read your data without changing it, and display a report. A few assist with data entry and management. - Run hledger with no arguments to list the commands available, and + Run hledger with no arguments to list the commands available, and hledger CMD to run a command. CMD can be the full command name, or its - standard abbreviation shown in the commands list, or any unambiguous + standard abbreviation shown in the commands list, or any unambiguous prefix of the name. Eg: hledger bal. Add-on commands - Add-on commands are extra subcommands provided by programs or scripts + Add-on commands are extra subcommands provided by programs or scripts in your PATH o whose name starts with hledger- - o whose name ends with a recognised file extension: .bat,.com,.exe, + o whose name ends with a recognised file extension: .bat,.com,.exe, .hs,.lhs,.pl,.py,.rb,.rkt,.sh or none o and (on unix, mac) which are executable by the current user. - Addons can be written in any language, but haskell scripts or programs + Addons can be written in any language, but haskell scripts or programs have a big advantage: they can use hledger's library code, for command- line options, parsing and reporting. - Several add-on commands are installed by the hledger-install script. + Several add-on commands are installed by the hledger-install script. See https://hledger.org/scripts.html for more details. Note in a hledger command line, add-on command flags must have a double @@ -613,18 +646,17 @@ Output $ hledger print > foo.txt - Some commands (print, register, stats, the balance commands) also pro- - vide the -o/--output-file option, which does the same thing without + Some commands (print, register, stats, the balance commands) also pro- + vide the -o/--output-file option, which does the same thing without needing the shell. Eg: $ hledger print -o foo.txt $ hledger print -o - # write to stdout (the default) Output format - Some commands offer other kinds of output, not just text on the termi- + Some commands offer other kinds of output, not just text on the termi- nal. Here are those commands and the formats currently supported: - - txt csv html json sql -------------------------------------------------------------------------------------- aregister Y Y Y Y @@ -638,19 +670,19 @@ Output o 1 Also affected by the balance commands' --layout option. - o 2 balance does not support html output without a report interval or + o 2 balance does not support html output without a report interval or with --budget. The output format is selected by the -O/--output-format=FMT option: $ hledger print -O csv # print CSV on stdout - or by the filename extension of an output file specified with the + or by the filename extension of an output file specified with the -o/--output-file=FILE.FMT option: $ hledger balancesheet -o foo.csv # write CSV to foo.csv - The -O option can be combined with -o to override the file extension, + The -O option can be combined with -o to override the file extension, if needed: $ hledger balancesheet -o foo.txt -O csv # write CSV to foo.txt @@ -658,7 +690,7 @@ Output Some notes about the various output formats: CSV output - o In CSV output, digit group marks (such as thousands separators) are + o In CSV output, digit group marks (such as thousands separators) are disabled automatically. HTML output @@ -668,46 +700,46 @@ Output JSON output o This is not yet much used; real-world feedback is welcome. - o Our JSON is rather large and verbose, since it is a faithful repre- - sentation of hledger's internal data types. To understand the JSON, - read the Haskell type definitions, which are mostly in + o Our JSON is rather large and verbose, since it is a faithful repre- + sentation of hledger's internal data types. To understand the JSON, + read the Haskell type definitions, which are mostly in https://github.com/simonmichael/hledger/blob/master/hledger- lib/Hledger/Data/Types.hs. - o hledger represents quantities as Decimal values storing up to 255 - significant digits, eg for repeating decimals. Such numbers can + o hledger represents quantities as Decimal values storing up to 255 + significant digits, eg for repeating decimals. Such numbers can arise in practice (from automatically-calculated transaction prices), - and would break most JSON consumers. So in JSON, we show quantities + and would break most JSON consumers. So in JSON, we show quantities as simple Numbers with at most 10 decimal places. We don't limit the - number of integer digits, but that part is under your control. We - hope this approach will not cause problems in practice; if you find + number of integer digits, but that part is under your control. We + hope this approach will not cause problems in practice; if you find otherwise, please let us know. (Cf #1195) SQL output o This is not yet much used; real-world feedback is welcome. - o SQL output is expected to work at least with SQLite, MySQL and Post- + o SQL output is expected to work at least with SQLite, MySQL and Post- gres. - o For SQLite, it will be more useful if you modify the generated id + o For SQLite, it will be more useful if you modify the generated id field to be a PRIMARY KEY. Eg: $ hledger print -O sql | sed 's/id serial/id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL/g' | ... - o SQL output is structured with the expectations that statements will - be executed in the empty database. If you already have tables cre- - ated via SQL output of hledger, you would probably want to either + o SQL output is structured with the expectations that statements will + be executed in the empty database. If you already have tables cre- + ated via SQL output of hledger, you would probably want to either clear tables of existing data (via delete or truncate SQL statements) or drop tables completely as otherwise your postings will be duped. Commodity styles - When displaying amounts, hledger infers a standard display style for + When displaying amounts, hledger infers a standard display style for each commodity/currency, as described below in Commodity display style. - If needed, this can be overridden by a -c/--commodity-style option - (except for cost amounts and amounts displayed by the print command, - which are always displayed with all decimal digits). For example, the - following will force dollar amounts to be displayed as shown: + If needed, this can be overridden by a -c/--commodity-style option (ex- + cept for cost amounts and amounts displayed by the print command, which + are always displayed with all decimal digits). For example, the fol- + lowing will force dollar amounts to be displayed as shown: $ hledger print -c '$1.000,0' @@ -765,105 +797,15 @@ Output to 9 (maximum output). Typically you would start with 1 and increase until you are seeing enough. Debug output goes to stderr, and is not affected by -o/--output-file (unless you redirect stderr to stdout, eg: - 2>&1). It will be interleaved with normal output, which can help - reveal when parts of the code are evaluated. To capture debug output - in a log file instead, you can usually redirect stderr, eg: + 2>&1). It will be interleaved with normal output, which can help re- + veal when parts of the code are evaluated. To capture debug output in + a log file instead, you can usually redirect stderr, eg: hledger bal --debug=3 2>hledger.log -Limitations - The need to precede add-on command options with -- when invoked from - hledger is awkward. - - When input data contains non-ascii characters, a suitable system locale - must be configured (or there will be an unhelpful error). Eg on POSIX, - set LANG to something other than C. - - In a Microsoft Windows CMD window, non-ascii characters and colours are - not supported. - - On Windows, non-ascii characters may not display correctly when running - a hledger built in CMD in MSYS/CYGWIN, or vice-versa. - - In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger - add. - - Not all of Ledger's journal file syntax is supported. See hledger and - Ledger > Differences > journal format. - - On large data files, hledger is slower and uses more memory than - Ledger. - -Troubleshooting - Here are some issues you might encounter when you run hledger (and - remember you can also seek help from the IRC channel, mail list or bug - tracker): - - Successfully installed, but "No command 'hledger' found" - stack and cabal install binaries into a special directory, which should - be added to your PATH environment variable. Eg on unix-like systems, - that is ~/.local/bin and ~/.cabal/bin respectively. - - I set a custom LEDGER_FILE, but hledger is still using the default file - LEDGER_FILE should be a real environment variable, not just a shell - variable. The command env | grep LEDGER_FILE should show it. You may - need to use export. Here's an explanation. - - Getting errors like "Illegal byte sequence" or "Invalid or incomplete - multibyte or wide character" or "commitAndReleaseBuffer: invalid argu- - ment (invalid character)" - Programs compiled with GHC (hledger, haskell build tools, etc.) need - to have a UTF-8-aware locale configured in the environment, otherwise - they will fail with these kinds of errors when they encounter non-ascii - characters. - - To fix it, set the LANG environment variable to some locale which sup- - ports UTF-8. The locale you choose must be installed on your system. - - Here's an example of setting LANG temporarily, on Ubuntu GNU/Linux: - - $ file my.journal - my.journal: UTF-8 Unicode text # the file is UTF8-encoded - $ echo $LANG - C # LANG is set to the default locale, which does not support UTF8 - $ locale -a # which locales are installed ? - C - en_US.utf8 # here's a UTF8-aware one we can use - POSIX - $ LANG=en_US.utf8 hledger -f my.journal print # ensure it is used for this command - - If available, C.UTF-8 will also work. If your preferred locale isn't - listed by locale -a, you might need to install it. Eg on - Ubuntu/Debian: - - $ apt-get install language-pack-fr - $ locale -a - C - en_US.utf8 - fr_BE.utf8 - fr_CA.utf8 - fr_CH.utf8 - fr_FR.utf8 - fr_LU.utf8 - POSIX - $ LANG=fr_FR.utf8 hledger -f my.journal print - - Here's how you could set it permanently, if you use a bash shell: - - $ echo "export LANG=en_US.utf8" >>~/.bash_profile - $ bash --login - - Exact spelling and capitalisation may be important. Note the differ- - ence on MacOS (UTF-8, not utf8). Some platforms (eg ubuntu) allow - variant spellings, but others (eg macos) require it to be exact: - - $ locale -a | grep -iE en_us.*utf - en_US.UTF-8 - $ LANG=en_US.UTF-8 hledger -f my.journal print - PART 2: DATA FORMATS Journal - hledger's default file format, representing a General Journal. Here's + hledger's default file format, representing a General Journal. Here's a cheatsheet/mini-tutorial, or you can skip ahead to About journal for- mat. @@ -929,7 +871,6 @@ Journal expenses:tax:us:2021 $500 ; plus means added to this account (debit) ; revenue/expense categories are also "accounts" - Kv 2022-01-01 ; The description is optional. ; Any currency/commodity symbols are allowed, on either side. assets:cash:wallet GBP -10 @@ -958,19 +899,20 @@ Journal 12/31 also allowed (but consistent YYYY-MM-DD is recommended). About journal format - hledger's usual data source is a plain text file containing journal - entries in hledger journal format. This file represents a standard - accounting general journal. I use file names ending in .journal, but + hledger's usual data source is a plain text file containing journal en- + tries in hledger journal format. This file represents a standard ac- + counting general journal. I use file names ending in .journal, but that's not required. The journal file contains a number of transaction entries, each describing a transfer of money (or any commodity) between two or more named accounts, in a simple format readable by both hledger and humans. - hledger's journal format is a compatible subset, mostly, of ledger's - journal format, so hledger can work with compatible ledger journal - files as well. It's safe, and encouraged, to run both hledger and - ledger on the same journal file, eg to validate the results you're get- - ting. + hledger's journal format is compatible with most of Ledger's journal + format, but not all of it. The differences and interoperation tips are + described at hledger and Ledger. With some care, and by avoiding in- + compatible features, you can keep your hledger journal readable by + Ledger and vice versa. This can useful eg for comparing the behaviour + of one app against the other. You can use hledger without learning any more about this file; just use the add or web or import commands to create and update it. @@ -991,9 +933,9 @@ Journal Comments Lines in the journal will be ignored if they begin with a hash (#) or a - semicolon (;). (See also Other syntax.) hledger will also ignore - regions beginning with a comment line and ending with an end comment - line (or file end). Here's a suggestion for choosing between them: + semicolon (;). (See also Other syntax.) hledger will also ignore re- + gions beginning with a comment line and ending with an end comment line + (or file end). Here's a suggestion for choosing between them: o # for top-level notes @@ -1022,8 +964,8 @@ Journal between two or more named accounts. Each transaction is recorded as a journal entry, beginning with a sim- - ple date in column 0. This can be followed by any of the following - optional fields, separated by spaces: + ple date in column 0. This can be followed by any of the following op- + tional fields, separated by spaces: o a status character (empty, !, or *) @@ -1060,8 +1002,8 @@ Journal You can give individual postings a different date from their parent transaction, by adding a posting comment containing a tag (see below) like date:DATE. This is probably the best way to control posting dates - precisely. Eg in this example the expense should appear in May - reports, and the deduction from checking should be reported on 6/1 for + precisely. Eg in this example the expense should appear in May re- + ports, and the deduction from checking should be reported on 6/1 for easy bank reconciliation: 2015/5/30 @@ -1081,10 +1023,9 @@ Journal Status Transactions, or individual postings within a transaction, can have a - status mark, which is a single character before the transaction - description or posting account name, separated from it by a space, - indicating one of three statuses: - + status mark, which is a single character before the transaction de- + scription or posting account name, separated from it by a space, indi- + cating one of three statuses: mark status ------------------ @@ -1097,8 +1038,8 @@ Journal status:* queries; or the U, P, C keys in hledger-ui. Note, in Ledger and in older versions of hledger, the "unmarked" state - is called "uncleared". As of hledger 1.3 we have renamed it to - unmarked for clarity. + is called "uncleared". As of hledger 1.3 we have renamed it to un- + marked for clarity. To replicate Ledger and old hledger's behaviour of also matching pend- ing, combine -U and -P. @@ -1111,7 +1052,6 @@ Journal What "uncleared", "pending", and "cleared" actually mean is up to you. Here's one suggestion: - status meaning -------------------------------------------------------------------------- uncleared recorded but not yet reconciled; needs review @@ -1121,8 +1061,8 @@ Journal rect With this scheme, you would use -PC to see the current balance at your - bank, -U to see things which will probably hit your bank soon (like - uncashed checks), and no flags to see the most up-to-date state of your + bank, -U to see things which will probably hit your bank soon (like un- + cashed checks), and no flags to see the most up-to-date state of your finances. Code @@ -1141,9 +1081,9 @@ Journal Payee and note You can optionally include a | (pipe) character in descriptions to sub- divide the description into separate fields for payee/payer name on the - left (up to the first |) and an additional note field on the right - (after the first |). This may be worthwhile if you need to do more - precise querying and pivoting by payee or by note. + left (up to the first |) and an additional note field on the right (af- + ter the first |). This may be worthwhile if you need to do more pre- + cise querying and pivoting by payee or by note. Transaction comments Text following ;, after a transaction description, and/or on indented @@ -1227,8 +1167,8 @@ Journal aliases. Amounts - After the account name, there is usually an amount. (Important: - between account name and amount, there must be two or more spaces.) + After the account name, there is usually an amount. (Important: be- + tween account name and amount, there must be two or more spaces.) hledger's amount format is flexible, supporting several international formats. Here are some examples. Amounts have a number (the "quan- @@ -1328,7 +1268,6 @@ Journal commodity INR 9,99,99,999.00 commodity 1 000 000.9455 - Commodity display style For the amounts in each commodity, hledger chooses a consistent display style to use in most reports. (Exceptions: price amounts, and all @@ -1363,10 +1302,10 @@ Journal o Use the maximum number of decimal places of all. - Cost amounts don't affect the commodity display style directly, but - occasionally they can do so indirectly (eg when a posting's amount is - inferred using a cost). If you find this causing problems, use a com- - modity directive to fix the display style. + Cost amounts don't affect the commodity display style directly, but oc- + casionally they can do so indirectly (eg when a posting's amount is in- + ferred using a cost). If you find this causing problems, use a commod- + ity directive to fix the display style. To summarise: each commodity's amounts will be normalised to (a) the style declared by a commodity directive, or (b) the style of the first @@ -1392,7 +1331,6 @@ Journal rounds to the nearest even number, eg 0.5 displayed with zero decimal places is "0"). - Costs After a posting amount, you can note its cost (when buying) or selling price (when selling) in another commodity, by writing either @ UNIT- @@ -1405,34 +1343,34 @@ Journal "cost", with the understanding that the transaction could be a purchase or a sale.) - Costs are usually written explicitly with @ or @@, but can also be - inferred automatically for simple multi-commodity transactions. Note, - if costs are inferred, the order of postings is significant; the first + Costs are usually written explicitly with @ or @@, but can also be in- + ferred automatically for simple multi-commodity transactions. Note, if + costs are inferred, the order of postings is significant; the first posting will have a cost attached, in the commodity of the second. As an example, here are several ways to record purchases of a foreign - currency in hledger, using the cost notation either explicitly or - implicitly: + currency in hledger, using the cost notation either explicitly or im- + plicitly: 1. Write the price per unit, as @ UNITPRICE after the amount: 2009/1/1 - assets:euros EUR100 @ $1.35 ; one hundred euros purchased at $1.35 each + assets:euros 100 @ $1.35 ; one hundred euros purchased at $1.35 each assets:dollars ; balancing amount is -$135.00 2. Write the total price, as @@ TOTALPRICE after the amount: 2009/1/1 - assets:euros EUR100 @@ $135 ; one hundred euros purchased at $135 for the lot + assets:euros 100 @@ $135 ; one hundred euros purchased at $135 for the lot assets:dollars 3. Specify amounts for all postings, using exactly two commodities, and let hledger infer the price that balances the transaction. Note the effect of posting order: the price is added to first posting, making - it EUR100 @@ $135, as in example 2: + it 100 @@ $135, as in example 2: 2009/1/1 - assets:euros EUR100 ; one hundred euros purchased + assets:euros 100 ; one hundred euros purchased assets:dollars $-135 ; for $135 Amounts can be converted to cost at report time using the -B/--cost @@ -1560,9 +1498,9 @@ Journal Assertions and multiple included files Multiple files included with the include directive are processed as if - concatenated into one file, preserving their order and the posting - order within each file. It means that balance assertions in later - files will see balance from earlier files. + concatenated into one file, preserving their order and the posting or- + der within each file. It means that balance assertions in later files + will see balance from earlier files. And if you have multiple postings to an account on the same day, split across multiple files, and you want to assert the account's balance on @@ -1575,8 +1513,8 @@ Journal ance from earlier files. This can be useful when you do not want prob- lems in earlier files to disrupt valid assertions in later files. - If you do want assertions to see balance from earlier files, use - include, or concatenate the files temporarily. + If you do want assertions to see balance from earlier files, use in- + clude, or concatenate the files temporarily. Assertions and commodities The asserted balance must be a simple single-commodity amount, and in @@ -1587,56 +1525,56 @@ Journal To assert the balance of more than one commodity in an account, you can write multiple postings, each asserting one commodity's balance. - You can make a stronger "total" balance assertion by writing a double + You can make a stronger "total" balance assertion by writing a double equals sign (== EXPECTEDBALANCE). This asserts that there are no other - commodities in the account besides the asserted one (or at least, that + commodities in the account besides the asserted one (or at least, that their balance is 0). 2013/1/1 a $1 - a 1EUR + a 1 b $-1 - c -1EUR + c -1 2013/1/2 ; These assertions succeed a 0 = $1 - a 0 = 1EUR + a 0 = 1 b 0 == $-1 - c 0 == -1EUR + c 0 == -1 - 2013/1/3 ; This assertion fails as 'a' also contains 1EUR + 2013/1/3 ; This assertion fails as 'a' also contains 1 a 0 == $1 It's not yet possible to make a complete assertion about a balance that - has multiple commodities. One workaround is to isolate each commodity + has multiple commodities. One workaround is to isolate each commodity into its own subaccount: 2013/1/1 a:usd $1 - a:euro 1EUR + a:euro 1 b 2013/1/2 a 0 == 0 a:usd 0 == $1 - a:euro 0 == 1EUR + a:euro 0 == 1 Assertions and prices Balance assertions ignore costs, and should normally be written without one: 2019/1/1 - (a) $1 @ EUR1 = $1 + (a) $1 @ 1 = $1 - We do allow prices to be written there, however, and print shows them, - even though they don't affect whether the assertion passes or fails. - This is for backward compatibility (hledger's close command used to - generate balance assertions with prices), and because balance assign- + We do allow prices to be written there, however, and print shows them, + even though they don't affect whether the assertion passes or fails. + This is for backward compatibility (hledger's close command used to + generate balance assertions with prices), and because balance assign- ments do use them (see below). Assertions and subaccounts - The balance assertions above (= and ==) do not count the balance from - subaccounts; they check the account's exclusive balance only. You can + The balance assertions above (= and ==) do not count the balance from + subaccounts; they check the account's exclusive balance only. You can assert the balance including subaccounts by writing =* or ==*, eg: 2019/1/1 @@ -1650,10 +1588,10 @@ Journal are not affected by the --real/-R flag or real: query. Assertions and auto postings - Balance assertions are affected by the --auto flag, which generates + Balance assertions are affected by the --auto flag, which generates auto postings, which can alter account balances. Because auto postings are optional in hledger, accounts affected by them effectively have two - balances. But balance assertions can only test one or the other of + balances. But balance assertions can only test one or the other of these. So to avoid making fragile assertions, either: o assert the balance calculated with --auto, and always use --auto with @@ -1666,15 +1604,15 @@ Journal avoid auto postings entirely). Assertions and precision - Balance assertions compare the exactly calculated amounts, which are - not always what is shown by reports. Eg a commodity directive may - limit the display precision, but this will not affect balance asser- + Balance assertions compare the exactly calculated amounts, which are + not always what is shown by reports. Eg a commodity directive may + limit the display precision, but this will not affect balance asser- tions. Balance assertion failure messages show exact amounts. Posting comments - Text following ;, at the end of a posting line, and/or on indented - lines immediately below it, form comments for that posting. They are - reproduced by print but otherwise ignored, except they may contain + Text following ;, at the end of a posting line, and/or on indented + lines immediately below it, form comments for that posting. They are + reproduced by print but otherwise ignored, except they may contain tags, which are not ignored. 2012-01-01 @@ -1684,14 +1622,14 @@ Journal ; a second comment line for posting 2 Tags - Tags are a way to add extra labels or labelled data to transactions, + Tags are a way to add extra labels or labelled data to transactions, postings, or accounts, which you can then search or pivot on. They are written as a word (optionally hyphenated) immediately followed - by a full colon, in a transaction or posting or account directive's - comment. (This is an exception to the usual rule that things in com- - ments are ignored.) Eg, here four different tags are recorded: one on - the checking account, two on the transaction, and one on the expenses + by a full colon, in a transaction or posting or account directive's + comment. (This is an exception to the usual rule that things in com- + ments are ignored.) Eg, here four different tags are recorded: one on + the checking account, two on the transaction, and one on the expenses posting: account assets:checking ; accounttag: @@ -1701,94 +1639,98 @@ Journal assets:checking $-1 expenses:food $1 ; postingtag: - Postings also inherit tags from their transaction and their account. - And transactions also acquire tags from their postings (and postings' - accounts). So in the example above, the expenses posting effectively + Postings also inherit tags from their transaction and their account. + And transactions also acquire tags from their postings (and postings' + accounts). So in the example above, the expenses posting effectively has all four tags (by inheriting from account and transaction), and the - transaction also has all four tags (by acquiring from the expenses + transaction also has all four tags (by acquiring from the expenses posting). - You can list tag names with hledger tags [NAMEREGEX], or match by tag + You can list tag names with hledger tags [NAMEREGEX], or match by tag name with a tag:NAMEREGEX query. Tag values - Tags can have a value, which is any text after the colon up until a - comma or end of line (with surrounding whitespace removed). Note this - means that hledger tag values can not contain commas. Eg in the fol- + Tags can have a value, which is any text after the colon up until a + comma or end of line (with surrounding whitespace removed). Note this + means that hledger tag values can not contain commas. Eg in the fol- lowing posting, the three tags' values are "value 1", "value 2", and "" (empty) respectively: expenses:food $10 ; foo, tag1: value 1 , tag2:value 2, bar tag3: , baz - Note that tags can be repeated, and are additive rather than overrid- - ing: when the same tag name is seen again with a new value, the new - name:value pair is added to the tags. (It is not possible to override + Note that tags can be repeated, and are additive rather than overrid- + ing: when the same tag name is seen again with a new value, the new + name:value pair is added to the tags. (It is not possible to override a tag's value or remove a tag.) - You can list a tag's values with hledger tags TAGNAME --values, or + You can list a tag's values with hledger tags TAGNAME --values, or match by tag value with a tag:NAMEREGEX=VALUEREGEX query. Directives - A directive is a line in the journal beginning with a special keyword, - that influences how the journal is processed, how things are displayed, - and so on. hledger's directives are based on (a subset of) Ledger's, - but there are many differences, and also some differences between - hledger versions. Here are some more definitions: + Besides transactions, there is something else you can put in a journal + file: directives. These are declarations, beginning with a keyword, + that modify hledger's behaviour. Some directives can have more spe- + cific subdirectives, indented below them. hledger's directives are + similar to Ledger's in many cases, but there are also many differences. + Directives are not required, but can be useful. Here are the main di- + rectives: - o subdirective - Some directives support subdirectives, written - indented below the parent directive. - - o decimal mark - The character to interpret as a decimal mark (period - or comma) when parsing amounts of a commodity. - - o display style - How to display amounts of a commodity in output: sym- - bol side and spacing, digit groups, decimal mark, and number of deci- - mal places. - - Directives are not required when starting out with hledger, but you - will probably want to add some as your needs grow. Here some key - directives for particular needs: - - - purpose directives + purpose directive -------------------------------------------------------------------------- READING DATA: - Declare file's decimal mark to help parse decimal-mark - amounts accurately - Rewrite account names alias - Comment out sections of the data comment - Include extra data files include + + Rewrite account names alias + Comment out sections of the file comment + Declare file's decimal mark, to help decimal-mark + parse amounts accurately + Include other data files include GENERATING DATA: - Generate recurring transactions or budget ~ - goals - Generate extra postings on transactions = + Generate recurring transactions or bud- ~ + get goals + Generate extra postings on existing = + transactions CHECKING FOR ERRORS: - Define valid entities to provide more error account, commodity, payee - checking + Define valid entities to provide more account, commodity, payee, tag + error checking REPORTING: - Declare accounts' type and display order account - Declare commodity display styles commodity - Declare market prices P + Declare accounts' type and display order account + Declare commodity display styles commodity + Declare market prices P + + Directives and multiple files + Directives vary in their scope, ie which journal entries and which in- + put files they affect. Most often, a directive will affect the follow- + ing entries and included files if any, until the end of the current + file - and no further. You might find this inconvenient! For example, + alias directives do not affect parent or sibling files. But there are + usually workarounds; for example, put alias directives in your top-most + file, before including other files. + + The restriction, though it may be annoying at first, is in a good + cause; it allows reports to be stable and deterministic, independent of + the order of input. Without it, reports could show different numbers + depending on the order of -f options, or the positions of include di- + rectives in your files. Directive effects - And here is what each directive does, and which files and journal - entries (transactions) it affects: + Here are all hledger's directives, with their effects and scope sum- + marised - nine main directives, plus four others which we consider non- + essential: - - direc- what it does ends - tive at - file + di- what it does ends + rec- at + tive file end? -------------------------------------------------------------------------------------- - account Declares an account, for checking all entries in all files; and N - its display order and type. Subdirectives: any text, ignored. - alias Rewrites account names, in following entries until end of cur- Y + ac- Declares an account, for checking all entries in all files; and N + count its display order and type. Subdirectives: any text, ignored. + alias Rewrites account names, in following entries until end of cur- Y rent file or end aliases. Command line equivalent: --alias - comment Ignores part of the journal file, until end of current file or Y - end comment. - commod- Declares up to four things: 1. a commodity symbol, for checking N,Y,N,N - ity all amounts in all files 2. the decimal mark for parsing - amounts of this commodity, in the following entries until end of + com- Ignores part of the journal file, until end of current file or Y + ment end comment. + com- Declares up to four things: 1. a commodity symbol, for checking N,Y,N,N + mod- all amounts in all files 2. the decimal mark for parsing + ity amounts of this commodity, in the following entries until end of current file (if there is no decimal-mark directive) 3. and the display style for amounts of this commodity 4. which is also the precision to use for balanced-transaction checking in this @@ -1799,91 +1741,77 @@ Journal mal- ties in following entries until next decimal-mark or end of cur- mark rent file. Included files can override. Takes precedence over commodity and D. - include Includes entries and directives from another file, as if they N - were written inline. Command line alternative: multiple + in- Includes entries and directives from another file, as if they N + clude were written inline. Command line alternative: multiple -f/--file payee Declares a payee name, for checking all entries in all files. N P Declares the market price of a commodity on some date, for value N reports. + + + ~ Declares a periodic transaction rule that generates future N (tilde) transactions with --forecast and budget goals with balance --budget. Other syntax: - - apply Prepends a common parent account to all account names, in fol- Y account lowing entries until end of current file or end apply account. D Sets a default commodity to use for no-symbol amounts;and, if Y,Y,N,N there is no commodity directive for this commodity: its decimal mark, balancing precision, and display style, as above. - Y Sets a default year to use for any yearless dates, in following Y + Y Sets a default year to use for any yearless dates, in following Y entries until end of current file. - = Declares an auto posting rule that generates extra postings on partly - (equals) matched transactions with --auto, in current, parent, and child + = Declares an auto posting rule that generates extra postings on partly + (equals) matched transactions with --auto, in current, parent, and child files (but not sibling files, see #1212). - Other Other directives from Ledger's file format are accepted but - Ledger ignored. + Other Other directives from Ledger's file format are accepted but ig- + Ledger nored. direc- tives - Directives and multiple files - If you use multiple -f/--file options, or the include directive, - hledger will process multiple input files. But directives which affect - input typically have effect only until the end of the file in which - they occur (and on any included files in that region). - - This may seem inconvenient, but it's intentional; it makes reports sta- - ble and deterministic, independent of the order of input. Otherwise - you could see different numbers if you happened to write -f options in - a different order, or if you moved includes around while cleaning up - your files. - - It can be surprising though; for example, it means that alias direc- - tives do not affect parent or sibling files (see below). - account directive account directives can be used to declare accounts (ie, the places that - amounts are transferred from and to). Though not required, these dec- + amounts are transferred from and to). Though not required, these dec- larations can provide several benefits: o They can document your intended chart of accounts, providing a refer- ence. - o In strict mode, they restrict which accounts may be posted to by + o In strict mode, they restrict which accounts may be posted to by transactions, which helps detect typos. - o They control account display order in reports, allowing non-alpha- + o They control account display order in reports, allowing non-alpha- betic sorting (eg Revenues to appear above Expenses). - o They help with account name completion (in hledger add, hledger-web, + o They help with account name completion (in hledger add, hledger-web, hledger-iadd, ledger-mode, etc.) o They can store additional account information as comments, or as tags which can be used to filter or pivot reports. - o They can help hledger know your accounts' types (asset, liability, - equity, revenue, expense), affecting reports like balancesheet and + o They can help hledger know your accounts' types (asset, liability, + equity, revenue, expense), affecting reports like balancesheet and incomestatement. - They are written as the word account followed by a hledger-style - account name, eg: + They are written as the word account followed by a hledger-style ac- + count name, eg: account assets:bank:checking - Note, however, that accounts declared in account directives are not - allowed to have surrounding brackets and parentheses, unlike accounts + Note, however, that accounts declared in account directives are not al- + lowed to have surrounding brackets and parentheses, unlike accounts used in postings. So the following journal will not parse: account (assets:bank:checking) Account comments Text following two or more spaces and ; at the end of an account direc- - tive line, and/or following ; on indented lines immediately below it, - form comments for that account. They are ignored except they may con- + tive line, and/or following ; on indented lines immediately below it, + form comments for that account. They are ignored except they may con- tain tags, which are not ignored. - The two-space requirement for same-line account comments is because ; + The two-space requirement for same-line account comments is because ; is allowed in account names. account assets:bank:checking ; same-line comment, at least 2 spaces before the semicolon @@ -1891,43 +1819,43 @@ Journal ; some tags - type:A, acctnum:12345 Account subdirectives - Ledger-style indented subdirectives are also accepted, but currently + Ledger-style indented subdirectives are also accepted, but currently ignored: account assets:bank:checking format subdirective is ignored Account error checking - By default, accounts need not be declared; they come into existence - when a posting references them. This is convenient, but it means - hledger can't warn you when you mis-spell an account name in the jour- + By default, accounts need not be declared; they come into existence + when a posting references them. This is convenient, but it means + hledger can't warn you when you mis-spell an account name in the jour- nal. Usually you'll find that error later, as an extra account in bal- ance reports, or an incorrect balance when reconciling. - In strict mode, enabled with the -s/--strict flag, hledger will report - an error if any transaction uses an account name that has not been - declared by an account directive. Some notes: + In strict mode, enabled with the -s/--strict flag, hledger will report + an error if any transaction uses an account name that has not been de- + clared by an account directive. Some notes: - o The declaration is case-sensitive; transactions must use the correct + o The declaration is case-sensitive; transactions must use the correct account name capitalisation. - o The account directive's scope is "whole file and below" (see direc- + o The account directive's scope is "whole file and below" (see direc- tives). This means it affects all of the current file, and any files - it includes, but not parent or sibling files. The position of - account directives within the file does not matter, though it's usual + it includes, but not parent or sibling files. The position of ac- + count directives within the file does not matter, though it's usual to put them at the top. - o Accounts can only be declared in journal files, but will affect - included files of all types. + o Accounts can only be declared in journal files, but will affect in- + cluded files of all types. - o It's currently not possible to declare "all possible subaccounts" + o It's currently not possible to declare "all possible subaccounts" with a wildcard; every account posted to must be declared. Account display order - The order in which account directives are written influences the order - in which accounts appear in reports, hledger-ui, hledger-web etc. By - default accounts appear in alphabetical order, but if you add these - account directives to the journal file: + The order in which account directives are written influences the order + in which accounts appear in reports, hledger-ui, hledger-web etc. By + default accounts appear in alphabetical order, but if you add these ac- + count directives to the journal file: account assets account liabilities @@ -1955,8 +1883,8 @@ Journal the position of other among the top-level accounts. This means: o you will sometimes declare parent accounts (eg account other above) - that you don't intend to post to, just to customize their display - order + that you don't intend to post to, just to customize their display or- + der o sibling accounts stay together (you couldn't display x:y in between a:b and a:c). @@ -1967,11 +1895,11 @@ Journal 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 - (described below). But generally we recommend you declare types - explicitly, by adding a type: tag to your top-level account directives. - Subaccounts will inherit the type of their parent. The tag's value - should be one of the five main account types: + if you are using common english-language top-level account names (de- + scribed below). But generally we recommend you declare types explic- + itly, by adding a type: tag to your top-level account directives. Sub- + accounts will inherit the type of their parent. The tag's value should + be one of the five main account types: o A or Asset (things you own) @@ -1990,8 +1918,8 @@ 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 - REPORTING).) + o V or Conversion (a subtype of Equity, for conversions (see COST RE- + PORTING).) Here is a typical set of account type declarations: @@ -2023,9 +1951,9 @@ Journal ^(income|revenue)s?(:|$) | Revenue ^expenses?(:|$) | Expense - o If you declare any account types, it's a good idea to declare an - account for all of the account types, because a mixture of declared - and name-inferred types can disrupt certain reports. + 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 Rewriting accounts > Aliases and account types. @@ -2087,18 +2015,18 @@ 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 - replace any occurrence of the old account name with the new one. Sub- - accounts are also affected. Eg: + 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 - expression.) + 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: @@ -2108,13 +2036,13 @@ Journal $ hledger --alias '/REGEX/=REPLACEMENT' ... - Any part of an account name matched by REGEX will be replaced by - REPLACEMENT. REGEX is case-insensitive as usual. + 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 @@ -2124,21 +2052,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: @@ -2162,8 +2090,8 @@ Journal hledger -f a.aliases -f b.journal - account aliases defined in a.aliases will not affect b.journal. - Including the aliases doesn't work either: + account aliases defined in a.aliases will not affect b.journal. In- + cluding the aliases doesn't work either: include a.aliases @@ -2217,8 +2145,8 @@ Journal Aliases and account types If an account with a type declaration (see Declaring accounts > Account - types) is renamed by an alias, normally the account type remains in - effect. + 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 @@ -2241,9 +2169,9 @@ Journal optionally be enforced, providing useful error checking. (Cf Com- modity error checking) - 2. It declares which decimal mark character (period or comma), to - expect when parsing input - useful to disambiguate international - number formats in your data. Without this, hledger will parse both + 2. It declares which decimal mark character (period or comma), to ex- + pect when parsing input - useful to disambiguate international num- + ber formats in your data. Without this, hledger will parse both 1,000 and 1.000 as 1. (Cf Amounts) 3. It declares how to render the commodity's amounts when displaying @@ -2345,21 +2273,21 @@ Journal The path may contain glob patterns to match multiple files, eg: include *.journal. - There is limited support for recursive wildcards: **/ (the slash is - required) matches 0 or more subdirectories. It's not super convenient + 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 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 hledger.1 -> Input files): - include timedot:~/notes/2020*.md. + ing the file extension (as described in hledger.1 -> Input files): in- + clude timedot:~/notes/2020*.md. P directive - The P directive declares a market price, which is a conversion rate - between 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, cryptocurrency exchange, the or foreign exchange market. + 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 + convert amounts of one commodity to their value in another, on or after + that date. These prices are often obtained from a stock exchange, + cryptocurrency exchange, the or foreign exchange market. The format is: @@ -2367,19 +2295,18 @@ Journal 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. - Examples: + of commodity 2 that one unit of commodity 1 is worth on this date. Ex- + amples: # one euro was worth $1.35 from 2009-01-01 onward: - P 2009-01-01 EUR $1.35 + P 2009-01-01 $1.35 # and $1.40 from 2010-01-01 onward: - P 2010-01-01 EUR $1.40 + P 2010-01-01 $1.40 The -V, -X and --value flags use these market prices to show amount values in another commodity. See Valuation. - payee directive payee PAYEE NAME @@ -2395,8 +2322,8 @@ Journal tag directive tag TAGNAME - This directive can be used to declare a limited set of tag names - allowed in tags. TAGNAME should be a valid tag name (no spaces). Eg: + 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 @@ -2428,8 +2355,8 @@ Journal 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 - improvement, but is worth studying. + 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 @@ -2458,15 +2385,14 @@ Journal expenses:utilities $400 assets:bank:checking - The period expression is the same syntax used for specifying multi- - period reports, just interpreted differently; there, it specifies - report periods; here it specifies recurrence dates (the periods' start - dates). + 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 - results 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 @@ -2475,11 +2401,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: @@ -2493,29 +2419,23 @@ 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 - expression. - - 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 - help you decide if you want to use them. + o Don't accidentally write two spaces in the middle of your period ex- + pression. Auto postings - The = directive declares a rule for automatically adding temporary - extra postings (visible in reports, not in the journal file) to all - transactions matched by a certain query, when you use the --auto flag. + The = directive declares a rule for generating temporary extra postings + on transactions. Wherever the rule matches an existing posting, it can + add one or more companion postings below that one, optionally influ- + enced by the matched posting's amount. This can be useful for generat- + ing tax postings with a standard percentage, for example. - Downsides: depending on generated data for your reports makes your - financial data less portable, less future-proof, and less trustworthy - in an audit. Also, because the feature is optional, other features - like balance assertions can break depending on whether it is on or off. + Note that depending on generated data is not ideal for financial + records (it's less portable, less future-proof, less auditable by oth- + ers, and less robust, since other features like balance assertions will + depend on using or not using --auto). An auto posting rule looks a bit like a transaction: @@ -2626,6 +2546,20 @@ Journal o _modified: - a hidden tag not appearing in the comment; this transac- 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 + 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 + 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 @@ -2655,20 +2589,20 @@ Journal 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- - ments' forcing of balances can hide errors. These things make your - financial data less portable, less future-proof, and less trustworthy - in an audit. + ments' forcing of balances can hide errors. These things make your fi- + nancial data less portable, less future-proof, and less trustworthy in + an audit. Balance assignments and prices A cost in a balance assignment will cause the calculated amount to have that price attached: 2019/1/1 - (a) = $1 @ EUR2 + (a) = $1 @ 2 $ hledger print --explicit 2019-01-01 - (a) $1 @ EUR2 = $1 @ EUR2 + (a) $1 @ 2 = $1 @ 2 Bracketed posting dates For setting posting dates and secondary posting dates, Ledger's brack- @@ -2684,13 +2618,13 @@ Journal 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 journal. - For compatibility/historical reasons, D also acts like a commodity - directive (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: @@ -2705,23 +2639,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 - directive is required (hledger check commodities ignores D directives). + 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 - commodity and decimal-mark. And it works differently from Ledger's D. + 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: @@ -2741,7 +2675,7 @@ Journal account directives are also affected, and so is any included content. - Account names entered via hledger add or hledger-web are not affected. + Account names entered via hledger add or hledger-web are not affected. Account aliases, if any, are applied after the parent account is prepended. @@ -2801,9 +2735,9 @@ Journal Star comments Lines beginning with * (star/asterisk) are also comment lines. This - feature allows Emacs users to insert org headings in their journal, - allowing them to fold/unfold/navigate it like an outline when viewed - with org mode. + 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 @@ -2842,8 +2776,8 @@ Journal (something:else) $5 ; <- this is not required to balance 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. + are called real postings. You can exclude virtual postings from re- + ports with the -R/--real flag or a real:1 query. Downsides: violates double entry bookkeeping, can be used to avoid fig- uring out correct entries, makes your financial data less portable and @@ -2875,7 +2809,6 @@ Journal See also https://hledger.org/ledger.html for a detailed hledger/Ledger syntax comparison. - CSV hledger can read CSV files (Character Separated Value - usually comma, semicolon, or tab) containing dated records, automatically converting @@ -2890,8 +2823,8 @@ CSV 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 - attributes. + and how to categorise transactions based on description or other at- + tributes. By default hledger looks for a rules file named like the CSV file with an extra .rules extension, in the same directory. Eg when asked to @@ -2925,10 +2858,10 @@ CSV The following kinds of rule can appear in the rules file, in any order. (Blank lines and lines beginning with # or ; or * are ignored.) - - separator declare the field separator, instead of rely- + source optionally declare which file to read data + from + 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 date- @@ -2939,26 +2872,50 @@ CSV opposite order to the overall file decimal-mark declare the decimal mark used in CSV amounts, when ambiguous - fields list name CSV fields for easy reference, and - optionally assign their values to hledger - fields - Field assignment assign a CSV value or interpolated text value + 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 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 asser- - tions/assignments to generate + 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 + (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 + 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 + in your system's downloads directory (~/Downloads, currently): + + source Checking1.csv + + And if you specify a glob pattern, hledger will read the most recent of + the matched files (useful with repeated downloads): + + source Checking1*.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 , @@ -2971,32 +2928,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. (Empty/blank lines are skipped automatically, so you don't need - to count those.) You'll need this whenever your CSV data contains - header lines. Header lines skipped in this way are ignored, and not - parsed as CSV. + 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 can also be used inside if blocks (described below), to skip indi- - vidual data records. Note records skipped in this way are still - required to be valid CSV, even though otherwise ignored. + 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 @@ -3016,33 +2973,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 intra-day transactions. Usually it can - auto-detect how the CSV records are ordered. But if it encounters CSV + chronologically, including intra-day transactions. Usually it can + 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... @@ -3056,8 +3013,8 @@ CSV newest-first intra-day-reversed - CSV records for each day are sometimes ordered in reverse compared to - the overall date order. Eg, here dates are newest first, but the + CSV records for each day are sometimes ordered in reverse compared to + the overall date order. Eg, here dates are newest first, but the transactions on each date are oldest first: 2022-10-02, txn 3... @@ -3065,7 +3022,7 @@ CSV 2022-10-01, txn 1... 2022-10-01, txn 2... - In this situation, add the intra-day-reversed rule, and hledger will + In this situation, add the intra-day-reversed rule, and hledger will compensate, improving the order of transactions. # transactions within each day are reversed with respect to the overall date order @@ -3078,10 +3035,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 @@ -3090,17 +3047,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 @@ -3110,35 +3067,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 - replaced by underscores). + 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 by their 1-based position in the CSV - record (%N), or by the name they were given in the fields list (%CSV- + 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 by their 1-based position in the CSV + record (%N), or by the name they were given in the fields list (%CSV- FIELD). Some examples: @@ -3151,27 +3108,27 @@ CSV Tips: - o Interpolation strips outer whitespace (so a CSV value like " 1 " - becomes 1 when interpolated) (#1051). + 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 - assignment, eg: + 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 code %Some_Id @@ -3185,7 +3142,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 @@ -3208,7 +3165,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. @@ -3217,88 +3174,115 @@ 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 "amount" field name variants, useful for different - situations: + Amount setting can get a bit complex. Assigning to amount is suffi- + cient for simple transactions, but there are four field name variants + you can use for different situations: - o amountN sets the amount of the Nth posting, and causes that posting - to be generated. By assigning to amount1, amount2, ... etc. you - can generate up to 99 postings. Posting numbers don't have to be - consecutive; in certain situations using a high number might be help- - ful to influence the layout of postings. + o amountN sets a specific posting's amount from one CSV field or arbi- + trary value. + Assigning to amountN sets the amount of the Nth posting - and also + causes that posting to be generated. N is most often 1 or 2 but can go + up to 99, potentially generating a 99-posting transaction. (Posting + numbers don't have to be consecutive; higher posting numbers can some- + times be useful with conditional rules, to ensure a certain ordering of + postings.) - o amountN-in and amountN-out should be used instead, as a pair, when - and only when the amount must be obtained from two CSV fields. Eg - when the CSV has separate Debit and Credit fields instead of a single - Amount field. Note: + o amountN-in/-out sets a specific posting's amount from two CSV fields. + When the amount is provided as two CSV fields - "Debit"/"Credit", "De- + posit"/"Withdrawal", "Money In"/"Money Out" or similar - assign those + fields to amountN-in and amountN-out respectively (or possibly the + other way round, depending on signs). This will set the Nth posting's + amount to whichever of the two CSV field values is non-zero. Some + notes: - o Don't think "-in is for the first posting and -out is for the sec- - ond posting" - that's not correct. Think: "amountN-in and amountN- - out together detect the amount for posting N, by inspecting two CSV - fields at once." + o Don't mix amountN and amountN-in/-out. When you have one CSV + amount field, use amountN. When you have two CSV amount fields, + use amountN-in/amountN-out. - o hledger assumes both CSV fields are unsigned, and will automati- - cally negate the -out value. + o amountN-in and amountN-out are always used together, as a pair. + Assign to both of them. - o It also expects that at least one of the values is empty or zero, - so it knows which one to ignore. If that's not the case you'll - need an if rule (see Setting amounts below). + o They do not generate two separate postings; rather, they generate + the Nth posting's single amount, from the value found in one or + other of the two CSV fields. - o amount, with no posting number (and similarly, amount-in and amount- - out with no number) are an older syntax. We keep them for backwards - compatibility, and because they have special behaviour that is some- - times convenient: + o In each record, at least one of the two CSV fields must contain a + zero amount or be empty. - o They set the amount of posting 1 and (negated) the amount of post- - ing 2. + o hledger assumes the two CSV fields contain unsigned numbers, and it + will automatically negate the -out amount. - o Posting 2's amount will be converted to cost if it has a cost - price. + o This variant can be convenient, but it doesn't handle every two- + amount-field situation; if you need more flexibility, use an if + rule (see "Setting amounts" below). - o Any of the newer rules for posting 1 or 2 (like amount1, or - amount2-in and amount2-out) will take precedence. This allows - incrementally migrating old rules files to the new syntax. + The other two variants are older and considered legacy syntax, but can + still be convenient sometimes: - There's more to say about amount-setting that doesn't fit here; please - see also "Setting amounts" below. + o amount sets posting 1 and 2's amounts from one CSV field or value. + Assigning to amount, with no posting number, + + o sets posting 1's amount (like amount1) + + o sets posting 2's amount to the same amount but with opposite sign; + and also converts it to cost if it has a cost price + + o can be overridden by amount1 and/or amount2 assignments. (This + helps with incremental migration of old rules files to the newer + syntax.) + + o amount-in/-out sets posting 1 and 2's amounts from two CSV fields. + Assigning amount-in and amount-out, with no posting numbers, to two CSV + fields reads whichever of the two values is non-zero as the amount, and + then sets the first two posting amounts as above. + + We recommend using only one of these variants within a rules file, + rather than mixing them. And remember that a fields list can also do + assignments, so eg naming a CSV field "amount" counts as an assignment + to amount; if you don't want that, call it something else, like + "amount_". + + In addition to this section, please see also the tips beginning at + "Working with CSV > Setting amounts" below. 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 symbol, eg if it is in a separate column. - currencyN prepends a currency symbol to just the Nth posting's amount. + 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 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, @@ -3314,11 +3298,11 @@ CSV RULE RULE - If any of the matchers succeeds, all of the indented rules will be - applied. 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. @@ -3344,26 +3328,26 @@ 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). 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: 2020-01-01; "Acme, Inc."; 1,000 @@ -3376,14 +3360,14 @@ CSV o By default they are OR'd (any one of them can match) - o When a matcher is preceded by ampersand (&) it will be AND'ed with + o When a matcher is preceded by ampersand (&) it will be AND'ed with the previous matcher (both of them must match). There's not yet an easy syntax to negate a matcher. 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,... @@ -3392,17 +3376,17 @@ CSV MATCHERC,VALUE1,VALUE2,... - The first character after if is taken to be the separator for the rest - of the table. It should be a non-alphanumeric character like , or | - that does not appear anywhere else in the table. (Note: it is unre- - lated to the CSV file's separator.) Whitespace can be used in the - matcher lines for readability, but not in the if line currently. The - table must be terminated by an empty line (or end of file). Each line + The first character after if is taken to be the separator for the rest + of the table. It should be a non-alphanumeric character like , or | + that does not appear anywhere else in the table. (Note: it is unre- + lated to the CSV file's separator.) Whitespace can be used in the + matcher lines for readability, but not in the if line currently. The + table must be terminated by an empty line (or end of file). Each line must contain the same number of separators; empty values are allowed. - The above means: try all of the matchers; whenever a matcher succeeds, - assign all of the values on that line to the corresponding hledger - fields; later lines can overrider earlier ones. It is equivalent to + The above means: try all of the matchers; whenever a matcher succeeds, + assign all of the values on that line to the corresponding hledger + fields; later lines can overrider earlier ones. It is equivalent to this sequence of if blocks: if MATCHERA @@ -3429,10 +3413,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 @@ -3448,9 +3432,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 @@ -3467,7 +3451,7 @@ 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' @@ -3522,6 +3506,31 @@ CSV file. But if you use the --rules-file option, that rules file will be used for all the CSV files. + Reading files specified by rule + Instead of specifying a CSV file in the command line, you can specify a + rules file, as in hledger -f foo.csv.rules CMD. By default this will + read data from foo.csv in the same directory, but you can add a source + rule to specify a different data file, perhaps located in your web + 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 + 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, + and then periodically follow a workflow like: + + 1. Download CSV from Foo's website, using your browser's defaults + + 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 + 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, @@ -3531,8 +3540,8 @@ CSV 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 - assertions generated from CSV right away, pipe into another hledger: + 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 @@ -3567,7 +3576,6 @@ CSV ious amount-setting situations: 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- ally 1 or 2 but can go up to 99. @@ -3582,7 +3590,6 @@ CSV amount1 %Amount 2. If the amount is in one of two CSV fields (eg Debit and Credit): - a. If both fields are unsigned: Assign the fields to amountN-in and amountN-out. This sets posting N's amount to whichever of these has a non-zero value. If it's the @@ -3623,8 +3630,9 @@ CSV set that explicitly. Amount signs - There is some special handling for amount signs, to simplify parsing - and sign-flipping: + There is some special handling making it easier to parse and to reverse + amount signs. (This only works for whole amounts, not for cost amounts + such as COST in amount1 AMT @ COST): o If an amount value begins with a plus sign: that will be removed: +AMT becomes AMT @@ -3632,15 +3640,18 @@ 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 + its absolute value, ie discard its sign. + Setting currency/commodity If the currency/commodity symbol is included in the CSV's amount field(s): @@ -3732,8 +3743,8 @@ CSV (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 - repeated, the last one wins: + Then "global" rules are evaluated, top to bottom. If a rule is re- + peated, the last one wins: o skip (at top level) @@ -3746,8 +3757,8 @@ CSV Then for each CSV record in turn: - o test all if blocks. If any of them contain a end rule, skip all - remaining CSV records. Otherwise if any of them contain a skip rule, + 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. @@ -3755,24 +3766,22 @@ CSV 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 - assigned to it (and interpolate the %CSVFIELD references), or a - default + 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- - mon.rules, and adding include common.rules to each CSV's rules file. + 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 used parts. @@ -4061,9 +4070,9 @@ Timeclock the time is always interpreted as a local time). Lines beginning with # or ; or *, and blank lines, are ignored. - i 2015/03/30 09:00:00 some:account name optional description after two spaces + i 2015/03/30 09:00:00 some account optional description after 2 spaces ; optional comment, tags: o 2015/03/30 09:20:00 - i 2015/03/31 22:21:45 another account + 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 @@ -4072,14 +4081,14 @@ Timeclock the above time log, hledger print generates these journal entries: $ hledger -f t.timeclock print - 2015-03-30 * optional description after two spaces - (some:account name) 0.33h + 2015-03-30 * optional description after 2 spaces ; optional comment, tags: + (some account) 0.33h 2015-03-31 * 22:21-23:59 - (another account) 1.64h + (another:account) 1.64h 2015-04-01 * 00:00-02:00 - (another account) 2.01h + (another:account) 2.01h Here is a sample.timeclock to download and some queries to try: @@ -4100,7 +4109,6 @@ Timeclock 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 @@ -4112,76 +4120,71 @@ Timedot A timedot file contains a series of day entries, which might look like this: - 2021-08-04 - hom:errands .... .... - fos:hledger:timedot .. ; docs + 2023-05-01 + hom:errands .... .... ; two hours + fos:hledger:timedot .. ; half an hour per:admin:finance - hledger reads this as three time transactions on this day, with each - dot representing a quarter-hour spent: + hledger reads this as a transaction on this day with three (unbalanced) + postings, where each dot represents "0.25". No commodity is assumed, + but normally we interpret it as hours, with each dot representing a + quarter-hour. It's convenient, though not required, to group the dots + in fours for easy reading. - $ hledger -f a.timedot print # .timedot file extension activates the timedot reader - 2021-08-04 * - (hom:errands) 2.00 + $ hledger -f a.timedot print # .timedot file extension (or timedot: prefix) is required + 2023-05-01 * + (hom:errands) 2.00 ; two hours + (fos:hledger:timedot) 0.50 ; half an hour + (per:admin:finance) 0 - 2021-08-04 * - (fos:hledger:timedot) 0.50 + A transaction begins with a non-indented simple date (Y-M-D, Y/M/D, or + Y.M.D). It can optionally be preceded by one or more stars and a + space, for Emacs org mode compatibility. It can optionally be followed + on the same line by a transaction description, and/or a transaction + comment following a semicolon. - 2021-08-04 * - (per:admin:finance) 0 + After the date line are zero or more time postings, consisting of: - A day entry begins with a date line: - - o a non-indented simple date (Y-M-D, Y/M/D, or Y.M.D). - - Optionally this can be followed on the same line by - - o a common transaction description for this day - - o a common transaction comment for this day, after a semicolon (;). - - After the date line are zero or more optionally-indented time transac- - tion lines, consisting of: - - o an account name - any word or phrase, usually a hledger-style account - name. + o an account name - any hledger-style account name, optionally hierar- + chical, optionally indented. o two or more spaces - a field separator, required if there is an amount (as in journal format). - o a timedot amount - dots representing quarter hours, or a number rep- - resenting hours. + o an optional timedot amount - dots representing quarter hours, or a + number representing hours, optionally with a unit suffix. - o an optional comment beginning with semicolon. This is ignored. + o an optional posting comment following a semicolon. - In more detail, timedot amounts can be: + Timedot amounts can be: - o dots: zero or more period characters, each representing one quarter- - hour. Spaces are ignored and can be used for grouping. Eg: .... .. + o dots: zero or more period characters (.), each representing 0.25. + Spaces are ignored and can be used for grouping. Eg: .... .. - o a number, representing hours. Eg: 1.5 + o or a number. Eg: 1.5 - o a number immediately followed by a unit symbol s, m, h, d, w, mo, or - y, representing seconds, minutes, hours, days weeks, months or years. - Eg 1.5h or 90m. The following equivalencies are assumed: - 60s = 1m, 60m = 1h, 24h = 1d, 7d = 1w, 30d = 1mo, 365d = 1y. (This - unit will not be visible in the generated transaction amount, which is - always in hours.) + o or a number immediately followed by a unit symbol s, m, h, d, w, mo, + or y. These are interpreted as seconds, minutes, hours, days weeks, + months or years, and converted to hours, assuming: + 60s = 1m, 60m = 1h, 24h = 1d, 7d = 1w, 30d = 1mo, 365d = 1y. Eg 90m is + parsed as 1.5. There is some added flexibility to help with keeping time log data in the same file as your notes, todo lists, etc.: o Blank lines and lines beginning with # or ; are ignored. - o Before the first date line, lines beginning with * are ignored. From - the first date line onward, a sequence of *'s followed by a space at - beginning of lines (ie, the headline prefix used by Emacs Org mode) - is ignored. This means the time log can be kept under an Org head- - line, and date lines or time transaction lines can be Org headlines. + o Before the first date line, lines beginning with * are ignored. - o Lines not ending with a double-space and amount are parsed as trans- - actions with zero amount. (Most hledger reports hide these by - default; add -E to see them.) + o From the first date line onward, one or more *'s followed by a space + at beginning of lines (ie, the headline prefix used by Emacs Org + mode) is ignored. This means the time log can be kept under an Org + headline, and date lines or time transaction lines can be Org head- + lines. + + o Lines not ending with a double-space and amount are parsed as post- + ings with zero amount. Note hledger's register reports hide these by + default (add -E to see them). More examples: @@ -4264,63 +4267,62 @@ PART 3: REPORTING CONCEPTS Time periods Report start & end date By default, most hledger reports will show the full span of time repre- - sented by the journal. The report start date will be the earliest + sented by the journal. The report start date will be the earliest transaction or posting date, and the report end date will be the latest transaction, posting, or market price date. - Often you will want to see a shorter time span, such as the current - month. You can specify a start and/or end date using -b/--begin, + Often you will want to see a shorter time span, such as the current + month. You can specify a start and/or end date using -b/--begin, -e/--end, -p/--period or a date: query (described below). All of these accept the smart date syntax (below). Some notes: - o End dates are exclusive, as in Ledger, so you should write the date + o End dates are exclusive, as in Ledger, so you should write the date after the last day you want to see in the report. - o As noted in reporting options: among start/end dates specified with + o As noted in reporting options: among start/end dates specified with options, the last (i.e. right-most) option takes precedence. - o The effective report start and end dates are the intersection of the - start/end dates from options and that from date: queries. That is, - date:2019-01 date:2019 -p'2000 to 2030' yields January 2019, the + o The effective report start and end dates are the intersection of the + start/end dates from options and that from date: queries. That is, + date:2019-01 date:2019 -p'2000 to 2030' yields January 2019, the smallest common time span. - o In some cases a report interval will adjust start/end dates to fall + o In some cases a report interval will adjust start/end dates to fall on interval boundaries (see below). Examples: - -b 2016/3/17 begin on St. Patrick's day 2016 -e 12/1 end at the start of december 1st of the current year (11/30 will be the last date included) -b thismonth all transactions on or after the 1st of the current month -p thismonth all transactions in the current month - date:2016/3/17.. the above written as queries instead (.. can also be - replaced with -) + date:2016/3/17.. the above written as queries instead (.. can also be re- + placed with -) date:..12/1 date:thismonth.. date:thismonth Smart dates hledger's user interfaces accept a "smart date" syntax for added conve- - nience. Smart dates optionally can be relative to today's date, be - written with english words, and have less-significant parts omitted + nience. Smart dates optionally can be relative to today's date, be + written with english words, and have less-significant parts omitted (missing parts are inferred as 1). Some examples: - - 2004/10/1, 2004-01-01, exact date, several separators allowed. Year + 2004/10/1, 2004-01-01, exact date, several separators allowed. Year 2004.9.1 is 4+ digits, month is 1-12, day is 1-31 2004 start of year 2004/10 start of month 10/1 month and day in current year 21 day in current month october, oct start of month in current year - - yesterday, today, tomor- -1, 0, 1 days from today row + + + last/this/next -1, 0, 1 periods from the current period day/week/month/quar- ter/year @@ -4339,7 +4341,6 @@ Time periods Some counterexamples - malformed digit sequences might give surprising results: - 201813 6 digits with an invalid month is parsed as start of 6-digit year 20181301 8 digits with an invalid month is parsed as start of @@ -4393,28 +4394,25 @@ Time periods Period expressions 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. + 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; + Several keywords like "from" and "to" are supported for readability; these are optional. "to" can also be written as ".." or "-". The spa- ces 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" -p "jan-apr" -p "this year to 4/1" @@ -4422,18 +4420,16 @@ Time periods If you specify only one date, the missing start or end date will be the earliest or latest transaction date in the journal: - -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 2009/2/1" @@ -4442,7 +4438,6 @@ Time periods or by using the "Q" quarter-year syntax (case insensitive): - -p "2009Q1" first quarter of 2009, equivalent to "2009/1/1 to 2009/4/1" -p "q4" fourth quarter of the current year @@ -4451,7 +4446,6 @@ Time periods 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" -p "monthly in 2008" -p "quarterly" @@ -4495,7 +4489,6 @@ Time periods Examples: - -p "bimonthly from 2008" -p "every 2 weeks" -p "every 5 months from @@ -4537,17 +4530,16 @@ Time periods Examples: - -p "every dates will be Mon, Wed, Fri; periods will be Mon- mon,wed,fri" 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 - accounts only to the specified depth, hiding deeper subaccounts. Use + 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. @@ -4557,8 +4549,8 @@ Queries subset of your data. Most hledger commands accept optional query argu- ments to restrict their scope. The syntax is as follows: - o Zero or more space-separated query terms. These are most often - account name substrings: + o Zero or more space-separated query terms. These are most often ac- + count name substrings: utilities food:groceries @@ -4604,8 +4596,8 @@ Queries rency/commodity symbol is fully matched by REGEX. (For a partial match, use .*REGEX.*). Note, to match special characters which are regex-significant, you need to escape them with \. And for characters - which are significant to your shell you may need one more level of - escaping. So eg to match the dollar sign: + 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:\\$. desc:REGEX @@ -4613,16 +4605,16 @@ Queries date:PERIODEXPR Match dates (or with the --date2 flag, secondary dates) within the - specified period. PERIODEXPR is a period expression with no report - interval. Examples: + 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. note:REGEX @@ -4630,7 +4622,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 @@ -4640,11 +4632,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] @@ -4714,26 +4706,26 @@ Queries query is their intersection. Queries and valuation - When amounts are converted to other commodities in cost or value - reports, cur: and amt: match the old commodity symbol and the old - amount quantity, not the new ones (except in hledger 1.22.0 where it's - reversed, see #1625). + 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.0 where it's re- + versed, see #1625). Querying with account aliases When account names are rewritten with --alias or alias, note that acct: will match either the old or the new account name. Querying with cost or value - When amounts are converted to other commodities in cost or value - reports, note that cur: matches the new commodity symbol, and not the - old one, and amt: matches the new quantity, and not the old one. Note: + When amounts are converted to other commodities in cost or value re- + ports, note that cur: matches the new commodity symbol, and not the old + one, and amt: matches the new quantity, and not the old one. Note: this changed in hledger 1.22, previously it was the reverse, see the discussion at #1625. Pivoting Normally, hledger groups and sums amounts within each account. The - --pivot FIELD option substitutes some other transaction field for - account names, causing amounts to be grouped and summed by that field's + --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 status, code, description, 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 @@ -4778,84 +4770,201 @@ Pivoting -2 EUR Generating data - Two features for generating transient data (visible only at report - time) are built in to hledger's journal format: + hledger has several features for generating data, such as: - o Auto posting rules can generate extra postings on certain transac- - tions. They are activated by the --auto flag. + o Periodic transaction rules can generate single or repeating transac- + tions following a template. These are usually dated in the future, + eg to help with forecasting. They are activated by the --forecast + option. - o Periodic transaction rules can generate repeating transactions, usu- - ally dated in the future, to help with forecasting or budgeting. - They are activated by the --forecast or balance --budget options, - described next. + o The balance command's --budget option uses these same periodic rules + to generate goals for the budget report. + + o Auto posting rules can generate extra postings on certain matched + transactions. They are always applied to forecast transactions; with + the --auto flag they are applied to transactions recorded in the + journal as well. + + o The --infer-equity flag infers missing conversion equity postings + from @/@@ costs. And the inverse --infer-costs flag infers missing + @/@@ costs from conversion equity postings. + + Generated data of this kind is temporary, existing only at report time. + But you can see it in the output of hledger print, and you can save + that to your journal, in effect converting it from temporary generated + data to permanent recorded data. This could be useful as a data entry + aid. + + If you are wondering what data is being generated and why, add the + --verbose-tags flag. In hledger print output you will see extra tags + like generated-transaction, generated-posting, and modified on gener- + ated/modified data. Also, even without --verbose-tags, generated data + always has equivalen hidden tags (with an underscore prefix), so eg you + could match generated transactions with tag:_generated-transaction. Forecasting - The --forecast flag activates any periodic transaction rules in the - journal. These will generate temporary additional transactions, usu- - ally recurring and in the future, which will appear in all reports. - hledger print --forecast is a good way to see them. + Forecasting, or speculative future reporting, can be useful for esti- + mating future balances, or for exploring different future scenarios. - This can be useful for estimating balances into the future, perhaps - experimenting with different 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 + see them. - It could also be useful for scripted data entry: you could describe - recurring transactions, and every so often copy the output of print - --forecast into the journal. + --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 + change many forecasted transactions. (These same rules can also gener- + ate budget goals, described in Budgeting.) - The generated transactions will have an extra tag, like generated- - transaction:~ PERIODICEXPR, indicating which periodic rule generated - them. There is also a similar, hidden tag, named _generated-transac- - tion:, which you can use to reliably match transactions generated "just - now" (rather than printed in the past). + 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 + exact rules are a little more complicated, and are given below.) - The forecast transactions are generated within a forecast period, which - is independent of the report period. (Forecast period sets the bounds - for generated transactions, report period controls which transactions - are reported.) The forecast period begins on: + 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, + 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- + quired. - o the start date provided within --forecast's argument, if any + Inspecting forecast transactions + print is the best command for inspecting and troubleshooting forecast + transactions. Eg: - o otherwise, the later of + ~ monthly from 2022-12-20 rent + assets:bank:checking + expenses:rent $1000 - o the report start date, if specified (with -b/-p/date:) + $ hledger print --forecast --today=2023/4/21 + 2023-05-20 rent + ; generated-transaction: ~ monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 - o the day after the latest ordinary transaction in the journal, if - any + 2023-06-20 rent + ; generated-transaction: ~ monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 - o otherwise today. + 2023-07-20 rent + ; generated-transaction: ~ monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 - It ends on: + 2023-08-20 rent + ; generated-transaction: ~ monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 - o the end date provided within --forecast's argument, if any + 2023-09-20 rent + ; generated-transaction: ~ monthly from 2022-12-20 + assets:bank:checking + expenses:rent $1000 - o otherwise, the report end date, if specified (with -e/-p/date:) + Here there are no ordinary transactions, so the forecasted transactions + begin on the first occurence after today's date. (You won't normally + use --today; it's just to make these examples reproducible.) - o otherwise 180 days (6 months) from today. + Forecast reports + Forecast transactions affect all reports, as you would expect. Eg: - Note, this means that ordinary transactions will suppress periodic - transactions, by default; the periodic transactions will not start - until after the last ordinary transaction. This is usually convenient, - but you can get around it in two ways: + $ hledger areg rent --forecast --today=2023/4/21 + Transactions in expenses:rent and subaccounts: + 2023-05-20 rent as:ba:checking $1000 $1000 + 2023-06-20 rent as:ba:checking $1000 $2000 + 2023-07-20 rent as:ba:checking $1000 $3000 + 2023-08-20 rent as:ba:checking $1000 $4000 + 2023-09-20 rent as:ba:checking $1000 $5000 - o If you need to record some transactions in the future, make them - periodic transactions (with a single occurrence, eg: ~ YYYY-MM-DD) - rather than ordinary transactions. That way they won't suppress - other periodic transactions. + $ hledger bal -M expenses --forecast --today=2023/4/21 + Balance changes in 2023-05-01..2023-09-30: - o Or give --forecast a period expression argument. A forecast period - specified this way can overlap ordinary transactions, and need not be - in the future. Some things to note: + || May Jun Jul Aug Sep + ===============++=================================== + expenses:rent || $1000 $1000 $1000 $1000 $1000 + ---------------++----------------------------------- + || $1000 $1000 $1000 $1000 $1000 - o You must use = between flag and argument; a space won't work. + Forecast tags + 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. - o The period expression can specify the forecast period's start date, - end date, or both. See also Report start & end date. + 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 + responsible. - o The period expression should not specify a report interval. (Each - periodic transaction rule specifies its own interval.) + 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 + (with luck) the exact rules, to help with troubleshooting: - Some examples: --forecast=202001-202004, --forecast=jan-, --fore- - cast=2021. + The forecast period starts on: + + o the later of + + o the start date in the periodic transaction rule + + o the start date in --forecast's argument + + o otherwise (if those are not available): the later of + + o the report start date specified with -b/-p/date: + + o the day after the latest ordinary transaction in the journal + + o otherwise (if none of these are available): today. + + The forecast period ends on: + + o the earlier of + + o the end date in the periodic transaction rule + + o the end date in --forecast's argument + + o otherwise: the report end date specified with -e/-p/date: + + o otherwise: 180 days (~6 months) from today. + + Forecast troubleshooting + When --forecast is not doing what you expect, one of these tips should + help: + + o Remember to use the --forecast option. + + o Remember to have at least one periodic transaction rule in your jour- + nal. + + o Test with print --forecast. + + 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- + scription fields. + + 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 + transactions. + + o Try setting explicit forecast start and/or end dates with --fore- + cast=START..END + + o Consult Forecast period, in detail, above. + + o Check inside the engine: add --debug=2 (eg). Budgeting With the balance command's --budget report, each periodic transaction @@ -4863,6 +4972,10 @@ Budgeting 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 + bal -M --budget --forecast ... + See also: Budgeting and Forecasting. Cost reporting @@ -4896,11 +5009,11 @@ Cost reporting 2022-01-01 assets:dollars $-135 ; 135 dollars is exchanged for.. - assets:euros EUR100 @ $1.35 ; one hundred euros purchased at $1.35 each + assets:euros 100 @ $1.35 ; one hundred euros purchased at $1.35 each $ hledger bal -N $-135 assets:dollars - EUR100 assets:euros + 100 assets:euros $ hledger bal -N -B $-135 assets:dollars $135 assets:euros # <- the euros' cost @@ -4908,17 +5021,17 @@ Cost reporting Notes: -B is sensitive to the order of postings when a cost is inferred: the - inferred price will be in the commodity of the last amount. So if - example 3's postings are reversed, while the transaction is equivalent, + inferred price will be in the commodity of the last amount. So if ex- + ample 3's postings are reversed, while the transaction is equivalent, -B shows something different: 2022-01-01 assets:dollars $-135 ; 135 dollars sold - assets:euros EUR100 ; for 100 euros + assets:euros 100 ; for 100 euros $ hledger bal -N -B - EUR-100 assets:dollars # <- the dollars' selling price - EUR100 assets:euros + -100 assets:dollars # <- the dollars' selling price + 100 assets:euros The @/@@ cost notation is convenient, but has some drawbacks: it does not truly balance the transaction, so it disrupts the accounting equa- @@ -4932,8 +5045,8 @@ Cost reporting 2022-01-01 one hundred euros purchased at $1.35 each assets:dollars $-135 equity:conversion $135 - equity:conversion EUR-100 - assets:euros EUR100 + equity:conversion -100 + assets:euros 100 This style is more correct, but it's also more verbose and makes cost reporting more difficult for PTA tools. @@ -4952,49 +5065,49 @@ Cost reporting 2022-01-01 assets:dollars -$135 - assets:euros EUR100 @ $1.35 + assets:euros 100 @ $1.35 $ hledger print --infer-equity 2022-01-01 assets:dollars $-135 - assets:euros EUR100 @ $1.35 - equity:conversion:$-EUR:EUR EUR-100 ; generated-posting: - equity:conversion:$-EUR:$ $135.00 ; generated-posting: + assets:euros 100 @ $1.35 + equity:conversion:$-: -100 ; generated-posting: + equity:conversion:$-:$ $135.00 ; generated-posting: The conversion account names can be changed with the conversion account type declaration. - --infer-equity is useful when when transactions have been recorded - using cost notation, to help preserve the accounting equation and bal- - ance reports' zero total, or to produce more conventional journal - entries for sharing with non-PTA-users. + --infer-equity is useful when when transactions have been recorded us- + ing cost notation, to help preserve the accounting equation and balance + reports' zero total, or to produce more conventional journal entries + for sharing with non-PTA-users. Inferring cost from equity postings The reverse operation is possible using --infer-costs, which detects - transactions written with equity conversion postings and adds cost - notation to them: + transactions written with equity conversion postings and adds cost no- + tation to them: 2022-01-01 assets:dollars $-135 equity:conversion $135 - equity:conversion EUR-100 - assets:euros EUR100 + equity:conversion -100 + assets:euros 100 $ hledger print --infer-costs 2022-01-01 - assets:dollars $-135 @@ EUR100 + assets:dollars $-135 @@ 100 equity:conversion $135 - equity:conversion EUR-100 - assets:euros EUR100 + equity:conversion -100 + assets:euros 100 - --infer-costs is useful when combined with -B/--cost, allowing cost - reporting even when transactions have been recorded using equity post- + --infer-costs is useful when combined with -B/--cost, allowing cost re- + porting even when transactions have been recorded using equity post- ings: $ hledger print --infer-costs -B 2009-01-01 - assets:dollars EUR-100 - assets:euros EUR100 + assets:dollars -100 + assets:euros 100 Notes: @@ -5039,8 +5152,8 @@ Cost reporting Conversion with implicit cost Let's assume 100 EUR is converted to 120 USD. You can just record the - outflow (100 EUR) and inflow (120 USD) in the appropriate asset - account: + outflow (100 EUR) and inflow (120 USD) in the appropriate asset ac- + count: 2021-01-01 assets:cash -100 EUR @@ -5095,8 +5208,8 @@ Cost reporting Conversion with equity postings In strict double entry bookkeeping, the above transaction is not bal- - anced in EUR or in USD, since some EUR disappears, and some USD - appears. This violates the accounting equation (A+L+E=0), and prevents + anced in EUR or in USD, since some EUR disappears, and some USD ap- + pears. This violates the accounting equation (A+L+E=0), and prevents reports like balancesheetequity from showing a zero total. The proper way to make it balance is to add a balancing posting for @@ -5174,8 +5287,8 @@ Valuation Instead of reporting amounts in their original commodity, hledger can convert them to cost/sale amount (using the conversion rate recorded in the transaction), and/or to market value (using some market price on a - certain date). This is controlled by the --value=TYPE[,COMMODITY] - option, which will be described below. We also provide the simpler -V + certain date). This is controlled by the --value=TYPE[,COMMODITY] op- + tion, which will be described below. We also provide the simpler -V and -X COMMODITY options, and often one of these is all you need: -V: Value @@ -5207,41 +5320,41 @@ Valuation 1. A declared market price or inferred market price: A's latest market price in B on or before the valuation date as declared by a P direc- - tive, or (with the --infer-market-prices flag) inferred from costs. + tive, or (with the --infer-market-prices flag) inferred from costs. 2. A reverse market price: the inverse of a declared or inferred market price from B to A. - 3. A forward chain of market prices: a synthetic price formed by com- + 3. A forward chain of market prices: a synthetic price formed by com- bining the shortest chain of "forward" (only 1 above) market prices, leading from A to B. - 4. Any chain of market prices: a chain of any market prices, including - both forward and reverse prices (1 and 2 above), leading from A to + 4. Any chain of market prices: a chain of any market prices, including + both forward and reverse prices (1 and 2 above), leading from A to B. - There is a limit to the length of these price chains; if hledger - reaches that length without finding a complete chain or exhausting all - possibilities, it will give up (with a "gave up" message visible in + There is a limit to the length of these price chains; if hledger + reaches that length without finding a complete chain or exhausting all + possibilities, it will give up (with a "gave up" message visible in --debug=2 output). That limit is currently 1000. - Amounts for which no suitable market price can be found, are not con- + Amounts for which no suitable market price can be found, are not con- verted. --infer-market-prices: market prices from transactions Normally, market value in hledger is fully controlled by, and requires, P directives in your journal. Since adding and updating those can be a - chore, and since transactions usually take place at close to market - value, why not use the recorded costs as additional market prices (as - Ledger does) ? Adding the --infer-market-prices flag to -V, -X or + chore, and since transactions usually take place at close to market + value, why not use the recorded costs as additional market prices (as + Ledger does) ? Adding the --infer-market-prices flag to -V, -X or --value enables this. - So for example, hledger bs -V --infer-market-prices will get market - prices both from P directives and from transactions. If both occur on + So for example, hledger bs -V --infer-market-prices will get market + prices both from P directives and from transactions. If both occur on the same day, the P directive takes precedence. There is a downside: value reports can sometimes be affected in confus- - ing/undesired ways by your journal entries. If this happens to you, + ing/undesired ways by your journal entries. If this happens to you, read all of this Valuation section carefully, and try adding --debug or --debug=2 to troubleshoot. @@ -5249,15 +5362,15 @@ Valuation o multicommodity transactions with explicit prices (@/@@) - o multicommodity transactions with implicit prices (no @, two commodi- - ties, unbalanced). (With these, the order of postings matters. + o multicommodity transactions with implicit prices (no @, two commodi- + ties, unbalanced). (With these, the order of postings matters. hledger print -x can be useful for troubleshooting.) o multicommodity transactions with equity postings, if cost is inferred with --infer-costs. - There is a limitation (bug) currently: when a valuation commodity is - not specified, prices inferred with --infer-market-prices do not help + There is a limitation (bug) currently: when a valuation commodity is + not specified, prices inferred with --infer-market-prices do not help select a default valuation commodity, as P prices would. So conversion might not happen because no valuation commodity was detected (--debug=2 will show this). To be safe, specify the valuation commmodity, eg: @@ -5267,8 +5380,8 @@ Valuation o --value=then,EUR --infer-market-prices, not --value=then --infer-mar- ket-prices - Signed costs and market prices can be confusing. For reference, here - is the current behaviour, since hledger 1.25. (If you think it should + Signed costs and market prices can be confusing. For reference, here + is the current behaviour, since hledger 1.25. (If you think it should work differently, see #1870.) 2022-01-01 Positive Unit prices @@ -5298,7 +5411,7 @@ Valuation b B -1 @@ A -1 All of the transactions above are considered balanced (and on each day, - the two transactions are considered equivalent). Here are the market + the two transactions are considered equivalent). Here are the market prices inferred for B: $ hledger -f- --infer-market-prices prices @@ -5311,23 +5424,23 @@ Valuation Valuation commodity When you specify a valuation commodity (-X COMM or --value TYPE,COMM): - hledger will convert all amounts to COMM, wherever it can find a suit- + hledger will convert all amounts to COMM, wherever it can find a suit- able market price (including by reversing or chaining prices). - When you leave the valuation commodity unspecified (-V or --value + When you leave the valuation commodity unspecified (-V or --value TYPE): - For each commodity A, hledger picks a default valuation commodity as + For each commodity A, hledger picks a default valuation commodity as follows, in this order of preference: 1. The price commodity from the latest P-declared market price for A on or before valuation date. 2. The price commodity from the latest P-declared market price for A on - any date. (Allows conversion to proceed when there are inferred + any date. (Allows conversion to proceed when there are inferred prices before the valuation date.) - 3. If there are no P directives at all (any commodity or date) and the - --infer-market-prices flag is used: the price commodity from the + 3. If there are no P directives at all (any commodity or date) and the + --infer-market-prices flag is used: the price commodity from the latest transaction-inferred price for A on or before valuation date. This means: @@ -5345,20 +5458,20 @@ Valuation Here are some quick examples of -V: ; one euro is worth this many dollars from nov 1 - P 2016/11/01 EUR $1.10 + P 2016/11/01 $1.10 ; purchase some euros on nov 3 2016/11/3 - assets:euros EUR100 + assets:euros 100 assets:checking ; the euro is worth fewer dollars by dec 21 - P 2016/12/21 EUR $1.03 + P 2016/12/21 $1.03 How many euros do I have ? $ hledger -f t.j bal -N euros - EUR100 assets:euros + 100 assets:euros What are they worth at end of nov 3 ? @@ -5484,8 +5597,8 @@ Valuation 2000-03-01 (a) 1 B - You may need to explicitly set a commodity's display style, when - reverse prices are used. Eg this output might be surprising: + You may need to explicitly set a commodity's display style, when re- + verse prices are used. Eg this output might be surprising: P 2000-01-01 A 2B @@ -5498,10 +5611,10 @@ Valuation a 0 b 0 - Explanation: because there's no amount or commodity directive specify- - ing a display style for A, 0.5A gets the default style, which shows no + Explanation: because there's no amount or commodity directive specify- + ing a display style for A, 0.5A gets the default style, which shows no decimal digits. Because the displayed amount looks like zero, the com- - modity symbol and minus sign are not displayed either. Adding a com- + modity symbol and minus sign are not displayed either. Adding a com- modity directive sets a more useful display style for A: P 2000-01-01 A 2B @@ -5517,7 +5630,7 @@ Valuation b -0.50A Interaction of valuation and queries - When matching postings based on queries in the presence of valuation, + When matching postings based on queries in the presence of valuation, the following happens. 1. The query is separated into two parts: @@ -5531,101 +5644,112 @@ Valuation 3. Valuation is applied to the postings. - 4. The postings are matched to the other parts of the query based on + 4. The postings are matched to the other parts of the query based on post-valued amounts. See: 1625 Effect of valuation on reports - Here is a reference for how valuation is supposed to affect each part - of hledger's reports (and a glossary). (It's wide, you'll have to - scroll sideways.) It may be useful when troubleshooting. If you find - problems, please report them, ideally with a reproducible example. - Related: #329, #1083. + Here is a reference for how valuation is supposed to affect each part + of hledger's reports (and a glossary). (It's wide, you'll have to + scroll sideways.) It may be useful when troubleshooting. If you find + problems, please report them, ideally with a reproducible example. Re- + lated: #329, #1083. - - Report -B, --cost -V, -X --value=then --value=end --value=DATE, - type --value=now - ----------------------------------------------------------------------------------------------- + Report -B, --cost -V, -X --value=then --value=end --value=DATE, + type --value=now + -------------------------------------------------------------------------------------------- print - - posting cost value at value at posting value at value at - amounts report end date report or DATE/today - or today journal end - balance unchanged unchanged unchanged unchanged unchanged + posting cost value at re- value at posting value at re- value at + amounts port end or date port or DATE/today + today journal end + balance unchanged unchanged unchanged unchanged unchanged asser- - tions/assign- - ments + tions/as- + signments register - starting bal- cost value at valued at day value at value at - ance (-H) report or each historical report or DATE/today - journal end posting was made journal end - starting bal- cost value at day valued at day value at day value at - ance (-H) before each historical before DATE/today - with report report or posting was made report or - interval journal journal - start start - posting cost value at value at posting value at value at - amounts report or date report or DATE/today - journal end journal end - summary post- summarised value at sum of postings value at value at - ing amounts cost period ends in interval, val- period ends DATE/today - with report ued at interval - interval start - running sum/average sum/average sum/average of sum/average sum/average - total/average of displayed of displayed displayed values of displayed of displayed - values values values values + starting cost value at re- valued at day value at re- value at + balance port or each historical port or DATE/today + (-H) journal end posting was made journal end + starting cost value at day valued at day value at day value at + balance before re- each historical before re- DATE/today + (-H) with port or posting was made port or + report journal journal + interval start start + posting cost value at re- value at posting value at re- value at + amounts port or date port or DATE/today + journal end journal end + summary summarised value at pe- sum of postings value at pe- value at + posting cost riod ends in interval, val- riod ends DATE/today + amounts ued at interval + with re- start + port in- + terval + running sum/average sum/average sum/average of sum/average sum/average + total/av- of displayed of displayed displayed values of displayed of displayed + erage values values values values - balance (bs, - bse, cf, is) - balance sums of value at value at posting value at value at - changes costs report end date report or DATE/today of - or today of journal end sums of post- - sums of of sums of ings - postings postings - budget like balance like balance like balance like bal- like balance - amounts changes changes changes ances changes - (--budget) - grand total sum of dis- sum of dis- sum of displayed sum of dis- sum of dis- - played val- played val- valued played val- played values - ues ues ues + balance + (bs, bse, + cf, is) + balance sums of value at re- value at posting value at re- value at + changes costs port end or date port or DATE/today of + today of journal end sums of post- + sums of of sums of ings + postings postings + budget like balance like balance like balance like bal- like balance + amounts changes changes changes ances changes + (--bud- + get) + grand to- sum of dis- sum of dis- sum of displayed sum of dis- sum of dis- + tal played val- played val- valued played val- played values + ues ues ues - balance (bs, - bse, cf, is) - with report - interval - starting bal- sums of value at sums of values of value at sums of post- - ances (-H) costs of report start postings before report start ings before - postings of sums of report start at of sums of report start - before all postings respective post- all postings - report start before ing dates before - report start report start - balance sums of same as sums of values of balance value at - changes (bal, costs of --value=end postings in change in DATE/today of - is, bs postings in period at respec- each period, sums of post- - --change, cf period tive posting valued at ings - --change) dates period ends - end balances sums of same as sums of values of period end value at - (bal -H, is costs of --value=end postings from balances, DATE/today of - --H, bs, cf) postings before period valued at sums of post- - from before start to period period ends ings - report start end at respective - to period posting dates - end - budget like balance like balance like balance like bal- like balance - amounts changes/end changes/end changes/end bal- ances changes/end - (--budget) balances balances ances balances - row totals, sums, aver- sums, aver- sums, averages of sums, aver- sums, aver- - row averages ages of dis- ages of dis- displayed values ages of dis- ages of dis- - (-T, -A) played val- played val- played val- played values - ues ues ues - column totals sums of dis- sums of dis- sums of displayed sums of dis- sums of dis- - played val- played val- values played val- played values - ues ues ues - grand total, sum, average sum, average sum, average of sum, average sum, average - grand average of column of column column totals of column of column - totals totals totals totals + balance + (bs, bse, + cf, is) + with re- + port in- + terval + starting sums of value at re- sums of values of value at re- sums of post- + balances costs of port start postings before port start ings before + (-H) postings be- of sums of report start at of sums of report start + fore report all postings respective post- all postings + start before re- ing dates before re- + port start port start + + + + balance sums of same as sums of values of balance value at + changes costs of --value=end postings in pe- change in DATE/today of + (bal, is, postings in riod at respec- each period, sums of post- + bs period tive posting valued at ings + --change, dates period ends + cf + --change) + end bal- sums of same as sums of values of period end value at + ances costs of --value=end postings from be- balances, DATE/today of + (bal -H, postings fore period start valued at sums of post- + is --H, from before to period end at period ends ings + bs, cf) report start respective post- + to period ing dates + end + budget like balance like balance like balance like bal- like balance + amounts changes/end changes/end changes/end bal- ances changes/end + (--bud- balances balances ances balances + get) + row to- sums, aver- sums, aver- sums, averages of sums, aver- sums, aver- + tals, row ages of dis- ages of dis- displayed values ages of dis- ages of dis- + averages played val- played val- played val- played values + (-T, -A) ues ues ues + column sums of dis- sums of dis- sums of displayed sums of dis- sums of dis- + totals played val- played val- values played val- played values + ues ues ues + grand to- sum, average sum, average sum, average of sum, average sum, average + tal, of column of column column totals of column of column to- + grand av- totals totals totals tals + erage --cumulative is omitted to save space, it works like -H but with a zero @@ -5695,12 +5819,12 @@ PART 4: COMMANDS o incomestatement (is) - show revenues and expenses REPORTS, VERSATILE - o balance (bal) - show balance changes, end balances, budgets, gains.. + o balance (bal) - show balance changes, end balances, budgets, gains.. o print - show transactions or export journal data - o register (reg) - show postings in one or more accounts & running - total + o register (reg) - show postings in one or more accounts & running to- + tal o roi - show return on investments @@ -5734,10 +5858,9 @@ PART 4: COMMANDS o demo - show small hledger demos in the terminal - ADD-ONS And here are some typical add-on commands. Some of these are installed - by the hledger-install script. If installed, they will appear in + by the hledger-install script. If installed, they will appear in hledger's commands list: o ui - run hledger's terminal UI @@ -5750,7 +5873,7 @@ PART 4: COMMANDS o stockquotes - download market prices from AlphaVantage - o Scripts and add-ons - check-fancyassertions, edit, fifo, git, move, + o Scripts and add-ons - check-fancyassertions, edit, fifo, git, move, pijul, plot, and more.. Next, each command is described in detail, in alphabetical order. @@ -5758,33 +5881,33 @@ PART 4: COMMANDS accounts Show account names. - This command lists account names. By default it shows all known - accounts, either used in transactions or declared with account direc- + This command lists account names. By default it shows all known ac- + counts, either used in transactions or declared with account direc- tives. With query arguments, only matched account names and account names ref- erenced by matched postings are shown. - Or it can show just the used accounts (--used/-u), the declared - accounts (--declared/-d), the accounts declared but not used - (--unused), the accounts used but not declared (--undeclared), or the - first account matched by an account name pattern, if any (--find). + Or it can show just the used accounts (--used/-u), the declared ac- + counts (--declared/-d), the accounts declared but not used (--unused), + the accounts used but not declared (--undeclared), or the first account + matched by an account name pattern, if any (--find). - It shows a flat list by default. With --tree, it uses indentation to - show the account hierarchy. In flat mode you can add --drop N to omit - the first few account name components. Account names can be depth- + It shows a flat list by default. With --tree, it uses indentation to + show the account hierarchy. In flat mode you can add --drop N to omit + the first few account name components. Account names can be depth- clipped with depth:N or --depth N or -N. - With --types, it also shows each account's type, if it's known. (See + With --types, it also shows each account's type, if it's known. (See Declaring accounts > Account types.) - With --positions, it also shows the file and line number of each - account's declaration, if any, and the account's overall declaration - order; these may be useful when troubleshooting account display order. + With --positions, it also shows the file and line number of each ac- + count's declaration, if any, and the account's overall declaration or- + der; these may be useful when troubleshooting account display order. With --directives, it adds the account keyword, showing valid account - directives which can be pasted into a journal file. This is useful - together with --undeclared when updating your account declarations to + directives which can be pasted into a journal file. This is useful to- + gether with --undeclared when updating your account declarations to satisfy hledger check accounts. The --find flag can be used to look up a single account name, in the @@ -5840,8 +5963,8 @@ PART 4: COMMANDS Features: - o add tries to provide useful defaults, using the most similar (by - description) recent transaction (filtered by the query, if any) as a + o add tries to provide useful defaults, using the most similar (by de- + scription) recent transaction (filtered by the query, if any) as a template. o You can also set the initial defaults with command line arguments. @@ -5861,7 +5984,7 @@ PART 4: COMMANDS o If you make a mistake, enter < at any prompt to go one step backward. - o Input prompts are displayed in a different colour when the terminal + o Input prompts are displayed in a different colour when the terminal supports it. Example (see https://hledger.org/add.html for a detailed tutorial): @@ -5891,29 +6014,29 @@ PART 4: COMMANDS Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2015/05/22]: $ - On Microsoft Windows, the add command makes sure that no part of the + On Microsoft Windows, the add command makes sure that no part of the file path ends with a period, as that would cause problems (#1056). aregister (areg) - Show the transactions and running historical balance of a single - account, with each transaction displayed as one line. + Show the transactions and running historical balance of a single ac- + count, with each transaction displayed as one line. aregister shows the overall transactions affecting a particular account - (and any subaccounts). Each report line represents one transaction in - this account. Transactions before the report start date are always - included in the running balance (--historical mode is always on). + (and any subaccounts). Each report line represents one transaction in + this account. Transactions before the report start date are always in- + cluded in the running balance (--historical mode is always on). - This is a more "real world", bank-like view than the register command - (which shows individual postings, possibly from multiple accounts, not + This is a more "real world", bank-like view than the register command + (which shows individual postings, possibly from multiple accounts, not necessarily in historical mode). As a quick rule of thumb: - use areg- ister for reviewing and reconciling real-world asset/liability accounts - use register for reviewing detailed revenues/expenses. - aregister requires one argument: the account to report on. You can - write either the full account name, or a case-insensitive regular - expression which will select the alphabetically first matched account. + aregister requires one argument: the account to report on. You can + write either the full account name, or a case-insensitive regular ex- + pression which will select the alphabetically first matched account. When there are multiple matches, the alphabetically-first choice can be surprising; eg if you have assets:per:checking 1 and assets:biz:check- @@ -5955,8 +6078,8 @@ PART 4: COMMANDS ensure perfect alignment, at the cost of more time and memory, use the --align-all flag. - This command also supports the output destination and output format - options. The output formats supported are txt, csv, and json. + This command also supports the output destination and output format op- + tions. The output formats supported are txt, csv, and json. aregister and custom posting dates Transactions whose date is outside the report period can still be @@ -6009,6 +6132,8 @@ PART 4: COMMANDS o or unrealised capital gain/loss (--gain) + o or postings count (--count) + ..in.. o one time period (the whole journal period by default) @@ -6037,8 +6162,8 @@ PART 4: COMMANDS ..with.. - o totals (-T), averages (-A), percentages (-%), inverted sign - (--invert) + o totals (-T), averages (-A), percentages (-%), inverted sign (--in- + vert) o rows and columns swapped (--transpose) @@ -6081,8 +6206,8 @@ PART 4: COMMANDS 0 Accounts with a zero balance (and no non-zero subaccounts, in tree mode - - see below) are hidden by default. Use -E/--empty to show them - (revealing assets:bank:checking here): + - see below) are hidden by default. Use -E/--empty to show them (re- + vealing assets:bank:checking here): $ hledger -f examples/sample.journal bal -E 0 assets:bank:checking @@ -6118,9 +6243,9 @@ PART 4: COMMANDS --------------------------------- 0 - The FMT format string specifies the formatting applied to each - account/balance pair. It may contain any suitable text, with data - fields interpolated like so: + The FMT format string specifies the formatting applied to each ac- + count/balance pair. It may contain any suitable text, with data fields + interpolated like so: %[MIN][.MAX](FIELDNAME) @@ -6146,9 +6271,9 @@ PART 4: COMMANDS o %, - render on one line, comma-separated - There are some quirks. Eg in one-line mode, %(depth_spacer) has no - effect, instead %(account) has indentation built in. Experimentation - may be needed to get pleasing results. + There are some quirks. Eg in one-line mode, %(depth_spacer) has no ef- + fect, instead %(account) has indentation built in. Experimentation may + be needed to get pleasing results. Some example formats: @@ -6239,19 +6364,18 @@ PART 4: COMMANDS -------------------- $2 - Showing declared accounts - With --declared, accounts which have been declared with an account - directive will be included in the balance report, even if they have no + With --declared, accounts which have been declared with an account di- + rective will be included in the balance report, even if they have no transactions. (Since they will have a zero balance, you will also need -E/--empty to see them.) More precisely, leaf declared accounts (with no subaccounts) will be included, since those are usually the more useful in reports. - The idea of this is to be able to see a useful "complete" balance - report, even when you don't have transactions in all of your declared - accounts yet. + The idea of this is to be able to see a useful "complete" balance re- + port, even when you don't have transactions in all of your declared ac- + counts yet. Sorting by amount With -S/--sort-amount, accounts with the largest (most positive) bal- @@ -6262,33 +6386,32 @@ PART 4: COMMANDS commodity, it is treated as 0). Revenues and liability balances are typically negative, however, so -S - shows these in reverse order. To work around this, you can add - --invert to flip the signs. (Or, use one of the higher-level reports, - which flip the sign automatically. Eg: hledger incomestatement -MAS). - + shows these in reverse order. To work around this, you can add --in- + vert to flip the signs. (Or, use one of the higher-level reports, + which flip the sign automatically. Eg: hledger incomestatement -MAS). Percentages - With -%/--percent, balance reports show each account's value expressed + With -%/--percent, balance reports show each account's value expressed as a percentage of the (column) total. Note it is not useful to calculate percentages if the amounts in a col- - umn have mixed signs. In this case, make a separate report for each + umn have mixed signs. In this case, make a separate report for each sign, eg: $ hledger bal -% amt:`>0` $ hledger bal -% amt:`<0` - Similarly, if the amounts in a column have mixed commodities, convert - them to one commodity with -B, -V, -X or --value, or make a separate + Similarly, if the amounts in a column have mixed commodities, convert + them to one commodity with -B, -V, -X or --value, or make a separate report for each commodity: $ hledger bal -% cur:\\$ - $ hledger bal -% cur:EUR + $ hledger bal -% cur: Multi-period balance report - With a report interval (set by the -D/--daily, -W/--weekly, - -M/--monthly, -Q/--quarterly, -Y/--yearly, or -p/--period flag), bal- - ance shows a tabular report, with columns representing successive time + With a report interval (set by the -D/--daily, -W/--weekly, + -M/--monthly, -Q/--quarterly, -Y/--yearly, or -p/--period flag), bal- + ance shows a tabular report, with columns representing successive time periods (and a title): $ hledger -f examples/sample.journal bal --quarterly income expenses -E @@ -6309,21 +6432,21 @@ PART 4: COMMANDS encompass the displayed subperiods (so that the first and last subpe- riods have the same duration as the others). - o Leading and trailing periods (columns) containing all zeroes are not + o Leading and trailing periods (columns) containing all zeroes are not shown, unless -E/--empty is used. - o Accounts (rows) containing all zeroes are not shown, unless + o Accounts (rows) containing all zeroes are not shown, unless -E/--empty is used. - o Amounts with many commodities are shown in abbreviated form, unless + o Amounts with many commodities are shown in abbreviated form, unless --no-elide is used. (experimental) - o Average and/or total columns can be added with the -A/--average and + o Average and/or total columns can be added with the -A/--average and -T/--row-total flags. o The --transpose flag can be used to exchange rows and columns. - o The --pivot FIELD option causes a different transaction field to be + o The --pivot FIELD option causes a different transaction field to be used as "account name". See PIVOTING. Multi-period reports with many periods can be too wide for easy viewing @@ -6337,33 +6460,33 @@ PART 4: COMMANDS o Reduce the terminal's font size - o View with a pager like less, eg: hledger bal -D --color=yes | less + o View with a pager like less, eg: hledger bal -D --color=yes | less -RS - o Output as CSV and use a CSV viewer like visidata (hledger bal -D -O - csv | vd -f csv), Emacs' csv-mode (M-x csv-mode, C-c C-a), or a + o Output as CSV and use a CSV viewer like visidata (hledger bal -D -O + csv | vd -f csv), Emacs' csv-mode (M-x csv-mode, C-c C-a), or a spreadsheet (hledger bal -D -o a.csv && open a.csv) - o Output as HTML and view with a browser: hledger bal -D -o a.html && + o Output as HTML and view with a browser: hledger bal -D -o a.html && open a.html Balance change, end balance - It's important to be clear on the meaning of the numbers shown in bal- + It's important to be clear on the meaning of the numbers shown in bal- ance reports. Here is some terminology we use: - A balance change is the net amount added to, or removed from, an - account during some period. + A balance change is the net amount added to, or removed from, an ac- + count during some period. - An end balance is the amount accumulated in an account as of some date - (and some time, but hledger doesn't store that; assume end of day in + An end balance is the amount accumulated in an account as of some date + (and some time, but hledger doesn't store that; assume end of day in your timezone). It is the sum of previous balance changes. - We call it a historical end balance if it includes all balance changes + We call it a historical end balance if it includes all balance changes since the account was created. For a real world account, this means it - will match the "historical record", eg the balances reported in your + will match the "historical record", eg the balances reported in your bank statements or bank web UI. (If they are correct!) - In general, balance changes are what you want to see when reviewing + In general, balance changes are what you want to see when reviewing revenues and expenses, and historical end balances are what you want to see when reviewing or reconciling asset, liability and equity accounts. @@ -6382,8 +6505,8 @@ PART 4: COMMANDS Balance report types The balance command is quite flexible; here is the full detail on how to control what it reports. If the following seems complicated, don't - worry - this is for advanced reporting, and it does typically take some - time and experimentation to get clear on all these report modes. + worry - this is for advanced reporting, and it does take time and ex- + perimentation to get familiar with all the report modes. There are three important option groups: @@ -6405,6 +6528,8 @@ PART 4: COMMANDS o --gain : show the unrealised capital gain/loss, (the current valued balance minus each amount's original cost) + o --count : show the count of postings + Accumulation type How amounts should accumulate across report periods. Another way to say it: which time period's postings should contribute to each cell's @@ -6420,13 +6545,13 @@ PART 4: COMMANDS o --historical/-H : calculate with postings from journal start to col- umn end, ie "all postings from before report start date until this - column's end". Typically used to see historical end balances of - assets/liabilities/equity. (default for balancesheet, balancesheete- + column's end". Typically used to see historical end balances of as- + sets/liabilities/equity. (default for balancesheet, balancesheete- quity, cashflow) Valuation type - Which kind of value or cost conversion should be applied, if any, - before displaying the report. It is one of: + Which kind of value or cost conversion should be applied, if any, be- + fore displaying the report. It is one of: o no valuation type : don't convert to cost or value (default) @@ -6442,8 +6567,8 @@ PART 4: COMMANDS o --value=now[,COMM] : convert amounts to market value on today's date - o --value=YYYY-MM-DD[,COMM] : convert amounts to market value on - another date + o --value=YYYY-MM-DD[,COMM] : convert amounts to market value on an- + other date or one of the equivalent simpler flags: @@ -6471,34 +6596,33 @@ PART 4: COMMANDS For reference, here is what the combinations of accumulation and valua- tion show: - Valua- no valuation --value= then --value= end --value= YYYY- tion:> MM-DD /now Accumu- lation:v ----------------------------------------------------------------------------------- --change change in period sum of posting- period-end DATE-value of - date market val- value of change change in - ues in period in period period - --cumu- change from sum of posting- period-end DATE-value of - lative report start to date market val- value of change change from + date market val- value of change change in pe- + ues in period in period riod + --cumu- change from re- sum of posting- period-end DATE-value of + lative port start to date market val- value of change change from period end ues from report from report report start start to period start to period to period end end end --his- change from sum of posting- period-end DATE-value of - torical journal start to date market val- value of change change from - /-H period end (his- ues from journal from journal journal start + torical journal start to date market val- value of change change from + /-H period end (his- ues from journal from journal journal start torical end bal- start to period start to period to period end ance) end end Budget report - The --budget report type activates extra columns showing any budget - goals for each account and period. The budget goals are defined by - periodic transactions. This is useful for comparing planned and actual + The --budget report type activates extra columns showing any budget + goals for each account and period. The budget goals are defined by pe- + riodic transactions. This is useful for comparing planned and actual income, expenses, time usage, etc. - For example, you can take average monthly expenses in the common - expense categories to construct a minimal monthly budget: + For example, you can take average monthly expenses in the common ex- + pense categories to construct a minimal monthly budget: ;; Budget ~ monthly @@ -6542,28 +6666,30 @@ PART 4: COMMANDS ----------------------++---------------------------------------------------- || 0 [ 0] 0 [ 0] - This is different from a normal balance report in several ways: + This is different from a normal balance report in several ways. Cur- + rently: - o Only accounts with budget goals during the report period are shown, - by default. + o Accounts with budget goals during the report period, and their par- + ents, are shown. - o In each column, in square brackets after the actual amount, budget - goal amounts are shown, and the actual/goal percentage. (Note: bud- - get goals should be in the same commodity as the actual amount.) + o Their subaccounts are not shown (regardless of the depth setting). - o All parent accounts are always shown, even in list mode. Eg assets, - assets:bank, and expenses above. + o Accounts without budget goals, if any, are aggregated and shown as + "". - o Amounts always include all subaccounts, budgeted or unbudgeted, even - in list mode. + o Amounts are always inclusive (subaccount-including), even in list + mode. - This means that the numbers displayed will not always add up! Eg - above, the expenses actual amount includes the gifts and supplies + o After each actual amount, the corresponding goal amount and percent- + age of goal reached are also shown, in square brackets. + + This means that the numbers displayed will not always add up! Eg + above, the expenses actual amount includes the gifts and supplies transactions, but the expenses:gifts and expenses:supplies accounts are not shown, as they have no budget amounts declared. - This can be confusing. When you need to make things clearer, use the - -E/--empty flag, which will reveal all accounts including unbudgeted + This can be confusing. When you need to make things clearer, use the + -E/--empty flag, which will reveal all accounts including unbudgeted ones, giving the full picture. Eg: $ hledger balance -M --budget --empty @@ -6610,19 +6736,19 @@ PART 4: COMMANDS hledger bal -M --budget type:rx - It's also common to limit or convert them to a single currency - (cur:COMM or -X COMM [--infer-market-prices]). If showing multiple + It's also common to limit or convert them to a single currency + (cur:COMM or -X COMM [--infer-market-prices]). If showing multiple currencies, --layout bare or --layout tall can help. For more examples and notes, see Budgeting. Budget report start date - This might be a bug, but for now: when making budget reports, it's a + This might be a bug, but for now: when making budget reports, it's a good idea to explicitly set the report's start date to the first day of - a reporting period, because a periodic rule like ~ monthly generates - its transactions on the 1st of each month, and if your journal has no - regular transactions on the 1st, the default report start date could - exclude that budget goal, which can be a little surprising. Eg here + a reporting period, because a periodic rule like ~ monthly generates + its transactions on the 1st of each month, and if your journal has no + regular transactions on the 1st, the default report start date could + exclude that budget goal, which can be a little surprising. Eg here the default report period is just the day of 2020-01-15: ~ monthly in 2020 @@ -6641,9 +6767,9 @@ PART 4: COMMANDS --------------++------------ || $400 - To avoid this, specify the budget report's period, or at least the - start date, with -b/-e/-p/date:, to ensure it includes the budget goal - transactions (periodic transactions) that you want. Eg, adding -b + To avoid this, specify the budget report's period, or at least the + start date, with -b/-e/-p/date:, to ensure it includes the budget goal + transactions (periodic transactions) that you want. Eg, adding -b 2020/1/1 to the above: $ hledger bal expenses --budget -b 2020/1/1 @@ -6656,12 +6782,12 @@ PART 4: COMMANDS || $400 [80% of $500] Budgets and subaccounts - You can add budgets to any account in your account hierarchy. If you + You can add budgets to any account in your account hierarchy. If you have budgets on both parent account and some of its children, then bud- - get(s) of the child account(s) would be added to the budget of their + get(s) of the child account(s) would be added to the budget of their parent, much like account balances behave. - In the most simple case this means that once you add a budget to any + In the most simple case this means that once you add a budget to any account, all its parents would have budget as well. To illustrate this, consider the following budget: @@ -6671,14 +6797,14 @@ PART 4: COMMANDS expenses:personal:electronics $100.00 liabilities - With this, monthly budget for electronics is defined to be $100 and - budget for personal expenses is an additional $1000, which implicitly + With this, monthly budget for electronics is defined to be $100 and + budget for personal expenses is an additional $1000, which implicitly means that budget for both expenses:personal and expenses is $1100. - Transactions in expenses:personal:electronics will be counted both - towards its $100 budget and $1100 of expenses:personal , and transac- - tions in any other subaccount of expenses:personal would be counted - towards only towards the budget of expenses:personal. + Transactions in expenses:personal:electronics will be counted both to- + wards its $100 budget and $1100 of expenses:personal , and transactions + in any other subaccount of expenses:personal would be counted towards + only towards the budget of expenses:personal. For example, let's consider these transactions: @@ -6703,9 +6829,9 @@ PART 4: COMMANDS expenses:personal $30.00 liabilities - As you can see, we have transactions in expenses:personal:electron- - ics:upgrades and expenses:personal:train tickets, and since both of - these accounts are without explicitly defined budget, these transac- + As you can see, we have transactions in expenses:personal:electron- + ics:upgrades and expenses:personal:train tickets, and since both of + these accounts are without explicitly defined budget, these transac- tions would be counted towards budgets of expenses:personal:electronics and expenses:personal accordingly: @@ -6721,7 +6847,7 @@ PART 4: COMMANDS -------------------------------++------------------------------- || 0 [ 0] - And with --empty, we can get a better picture of budget allocation and + And with --empty, we can get a better picture of budget allocation and consumption: $ hledger balance --budget -M --empty @@ -6740,65 +6866,64 @@ PART 4: COMMANDS Selecting budget goals The budget report evaluates periodic transaction rules to generate spe- - cial "goal transactions", which generate the goal amounts for each - account in each report subperiod. When troubleshooting, you can use + cial "goal transactions", which generate the goal amounts for each ac- + count in each report subperiod. When troubleshooting, you can use print --forecast to show these as forecasted transactions: $ hledger print --forecast=BUDGETREPORTPERIOD tag:generated - By default, the budget report uses all available periodic transaction - rules to generate goals. This includes rules with a different report - interval from your report. Eg if you have daily, weekly and monthly - periodic rules, all of these will contribute to the goals in a monthly + By default, the budget report uses all available periodic transaction + rules to generate goals. This includes rules with a different report + interval from your report. Eg if you have daily, weekly and monthly + periodic rules, all of these will contribute to the goals in a monthly budget report. - You can select a subset of periodic rules by providing an argument to - the --budget flag. --budget=DESCPAT will match all periodic rules + You can select a subset of periodic rules by providing an argument to + the --budget flag. --budget=DESCPAT will match all periodic rules whose description contains DESCPAT, a case-insensitive substring (not a - regular expression or query). This means you can give your periodic - rules descriptions (remember that two spaces are needed), and then - select from multiple budgets defined in your journal. + regular expression or query). This means you can give your periodic + rules descriptions (remember that two spaces are needed), and then se- + lect from multiple budgets defined in your journal. Budget vs forecast - hledger --forecast ... and hledger balance --budget ... are separate - features, though both of them use the periodic transaction rules - defined in the journal, and both of them generate temporary transac- - tions for reporting purposes ("forecast transactions" and "budget goal - transactions", respectively). You can use both features at the same - time if you want. Here are some differences between them, as of - hledger 1.29: + hledger --forecast ... and hledger balance --budget ... are separate + features, though both of them use the periodic transaction rules de- + fined in the journal, and both of them generate temporary transactions + for reporting purposes ("forecast transactions" and "budget goal trans- + actions", respectively). You can use both features at the same time if + you want. Here are some differences between them, as of hledger 1.29: CLI: o --forecast is a general hledger option, usable with any command - o --budget is a balance command option, usable only with that command. + o --budget is a balance command option, usable only with that command. Visibility of generated transactions: o forecast transactions are visible in any report, like ordinary trans- actions - o budget goal transactions are invisible except for the goal amounts + o budget goal transactions are invisible except for the goal amounts they produce in --budget reports. Periodic transaction rules: o --forecast uses all available periodic transaction rules - o --budget uses all periodic rules (--budget) or a selected subset + o --budget uses all periodic rules (--budget) or a selected subset (--budget=DESCPAT) Period of generated transactions: o --forecast generates forecast transactions - o from after the last regular transaction to the end of the report + o from after the last regular transaction to the end of the report period (--forecast) o or, during a specified period (--forecast=PERIODEXPR) - o possibly further restricted by a period specified in the periodic + o possibly further restricted by a period specified in the periodic transaction rule o and always restricted within the bounds of the report period @@ -6807,30 +6932,29 @@ PART 4: COMMANDS o throughout the report period - o possibly restricted by a period specified in the periodic transac- + o possibly restricted by a period specified in the periodic transac- tion rule. Data layout - The --layout option affects how balance reports show multi-commodity - amounts and commodity symbols, which can improve readability. It can + The --layout option affects how balance reports show multi-commodity + amounts and commodity symbols, which can improve readability. It can also normalise the data for easy consumption by other programs. It has four possible values: - o --layout=wide[,WIDTH]: commodities are shown on a single line, - optionally elided to WIDTH + 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 o --layout=bare: commodity symbols are in their own column, amounts are bare numbers - o --layout=tidy: data is normalised to easily-consumed "tidy" form, + o --layout=tidy: data is normalised to easily-consumed "tidy" form, with one row per data value - Here are the --layout modes supported by each output format; note only + Here are the --layout modes supported by each output format; note only CSV output supports all of them: - - txt csv html json sql ------------------------------------- wide Y Y Y @@ -6851,7 +6975,7 @@ PART 4: COMMANDS ------------------++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || 10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT 70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT -11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT - o Limited wide layout. A width limit reduces the width, but some com- + o Limited wide layout. A width limit reduces the width, but some com- modities will be hidden: $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide,32 @@ -6863,7 +6987,7 @@ PART 4: COMMANDS ------------------++--------------------------------------------------------------------------------------------------------------------------- || 10.00 ITOT, 337.18 USD, 2 more.. 70.00 GLD, 18.00 ITOT, 3 more.. -11.00 ITOT, 3 more.. 70.00 GLD, 17.00 ITOT, 3 more.. - o Tall layout. Each commodity gets a new line (may be different in + o Tall layout. Each commodity gets a new line (may be different in each column), and account names are repeated: $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=tall @@ -6883,7 +7007,7 @@ PART 4: COMMANDS || 106.00 VHT 10.00 VEA 170.00 VHT 36.00 VEA || 18.00 VHT 294.00 VHT - o Bare layout. Commodity symbols are kept in one column, each commod- + o Bare layout. Commodity symbols are kept in one column, each commod- ity gets its own report row, account names are repeated: $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=bare @@ -6903,7 +7027,7 @@ PART 4: COMMANDS || VEA 12.00 10.00 14.00 36.00 || VHT 106.00 18.00 170.00 294.00 - o Bare layout also affects CSV output, which is useful for producing + o Bare layout also affects CSV output, which is useful for producing data that is easier to consume, eg for making charts: $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -O csv --layout=bare @@ -6920,7 +7044,7 @@ PART 4: COMMANDS "total","VHT","294.00" o Tidy layout produces normalised "tidy data", where every variable has - its own column and each row represents a single data point. See + its own column and each row represents a single data point. See https://cran.r-project.org/web/packages/tidyr/vignettes/tidy- data.html for more. This is the easiest kind of data for other soft- ware to consume. Here's how it looks: @@ -6947,25 +7071,25 @@ PART 4: COMMANDS Some frequently used balance options/reports are: o bal -M revenues expenses - Show revenues/expenses in each month. Also available as the incomes- + Show revenues/expenses in each month. Also available as the incomes- tatement command. o bal -M -H assets liabilities - Show historical asset/liability balances at each month end. Also + Show historical asset/liability balances at each month end. Also available as the balancesheet command. o bal -M -H assets liabilities equity - Show historical asset/liability/equity balances at each month end. + Show historical asset/liability/equity balances at each month end. Also available as the balancesheetequity command. o bal -M assets not:receivable - Show changes to liquid assets in each month. Also available as the + Show changes to liquid assets in each month. Also available as the cashflow command. Also: o bal -M expenses -2 -SA - Show monthly expenses summarised to depth 2 and sorted by average + Show monthly expenses summarised to depth 2 and sorted by average amount. o bal -M --budget expenses @@ -6981,14 +7105,14 @@ PART 4: COMMANDS balancesheet (bs) - This command displays a balance sheet, showing historical ending bal- + This command displays a balance sheet, showing historical ending bal- ances of asset and liability accounts. (To see equity as well, use the - balancesheetequity command.) Amounts are shown with normal positive + balancesheetequity command.) Amounts are shown with normal positive sign, as in conventional financial statements. - This report shows accounts declared with the Asset, Cash or Liability - type (see account types). Or if no such accounts are declared, it - shows top-level accounts named asset or liability (case insensitive, + This report shows accounts declared with the Asset, Cash or Liability + type (see account types). Or if no such accounts are declared, it + shows top-level accounts named asset or liability (case insensitive, plurals allowed) and their subaccounts. Example: @@ -7013,26 +7137,26 @@ PART 4: COMMANDS 0 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. - It is similar to hledger balance -H assets liabilities, but with - smarter account detection, and liabilities displayed with their sign + ports many of that command's features, such as multi-period reports. + It is similar to hledger balance -H assets liabilities, but with + smarter account detection, and liabilities displayed with their sign flipped. - This command also supports the output destination and output format - options The output formats supported are txt, csv, html, and (experi- - mental) json. + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, html, and (experimen- + tal) json. balancesheetequity (bse) - This command displays a balance sheet, showing historical ending bal- - ances of asset, liability and equity accounts. Amounts are shown with + This command displays a balance sheet, showing historical ending bal- + ances of asset, liability and equity accounts. Amounts are shown with normal positive sign, as in conventional financial statements. - This report shows accounts declared with the Asset, Cash, Liability or - Equity type (see account types). Or if no such accounts are declared, - it shows top-level accounts named asset, liability or equity (case - insensitive, plurals allowed) and their subaccounts. + This report shows accounts declared with the Asset, Cash, Liability or + Equity type (see account types). Or if no such accounts are declared, + it shows top-level accounts named asset, liability or equity (case in- + sensitive, plurals allowed) and their subaccounts. Example: @@ -7061,33 +7185,33 @@ PART 4: COMMANDS 0 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. + ports many of that command's features, such as multi-period reports. It is similar to hledger balance -H assets liabilities equity, but with - smarter account detection, and liabilities/equity displayed with their + smarter account detection, and liabilities/equity displayed with their sign flipped. - This command also supports the output destination and output format - options The output formats supported are txt, csv, html, and (experi- - mental) json. + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, html, and (experimen- + tal) json. cashflow (cf) - This command displays a cashflow statement, showing the inflows and - outflows affecting "cash" (ie, liquid, easily convertible) assets. - Amounts are shown with normal positive sign, as in conventional finan- + This command displays a cashflow statement, showing the inflows and + outflows affecting "cash" (ie, liquid, easily convertible) assets. + Amounts are shown with normal positive sign, as in conventional finan- cial statements. - This report shows accounts declared with the Cash type (see account + This report shows accounts declared with the Cash type (see account types). Or if no such accounts are declared, it shows accounts - o under a top-level account named asset (case insensitive, plural - allowed) + o under a top-level account named asset (case insensitive, plural al- + lowed) o whose name contains some variation of cash, bank, checking or saving. - More precisely: all accounts matching this case insensitive regular - expression: + More precisely: all accounts matching this case insensitive regular ex- + pression: ^assets?(:.+)?:(cash|bank|che(ck|que?)(ing)?|savings?|currentcash)(:|$) @@ -7110,21 +7234,21 @@ PART 4: COMMANDS $-1 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. - It is similar to hledger balance assets not:fixed not:investment + ports many of that command's features, such as multi-period reports. + It is similar to hledger balance assets not:fixed not:investment not:receivable, but with smarter account detection. - This command also supports the output destination and output format - options The output formats supported are txt, csv, html, and (experi- - mental) json. + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, html, and (experimen- + tal) json. check Check for various kinds of errors in your data. - hledger provides a number of built-in error checks to help prevent - problems in your data. Some of these are run automatically; or, you - can use this check command to run them on demand, with no output and a - zero exit code if all is well. Specify their names (or a prefix) as + hledger provides a number of built-in error checks to help prevent + problems in your data. Some of these are run automatically; or, you + can use this check command to run them on demand, with no output and a + zero exit code if all is well. Specify their names (or a prefix) as argument(s). Some examples: @@ -7133,7 +7257,7 @@ PART 4: COMMANDS hledger check -s # basic + strict checks hledger check ordereddates payees # basic + two other checks - If you are an Emacs user, you can also configure flycheck-hledger to + 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: @@ -7198,12 +7322,12 @@ PART 4: COMMANDS est posting. This aims to prevent the situation where you are regu- larly updating your journal, but forgetting to check your balances against the real world, then one day must dig back through months of - data to find an error. It assumes that adding a balance assertion - requires/reminds you to check the real-world balance. That may not be + data to find an error. It assumes that adding a balance assertion re- + quires/reminds you to check the real-world balance. That may not be true if you auto-generate balance assertions from bank data; in that case, I recommend to import transactions uncleared, then use the man- - ual-review-and-mark-cleared phase as a reminder to check the latest - assertions against real-world balances. + ual-review-and-mark-cleared phase as a reminder to check the latest as- + sertions against real-world balances. close (equity) @@ -7213,35 +7337,35 @@ PART 4: COMMANDS balances to a new journal file, or for merging earnings into equity at end of accounting period. - By default, it prints a transaction that zeroes out ALE accounts - (asset, liability, equity accounts; this requires account types to be - configured); or if ACCTQUERY is provided, the accounts matched by that. + By default, it prints a transaction that zeroes out ALE accounts (as- + set, liability, equity accounts; this requires account types to be con- + figured); or if ACCTQUERY is provided, the accounts matched by that. (experimental) - This command has four main modes, corresponding to the most common use + This command has four main modes, corresponding to the most common use cases: - 1. With --close (default), it prints a "closing balances" transaction - that zeroes out ALE (asset, liability, equity) accounts by default - (this requires account types to be inferred or declared); or, the + 1. With --close (default), it prints a "closing balances" transaction + that zeroes out ALE (asset, liability, equity) accounts by default + (this requires account types to be inferred or declared); or, the accounts matched by the provided ACCTQUERY arguments. - 2. With --open, it prints an opposite "opening balances" transaction + 2. With --open, it prints an opposite "opening balances" transaction that restores those balances from zero. This is similar to Ledger's equity command. 3. With --migrate, it prints both the closing and opening transactions. - This is the preferred way to migrate balances to a new file: run - hledger close --migrate, add the closing transaction at the end of - the old file, and add the opening transaction at the start of the - new file. The matching closing/opening transactions cancel each - other out, preserving correct balances during multi-file reporting. + This is the preferred way to migrate balances to a new file: run + hledger close --migrate, add the closing transaction at the end of + the old file, and add the opening transaction at the start of the + new file. The matching closing/opening transactions cancel each + other out, preserving correct balances during multi-file reporting. 4. With --retain, it prints a "retain earnings" transaction that trans- fers RX (revenue and expense) balances to equity:retained earnings. - Businesses traditionally do this at the end of each accounting - period; it is less necessary with computer-based accounting, but it + Businesses traditionally do this at the end of each accounting pe- + riod; it is less necessary with computer-based accounting, but it could still be useful if you want to see the accounting equation (A=L+E) satisfied. @@ -7253,8 +7377,8 @@ PART 4: COMMANDS o the account to transfer to/from can be changed with --close-acct=ACCT and --open-acct=ACCT - o the accounts to be closed/opened can be changed with ACCTQUERY - (account query arguments). + o the accounts to be closed/opened can be changed with ACCTQUERY (ac- + count query arguments). By default just one destination/source posting will be used, with its amount left implicit. With --x/--explicit, the amount will be shown @@ -7272,8 +7396,8 @@ PART 4: COMMANDS The default closing date is yesterday, or the journal's end date, whichever is later. You can change this by specifying a report end - date; (The report start date does not matter.) The last day of the - report period will be the closing date; eg -e 2022 means "close on + date; (The report start date does not matter.) The last day of the re- + port period will be the closing date; eg -e 2022 means "close on 2022-12-31". The opening date is always the day after the closing date. @@ -7296,8 +7420,8 @@ PART 4: COMMANDS expenses:food 5 assets:bank:checking -5 ; date: 2023-01-02 - To solve that you can transfer the money to and from a temporary - account, in effect splitting the multi-day transaction into two single- + To solve that you can transfer the money to and from a temporary ac- + count, in effect splitting the multi-day transaction into two single- day transactions: ; in 2022.journal: @@ -7311,8 +7435,8 @@ PART 4: COMMANDS assets:bank:checking -5 Example: retain earnings - Record 2022's revenues/expenses as retained earnings on 2022-12-31, - appending the generated transaction to the journal: + Record 2022's revenues/expenses as retained earnings on 2022-12-31, ap- + pending the generated transaction to the journal: $ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal @@ -7430,16 +7554,16 @@ PART 4: COMMANDS demo Play demos of hledger usage in the terminal, if asciinema is installed. - Run this command with no argument to list the demos. To play a demo, + Run this command with no argument to list the demos. To play a demo, write its number or a prefix or substring of its title. Tips: Make your terminal window large enough to see the demo clearly. - During playback, several keys are available: SPACE to pause/unpause, . + During playback, several keys are available: SPACE to pause/unpause, . to step forward (while paused), CTRL-c quit. asciinema options can be added following a double dash, such as -s N to - adjust speed and -i SECS to limit pauses. Run asciinema -h to list + adjust speed and -i SECS to limit pauses. Run asciinema -h to list these options. Examples: @@ -7453,7 +7577,7 @@ PART 4: COMMANDS List the unique descriptions that appear in transactions. This command lists the unique descriptions that appear in transactions, - in alphabetic order. You can add a query to select a subset of trans- + in alphabetic order. You can add a query to select a subset of trans- actions. Example: @@ -7464,13 +7588,13 @@ PART 4: COMMANDS Person A diff - Compares a particular account's transactions in two input files. It + Compares a particular account's transactions in two input files. It shows any transactions to this account which are in one file but not in the other. More precisely, for each posting affecting this account in either file, - it looks for a corresponding posting in the other file which posts the - same amount to the same account (ignoring date, description, etc.) + it looks for a corresponding posting in the other file which posts the + same amount to the same account (ignoring date, description, etc.) Since postings not transactions are compared, this also works when mul- tiple bank transactions have been combined into a single journal entry. @@ -7493,29 +7617,29 @@ PART 4: COMMANDS files List all files included in the journal. With a REGEX argument, only - file names matching the regular expression (case sensitive) are shown. + file names matching the regular expression (case sensitive) are shown. help - Show the hledger user manual in the terminal, with info, man, or a - pager. With a TOPIC argument, open it at that topic if possible. - TOPIC can be any heading in the manual, or a heading prefix, case - insensitive. Eg: commands, print, forecast, journal, amount, "auto - postings". + Show the hledger user manual in the terminal, with info, man, or a + pager. With a TOPIC argument, open it at that topic if possible. + TOPIC can be any heading in the manual, or a heading prefix, case in- + sensitive. Eg: commands, print, forecast, journal, amount, "auto post- + ings". This command shows the hledger manual built in to your hledger version. It can be useful when offline, or when you prefer the terminal to a web - browser, or when the appropriate hledger manual or viewing tools are + browser, or when the appropriate hledger manual or viewing tools are not installed on your system. - By default it chooses the best viewer found in $PATH, trying (in this - order): info, man, $PAGER, less, more. You can force the use of info, - man, or a pager with the -i, -m, or -p flags, If no viewer can be + By default it chooses the best viewer found in $PATH, trying (in this + order): info, man, $PAGER, less, more. You can force the use of info, + man, or a pager with the -i, -m, or -p flags, If no viewer can be found, or the command is run non-interactively, it just prints the man- ual to stdout. - If using info, note that version 6 or greater is needed for TOPIC - lookup. If you are on mac you will likely have info 4.8, and should - consider installing a newer version, eg with brew install texinfo + If using info, note that version 6 or greater is needed for TOPIC + lookup. If you are on mac you will likely have info 4.8, and should + consider installing a newer version, eg with brew install texinfo (#1770). Examples @@ -7526,71 +7650,71 @@ PART 4: COMMANDS $ hledger help -m journal # show it with man, even if info is installed import - Read new transactions added to each FILE since last run, and add them - to the journal. Or with --dry-run, just print the transactions that - would be added. Or with --catchup, just mark all of the FILEs' trans- + Read new transactions added to each FILE since last run, and add them + to the journal. Or with --dry-run, just print the transactions that + would be added. Or with --catchup, just mark all of the FILEs' trans- actions as imported, without actually importing any. - This command may append new transactions to the main journal file - (which should be in journal format). Existing transactions are not - changed. This is one of the few hledger commands that writes to the + This command may append new transactions to the main journal file + (which should be in journal format). Existing transactions are not + changed. This is one of the few hledger commands that writes to the journal file (see also add). - Unlike other hledger commands, with import the journal file is an out- + Unlike other hledger commands, with import the journal file is an out- put file, and will be modified, though only by appending (existing data - will not be changed). The input files are specified as arguments, so - to import one or more CSV files to your main journal, you will run + will not be changed). The input files are specified as arguments, so + to import one or more CSV files to your main journal, you will run hledger import bank.csv or perhaps hledger import *.csv. Note you can import from any file format, though CSV files are the most common import source, and these docs focus on that case. Deduplication - As a convenience import does deduplication while reading transactions. + As a convenience import does deduplication while reading transactions. This does not mean "ignore transactions that look the same", but rather "ignore transactions that have been seen before". This is intended for - when you are periodically importing foreign data which may contain - already-imported transactions. So eg, if every day you download bank - CSV files containing redundant data, you can safely run hledger import - bank.csv and only new transactions will be imported. (import is idem- + when you are periodically importing foreign data which may contain al- + ready-imported transactions. So eg, if every day you download bank CSV + files containing redundant data, you can safely run hledger import + bank.csv and only new transactions will be imported. (import is idem- potent.) - Since the items being read (CSV records, eg) often do not come with - unique identifiers, hledger detects new transactions by date, assuming + Since the items being read (CSV records, eg) often do not come with + unique identifiers, hledger detects new transactions by date, assuming that: 1. new items always have the newest dates 2. item dates do not change across reads - 3. and items with the same date remain in the same relative order + 3. and items with the same date remain in the same relative order across reads. - These are often true of CSV files representing transactions, or true - enough so that it works pretty well in practice. 1 is important, but + These are often true of CSV files representing transactions, or true + enough so that it works pretty well in practice. 1 is important, but violations of 2 and 3 amongst the old transactions won't matter (and if - you import often, the new transactions will be few, so less likely to + you import often, the new transactions will be few, so less likely to be the ones affected). - hledger remembers the latest date processed in each input file by sav- + hledger remembers the latest date processed in each input file by sav- ing a hidden ".latest" state file in the same directory. Eg when read- - ing finance/bank.csv, it will look for and update the finance/.lat- - est.bank.csv state file. The format is simple: one or more lines con- - taining the same ISO-format date (YYYY-MM-DD), meaning "I have pro- - cessed transactions up to this date, and this many of them on that + ing finance/bank.csv, it will look for and update the finance/.lat- + est.bank.csv state file. The format is simple: one or more lines con- + taining the same ISO-format date (YYYY-MM-DD), meaning "I have pro- + cessed transactions up to this date, and this many of them on that date." Normally you won't see or manipulate these state files yourself. - But if needed, you can delete them to reset the state (making all - transactions "new"), or you can construct them to "catch up" to a cer- + But if needed, you can delete them to reset the state (making all + transactions "new"), or you can construct them to "catch up" to a cer- tain date. - Note deduplication (and updating of state files) can also be done by + Note deduplication (and updating of state files) can also be done by print --new, but this is less often used. Import testing - With --dry-run, the transactions that will be imported are printed to + With --dry-run, the transactions that will be imported are printed to the terminal, without updating your journal or state files. The output - is valid journal format, like the print command, so you can re-parse - it. Eg, to see any importable transactions which CSV rules have not + is valid journal format, like the print command, so you can re-parse + it. Eg, to see any importable transactions which CSV rules have not categorised: $ hledger import --dry bank.csv | hledger -f- -I print unknown @@ -7606,17 +7730,17 @@ PART 4: COMMANDS do a --dry-run first and fix any problems before the real import. Importing balance assignments - Entries added by import will have their posting amounts made explicit - (like hledger print -x). This means that any balance assignments in - imported files must be evaluated; but, imported files don't get to see - the main file's account balances. As a result, importing entries with + Entries added by import will have their posting amounts made explicit + (like hledger print -x). This means that any balance assignments in + imported files must be evaluated; but, imported files don't get to see + the main file's account balances. As a result, importing entries with balance assignments (eg from an institution that provides only balances - and not posting amounts) will probably generate incorrect posting + and not posting amounts) will probably generate incorrect posting amounts. To avoid this problem, use print instead of import: $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE - (If you think import should leave amounts implicit like print does, + (If you think import should leave amounts implicit like print does, please test it and send a pull request.) Commodity display styles @@ -7626,13 +7750,13 @@ PART 4: COMMANDS incomestatement (is) - This command displays an income statement, showing revenues and - expenses during one or more periods. Amounts are shown with normal - positive sign, as in conventional financial statements. + This command displays an income statement, showing revenues and ex- + penses during one or more periods. Amounts are shown with normal posi- + tive sign, as in conventional financial statements. - This report shows accounts declared with the Revenue or Expense type - (see account types). Or if no such accounts are declared, it shows - top-level accounts named revenue or income or expense (case insensi- + This report shows accounts declared with the Revenue or Expense type + (see account types). Or if no such accounts are declared, it shows + top-level accounts named revenue or income or expense (case insensi- tive, plurals allowed) and their subaccounts. Example: @@ -7659,21 +7783,21 @@ PART 4: COMMANDS 0 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. + ports many of that command's features, such as multi-period reports. It is similar to hledger balance '(revenues|income)' expenses, but with - smarter account detection, and revenues/income displayed with their + smarter account detection, and revenues/income displayed with their sign flipped. - This command also supports the output destination and output format - options The output formats supported are txt, csv, html, and (experi- - mental) json. + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, html, and (experimen- + tal) json. notes List the unique notes that appear in transactions. - This command lists the unique notes that appear in transactions, in - alphabetic order. You can add a query to select a subset of transac- - tions. The note is the part of the transaction description after a | + This command lists the unique notes that appear in transactions, in al- + phabetic order. You can add a query to select a subset of transac- + tions. The note is the part of the transaction description after a | character (or if there is no |, the whole description). Example: @@ -7685,14 +7809,14 @@ PART 4: COMMANDS payees List the unique payee/payer names that appear in transactions. - This command lists unique payee/payer names which have been declared - with payee directives (--declared), used in transaction descriptions + This command lists unique payee/payer names which have been declared + with payee directives (--declared), used in transaction descriptions (--used), or both (the default). - The payee/payer is the part of the transaction description before a | + The payee/payer is the part of the transaction description before a | character (or if there is no |, the whole description). - You can add query arguments to select a subset of transactions. This + You can add query arguments to select a subset of transactions. This implies --used. Example: @@ -7703,10 +7827,10 @@ PART 4: COMMANDS Person A prices - Print market price directives from the journal. With --infer-market- - prices, generate additional market prices from costs. With --infer- - reverse-prices, also generate market prices by inverting known prices. - Prices can be filtered by a query. Price amounts are displayed with + Print market price directives from the journal. With --infer-market- + prices, generate additional market prices from costs. With --infer-re- + verse-prices, also generate market prices by inverting known prices. + Prices can be filtered by a query. Price amounts are displayed with their full precision. print @@ -7715,18 +7839,18 @@ PART 4: COMMANDS The print command displays full journal entries (transactions) from the journal file, sorted by date (or with --date2, by secondary date). - Amounts are shown mostly normalised to commodity display style, eg the - placement of commodity symbols will be consistent. All of their deci- + Amounts are shown mostly normalised to commodity display style, eg the + placement of commodity symbols will be consistent. All of their deci- mal places are shown, as in the original journal entry (with one alter- ation: in some cases trailing zeroes are added.) Amounts are shown right-aligned within each transaction (but not across all transactions). - Directives and inter-transaction comments are not shown, currently. + Directives and inter-transaction comments are not shown, currently. This means the print command is somewhat lossy, and if you are using it - to reformat your journal you should take care to also copy over the - directives and file-level comments. + to reformat your journal you should take care to also copy over the di- + rectives and file-level comments. Eg: @@ -7752,7 +7876,7 @@ PART 4: COMMANDS liabilities:debts $1 assets:bank:checking $-1 - print's output is usually a valid hledger journal, and you can process + print's output is usually a valid hledger journal, and you can process it again with a second hledger command. This can be useful for certain kinds of search, eg: @@ -7762,7 +7886,7 @@ PART 4: COMMANDS There are some situations where print's output can become unparseable: - o Valuation affects posting amounts but not balance assertion or bal- + o Valuation affects posting amounts but not balance assertion or bal- ance assignment amounts, potentially causing those to fail. o Auto postings can generate postings with too many missing amounts. @@ -7771,33 +7895,33 @@ PART 4: COMMANDS Normally, the journal entry's explicit or implicit amount style is pre- served. For example, when an amount is omitted in the journal, it will - not appear in the output. Similarly, when a cost is implied but not - written, it will not appear in the output. You can use the - -x/--explicit flag to make all amounts and costs explicit, which can be - useful for troubleshooting or for making your journal more readable and - robust against data entry errors. -x is also implied by using any of + not appear in the output. Similarly, when a cost is implied but not + written, it will not appear in the output. You can use the -x/--ex- + plicit flag to make all amounts and costs explicit, which can be useful + for troubleshooting or for making your journal more readable and robust + against data entry errors. -x is also implied by using any of -B,-V,-X,--value. - Note, -x/--explicit will cause postings with a multi-commodity amount - (these can arise when a multi-commodity transaction has an implicit - amount) to be split into multiple single-commodity postings, keeping + Note, -x/--explicit will cause postings with a multi-commodity amount + (these can arise when a multi-commodity transaction has an implicit + amount) to be split into multiple single-commodity postings, keeping the output parseable. - With -B/--cost, amounts with costs are converted to cost using that + With -B/--cost, amounts with costs are converted to cost using that price. This can be used for troubleshooting. - With -m DESC/--match=DESC, print does a fuzzy search for one recent - transaction whose description is most similar to DESC. DESC should - contain at least two characters. If there is no similar-enough match, - no transaction will be shown and the program exit code will be non- + With -m DESC/--match=DESC, print does a fuzzy search for one recent + transaction whose description is most similar to DESC. DESC should + contain at least two characters. If there is no similar-enough match, + no transaction will be shown and the program exit code will be non- zero. - With --new, hledger prints only transactions it has not seen on a pre- - vious run. This uses the same deduplication system as the import com- + With --new, hledger prints only transactions it has not seen on a pre- + vious run. This uses the same deduplication system as the import com- mand. (See import's docs for details.) - This command also supports the output destination and output format - options The output formats supported are txt, csv, and (experimental) + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, and (experimental) json and sql. Here's an example of print's CSV output: @@ -7816,20 +7940,20 @@ PART 4: COMMANDS "5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","","" "5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","","" - o There is one CSV record per posting, with the parent transaction's + o There is one CSV record per posting, with the parent transaction's fields repeated. o The "txnidx" (transaction index) field shows which postings belong to - the same transaction. (This number might change if transactions are - reordered within the file, files are parsed/included in a different + the same transaction. (This number might change if transactions are + reordered within the file, files are parsed/included in a different order, etc.) - o The amount is separated into "commodity" (the symbol) and "amount" + o The amount is separated into "commodity" (the symbol) and "amount" (numeric quantity) fields. o The numeric amount is repeated in either the "credit" or "debit" col- - umn, for convenience. (Those names are not accurate in the account- - ing sense; it just puts negative amounts under credit and zero or + umn, for convenience. (Those names are not accurate in the account- + ing sense; it just puts negative amounts under credit and zero or greater amounts under debit.) register @@ -7838,14 +7962,14 @@ PART 4: COMMANDS Show postings and their running total. The register command displays matched postings, across all accounts, in - date order, with their running total or running historical balance. - (See also the aregister command, which shows matched transactions in a + date order, with their running total or running historical balance. + (See also the aregister command, which shows matched transactions in a specific account.) register normally shows line per posting, but note that multi-commodity amounts will occupy multiple lines (one line per commodity). - It is typically used with a query selecting a particular account, to + It is typically used with a query selecting a particular account, to see that account's activity: $ hledger register checking @@ -7856,14 +7980,14 @@ PART 4: COMMANDS With --date2, it shows and sorts by secondary date instead. - For performance reasons, column widths are chosen based on the first - 1000 lines; this means unusually wide values in later lines can cause - visual discontinuities as column widths are adjusted. If you want to - ensure perfect alignment, at the cost of more time and memory, use the + For performance reasons, column widths are chosen based on the first + 1000 lines; this means unusually wide values in later lines can cause + visual discontinuities as column widths are adjusted. If you want to + ensure perfect alignment, at the cost of more time and memory, use the --align-all flag. - The --historical/-H flag adds the balance from any undisplayed prior - postings to the running total. This is useful when you want to see + The --historical/-H flag adds the balance from any undisplayed prior + postings to the running total. This is useful when you want to see only recent activity, with a historically accurate running balance: $ hledger register checking -b 2008/6 --historical @@ -7873,30 +7997,30 @@ PART 4: COMMANDS The --depth option limits the amount of sub-account detail displayed. - The --average/-A flag shows the running average posting amount instead + The --average/-A flag shows the running average posting amount instead of the running total (so, the final number displayed is the average for - the whole report period). This flag implies --empty (see below). It - is affected by --historical. It works best when showing just one - account and one commodity. + the whole report period). This flag implies --empty (see below). It + is affected by --historical. It works best when showing just one ac- + count and one commodity. - The --related/-r flag shows the other postings in the transactions of + The --related/-r flag shows the other postings in the transactions of the postings which would normally be shown. - The --invert flag negates all amounts. For example, it can be used on + The --invert flag negates all amounts. For example, it can be used on an income account where amounts are normally displayed as negative num- - bers. It's also useful to show postings on the checking account - together with the related account: + bers. It's also useful to show postings on the checking account to- + gether with the related account: $ hledger register --related --invert assets:checking - With a reporting interval, register shows summary postings, one per - interval, aggregating the postings to each account: + With a reporting interval, register shows summary postings, one per in- + terval, aggregating the postings to each account: $ hledger register --monthly income 2008/01 income:salary $-1 $-1 2008/06 income:gifts $-1 $-2 - Periods with no activity, and summary postings with a zero amount, are + Periods with no activity, and summary postings with a zero amount, are not shown by default; use the --empty/-E flag to see them: $ hledger register --monthly income -E @@ -7913,33 +8037,33 @@ PART 4: COMMANDS 2008/11 0 $-2 2008/12 0 $-2 - Often, you'll want to see just one line per interval. The --depth - option helps with this, causing subaccounts to be aggregated: + Often, you'll want to see just one line per interval. The --depth op- + tion helps with this, causing subaccounts to be aggregated: $ hledger register --monthly assets --depth 1h 2008/01 assets $1 $1 2008/06 assets $-1 0 2008/12 assets $-1 $-1 - Note when using report intervals, if you specify start/end dates these - will be adjusted outward if necessary to contain a whole number of - intervals. This ensures that the first and last intervals are full + Note when using report intervals, if you specify start/end dates these + will be adjusted outward if necessary to contain a whole number of in- + tervals. This ensures that the first and last intervals are full length and comparable to the others in the report. - With -m DESC/--match=DESC, register does a fuzzy search for one recent + With -m DESC/--match=DESC, register does a fuzzy search for one recent posting whose description is most similar to DESC. DESC should contain at least two characters. If there is no similar-enough match, no post- ing will be shown and the program exit code will be non-zero. Custom register output - register uses the full terminal width by default, except on windows. - You can override this by setting the COLUMNS environment variable (not + register uses the full terminal width by default, except on windows. + You can override this by setting the COLUMNS environment variable (not a bash shell variable) or by using the --width/-w option. - The description and account columns normally share the space equally - (about half of (width - 40) each). You can adjust this by adding a - description width as part of --width's argument, comma-separated: - --width W,D . Here's a diagram (won't display correctly in --help): + The description and account columns normally share the space equally + (about half of (width - 40) each). You can adjust this by adding a de- + scription width as part of --width's argument, comma-separated: --width + W,D . Here's a diagram (won't display correctly in --help): <--------------------------------- width (W) ----------------------------------> date (10) description (D) account (W-41-D) amount (12) balance (12) @@ -7954,19 +8078,19 @@ PART 4: COMMANDS $ hledger reg -w 100,40 # set overall width 100, description width 40 $ hledger reg -w $COLUMNS,40 # use terminal width, & description width 40 - This command also supports the output destination and output format - options The output formats supported are txt, csv, and (experimental) + This command also supports the output destination and output format op- + tions The output formats supported are txt, csv, and (experimental) json. rewrite Print all transactions, rewriting the postings of matched transactions. - For now the only rewrite available is adding new postings, like print + For now the only rewrite available is adding new postings, like print --auto. This is a start at a generic rewriter of transaction entries. It reads - the default journal and prints the transactions, like print, but adds + the default journal and prints the transactions, like print, but adds one or more specified postings to any transactions matching QUERY. The - posting amounts can be fixed, or a multiplier of the existing transac- + posting amounts can be fixed, or a multiplier of the existing transac- tion's first posting amount. Examples: @@ -7982,7 +8106,7 @@ PART 4: 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: @@ -7992,16 +8116,16 @@ PART 4: COMMANDS $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"' $ hledger rewrite -- ^income --add-posting '(budget:foreign currency) *0.25 JPY; diversify' - Argument for --add-posting option is a usual posting of transaction - with an exception for amount specification. More precisely, you can + Argument for --add-posting option is a usual posting of transaction + with an exception for amount specification. More precisely, you can use '*' (star symbol) before the amount to indicate that that this is a - factor for an amount of original matched posting. If the amount - includes a commodity name, the new posting amount will be in the new - commodity; otherwise, it will be in the matched posting amount's com- - modity. + factor for an amount of original matched posting. If the amount in- + cludes a commodity name, the new posting amount will be in the new com- + modity; otherwise, it will be in the matched posting amount's commod- + ity. Re-write rules in a file - During the run this tool will execute so called "Automated Transac- + 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. @@ -8016,7 +8140,7 @@ PART 4: 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. @@ -8029,12 +8153,12 @@ PART 4: 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' @@ -8058,10 +8182,10 @@ PART 4: 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: @@ -8069,14 +8193,14 @@ PART 4: 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. @@ -8086,9 +8210,9 @@ PART 4: COMMANDS Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on your investments. - At a minimum, you need to supply a query (which could be just an - account name) to select your investment(s) with --inv, and another - query to identify your profit and loss transactions with --pnl. + 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 @@ -8106,8 +8230,8 @@ PART 4: COMMANDS 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 - becomes negative at some point in time. + Possible causes: IRR is huge (>1000000%), balance of investment be- + comes negative at some point in time. o Error (SearchFailed): Failed to find solution for Internal Rate of Return (IRR). Either search does not converge to a solution, or con- @@ -8145,8 +8269,8 @@ PART 4: COMMANDS 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 - assets, or otherwise converting between your investment commodity and + o "Cash flow" is depositing or withdrawing money, buying or selling as- + sets, or otherwise converting between your investment commodity and any other commodity. Example: 2019-01-01 Investing in Snake Oil @@ -8165,8 +8289,8 @@ PART 4: COMMANDS 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 - return. + and loss" postings will be considered as part of your investment re- + turn. Example: if you use --inv snake --pnl equity:unrealized, then postings in the example below would be classifed as: @@ -8201,8 +8325,8 @@ PART 4: COMMANDS would be smaller (in absolute numbers), and will be a smaller percent- age of your initial investment, and if you are adding to your invest- ment, you will receive bigger absolute gains (but probably at the same - rate of return). IRR is a way to compute rate of return for each - period between in-flow or out-flow of money, and then combine them in a + rate of return). IRR is a way to compute rate of return for each pe- + riod between in-flow or out-flow of money, and then combine them in a way that gives you a compound annual rate of return that investment is expected to generate. @@ -8330,7 +8454,6 @@ PART 4: COMMANDS 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 hledger. @@ -8355,8 +8478,8 @@ PART 5: COMMON TASKS Constructing command lines hledger has a flexible command line interface. We strive to keep it - simple and ergonomic, but if you run into one of the sharp edges - described in OPTIONS, here are some tips that might help: + 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 common options there too: hledger CMD OPTS ARGS) @@ -8372,7 +8495,7 @@ PART 5: COMMON TASKS 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 @@ -8380,9 +8503,9 @@ PART 5: COMMON TASKS 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. + You can override this by setting the LEDGER_FILE environment variable. 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 + and to start a new file each year. So you could do something like this: $ mkdir ~/finance @@ -8406,20 +8529,20 @@ PART 5: COMMON TASKS Market prices : 0 () 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 - two accounts, like your checking account or cash wallet; and pick a - recent starting date, like today or the start of the week. You can - always come back later and add more accounts and older transactions, eg + 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 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: 2020-01-01 * opening balances @@ -8429,19 +8552,19 @@ PART 5: COMMON TASKS 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 @@ -8478,18 +8601,18 @@ PART 5: COMMON TASKS Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2020-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' 2020.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: 2020/1/10 * gift received @@ -8505,22 +8628,22 @@ PART 5: COMMON TASKS 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 - already-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: @@ -8530,26 +8653,26 @@ PART 5: COMMON TASKS 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 - reported by hledger reg checking -C. This will be easier if you - generally record transaction dates quite similar to your bank's - clearing dates. + 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- - updating register while you edit the journal: hledger-ui --watch --reg- - ister checking -C + 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 2020-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' 2020.journal @@ -8621,7 +8744,7 @@ PART 5: COMMON TASKS -------------------- 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 @@ -8631,7 +8754,7 @@ PART 5: COMMON TASKS -------------------- $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 @@ -8698,18 +8821,79 @@ PART 5: COMMON TASKS 2020-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 + (https://hledger.org/support). + Some known issues and limitations: + + 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 + 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 + 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 + 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- + 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 + window. + + 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 + variable. Eg on unix, the command env | grep LEDGER_FILE should show + 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 + 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 + 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 + 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: + Here's one common way to configure this permanently for your shell: + + $ echo "export LANG=en_US.utf8" >>~/.profile + # 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. + See hledger and Ledger for full details. -REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger chat or - hledger mail list) AUTHORS @@ -8730,4 +8914,4 @@ SEE ALSO -hledger-1.29.99 April 2023 HLEDGER(1) +hledger-1.29.99 May 2023 HLEDGER(1)