From 6bf2afe80c9ff6ab9037156b716b2404e9479903 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 27 Mar 2023 11:07:56 -1000 Subject: [PATCH] ;doc: update manuals --- hledger-ui/hledger-ui.1 | 12 + hledger-ui/hledger-ui.info | 39 +- hledger-ui/hledger-ui.txt | 87 +- hledger/hledger.1 | 57 +- hledger/hledger.info | 536 ++++++------ hledger/hledger.txt | 1625 ++++++++++++++++++------------------ 6 files changed, 1203 insertions(+), 1153 deletions(-) diff --git a/hledger-ui/hledger-ui.1 b/hledger-ui/hledger-ui.1 index b703da8d3..6b9a0366f 100644 --- a/hledger-ui/hledger-ui.1 +++ b/hledger-ui/hledger-ui.1 @@ -471,6 +471,18 @@ They will vary depending on which account register you came from The #N number preceding them is the transaction\[aq]s position within the complete unfiltered journal, which is a more stable id (at least until the next reload). +.PP +On this screen (and the register screen), the \f[V]E\f[R] key will open +your text editor with the cursor positioned at the current transaction +if possible. +.PP +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 \f[V]E\f[R] key, currently you +must: - press \f[V]E\f[R], edit and save the file, then exit the editor, +returning to hledger-ui - press \f[V]g\f[R] to reload the file (or use +\f[V]-w/--watch\f[R] mode) - press \f[V]LEFT\f[R] then \f[V]RIGHT\f[R] +to exit and re-enter the transaction screen. .SS Error .PP This screen will appear if there is a problem, such as a parse error, diff --git a/hledger-ui/hledger-ui.info b/hledger-ui/hledger-ui.info index 197cb62e5..fee424be5 100644 --- a/hledger-ui/hledger-ui.info +++ b/hledger-ui/hledger-ui.info @@ -519,6 +519,17 @@ preceding them is the transaction’s position within the complete unfiltered journal, 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 +possible. + + 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-enter the transaction screen. +  File: hledger-ui.info, Node: Error, Prev: Transaction, Up: SCREENS @@ -692,20 +703,20 @@ Node: Register14910 Ref: #register15034 Node: Transaction17046 Ref: #transaction17169 -Node: Error18053 -Ref: #error18147 -Node: TIPS18391 -Ref: #tips18490 -Node: Watch mode18532 -Ref: #watch-mode18639 -Node: Debug output20127 -Ref: #debug-output20238 -Node: ENVIRONMENT20458 -Ref: #environment20569 -Node: FILES21992 -Ref: #files22091 -Node: BUGS22351 -Ref: #bugs22428 +Node: Error18628 +Ref: #error18722 +Node: TIPS18966 +Ref: #tips19065 +Node: Watch mode19107 +Ref: #watch-mode19214 +Node: Debug output20702 +Ref: #debug-output20813 +Node: ENVIRONMENT21033 +Ref: #environment21144 +Node: FILES22567 +Ref: #files22666 +Node: BUGS22926 +Ref: #bugs23003  End Tag Table diff --git a/hledger-ui/hledger-ui.txt b/hledger-ui/hledger-ui.txt index b4132149c..540168242 100644 --- a/hledger-ui/hledger-ui.txt +++ b/hledger-ui/hledger-ui.txt @@ -422,48 +422,59 @@ SCREENS 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- + 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 + 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- + 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: - Changes might not be detected with certain editors, possibly including - Jetbrains IDEs, gedit, other Gnome applications; or on certain unusual + 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, + ing g in the hledger-ui window. (Or see #1617 for another workaround, and let us know if it works for you.) - 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) + 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). Debug output - You can add --debug[=N] to the command line to log debug output. This - will be logged to the file hledger-ui.log in the current directory. N + You can add --debug[=N] to the command line to log debug output. This + 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). ENVIRONMENT @@ -473,17 +484,17 @@ ENVIRONMENT 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 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 + 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 + 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: @@ -494,20 +505,20 @@ ENVIRONMENT 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- + 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- + 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 + 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. BUGS @@ -516,13 +527,13 @@ BUGS -V affects only the accounts screen. 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 + which may cause a noticeable pause with large files. Also there is no visual indication that this is in progress. - --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- + --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. @@ -533,7 +544,7 @@ BUGS REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger chat or + Report bugs at http://bugs.hledger.org (or on the #hledger chat or hledger mail list) diff --git a/hledger/hledger.1 b/hledger/hledger.1 index d48d19cf2..40551e07e 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -6576,8 +6576,8 @@ A special query term used automatically in hledger-web only: tells hledger-web to show the transaction register for an account.) .SS Combining query terms .PP -When given multiple query terms, most commands select things which -match: +When given multiple space-separated query terms, most commands select +things which match: .IP \[bu] 2 any of the description terms AND .IP \[bu] 2 @@ -6597,32 +6597,35 @@ have no postings matching any of the negative account terms AND .IP \[bu] 2 match all the other terms. .PP -Although these fixed rules are enough for many needs, we do not support -full boolean expressions (#203), (and you should not write AND or OR in -your queries). -This makes certain queries hard to express, but here are some tricks -that can help: -.IP "1." 3 -Use a doubled \f[V]not:\f[R] prefix. -Eg, to print only the food expenses paid with cash: -.RS 4 -.IP -.nf -\f[C] -$ hledger print food not:not:cash -\f[R] -.fi +We also support more complex boolean queries with the \[aq]expr:\[aq] +prefix. +This allows one to combine queries using one of three operators: AND, +OR, and NOT, where NOT is different syntax for \[aq]not:\[aq]. +.PP +Examples of such queries are: +.IP \[bu] 2 +Match transactions with \[aq]cool\[aq] in the description AND with the +\[aq]A\[aq] tag +.RS 2 +.PP +\f[V]expr:\[dq]desc:cool AND tag:A\[dq]\f[R] .RE -.IP "2." 3 -Or pre-filter the transactions with \f[V]print\f[R], piping the result -into a second hledger command (with balance assertions disabled): -.RS 4 -.IP -.nf -\f[C] -$ hledger print cash | hledger -f- -I balance food -\f[R] -.fi +.IP \[bu] 2 +Match transactions NOT to the \[aq]expenses:food\[aq] account OR with +the \[aq]A\[aq] tag +.RS 2 +.PP +\f[V]expr:\[dq]NOT expenses:food OR tag:A\[dq]\f[R] +.RE +.IP \[bu] 2 +Match transactions NOT involving the \[aq]expenses:food\[aq] account OR +with the \[aq]A\[aq] tag AND involving the \[aq]expenses:drink\[aq] +account. +(the AND is implicitly added by space-separation, following the rules +above) +.RS 2 +.PP +\f[V]expr:\[dq]expenses:food OR (tag:A expenses:drink)\[dq]\f[R] .RE .SS Queries and command options .PP diff --git a/hledger/hledger.info b/hledger/hledger.info index bac79d6ad..e1ae2533c 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -5689,8 +5689,8 @@ File: hledger.info, Node: Combining query terms, Next: Queries and command opt 17.2 Combining query terms ========================== -When given multiple query terms, most commands select things which -match: +When given multiple space-separated query terms, most commands select +things which match: • any of the description terms AND • any of the account terms AND @@ -5704,20 +5704,28 @@ match: • have no postings matching any of the negative account terms AND • match all the other terms. - Although these fixed rules are enough for many needs, we do not -support full boolean expressions (#203), (and you should not write AND -or OR in your queries). This makes certain queries hard to express, but -here are some tricks that can help: + We also support more complex boolean queries with the ’expr:’ prefix. +This allows one to combine queries using one of three operators: AND, +OR, and NOT, where NOT is different syntax for ’not:’. - 1. Use a doubled ‘not:’ prefix. Eg, to print only the food expenses - paid with cash: + Examples of such queries are: - $ hledger print food not:not:cash + • Match transactions with ’cool’ in the description AND with the ’A’ + tag - 2. Or pre-filter the transactions with ‘print’, piping the result into - a second hledger command (with balance assertions disabled): + ‘expr:"desc:cool AND tag:A"’ - $ hledger print cash | hledger -f- -I balance food + • Match transactions NOT to the ’expenses:food’ account OR with the + ’A’ tag + + ‘expr:"NOT expenses:food OR tag:A"’ + + • Match transactions NOT involving the ’expenses:food’ account OR + with the ’A’ tag AND involving the ’expenses:drink’ account. (the + AND is implicitly added by space-separation, following the rules + above) + + ‘expr:"expenses:food OR (tag:A expenses:drink)"’  File: hledger.info, Node: Queries and command options, Next: Queries and valuation, Prev: Combining query terms, Up: Queries @@ -10739,258 +10747,258 @@ Node: Query types200808 Ref: #query-types200929 Node: Combining query terms204269 Ref: #combining-query-terms204446 -Node: Queries and command options205544 -Ref: #queries-and-command-options205743 -Node: Queries and valuation206008 -Ref: #queries-and-valuation206203 -Node: Querying with account aliases206442 -Ref: #querying-with-account-aliases206653 -Node: Querying with cost or value206795 -Ref: #querying-with-cost-or-value206972 -Node: Pivoting207281 -Ref: #pivoting207395 -Node: Generating data208883 -Ref: #generating-data209015 -Node: Forecasting209513 -Ref: #forecasting209638 -Node: Budgeting212525 -Ref: #budgeting212645 -Node: Cost reporting212916 -Ref: #cost-reporting213044 -Node: -B Convert to cost214159 -Ref: #b-convert-to-cost214315 -Node: Equity conversion postings215723 -Ref: #equity-conversion-postings215937 -Node: Inferring equity postings from cost216832 -Ref: #inferring-equity-postings-from-cost217081 -Node: Inferring cost from equity postings217900 -Ref: #inferring-cost-from-equity-postings218148 -Node: When to infer cost/equity219957 -Ref: #when-to-infer-costequity220175 -Node: How to record conversions220583 -Ref: #how-to-record-conversions220775 -Node: Conversion with implicit cost221066 -Ref: #conversion-with-implicit-cost221271 -Node: Conversion with explicit cost222176 -Ref: #conversion-with-explicit-cost222421 -Node: Conversion with equity postings222848 -Ref: #conversion-with-equity-postings223117 -Node: Conversion with equity postings and explicit cost223954 -Ref: #conversion-with-equity-postings-and-explicit-cost224221 -Node: Cost tips224695 -Ref: #cost-tips224821 -Node: Valuation225557 -Ref: #valuation225681 -Node: -V Value226467 -Ref: #v-value226593 -Node: -X Value in specified commodity226792 -Ref: #x-value-in-specified-commodity226987 -Node: Valuation date227144 -Ref: #valuation-date227315 -Node: Finding market price227754 -Ref: #finding-market-price227959 -Node: --infer-market-prices market prices from transactions229139 -Ref: #infer-market-prices-market-prices-from-transactions229417 -Node: Valuation commodity232263 -Ref: #valuation-commodity232476 -Node: Simple valuation examples233721 -Ref: #simple-valuation-examples233919 -Node: --value Flexible valuation234582 -Ref: #value-flexible-valuation234788 -Node: More valuation examples236474 -Ref: #more-valuation-examples236683 -Node: Interaction of valuation and queries238694 -Ref: #interaction-of-valuation-and-queries238935 -Node: Effect of valuation on reports239415 -Ref: #effect-of-valuation-on-reports239612 -Node: PART 4 COMMANDS247371 -Ref: #part-4-commands247514 -Node: Commands overview247893 -Ref: #commands-overview248027 -Node: DATA ENTRY248206 -Ref: #data-entry248330 -Node: DATA CREATION248533 -Ref: #data-creation248687 -Node: DATA MANAGEMENT248811 -Ref: #data-management248976 -Node: REPORTS FINANCIAL249101 -Ref: #reports-financial249276 -Node: REPORTS VERSATILE249591 -Ref: #reports-versatile249764 -Node: REPORTS BASIC250025 -Ref: #reports-basic250177 -Node: HELP250710 -Ref: #help250832 -Node: ADD-ONS250946 -Ref: #add-ons251052 -Node: accounts251649 -Ref: #accounts251782 -Node: activity253757 -Ref: #activity253876 -Node: add254250 -Ref: #add254360 -Node: aregister257221 -Ref: #aregister257342 -Node: aregister and custom posting dates260318 -Ref: #aregister-and-custom-posting-dates260484 -Node: balance261052 -Ref: #balance261178 -Node: balance features262183 -Ref: #balance-features262323 -Node: Simple balance report264453 -Ref: #simple-balance-report264638 -Node: Balance report line format266283 -Ref: #balance-report-line-format266485 -Node: Filtered balance report268735 -Ref: #filtered-balance-report268927 -Node: List or tree mode269254 -Ref: #list-or-tree-mode269422 -Node: Depth limiting270797 -Ref: #depth-limiting270963 -Node: Dropping top-level accounts271580 -Ref: #dropping-top-level-accounts271780 -Node: Showing declared accounts272094 -Ref: #showing-declared-accounts272293 -Node: Sorting by amount272834 -Ref: #sorting-by-amount273001 -Node: Percentages273691 -Ref: #percentages273850 -Node: Multi-period balance report274420 -Ref: #multi-period-balance-report274620 -Node: Balance change end balance277013 -Ref: #balance-change-end-balance277222 -Node: Balance report types278670 -Ref: #balance-report-types278851 -Node: Calculation type279367 -Ref: #calculation-type279522 -Node: Accumulation type280053 -Ref: #accumulation-type280233 -Node: Valuation type281161 -Ref: #valuation-type281349 -Node: Combining balance report types282416 -Ref: #combining-balance-report-types282610 -Node: Budget report284514 -Ref: #budget-report284666 -Node: Budget report start date290400 -Ref: #budget-report-start-date290578 -Node: Budgets and subaccounts291940 -Ref: #budgets-and-subaccounts292147 -Node: Selecting budget goals295633 -Ref: #selecting-budget-goals295832 -Node: Budget vs forecast296879 -Ref: #budget-vs-forecast297038 -Node: Data layout298738 -Ref: #data-layout298888 -Node: Useful balance reports306829 -Ref: #useful-balance-reports306979 -Node: balancesheet308132 -Ref: #balancesheet308277 -Node: balancesheetequity309643 -Ref: #balancesheetequity309801 -Node: cashflow311244 -Ref: #cashflow311375 -Node: check312861 -Ref: #check312975 -Node: Basic checks313781 -Ref: #basic-checks313901 -Node: Strict checks314439 -Ref: #strict-checks314582 -Node: Other checks315023 -Ref: #other-checks315165 -Node: Custom checks315742 -Ref: #custom-checks315899 -Node: More about specific checks316320 -Ref: #more-about-specific-checks316482 -Node: close317214 -Ref: #close317325 -Node: close and costs319711 -Ref: #close-and-costs319855 -Node: close and balance assertions320144 -Ref: #close-and-balance-assertions320346 -Node: Example retain earnings321517 -Ref: #example-retain-earnings321734 -Node: Example migrate balances to a new file322092 -Ref: #example-migrate-balances-to-a-new-file322357 -Node: Example excluding closing/opening transactions322910 -Ref: #example-excluding-closingopening-transactions323159 -Node: codes324337 -Ref: #codes324454 -Node: commodities325330 -Ref: #commodities325458 -Node: demo325528 -Ref: #demo325649 -Node: descriptions326505 -Ref: #descriptions326635 -Node: diff326926 -Ref: #diff327041 -Node: files328087 -Ref: #files328196 -Node: help328337 -Ref: #help-1328446 -Node: import329436 -Ref: #import329559 -Node: Deduplication330667 -Ref: #deduplication330792 -Node: Import testing332714 -Ref: #import-testing332879 -Node: Importing balance assignments333730 -Ref: #importing-balance-assignments333936 -Node: Commodity display styles334593 -Ref: #commodity-display-styles334766 -Node: incomestatement334895 -Ref: #incomestatement335037 -Node: notes336404 -Ref: #notes336526 -Node: payees336888 -Ref: #payees337003 -Node: prices337528 -Ref: #prices337643 -Node: print337945 -Ref: #print338060 -Node: register343506 -Ref: #register343628 -Node: Custom register output348737 -Ref: #custom-register-output348868 -Node: rewrite350243 -Ref: #rewrite350361 -Node: Re-write rules in a file352273 -Ref: #re-write-rules-in-a-file352436 -Node: Diff output format353589 -Ref: #diff-output-format353772 -Node: rewrite vs print --auto354884 -Ref: #rewrite-vs.-print---auto355046 -Node: roi355620 -Ref: #roi355727 -Node: Spaces and special characters in --inv and --pnl357488 -Ref: #spaces-and-special-characters-in---inv-and---pnl357736 -Node: Semantics of --inv and --pnl358234 -Ref: #semantics-of---inv-and---pnl358481 -Node: IRR and TWR explained360359 -Ref: #irr-and-twr-explained360519 -Node: stats363631 -Ref: #stats363739 -Node: tags365136 -Ref: #tags-1365243 -Node: test366260 -Ref: #test366353 -Node: PART 5 COMMON TASKS367103 -Ref: #part-5-common-tasks367236 -Node: Getting help367510 -Ref: #getting-help367651 -Node: Constructing command lines368415 -Ref: #constructing-command-lines368616 -Node: Starting a journal file369297 -Ref: #starting-a-journal-file369504 -Node: Setting opening balances370702 -Ref: #setting-opening-balances370907 -Node: Recording transactions374060 -Ref: #recording-transactions374249 -Node: Reconciling374805 -Ref: #reconciling374957 -Node: Reporting377270 -Ref: #reporting377419 -Node: Migrating to a new file381408 -Ref: #migrating-to-a-new-file381565 +Node: Queries and command options205784 +Ref: #queries-and-command-options205983 +Node: Queries and valuation206248 +Ref: #queries-and-valuation206443 +Node: Querying with account aliases206682 +Ref: #querying-with-account-aliases206893 +Node: Querying with cost or value207035 +Ref: #querying-with-cost-or-value207212 +Node: Pivoting207521 +Ref: #pivoting207635 +Node: Generating data209123 +Ref: #generating-data209255 +Node: Forecasting209753 +Ref: #forecasting209878 +Node: Budgeting212765 +Ref: #budgeting212885 +Node: Cost reporting213156 +Ref: #cost-reporting213284 +Node: -B Convert to cost214399 +Ref: #b-convert-to-cost214555 +Node: Equity conversion postings215963 +Ref: #equity-conversion-postings216177 +Node: Inferring equity postings from cost217072 +Ref: #inferring-equity-postings-from-cost217321 +Node: Inferring cost from equity postings218140 +Ref: #inferring-cost-from-equity-postings218388 +Node: When to infer cost/equity220197 +Ref: #when-to-infer-costequity220415 +Node: How to record conversions220823 +Ref: #how-to-record-conversions221015 +Node: Conversion with implicit cost221306 +Ref: #conversion-with-implicit-cost221511 +Node: Conversion with explicit cost222416 +Ref: #conversion-with-explicit-cost222661 +Node: Conversion with equity postings223088 +Ref: #conversion-with-equity-postings223357 +Node: Conversion with equity postings and explicit cost224194 +Ref: #conversion-with-equity-postings-and-explicit-cost224461 +Node: Cost tips224935 +Ref: #cost-tips225061 +Node: Valuation225797 +Ref: #valuation225921 +Node: -V Value226707 +Ref: #v-value226833 +Node: -X Value in specified commodity227032 +Ref: #x-value-in-specified-commodity227227 +Node: Valuation date227384 +Ref: #valuation-date227555 +Node: Finding market price227994 +Ref: #finding-market-price228199 +Node: --infer-market-prices market prices from transactions229379 +Ref: #infer-market-prices-market-prices-from-transactions229657 +Node: Valuation commodity232503 +Ref: #valuation-commodity232716 +Node: Simple valuation examples233961 +Ref: #simple-valuation-examples234159 +Node: --value Flexible valuation234822 +Ref: #value-flexible-valuation235028 +Node: More valuation examples236714 +Ref: #more-valuation-examples236923 +Node: Interaction of valuation and queries238934 +Ref: #interaction-of-valuation-and-queries239175 +Node: Effect of valuation on reports239655 +Ref: #effect-of-valuation-on-reports239852 +Node: PART 4 COMMANDS247611 +Ref: #part-4-commands247754 +Node: Commands overview248133 +Ref: #commands-overview248267 +Node: DATA ENTRY248446 +Ref: #data-entry248570 +Node: DATA CREATION248773 +Ref: #data-creation248927 +Node: DATA MANAGEMENT249051 +Ref: #data-management249216 +Node: REPORTS FINANCIAL249341 +Ref: #reports-financial249516 +Node: REPORTS VERSATILE249831 +Ref: #reports-versatile250004 +Node: REPORTS BASIC250265 +Ref: #reports-basic250417 +Node: HELP250950 +Ref: #help251072 +Node: ADD-ONS251186 +Ref: #add-ons251292 +Node: accounts251889 +Ref: #accounts252022 +Node: activity253997 +Ref: #activity254116 +Node: add254490 +Ref: #add254600 +Node: aregister257461 +Ref: #aregister257582 +Node: aregister and custom posting dates260558 +Ref: #aregister-and-custom-posting-dates260724 +Node: balance261292 +Ref: #balance261418 +Node: balance features262423 +Ref: #balance-features262563 +Node: Simple balance report264693 +Ref: #simple-balance-report264878 +Node: Balance report line format266523 +Ref: #balance-report-line-format266725 +Node: Filtered balance report268975 +Ref: #filtered-balance-report269167 +Node: List or tree mode269494 +Ref: #list-or-tree-mode269662 +Node: Depth limiting271037 +Ref: #depth-limiting271203 +Node: Dropping top-level accounts271820 +Ref: #dropping-top-level-accounts272020 +Node: Showing declared accounts272334 +Ref: #showing-declared-accounts272533 +Node: Sorting by amount273074 +Ref: #sorting-by-amount273241 +Node: Percentages273931 +Ref: #percentages274090 +Node: Multi-period balance report274660 +Ref: #multi-period-balance-report274860 +Node: Balance change end balance277253 +Ref: #balance-change-end-balance277462 +Node: Balance report types278910 +Ref: #balance-report-types279091 +Node: Calculation type279607 +Ref: #calculation-type279762 +Node: Accumulation type280293 +Ref: #accumulation-type280473 +Node: Valuation type281401 +Ref: #valuation-type281589 +Node: Combining balance report types282656 +Ref: #combining-balance-report-types282850 +Node: Budget report284754 +Ref: #budget-report284906 +Node: Budget report start date290640 +Ref: #budget-report-start-date290818 +Node: Budgets and subaccounts292180 +Ref: #budgets-and-subaccounts292387 +Node: Selecting budget goals295873 +Ref: #selecting-budget-goals296072 +Node: Budget vs forecast297119 +Ref: #budget-vs-forecast297278 +Node: Data layout298978 +Ref: #data-layout299128 +Node: Useful balance reports307069 +Ref: #useful-balance-reports307219 +Node: balancesheet308372 +Ref: #balancesheet308517 +Node: balancesheetequity309883 +Ref: #balancesheetequity310041 +Node: cashflow311484 +Ref: #cashflow311615 +Node: check313101 +Ref: #check313215 +Node: Basic checks314021 +Ref: #basic-checks314141 +Node: Strict checks314679 +Ref: #strict-checks314822 +Node: Other checks315263 +Ref: #other-checks315405 +Node: Custom checks315982 +Ref: #custom-checks316139 +Node: More about specific checks316560 +Ref: #more-about-specific-checks316722 +Node: close317454 +Ref: #close317565 +Node: close and costs319951 +Ref: #close-and-costs320095 +Node: close and balance assertions320384 +Ref: #close-and-balance-assertions320586 +Node: Example retain earnings321757 +Ref: #example-retain-earnings321974 +Node: Example migrate balances to a new file322332 +Ref: #example-migrate-balances-to-a-new-file322597 +Node: Example excluding closing/opening transactions323150 +Ref: #example-excluding-closingopening-transactions323399 +Node: codes324577 +Ref: #codes324694 +Node: commodities325570 +Ref: #commodities325698 +Node: demo325768 +Ref: #demo325889 +Node: descriptions326745 +Ref: #descriptions326875 +Node: diff327166 +Ref: #diff327281 +Node: files328327 +Ref: #files328436 +Node: help328577 +Ref: #help-1328686 +Node: import329676 +Ref: #import329799 +Node: Deduplication330907 +Ref: #deduplication331032 +Node: Import testing332954 +Ref: #import-testing333119 +Node: Importing balance assignments333970 +Ref: #importing-balance-assignments334176 +Node: Commodity display styles334833 +Ref: #commodity-display-styles335006 +Node: incomestatement335135 +Ref: #incomestatement335277 +Node: notes336644 +Ref: #notes336766 +Node: payees337128 +Ref: #payees337243 +Node: prices337768 +Ref: #prices337883 +Node: print338185 +Ref: #print338300 +Node: register343746 +Ref: #register343868 +Node: Custom register output348977 +Ref: #custom-register-output349108 +Node: rewrite350483 +Ref: #rewrite350601 +Node: Re-write rules in a file352513 +Ref: #re-write-rules-in-a-file352676 +Node: Diff output format353829 +Ref: #diff-output-format354012 +Node: rewrite vs print --auto355124 +Ref: #rewrite-vs.-print---auto355286 +Node: roi355860 +Ref: #roi355967 +Node: Spaces and special characters in --inv and --pnl357728 +Ref: #spaces-and-special-characters-in---inv-and---pnl357976 +Node: Semantics of --inv and --pnl358474 +Ref: #semantics-of---inv-and---pnl358721 +Node: IRR and TWR explained360599 +Ref: #irr-and-twr-explained360759 +Node: stats363871 +Ref: #stats363979 +Node: tags365376 +Ref: #tags-1365483 +Node: test366500 +Ref: #test366593 +Node: PART 5 COMMON TASKS367343 +Ref: #part-5-common-tasks367476 +Node: Getting help367750 +Ref: #getting-help367891 +Node: Constructing command lines368655 +Ref: #constructing-command-lines368856 +Node: Starting a journal file369537 +Ref: #starting-a-journal-file369744 +Node: Setting opening balances370942 +Ref: #setting-opening-balances371147 +Node: Recording transactions374300 +Ref: #recording-transactions374489 +Node: Reconciling375045 +Ref: #reconciling375197 +Node: Reporting377510 +Ref: #reporting377659 +Node: Migrating to a new file381648 +Ref: #migrating-to-a-new-file381805  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index 708a8fe8b..90c95678d 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -4645,8 +4645,8 @@ Queries hledger-web to show the transaction register for an account.) Combining query terms - When given multiple query terms, most commands select things which - match: + When given multiple space-separated query terms, most commands select + things which match: o any of the description terms AND @@ -4666,31 +4666,38 @@ Queries o match all the other terms. - Although these fixed rules are enough for many needs, we do not support - full boolean expressions (#203), (and you should not write AND or OR in - your queries). This makes certain queries hard to express, but here - are some tricks that can help: + We also support more complex boolean queries with the 'expr:' prefix. + This allows one to combine queries using one of three operators: AND, + OR, and NOT, where NOT is different syntax for 'not:'. - 1. Use a doubled not: prefix. Eg, to print only the food expenses paid - with cash: + Examples of such queries are: - $ hledger print food not:not:cash + o Match transactions with 'cool' in the description AND with the 'A' + tag - 2. Or pre-filter the transactions with print, piping the result into a - second hledger command (with balance assertions disabled): + expr:"desc:cool AND tag:A" - $ hledger print cash | hledger -f- -I balance food + o Match transactions NOT to the 'expenses:food' account OR with the 'A' + tag + + expr:"NOT expenses:food OR tag:A" + + o Match transactions NOT involving the 'expenses:food' account OR with + the 'A' tag AND involving the 'expenses:drink' account. (the AND is + implicitly added by space-separation, following the rules above) + + expr:"expenses:food OR (tag:A expenses:drink)" Queries and command options - Some queries can also be expressed as command-line options: depth:2 is + Some queries can also be expressed as command-line options: depth:2 is equivalent to --depth 2, date:2020 is equivalent to -p 2020, etc. When - you mix command options and query arguments, generally the resulting + you mix command options and query arguments, generally the resulting query is their intersection. Queries and 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 + 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). Querying with account aliases @@ -4698,20 +4705,20 @@ Queries 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 + When amounts are converted to other commodities in cost or value + reports, note that cur: matches the new commodity symbol, and not the old one, and amt: matches the new quantity, and not the old one. Note: - this changed in hledger 1.22, previously it was the reverse, see the + 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 + 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 - 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 - displayed. Values containing colon:separated:parts will be displayed + 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 + displayed. Values containing colon:separated:parts will be displayed hierarchically, like account names. Some examples: @@ -4743,7 +4750,7 @@ Pivoting -------------------- -2 EUR - Another way (the acct: query matches against the pivoted "account + Another way (the acct: query matches against the pivoted "account name"): $ hledger balance --pivot member acct:. @@ -4752,39 +4759,39 @@ Pivoting -2 EUR Generating data - Two features for generating transient data (visible only at report + Two features for generating transient data (visible only at report time) are built in to hledger's journal format: - o Auto posting rules can generate extra postings on certain transac- + 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 repeating transactions, usu- - ally dated in the future, to help with forecasting or budgeting. - They are activated by the --forecast or balance --budget options, + 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. 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. + 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. - This can be useful for estimating balances into the future, perhaps + This can be useful for estimating balances into the future, perhaps experimenting with different scenarios. - It could also be useful for scripted data entry: you could describe - recurring transactions, and every so often copy the output of print + 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. - 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- + 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). 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 + 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: o the start date provided within --forecast's argument, if any @@ -4793,7 +4800,7 @@ Forecasting o the report start date, if specified (with -b/-p/date:) - o the day after the latest ordinary transaction in the journal, if + o the day after the latest ordinary transaction in the journal, if any o otherwise today. @@ -4806,17 +4813,17 @@ Forecasting o otherwise 180 days (6 months) from today. - Note, this means that ordinary transactions will suppress periodic - transactions, by default; the periodic transactions will not start + 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: - 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 + 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. - o Or give --forecast a period expression argument. A forecast period + 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: @@ -4825,44 +4832,44 @@ Forecasting o The period expression can specify the forecast period's start date, end date, or both. See also Report start & end date. - o The period expression should not specify a report interval. (Each + o The period expression should not specify a report interval. (Each periodic transaction rule specifies its own interval.) - Some examples: --forecast=202001-202004, --forecast=jan-, --fore- + Some examples: --forecast=202001-202004, --forecast=jan-, --fore- cast=2021. Budgeting - With the balance command's --budget report, each periodic transaction - rule generates recurring budget goals in specified accounts, and goals - and actual performance can be compared. See the balance command's doc + With the balance command's --budget report, each periodic transaction + rule generates recurring budget goals in specified accounts, and goals + and actual performance can be compared. See the balance command's doc below. See also: Budgeting and Forecasting. Cost reporting - This section is about recording the cost of things, in transactions - where one commodity is exchanged for another. Eg an exchange of cur- + This section is about recording the cost of things, in transactions + where one commodity is exchanged for another. Eg an exchange of cur- rency, or a stock purchase or sale. First, a quick glossary: - o Conversion - an exchange of one currency or commodity for another. - Eg a foreign currency exchange, or a purchase or sale of stock or + o Conversion - an exchange of one currency or commodity for another. + Eg a foreign currency exchange, or a purchase or sale of stock or cryptocurrency. - o Conversion transaction - a transaction involving one or more conver- + o Conversion transaction - a transaction involving one or more conver- sions. o Conversion rate - the cost per unit of one commodity in the other, ie the exchange rate. - o Cost - how much of one commodity was paid to acquire the other. And - more generally, in hledger docs: the amount exchanged in the "sec- + o Cost - how much of one commodity was paid to acquire the other. And + more generally, in hledger docs: the amount exchanged in the "sec- ondary" commodity (usually your base currency), whether in a purchase - or a sale, and whether expressed per unit or in total. Also, the + or a sale, and whether expressed per unit or in total. Also, the "@/@@ PRICE" notation used to represent this. -B: Convert to cost - As discussed in JOURNAL > Costs, when recording a transaction you can - also record the amount's cost in another commodity, by adding @ UNIT- + As discussed in JOURNAL > Costs, when recording a transaction you can + also record the amount's cost in another commodity, by adding @ UNIT- PRICE or @@ TOTALPRICE. Then you can see a report with amounts converted to cost, by adding the @@ -4881,8 +4888,8 @@ 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 + -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, -B shows something different: @@ -4894,13 +4901,13 @@ Cost reporting EUR-100 assets:dollars # <- the dollars' selling price EUR100 assets:euros - The @/@@ cost notation is convenient, but has some drawbacks: it does - not truly balance the transaction, so it disrupts the accounting equa- + The @/@@ cost notation is convenient, but has some drawbacks: it does + not truly balance the transaction, so it disrupts the accounting equa- tion and tends to causes a non-zero total in balance reports. Equity conversion postings By contrast, conventional double entry bookkeeping (DEB) uses a differ- - ent notation: an extra pair of equity postings to balance conversion + ent notation: an extra pair of equity postings to balance conversion transactions. In this style, the above entry might be written: 2022-01-01 one hundred euros purchased at $1.35 each @@ -4909,15 +4916,15 @@ Cost reporting equity:conversion EUR-100 assets:euros EUR100 - This style is more correct, but it's also more verbose and makes cost + This style is more correct, but it's also more verbose and makes cost reporting more difficult for PTA tools. - Happily, current hledger can read either notation, or convert one to + Happily, current hledger can read either notation, or convert one to the other when needed, so you can use the one you prefer. - You can even use cost notation and equivalent conversion postings at - the same time, for clarity. hledger will ignore the redundancy. But - be sure the cost and conversion posting amounts match, or you'll see a + You can even use cost notation and equivalent conversion postings at + the same time, for clarity. hledger will ignore the redundancy. But + be sure the cost and conversion posting amounts match, or you'll see a not-so-clear transaction balancing error message. Inferring equity postings from cost @@ -4938,14 +4945,14 @@ Cost reporting 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 + --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. Inferring cost from equity postings - The reverse operation is possible using --infer-costs, which detects - transactions written with equity conversion postings and adds cost + The reverse operation is possible using --infer-costs, which detects + transactions written with equity conversion postings and adds cost notation to them: 2022-01-01 @@ -4961,8 +4968,8 @@ Cost reporting equity:conversion EUR-100 assets:euros EUR100 - --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 + reporting even when transactions have been recorded using equity post- ings: $ hledger print --infer-costs -B @@ -4979,7 +4986,7 @@ Cost reporting 2. two equity postings, next to one another 3. the equity accounts must be declared, with account type V/Conversion - (or if they are not declared, they must be named equity:conversion, + (or if they are not declared, they must be named equity:conversion, equity:trade, equity:trading or subaccounts of these) 4. the equity postings' amounts must exactly match the non-equity post- @@ -4987,41 +4994,41 @@ Cost reporting Multiple such exchanges can coexist within a single transaction. - When inferring cost, the order of postings matters: the cost is added - to the first of the non-equity postings involved in the exchange, in - the commodity of the last non-equity posting involved in the exchange. + When inferring cost, the order of postings matters: the cost is added + to the first of the non-equity postings involved in the exchange, in + the commodity of the last non-equity posting involved in the exchange. If you don't want to write your postings in the required order, you can use explicit cost notation instead. - --infer-equity and --infer-costs can be used together, if you have a + --infer-equity and --infer-costs can be used together, if you have a mixture of both notations in your journal. When to infer cost/equity - Inferring equity postings or costs is still fairly new, so not enabled - by default. We're not sure yet if that should change. Here are two + Inferring equity postings or costs is still fairly new, so not enabled + by default. We're not sure yet if that should change. Here are two suggestions to try, experience reports welcome: - 1. When you use -B, always use --infer-costs as well. Eg: hledger bal + 1. When you use -B, always use --infer-costs as well. Eg: hledger bal -B --infer-costs - 2. Always run hledger with both flags enabled. Eg: alias hl="hledger + 2. Always run hledger with both flags enabled. Eg: alias hl="hledger --infer-equity --infer-costs" How to record conversions - Essentially there are four ways to record a conversion transaction in + Essentially there are four ways to record a conversion transaction in hledger. Here are all of them, with pros and cons. 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 + 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: 2021-01-01 assets:cash -100 EUR assets:cash 120 USD - hledger will assume this transaction is balanced, inferring that the - conversion rate must be 1 EUR = 1.20 USD. You can see the inferred + hledger will assume this transaction is balanced, inferring that the + conversion rate must be 1 EUR = 1.20 USD. You can see the inferred rate by using hledger print -x. Pro: @@ -5030,18 +5037,18 @@ Cost reporting Con: - o Less error checking - typos in amounts or commodity symbols may not + o Less error checking - typos in amounts or commodity symbols may not be detected o Conversion rate is not clear - o Disturbs the accounting equation, unless you add the --infer-equity + o Disturbs the accounting equation, unless you add the --infer-equity flag - You can prevent accidental implicit conversions due to a mistyped com- + You can prevent accidental implicit conversions due to a mistyped com- modity symbol, by using hledger check commodities. - You can prevent implicit conversions entirely, by using hledger check + You can prevent implicit conversions entirely, by using hledger check balancednoautoconversion, or -s/--strict. Conversion with explicit cost @@ -5064,16 +5071,16 @@ Cost reporting Con: - o Disturbs the accounting equation, unless you add the --infer-equity + o Disturbs the accounting equation, unless you add the --infer-equity flag 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 + 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 reports like balancesheetequity from showing a zero total. - The proper way to make it balance is to add a balancing posting for + The proper way to make it balance is to add a balancing posting for each commodity, using an equity account: 2021-01-01 @@ -5124,98 +5131,98 @@ Cost reporting o Not compatible with ledger Cost tips - o Recording the cost/conversion rate explicitly is good because it + o Recording the cost/conversion rate explicitly is good because it makes that clear and helps detect errors. - o Recording equity postings is good because it is correct bookkeeping + o Recording equity postings is good because it is correct bookkeeping and preserves the accounting equation. o Combining these is possible. - o When you want to see the cost (or sale proceeds) of things, use -B + o When you want to see the cost (or sale proceeds) of things, use -B (short form of --cost). - o If you use conversion postings without cost notation, add --infer- + o If you use conversion postings without cost notation, add --infer- costs also. o If you use cost notation without conversion postings, and you want to - see a balanced balance sheet or print correct journal entries, use + see a balanced balance sheet or print correct journal entries, use --infer-equity. o Conversion to cost is performed before valuation (described next). Valuation - Instead of reporting amounts in their original commodity, hledger can + Instead of reporting amounts in their original commodity, hledger can convert them to cost/sale amount (using the conversion rate recorded in - the transaction), and/or to market value (using some market price on a - certain date). This is controlled by the --value=TYPE[,COMMODITY] - option, which will be described below. We also provide the simpler -V + the transaction), and/or to market value (using some market price on a + certain date). This is controlled by the --value=TYPE[,COMMODITY] + option, which will be described below. We also provide the simpler -V and -X COMMODITY options, and often one of these is all you need: -V: Value - The -V/--market flag converts amounts to market value in their default + The -V/--market flag converts amounts to market value in their default valuation commodity, using the market prices in effect on the valuation date(s), if any. More on these in a minute. -X: Value in specified commodity The -X/--exchange=COMM option is like -V, except you tell it which cur- - rency you want to convert to, and it tries to convert everything to + rency you want to convert to, and it tries to convert everything to that. Valuation date - Since market prices can change from day to day, market value reports + Since market prices can change from day to day, market value reports have a valuation date (or more than one), which determines which market prices will be used. For single period reports, if an explicit report end date is specified, - that will be used as the valuation date; otherwise the valuation date + that will be used as the valuation date; otherwise the valuation date is the journal's end date. - For multiperiod reports, each column/period is valued on the last day + For multiperiod reports, each column/period is valued on the last day of the period, by default. Finding market price - To convert a commodity A to its market value in another commodity B, - hledger looks for a suitable market price (exchange rate) as follows, + To convert a commodity A to its market value in another commodity B, + hledger looks for a suitable market price (exchange rate) as follows, in this order of preference : - 1. A declared market price or inferred market price: A's latest market + 1. A declared market price or inferred market price: A's latest market price in B on or before the valuation date as declared by a P direc- - tive, or (with the --infer-market-prices flag) inferred from costs. + 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. @@ -5223,15 +5230,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: @@ -5241,8 +5248,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 @@ -5272,7 +5279,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 @@ -5285,34 +5292,34 @@ 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: - o If you have P directives, they determine which commodities -V will + o If you have P directives, they determine which commodities -V will convert, and to what. - o If you have no P directives, and use the --infer-market-prices flag, + o If you have no P directives, and use the --infer-market-prices flag, costs determine it. - Amounts for which no valuation commodity can be found are not con- + Amounts for which no valuation commodity can be found are not con- verted. Simple valuation examples @@ -5339,7 +5346,7 @@ Valuation $ hledger -f t.j bal -N euros -V -e 2016/11/4 $110.00 assets:euros - What are they worth after 2016/12/21 ? (no report end date specified, + What are they worth after 2016/12/21 ? (no report end date specified, defaults to today) $ hledger -f t.j bal -N euros -V @@ -5359,31 +5366,31 @@ Valuation The TYPE part selects cost or value and valuation date: --value=then - Convert amounts to their value in the default valuation commod- + Convert amounts to their value in the default valuation commod- ity, using market prices on each posting's date. --value=end - Convert amounts to their value in the default valuation commod- - ity, using market prices on the last day of the report period - (or if unspecified, the journal's end date); or in multiperiod + Convert amounts to their value in the default valuation commod- + ity, using market prices on the last day of the report period + (or if unspecified, the journal's end date); or in multiperiod reports, market prices on the last day of each subperiod. --value=now - Convert amounts to their value in the default valuation commod- - ity using current market prices (as of when report is gener- + Convert amounts to their value in the default valuation commod- + ity using current market prices (as of when report is gener- ated). --value=YYYY-MM-DD - Convert amounts to their value in the default valuation commod- + Convert amounts to their value in the default valuation commod- ity using market prices on this date. To select a different valuation commodity, add the optional ,COMM part: - a comma, then the target commodity's symbol. Eg: --value=now,EUR. + a comma, then the target commodity's symbol. Eg: --value=now,EUR. hledger will do its best to convert amounts to this commodity, deducing market prices as described above. More valuation examples - Here are some examples showing the effect of --value, as seen with + Here are some examples showing the effect of --value, as seen with print: P 2000-01-01 A 1 B @@ -5421,7 +5428,7 @@ Valuation 2000-02-01 (a) 2 B - With no report period specified, that shows the value as of the last + With no report period specified, that shows the value as of the last day of the journal (2000-03-01): $ hledger -f- print --value=end @@ -5458,7 +5465,7 @@ Valuation 2000-03-01 (a) 1 B - You may need to explicitly set a commodity's display style, when + You may need to explicitly set a commodity's display style, when reverse prices are used. Eg this output might be surprising: P 2000-01-01 A 2B @@ -5472,10 +5479,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 @@ -5491,7 +5498,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: @@ -5505,16 +5512,16 @@ 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. + 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. @@ -5522,7 +5529,7 @@ Valuation type --value=now ----------------------------------------------------------------------------------------------- print - posting cost value at value at posting value at value at + 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 @@ -5539,7 +5546,7 @@ Valuation 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 + 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 @@ -5552,22 +5559,24 @@ Valuation balance (bs, bse, cf, is) - balance sums of value at value at posting value at value at + 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- + 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- + 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) + 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 @@ -5579,10 +5588,6 @@ Valuation 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- @@ -5594,10 +5599,10 @@ Valuation 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- + 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- + 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 @@ -5612,29 +5617,29 @@ Valuation cost calculated using price(s) recorded in the transaction(s). - value market value using available market price declarations, or the + value market value using available market price declarations, or the unchanged amount if no conversion rate can be found. report start - the first day of the report period specified with -b or -p or + the first day of the report period specified with -b or -p or date:, otherwise today. report or journal start - the first day of the report period specified with -b or -p or - date:, otherwise the earliest transaction date in the journal, + the first day of the report period specified with -b or -p or + date:, otherwise the earliest transaction date in the journal, otherwise today. report end - the last day of the report period specified with -e or -p or + the last day of the report period specified with -e or -p or date:, otherwise today. report or journal end - the last day of the report period specified with -e or -p or - date:, otherwise the latest transaction date in the journal, + the last day of the report period specified with -e or -p or + date:, otherwise the latest transaction date in the journal, otherwise today. report interval - a flag (-D/-W/-M/-Q/-Y) or period expression that activates the + a flag (-D/-W/-M/-Q/-Y) or period expression that activates the report's multi-period mode (whether showing one or many subperi- ods). @@ -5672,11 +5677,11 @@ 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 + o register (reg) - show postings in one or more accounts & running total o roi - show return on investments @@ -5714,7 +5719,7 @@ PART 4: COMMANDS 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 @@ -5727,7 +5732,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. @@ -5735,38 +5740,38 @@ 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 + accounts, 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 + 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). - 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 + account's declaration, if any, and the account's overall declaration + order; 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 + 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 satisfy hledger check accounts. - The --find flag can be used to look up a single account name, in the - same way that the aregister command does. It returns the alphanumeri- - cally-first matched account name, or if none can be found, it fails + The --find flag can be used to look up a single account name, in the + same way that the aregister command does. It returns the alphanumeri- + cally-first matched account name, or if none can be found, it fails with a non-zero exit code. Examples: @@ -5787,8 +5792,8 @@ PART 4: COMMANDS activity Show an ascii barchart of posting counts per interval. - The activity command displays an ascii histogram showing transaction - counts by day, week, month or other reporting interval (by day is the + The activity command displays an ascii histogram showing transaction + counts by day, week, month or other reporting interval (by day is the default). With query arguments, it counts only matched transactions. Examples: @@ -5800,36 +5805,36 @@ PART 4: COMMANDS 2008-10-01 ** add - Prompt for transactions and add them to the journal. Any arguments + Prompt for transactions and add them to the journal. Any arguments will be used as default inputs for the first N prompts. - Many hledger users edit their journals directly with a text editor, or - generate them from CSV. For more interactive data entry, there is the - add command, which prompts interactively on the console for new trans- - actions, and appends them to the main journal file (which should be in - journal format). Existing transactions are not changed. This is one - of the few hledger commands that writes to the journal file (see also + Many hledger users edit their journals directly with a text editor, or + generate them from CSV. For more interactive data entry, there is the + add command, which prompts interactively on the console for new trans- + actions, and appends them to the main journal file (which should be in + journal format). Existing transactions are not changed. This is one + of the few hledger commands that writes to the journal file (see also import). To use it, just run hledger add and follow the prompts. You can add as - many transactions as you like; when you are finished, enter . or press + many transactions as you like; when you are finished, enter . or press control-d or control-c to exit. Features: - o add tries to provide useful defaults, using the most similar (by - description) recent transaction (filtered by the query, if any) as a + o add tries to provide useful defaults, using the most similar (by + description) recent transaction (filtered by the query, if any) as a template. o You can also set the initial defaults with command line arguments. o Readline-style edit keys can be used during data entry. - o The tab key will auto-complete whenever possible - accounts, pay- - ees/descriptions, dates (yesterday, today, tomorrow). If the input + o The tab key will auto-complete whenever possible - accounts, pay- + ees/descriptions, dates (yesterday, today, tomorrow). If the input area is empty, it will insert the default value. - o If the journal defines a default commodity, it will be added to any + o If the journal defines a default commodity, it will be added to any bare numbers entered. o A parenthesised transaction code may be entered following a date. @@ -5838,7 +5843,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): @@ -5868,82 +5873,82 @@ 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 + Show the transactions and running historical balance of a single account, 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 + (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). - 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 + expression 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- - ing 2 accounts, hledger areg checking would select assets:biz:checking - 2. It's just a convenience to save typing, so if in doubt, write the + surprising; eg if you have assets:per:checking 1 and assets:biz:check- + ing 2 accounts, hledger areg checking would select assets:biz:checking + 2. It's just a convenience to save typing, so if in doubt, write the full account name, or a distinctive substring that matches uniquely. - Transactions involving subaccounts of this account will also be shown. - aregister ignores depth limits, so its final total will always match a + Transactions involving subaccounts of this account will also be shown. + aregister ignores depth limits, so its final total will always match a balance report with similar arguments. - Any additional arguments form a query which will filter the transac- + Any additional arguments form a query which will filter the transac- tions shown. Note some queries will disturb the running balance, caus- ing it to be different from the account's real-world running balance. - An example: this shows the transactions and historical running balance + An example: this shows the transactions and historical running balance during july, in the first account whose name contains "checking": $ hledger areg checking date:jul Each aregister line item shows: - o the transaction's date (or the relevant posting's date if different, + o the transaction's date (or the relevant posting's date if different, see below) - o the names of all the other account(s) involved in this transaction + o the names of all the other account(s) involved in this transaction (probably abbreviated) o the total change to this account's balance from this transaction o the account's historical running balance after this transaction. - Transactions making a net change of zero are not shown by default; add + Transactions making a net change of zero are not shown by default; add the -E/--empty flag to show them. - 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. - This command also supports the output destination and output format + This command also supports the output destination and output format options. 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 - shown, if they have a posting to this account dated inside the report - period. (And in this case it's the posting date that is shown.) This + Transactions whose date is outside the report period can still be + shown, if they have a posting to this account dated inside the report + period. (And in this case it's the posting date that is shown.) This ensures that aregister can show an accurate historical running balance, matching the one shown by register -H with the same arguments. - To filter strictly by transaction date instead, add the --txn-dates - flag. If you use this flag and some of your postings have custom + To filter strictly by transaction date instead, add the --txn-dates + flag. If you use this flag and some of your postings have custom dates, it's probably best to assume the running balance is wrong. balance @@ -5951,19 +5956,19 @@ PART 4: COMMANDS Show accounts and their balances. - balance is one of hledger's oldest and most versatile commands, for - listing account balances, balance changes, values, value changes and + balance is one of hledger's oldest and most versatile commands, for + listing account balances, balance changes, values, value changes and more, during one time period or many. Generally it shows a table, with rows representing accounts, and columns representing periods. - Note there are some higher-level variants of the balance command with - convenient defaults, which can be simpler to use: balancesheet, bal- + Note there are some higher-level variants of the balance command with + convenient defaults, which can be simpler to use: balancesheet, bal- ancesheetequity, cashflow and incomestatement. When you need more con- trol, then use balance. balance features - Here's a quick overview of the balance command's features, followed by - more detailed descriptions and examples. Many of these work with the + Here's a quick overview of the balance command's features, followed by + more detailed descriptions and examples. Many of these work with the higher-level commands as well. balance can show.. @@ -6014,7 +6019,7 @@ PART 4: COMMANDS ..with.. - o totals (-T), averages (-A), percentages (-%), inverted sign + o totals (-T), averages (-A), percentages (-%), inverted sign (--invert) o rows and columns swapped (--transpose) @@ -6026,24 +6031,24 @@ PART 4: COMMANDS o commodities displayed on the same line or multiple lines (--layout) This command supports the output destination and output format options, - with output formats txt, csv, json, and (multi-period reports only:) - html. In txt output in a colour-supporting terminal, negative amounts + with output formats txt, csv, json, and (multi-period reports only:) + html. In txt output in a colour-supporting terminal, negative amounts are shown in red. - The --related/-r flag shows the balance of the other postings in the + The --related/-r flag shows the balance of the other postings in the transactions of the postings which would normally be shown. Simple balance report - With no arguments, balance shows a list of all accounts and their - change of balance - ie, the sum of posting amounts, both inflows and - outflows - during the entire period of the journal. ("Simple" here - means just one column of numbers, covering a single period. You can + With no arguments, balance shows a list of all accounts and their + change of balance - ie, the sum of posting amounts, both inflows and + outflows - during the entire period of the journal. ("Simple" here + means just one column of numbers, covering a single period. You can also have multi-period reports, described later.) - For real-world accounts, these numbers will normally be their end bal- + For real-world accounts, these numbers will normally be their end bal- ance at the end of the journal period; more on this below. - Accounts are sorted by declaration order if any, and then alphabeti- + Accounts are sorted by declaration order if any, and then alphabeti- cally by account name. For instance (using examples/sample.journal): $ hledger -f examples/sample.journal bal @@ -6058,7 +6063,7 @@ 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 + - see below) are hidden by default. Use -E/--empty to show them (revealing assets:bank:checking here): $ hledger -f examples/sample.journal bal -E @@ -6073,12 +6078,12 @@ PART 4: COMMANDS -------------------- 0 - The total of the amounts displayed is shown as the last line, unless + The total of the amounts displayed is shown as the last line, unless -N/--no-total is used. Balance report line format For single-period balance reports displayed in the terminal (only), you - can use --format FMT to customise the format and content of each line. + can use --format FMT to customise the format and content of each line. Eg: $ hledger -f examples/sample.journal balance --format "%20(account) %12(total)" @@ -6096,7 +6101,7 @@ 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 + account/balance pair. It may contain any suitable text, with data fields interpolated like so: %[MIN][.MAX](FIELDNAME) @@ -6107,14 +6112,14 @@ PART 4: COMMANDS o FIELDNAME must be enclosed in parentheses, and can be one of: - o depth_spacer - a number of spaces equal to the account's depth, or + o depth_spacer - a number of spaces equal to the account's depth, or if MIN is specified, MIN * depth spaces. o account - the account's name o total - the account's balance/posted total, right justified - Also, FMT can begin with an optional prefix to control how multi-com- + Also, FMT can begin with an optional prefix to control how multi-com- modity amounts are rendered: o %_ - render on multiple lines, bottom-aligned (the default) @@ -6123,26 +6128,26 @@ 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 + There are some quirks. Eg in one-line mode, %(depth_spacer) has no + effect, instead %(account) has indentation built in. Experimentation may be needed to get pleasing results. Some example formats: o %(total) - the account's total - o %-20.20(account) - the account's name, left justified, padded to 20 + o %-20.20(account) - the account's name, left justified, padded to 20 characters and clipped at 20 characters - o %,%-50(account) %25(total) - account name padded to 50 characters, - total padded to 20 characters, with multiple commodities rendered on + o %,%-50(account) %25(total) - account name padded to 50 characters, + total padded to 20 characters, with multiple commodities rendered on one line - o %20(total) %2(depth_spacer)%-(account) - the default format for the + o %20(total) %2(depth_spacer)%-(account) - the default format for the single-column balance report Filtered balance report - You can show fewer accounts, a different time period, totals from + You can show fewer accounts, a different time period, totals from cleared transactions only, etc. by using query arguments or options to limit the postings being matched. Eg: @@ -6152,10 +6157,10 @@ PART 4: COMMANDS $-2 List or tree mode - By default, or with -l/--flat, accounts are shown as a flat list with + By default, or with -l/--flat, accounts are shown as a flat list with their full names visible, as in the examples above. - With -t/--tree, the account hierarchy is shown, with subaccounts' + With -t/--tree, the account hierarchy is shown, with subaccounts' "leaf" names indented below their parent: $ hledger -f examples/sample.journal balance @@ -6175,26 +6180,26 @@ PART 4: COMMANDS Notes: o "Boring" accounts are combined with their subaccount for more compact - output, unless --no-elide is used. Boring accounts have no balance - of their own and just one subaccount (eg assets:bank and liabilities + output, unless --no-elide is used. Boring accounts have no balance + of their own and just one subaccount (eg assets:bank and liabilities above). - o All balances shown are "inclusive", ie including the balances from - all subaccounts. Note this means some repetition in the output, + o All balances shown are "inclusive", ie including the balances from + all subaccounts. Note this means some repetition in the output, which requires explanation when sharing reports with non-plaintextac- - counting-users. A tree mode report's final total is the sum of the + counting-users. A tree mode report's final total is the sum of the top-level balances shown, not of all the balances shown. - o Each group of sibling accounts (ie, under a common parent) is sorted + o Each group of sibling accounts (ie, under a common parent) is sorted separately. Depth limiting - With a depth:NUM query, or --depth NUM option, or just -NUM (eg: -3) - balance reports will show accounts only to the specified depth, hiding - the deeper subaccounts. This can be useful for getting an overview + With a depth:NUM query, or --depth NUM option, or just -NUM (eg: -3) + balance reports will show accounts only to the specified depth, hiding + the deeper subaccounts. This can be useful for getting an overview without too much detail. - Account balances at the depth limit always include the balances from + Account balances at the depth limit always include the balances from any deeper subaccounts (even in list mode). Eg, limiting to depth 1: $ hledger -f examples/sample.journal balance -1 @@ -6206,7 +6211,7 @@ PART 4: COMMANDS 0 Dropping top-level accounts - You can also hide one or more top-level account name parts, using + You can also hide one or more top-level account name parts, using --drop NUM. This can be useful for hiding repetitive top-level account names: @@ -6218,54 +6223,54 @@ PART 4: COMMANDS 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 + directive will be included in the balance report, even if they have no transactions. (Since they will have a zero balance, you will also need -E/--empty to see them.) - More precisely, leaf declared accounts (with no subaccounts) will be + 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 + 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. Sorting by amount - With -S/--sort-amount, accounts with the largest (most positive) bal- - ances are shown first. Eg: hledger bal expenses -MAS shows your big- - gest averaged monthly expenses first. When more than one commodity is - present, they will be sorted by the alphabetically earliest commodity - first, and then by subsequent commodities (if an amount is missing a + With -S/--sort-amount, accounts with the largest (most positive) bal- + ances are shown first. Eg: hledger bal expenses -MAS shows your big- + gest averaged monthly expenses first. When more than one commodity is + present, they will be sorted by the alphabetically earliest commodity + first, and then by subsequent commodities (if an amount is missing a commodity, it is treated as 0). - Revenues and liability balances are typically negative, however, so -S - shows these in reverse order. To work around this, you can add - --invert to flip the signs. (Or, use one of the higher-level reports, - which flip the sign automatically. Eg: hledger incomestatement -MAS). + Revenues and liability balances are typically negative, however, so -S + shows these in reverse order. To work around this, you can add + --invert to flip the signs. (Or, use one of the higher-level reports, + which flip the sign automatically. Eg: hledger incomestatement -MAS). Percentages - With -%/--percent, balance reports show each account's value expressed + With -%/--percent, balance reports show each account's value expressed as a percentage of the (column) total. 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 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 @@ -6286,21 +6291,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 @@ -6314,57 +6319,57 @@ PART 4: COMMANDS o Reduce the terminal's font size - o View with a pager like less, eg: hledger bal -D --color=yes | less + o View with a pager like less, eg: hledger bal -D --color=yes | less -RS - o Output as CSV and use a CSV viewer like visidata (hledger bal -D -O - csv | vd -f csv), Emacs' csv-mode (M-x csv-mode, C-c C-a), or a + o Output as CSV and use a CSV viewer like visidata (hledger bal -D -O + csv | vd -f csv), Emacs' csv-mode (M-x csv-mode, C-c C-a), or a spreadsheet (hledger bal -D -o a.csv && open a.csv) - o Output as HTML and view with a browser: hledger bal -D -o a.html && + o Output as HTML and view with a browser: hledger bal -D -o a.html && open a.html Balance change, end balance - It's important to be clear on the meaning of the numbers shown in bal- + It's important to be clear on the meaning of the numbers shown in bal- ance reports. Here is some terminology we use: - A balance change is the net amount added to, or removed from, an + A balance change is the net amount added to, or removed from, an account during some period. - An end balance is the amount accumulated in an account as of some date - (and some time, but hledger doesn't store that; assume end of day in + An end balance is the amount accumulated in an account as of some date + (and some time, but hledger doesn't store that; assume end of day in your timezone). It is the sum of previous balance changes. - We call it a historical end balance if it includes all balance changes + We call it a historical end balance if it includes all balance changes since the account was created. For a real world account, this means it - will match the "historical record", eg the balances reported in your + will match the "historical record", eg the balances reported in your bank statements or bank web UI. (If they are correct!) - In general, balance changes are what you want to see when reviewing + In general, balance changes are what you want to see when reviewing revenues and expenses, and historical end balances are what you want to see when reviewing or reconciling asset, liability and equity accounts. - balance shows balance changes by default. To see accurate historical + balance shows balance changes by default. To see accurate historical end balances: - 1. Initialise account starting balances with an "opening balances" - transaction (a transfer from equity to the account), unless the + 1. Initialise account starting balances with an "opening balances" + transaction (a transfer from equity to the account), unless the journal covers the account's full lifetime. 2. Include all of of the account's prior postings in the report, by not - specifying a report start date, or by using the -H/--historical + specifying a report start date, or by using the -H/--historical flag. (-H causes report start date to be ignored when summing post- ings.) Balance report types - 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 + 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. There are three important option groups: - hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] + hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] ... Calculation type @@ -6376,44 +6381,44 @@ PART 4: COMMANDS each account/period) o --valuechange : show the change in period-end historical balance val- - ues (caused by deposits, withdrawals, and/or market price fluctua- + ues (caused by deposits, withdrawals, and/or market price fluctua- tions) - o --gain : show the unrealised capital gain/loss, (the current valued + o --gain : show the unrealised capital gain/loss, (the current valued balance minus each amount's original cost) 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 + How amounts should accumulate across report periods. Another way to + say it: which time period's postings should contribute to each cell's calculation. It is one of: - o --change : calculate with postings from column start to column end, - ie "just this column". Typically used to see revenues/expenses. + o --change : calculate with postings from column start to column end, + ie "just this column". Typically used to see revenues/expenses. (default for balance, incomestatement) - o --cumulative : calculate with postings from report start to column - end, ie "previous columns plus this column". Typically used to show + o --cumulative : calculate with postings from report start to column + end, ie "previous columns plus this column". Typically used to show changes accumulated since the report's start date. Not often used. - o --historical/-H : calculate with postings from journal start to col- - umn end, ie "all postings from before report start date until this - column's end". Typically used to see historical end balances of + 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- quity, cashflow) Valuation type - Which kind of value or cost conversion should be applied, if any, + Which kind of value or cost conversion should be applied, if any, before displaying the report. It is one of: o no valuation type : don't convert to cost or value (default) - o --value=cost[,COMM] : convert amounts to cost (then optionally to + o --value=cost[,COMM] : convert amounts to cost (then optionally to some other commodity) - o --value=then[,COMM] : convert amounts to market value on transaction + o --value=then[,COMM] : convert amounts to market value on transaction dates - o --value=end[,COMM] : convert amounts to market value on period end + o --value=end[,COMM] : convert amounts to market value on period end date(s) (default with --valuechange, --gain) @@ -6424,7 +6429,7 @@ PART 4: COMMANDS or one of the equivalent simpler flags: - o -B/--cost : like --value=cost (though, note --cost and --value are + o -B/--cost : like --value=cost (though, note --cost and --value are independent options which can both be used at once) o -V/--market : like --value=end @@ -6434,13 +6439,13 @@ PART 4: COMMANDS See Cost reporting and Valuation for more about these. Combining balance report types - Most combinations of these options should produce reasonable reports, - but if you find any that seem wrong or misleading, let us know. The + Most combinations of these options should produce reasonable reports, + but if you find any that seem wrong or misleading, let us know. The following restrictions are applied: o --valuechange implies --value=end - o --valuechange makes --change the default when used with the bal- + o --valuechange makes --change the default when used with the bal- ancesheet/balancesheetequity commands o --cumulative or --historical disables --row-total/-T @@ -6455,26 +6460,26 @@ PART 4: COMMANDS lation:v ----------------------------------------------------------------------------------- --change change in period sum of posting- period-end DATE-value of - date market val- value of change change in + date market val- value of change change in ues in period in period period --cumu- change from sum of posting- period-end DATE-value of - lative report start to date market val- value of change change from + lative report start to date market val- value of change change from period end ues from report from report report start start to period start to period to period end end end --his- change from sum of posting- period-end DATE-value of - torical journal start to date market val- value of change change from - /-H period end (his- ues from journal from journal journal start + torical journal start to date market val- value of change change from + /-H period end (his- ues from journal from journal journal start torical end bal- start to period start to period to period end ance) end end Budget report - The --budget report type activates extra columns showing any budget - goals for each account and period. The budget goals are defined by + 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 income, expenses, time usage, etc. - For example, you can take average monthly expenses in the common + For example, you can take average monthly expenses in the common expense categories to construct a minimal monthly budget: ;; Budget @@ -6521,26 +6526,26 @@ PART 4: COMMANDS This is different from a normal balance report in several ways: - o Only accounts with budget goals during the report period are shown, + o Only accounts with budget goals during the report period are shown, by default. - o In each column, in square brackets after the actual amount, budget - goal amounts are shown, and the actual/goal percentage. (Note: bud- + o In each column, in square brackets after the actual amount, budget + goal amounts are shown, and the actual/goal percentage. (Note: bud- get goals should be in the same commodity as the actual amount.) - o All parent accounts are always shown, even in list mode. Eg assets, + o All parent accounts are always shown, even in list mode. Eg assets, assets:bank, and expenses above. - o Amounts always include all subaccounts, budgeted or unbudgeted, even + o Amounts always include all subaccounts, budgeted or unbudgeted, even in list mode. - This means that the numbers displayed will not always add up! Eg - above, the expenses actual amount includes the gifts and supplies + 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 @@ -6587,19 +6592,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 @@ -6618,9 +6623,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 @@ -6633,12 +6638,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: @@ -6648,13 +6653,13 @@ 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 + Transactions in expenses:personal:electronics will be counted both + towards its $100 budget and $1100 of expenses:personal , and transac- + tions in any other subaccount of expenses:personal would be counted towards only towards the budget of expenses:personal. For example, let's consider these transactions: @@ -6680,9 +6685,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: @@ -6698,7 +6703,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 @@ -6717,65 +6722,65 @@ 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 + account 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 + 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. 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 --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: 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 @@ -6784,12 +6789,12 @@ 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: @@ -6801,10 +6806,10 @@ PART 4: COMMANDS o --layout=bare: commodity symbols are in their own column, amounts are bare numbers - o --layout=tidy: data is normalised to easily-consumed "tidy" form, + o --layout=tidy: data is normalised to easily-consumed "tidy" form, with one row per data value - Here are the --layout modes supported by each output format; note only + Here are the --layout modes supported by each output format; note only CSV output supports all of them: @@ -6828,7 +6833,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 @@ -6840,7 +6845,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 @@ -6860,7 +6865,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 @@ -6880,7 +6885,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 @@ -6897,7 +6902,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: @@ -6924,25 +6929,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 @@ -6958,14 +6963,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: @@ -6990,25 +6995,25 @@ 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- + This command also supports the output destination and output format + options The output formats supported are txt, csv, html, and (experi- mental) 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 + This report shows accounts declared with the Asset, Cash, Liability or + Equity type (see account types). Or if no such accounts are declared, + it shows top-level accounts named asset, liability or equity (case insensitive, plurals allowed) and their subaccounts. Example: @@ -7038,32 +7043,32 @@ 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- + This command also supports the output destination and output format + options The output formats supported are txt, csv, html, and (experi- mental) 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 + o under a top-level account named asset (case insensitive, plural allowed) o whose name contains some variation of cash, bank, checking or saving. - More precisely: all accounts matching this case insensitive regular + More precisely: all accounts matching this case insensitive regular expression: ^assets?(:.+)?:(cash|bank|che(ck|que?)(ing)?|savings?|currentcash)(:|$) @@ -7087,21 +7092,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- + This command also supports the output destination and output format + options The output formats supported are txt, csv, html, and (experi- mental) json. check Check 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: @@ -7110,7 +7115,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: @@ -7122,34 +7127,34 @@ PART 4: COMMANDS o parseable - data files are well-formed and can be successfully parsed o balancedwithautoconversion - all transactions are balanced, inferring - missing amounts where necessary, and possibly converting commodities + missing amounts where necessary, and possibly converting commodities using costs or automatically-inferred costs - o assertions - all balance assertions in the journal are passing. + o assertions - all balance assertions in the journal are passing. (This check can be disabled with -I/--ignore-assertions.) Strict checks These additional checks are run when the -s/--strict (strict mode) flag - is used. Or, they can be run by giving their names as arguments to + is used. Or, they can be run by giving their names as arguments to check: o accounts - all account names used by transactions have been declared o commodities - all commodity symbols used have been declared - o balancednoautoconversion - transactions are balanced, possibly using + o balancednoautoconversion - transactions are balanced, possibly using explicit costs but not inferred ones Other checks - These checks can be run only by giving their names as arguments to - check. They are more specialised and not desirable for everyone, + These checks can be run only by giving their names as arguments to + check. They are more specialised and not desirable for everyone, therefore optional: o ordereddates - transactions are ordered by date within each file o payees - all payees used by transactions have been declared - o recentassertions - all accounts with balance assertions have a bal- + o recentassertions - all accounts with balance assertions have a bal- ance assertion no more than 7 days before their latest posting o tags - all tags used by transactions have been declared @@ -7157,105 +7162,105 @@ PART 4: COMMANDS o uniqueleafnames - all account leaf names are unique Custom checks - A few more checks are are available as separate add-on commands, in + A few more checks are are available as separate add-on commands, in https://github.com/simonmichael/hledger/tree/master/bin: - o hledger-check-tagfiles - all tag values containing / (a forward + o hledger-check-tagfiles - all tag values containing / (a forward slash) exist as file paths - o hledger-check-fancyassertions - more complex balance assertions are + o hledger-check-fancyassertions - more complex balance assertions are passing You could make similar scripts to perform your own custom checks. See: Cookbook -> Scripting. More about specific checks - hledger check recentassertions will complain if any balance-asserted + hledger check recentassertions will complain if any balance-asserted account does not have a balance assertion within 7 days before its lat- - 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 - 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 + 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 + 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. close close [--retain | --migrate | --open] [QUERY] - By default: prints a transaction that zeroes out ("closes") all - accounts, transferring their balances to an equity account. Query + By default: prints a transaction that zeroes out ("closes") all + accounts, transferring their balances to an equity account. Query arguments can be added to override the accounts selection. Three other modes are supported: - --retain: prints a transaction closing revenue and expense balances. - This is traditionally done by businesses at the end of each accounting + --retain: prints a transaction closing revenue and expense balances. + This is traditionally done by businesses at the end of each accounting period; it is less necessary in personal and computer-based accounting, but it can help balance the accounting equation A=L+E. - --migrate: prints a transaction to close asset, liability and most - equity balances, and another transaction to re-open them. This can be - useful when starting a new file (for performance or data protection). + --migrate: prints a transaction to close asset, liability and most + equity balances, and another transaction to re-open them. This can be + useful when starting a new file (for performance or data protection). Adding the closing transaction to the old file allows old and new files to be combined. --open: as above, but prints just the opening transaction. This can be - useful for starting a new file, leaving the old file unchanged. Simi- + useful for starting a new file, leaving the old file unchanged. Simi- lar to Ledger's equity command. - You can change the equity account name with --close-acct ACCT. It - defaults to equity:retained earnings with --retain, or equity:open- + You can change the equity account name with --close-acct ACCT. It + defaults to equity:retained earnings with --retain, or equity:open- ing/closing balances otherwise. - You can change the transaction description(s) with --close-desc 'DESC' - and --open-desc 'DESC'. It defaults to retain earnings with --retain, + You can change the transaction description(s) with --close-desc 'DESC' + and --open-desc 'DESC'. It defaults to retain earnings with --retain, or closing balances and opening balances otherwise. Just one posting to the equity account will be used by default, with an implicit amount. - With --x/--explicit the amount will be shown explicitly, and if it + With --x/--explicit the amount will be shown explicitly, and if it involves multiple commodities, a separate posting will be generated for each commodity. - With --interleaved, each equity posting is shown next to the corre- + With --interleaved, each equity posting is shown next to the corre- sponding source/destination posting. - 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 - 2022-12-31". The opening date is always the day after the closing + 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 + 2022-12-31". The opening date is always the day after the closing date. close and costs - With --show-costs, any amount costs are shown, with separate postings + With --show-costs, any amount costs are shown, with separate postings for each cost. (This currently the best way to view investment assets, - showing lots and cost bases.) If you have many currency conversion or + showing lots and cost bases.) If you have many currency conversion or investment transactions, it can generate very large journal entries. close and balance assertions - Balance assertions will be generated, verifying that the accounts have - been reset to zero (and then restored to their previous balances, if + Balance assertions will be generated, verifying that the accounts have + been reset to zero (and then restored to their previous balances, if there is an opening transaction). - These provide useful error checking, but you can ignore them temporar- + These provide useful error checking, but you can ignore them temporar- ily with -I, or remove them if you prefer. - You probably should avoid filtering transactions by status or realness - (-C, -R, status:), or generating postings (--auto), with this command, + You probably should avoid filtering transactions by status or realness + (-C, -R, status:), or generating postings (--auto), with this command, since the balance assertions would depend on these. - Note custom posting dates spanning the file boundary will disrupt the + Note custom posting dates spanning the file boundary will disrupt the balance assertions: 2023-12-30 a purchase made in december, cleared in january expenses:food 5 assets:bank:checking -5 ; date: 2023-01-02 - To solve that you can transfer the money to and from a temporary + To solve that you can transfer the money to and from a temporary account, in effect splitting the multi-day transaction into two single- day transactions: @@ -7270,38 +7275,38 @@ PART 4: COMMANDS assets:bank:checking -5 Example: retain earnings - Record 2022's revenues/expenses as retained earnings on 2022-12-31, + Record 2022's revenues/expenses as retained earnings on 2022-12-31, appending the generated transaction to the journal: $ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal - Now 2022's income statement will show only zeroes. To see it again, + Now 2022's income statement will show only zeroes. To see it again, exclude the retain transaction. Eg: $ hledger -f 2022.journal is not:desc:'retain earnings' Example: migrate balances to a new file - Close assets/liabilities/equity on 2022-12-31 and re-open them on + Close assets/liabilities/equity on 2022-12-31 and re-open them on 2023-01-01: $ hledger close --migrate -f 2022.journal -p 2022 # copy/paste the closing transaction to the end of 2022.journal # copy/paste the opening transaction to the start of 2023.journal - Now 2022's balance sheet will show only zeroes, indicating a balanced - accounting equation. (Unless you are using @/@@ notation - in that + Now 2022's balance sheet will show only zeroes, indicating a balanced + accounting equation. (Unless you are using @/@@ notation - in that case, try adding --infer-equity.) To see it again, exclude the closing transaction. Eg: $ hledger -f 2022.journal bs not:desc:'closing balances' Example: excluding closing/opening transactions - When combining many files for multi-year reports, the closing/opening - transactions cause some noise in reports like print and register. You + When combining many files for multi-year reports, the closing/opening + transactions cause some noise in reports like print and register. You can exclude them as shown above, but not:desc:... could be fragile, and - also you will need to avoid excluding the very first opening transac- - tion, which can be awkward. Here is a way to do it, using tags: add - clopen: tags to all opening/closing balances transactions except the + also you will need to avoid excluding the very first opening transac- + tion, which can be awkward. Here is a way to do it, using tags: add + clopen: tags to all opening/closing balances transactions except the first, like this: ; 2021.journal @@ -7327,7 +7332,7 @@ PART 4: COMMANDS include 2022.journal include 2023.journal - The clopen: tag can exclude all but the first opening transaction. To + The clopen: tag can exclude all but the first opening transaction. To show a clean multi-year checking register: $ hledger -f all.journal areg checking not:tag:clopen @@ -7340,13 +7345,13 @@ PART 4: COMMANDS codes List the codes seen in transactions, in the order parsed. - This command prints the value of each transaction's code field, in the - order transactions were parsed. The transaction code is an optional - value written in parentheses between the date and description, often + This command prints the value of each transaction's code field, in the + order transactions were parsed. The transaction code is an optional + value written in parentheses between the date and description, often used to store a cheque number, order number or similar. Transactions aren't required to have a code, and missing or empty codes - will not be shown by default. With the -E/--empty flag, they will be + will not be shown by default. With the -E/--empty flag, they will be printed as blank lines. You can add a query to select a subset of transactions. @@ -7386,16 +7391,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: @@ -7409,7 +7414,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: @@ -7420,18 +7425,18 @@ 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. This is useful eg if you have downloaded an account's transactions from - your bank (eg as CSV data). When hledger and your bank disagree about + your bank (eg as CSV data). When hledger and your bank disagree about the account balance, you can compare the bank data with your journal to find out the cause. @@ -7448,22 +7453,22 @@ PART 4: COMMANDS These transactions are in the second file only: files - List all files included in the journal. With a REGEX argument, only - file names matching the regular expression (case sensitive) are shown. + List all files included in the journal. With a REGEX argument, only + file names matching the regular expression (case sensitive) are shown. help - Show the hledger user manual in the terminal, with info, man, or a - pager. With a TOPIC argument, open it at that topic if possible. - TOPIC can be any heading in the manual, or a heading prefix, case - insensitive. Eg: commands, print, forecast, journal, amount, "auto + Show the hledger user manual in the terminal, with info, man, or a + pager. With a TOPIC argument, open it at that topic if possible. + TOPIC can be any heading in the manual, or a heading prefix, case + insensitive. Eg: commands, print, forecast, journal, amount, "auto postings". This command shows the hledger manual built in to your hledger version. It can be useful when offline, or when you prefer the terminal to a web - browser, or when the appropriate hledger manual or viewing tools are + 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 (preferring info + By default it chooses the best viewer found in $PATH (preferring info since the hledger manual is large). You can select a particular viewer with the -i, -m, or -p flags. @@ -7474,71 +7479,71 @@ PART 4: COMMANDS $ hledger help journal # show the journal topic in the hledger manual 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 + already-imported transactions. So eg, if every day you download bank + CSV files containing redundant data, you can safely run hledger import + bank.csv and only new transactions will be imported. (import is idem- potent.) - Since the items being read (CSV records, eg) often do not come with - unique identifiers, hledger detects new transactions by date, assuming + Since the items being read (CSV records, eg) often do not come with + unique identifiers, hledger detects new transactions by date, assuming that: 1. new items always have the newest dates 2. item dates do not change across reads - 3. and items with the same date remain in the same relative order + 3. and items with the same date remain in the same relative order across reads. - These are often true of CSV files representing transactions, or true - enough so that it works pretty well in practice. 1 is important, but + These are often true of CSV files representing transactions, or true + enough so that it works pretty well in practice. 1 is important, but violations of 2 and 3 amongst the old transactions won't matter (and if - you import often, the new transactions will be few, so less likely to + you import often, the new transactions will be few, so less likely to be the ones affected). - hledger remembers the latest date processed in each input file by sav- + hledger remembers the latest date processed in each input file by sav- ing a hidden ".latest" state file in the same directory. Eg when read- - ing finance/bank.csv, it will look for and update the finance/.lat- - est.bank.csv state file. The format is simple: one or more lines con- - taining the same ISO-format date (YYYY-MM-DD), meaning "I have pro- - cessed transactions up to this date, and this many of them on that + ing finance/bank.csv, it will look for and update the finance/.lat- + est.bank.csv state file. The format is simple: one or more lines con- + taining the same ISO-format date (YYYY-MM-DD), meaning "I have pro- + cessed transactions up to this date, and this many of them on that date." Normally you won't see or manipulate these state files yourself. - But if needed, you can delete them to reset the state (making all - transactions "new"), or you can construct them to "catch up" to a cer- + But if needed, you can delete them to reset the state (making all + transactions "new"), or you can construct them to "catch up" to a cer- tain date. - Note deduplication (and updating of state files) can also be done by + Note deduplication (and updating of state files) can also be done by print --new, but this is less often used. Import testing - With --dry-run, the transactions that will be imported are printed to + With --dry-run, the transactions that will be imported are printed to the terminal, without updating your journal or state files. The output - is valid journal format, like the print command, so you can re-parse - it. Eg, to see any importable transactions which CSV rules have not + is valid journal format, like the print command, so you can re-parse + it. Eg, to see any importable transactions which CSV rules have not categorised: $ hledger import --dry bank.csv | hledger -f- -I print unknown @@ -7554,17 +7559,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 @@ -7575,12 +7580,12 @@ PART 4: COMMANDS (is) This command displays an income statement, showing revenues and - expenses during one or more periods. Amounts are shown with normal + expenses during one or more periods. Amounts are shown with normal positive sign, as in conventional financial statements. - 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: @@ -7607,21 +7612,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- + This command also supports the output destination and output format + options The output formats supported are txt, csv, html, and (experi- mental) 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 + alphabetic order. You can add a query to select a subset of transac- + tions. The note is the part of the transaction description after a | character (or if there is no |, the whole description). Example: @@ -7633,14 +7638,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: @@ -7651,10 +7656,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- + reverse-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 @@ -7663,17 +7668,17 @@ 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 + to reformat your journal you should take care to also copy over the directives and file-level comments. Eg: @@ -7700,7 +7705,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: @@ -7710,7 +7715,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. @@ -7719,33 +7724,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 + 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 + 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 + options The output formats supported are txt, csv, and (experimental) json and sql. Here's an example of print's CSV output: @@ -7764,20 +7769,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 @@ -7786,14 +7791,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 @@ -7804,14 +7809,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 @@ -7821,30 +7826,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 + the whole report period). This flag implies --empty (see below). It + is affected by --historical. It works best when showing just one account and one commodity. - The --related/-r flag shows the other postings in the transactions of + The --related/-r flag shows the other postings in the transactions of the postings which would normally be shown. - The --invert flag negates all amounts. For example, it can be used on + The --invert flag negates all amounts. For example, it can be used on an income account where amounts are normally displayed as negative num- - bers. It's also useful to show postings on the checking account + bers. It's also useful to show postings on the checking account together with the related account: $ hledger register --related --invert assets:checking - With a reporting interval, register shows summary postings, one per + With a reporting interval, register shows summary postings, one per interval, aggregating the postings to each account: $ hledger register --monthly income 2008/01 income:salary $-1 $-1 2008/06 income:gifts $-1 $-2 - Periods with no activity, and summary postings with a zero amount, are + Periods with no activity, and summary postings with a zero amount, are not shown by default; use the --empty/-E flag to see them: $ hledger register --monthly income -E @@ -7861,7 +7866,7 @@ PART 4: COMMANDS 2008/11 0 $-2 2008/12 0 $-2 - Often, you'll want to see just one line per interval. The --depth + Often, you'll want to see just one line per interval. The --depth option helps with this, causing subaccounts to be aggregated: $ hledger register --monthly assets --depth 1h @@ -7869,24 +7874,24 @@ PART 4: COMMANDS 2008/06 assets $-1 0 2008/12 assets $-1 $-1 - Note when using report intervals, if you specify start/end dates these - will be adjusted outward if necessary to contain a whole number of - intervals. This ensures that the first and last intervals are full + Note when using report intervals, if you specify start/end dates these + will be adjusted outward if necessary to contain a whole number of + intervals. This ensures that the first and last intervals are full length and comparable to the others in the report. - 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: + The description and account columns normally share the space equally + (about half of (width - 40) each). You can adjust this by adding a + description width as part of --width's argument, comma-separated: --width W,D . Here's a diagram (won't display correctly in --help): <--------------------------------- width (W) ----------------------------------> @@ -7902,19 +7907,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 + options 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: @@ -7930,7 +7935,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: @@ -7940,16 +7945,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- + factor for an amount of original matched posting. If the amount + includes a commodity name, the new posting amount will be in the new + commodity; otherwise, it will be in the matched posting amount's com- modity. Re-write rules in a file - During the run this tool will execute so called "Automated Transac- + During the run this tool will execute so called "Automated Transac- tions" found in any journal it process. I.e instead of specifying this operations in command line you can put them in a journal file. @@ -7964,7 +7969,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. @@ -7977,12 +7982,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' @@ -8006,10 +8011,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: @@ -8017,53 +8022,53 @@ 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. + o rewrite applies rules specified on command line or in the journal. print --auto applies rules specified in the journal. roi - Shows the time-weighted (TWR) and money-weighted (IRR) rate of return + Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on your investments. - At a minimum, you need to supply a query (which could be just an - account name) to select your investment(s) with --inv, and another + At a minimum, you need to supply a query (which could be just an + account name) to select your investment(s) with --inv, and another query to identify your profit and loss transactions with --pnl. - If you do not record changes in the value of your investment manually, - or do not require computation of time-weighted return (TWR), --pnl + If you do not record changes in the value of your investment manually, + or do not require computation of time-weighted return (TWR), --pnl could be an empty query (--pnl "" or --pnl STR where STR does not match any of your accounts). - This command will compute and display the internalized rate of return - (IRR) and time-weighted rate of return (TWR) for your investments for - the time period requested. Both rates of return are annualized before + This command will compute and display the internalized rate of return + (IRR) and time-weighted rate of return (TWR) for your investments for + the time period requested. Both rates of return are annualized before display, regardless of the length of reporting interval. - Price directives will be taken into account if you supply appropriate + Price directives will be taken into account if you supply appropriate --cost or --value flags (see VALUATION). Note, in some cases this report can fail, for these reasons: - o Error (NotBracketed): No solution for Internal Rate of Return (IRR). - Possible causes: IRR is huge (>1000000%), balance of investment + o Error (NotBracketed): No solution for Internal Rate of Return (IRR). + Possible causes: IRR is huge (>1000000%), balance of investment becomes negative at some point in time. - o Error (SearchFailed): Failed to find solution for Internal Rate of + o Error (SearchFailed): Failed to find solution for Internal Rate of Return (IRR). Either search does not converge to a solution, or con- verges too slowly. Examples: - o Using roi to compute total return of investment in stocks: + o Using roi to compute total return of investment in stocks: https://github.com/simonmichael/hledger/blob/master/examples/invest- ing/roi-unrealised.ledger @@ -8073,27 +8078,27 @@ PART 4: COMMANDS Note that --inv and --pnl's argument is a query, and queries could have several space-separated terms (see QUERIES). - To indicate that all search terms form single command-line argument, + To indicate that all search terms form single command-line argument, you will need to put them in quotes (see Special characters): $ hledger roi --inv 'term1 term2 term3 ...' - If any query terms contain spaces themselves, you will need an extra + If any query terms contain spaces themselves, you will need an extra level of nested quoting, eg: $ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'" Semantics of --inv and --pnl - Query supplied to --inv has to match all transactions that are related + Query supplied to --inv has to match all transactions that are related to your investment. Transactions not matching --inv will be ignored. In these transactions, ROI will conside postings that match --inv to be - "investment postings" and other postings (not matching --inv) will be - sorted into two categories: "cash flow" and "profit and loss", as ROI - needs to know which part of the investment value is your contributions + "investment postings" and other postings (not matching --inv) will be + sorted into two categories: "cash flow" and "profit and loss", as ROI + needs to know which part of the investment value is your contributions and which is due to the return on investment. - o "Cash flow" is depositing or withdrawing money, buying or selling + o "Cash flow" is depositing or withdrawing money, buying or selling assets, or otherwise converting between your investment commodity and any other commodity. Example: @@ -8111,12 +8116,12 @@ PART 4: COMMANDS investment:snake oil = $57 equity:unrealized profit or loss - All non-investment postings are assumed to be "cash flow", unless they - match --pnl query. Changes in value of your investment due to "profit - and loss" postings will be considered as part of your investment + 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. - Example: if you use --inv snake --pnl equity:unrealized, then postings + Example: if you use --inv snake --pnl equity:unrealized, then postings in the example below would be classifed as: 2019-01-01 Snake Oil #1 @@ -8133,57 +8138,57 @@ PART 4: COMMANDS snake oil $50 ; investment posting IRR and TWR explained - "ROI" stands for "return on investment". Traditionally this was com- - puted as a difference between current value of investment and its ini- + "ROI" stands for "return on investment". Traditionally this was com- + puted as a difference between current value of investment and its ini- tial value, expressed in percentage of the initial value. However, this approach is only practical in simple cases, where invest- - ments receives no in-flows or out-flows of money, and where rate of + ments receives no in-flows or out-flows of money, and where rate of growth is fixed over time. For more complex scenarios you need differ- - ent ways to compute rate of return, and this command implements two of + ent ways to compute rate of return, and this command implements two of them: IRR and TWR. - Internal rate of return, or "IRR" (also called "money-weighted rate of - return") takes into account effects of in-flows and out-flows. + Internal rate of return, or "IRR" (also called "money-weighted rate of + return") takes into account effects of in-flows and out-flows. Naively, if you are withdrawing from your investment, your future gains - 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 + 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 - way that gives you a compound annual rate of return that investment is + way that gives you a compound annual rate of return that investment is expected to generate. - As mentioned before, in-flows and out-flows would be any cash that you + As mentioned before, in-flows and out-flows would be any cash that you personally put in or withdraw, and for the "roi" command, these are the - postings that match the query in the--inv argument and NOT match the + postings that match the query in the--inv argument and NOT match the query in the--pnl argument. - If you manually record changes in the value of your investment as - transactions that balance them against "profit and loss" (or "unreal- - ized gains") account or use price directives, then in order for IRR to - compute the precise effect of your in-flows and out-flows on the rate - of return, you will need to record the value of your investement on or + If you manually record changes in the value of your investment as + transactions that balance them against "profit and loss" (or "unreal- + ized gains") account or use price directives, then in order for IRR to + compute the precise effect of your in-flows and out-flows on the rate + of return, you will need to record the value of your investement on or close to the days when in- or out-flows occur. - In technical terms, IRR uses the same approach as computation of net + In technical terms, IRR uses the same approach as computation of net present value, and tries to find a discount rate that makes net present value of all the cash flows of your investment to add up to zero. This - could be hard to wrap your head around, especially if you haven't done + could be hard to wrap your head around, especially if you haven't done discounted cash flow analysis before. Implementation of IRR in hledger should produce results that match the XIRR formula in Excel. - Second way to compute rate of return that roi command implements is + Second way to compute rate of return that roi command implements is called "time-weighted rate of return" or "TWR". Like IRR, it will also - break the history of your investment into periods between in-flows, - out-flows and value changes, to compute rate of return per each period - and then a compound rate of return. However, internal workings of TWR + break the history of your investment into periods between in-flows, + out-flows and value changes, to compute rate of return per each period + and then a compound rate of return. However, internal workings of TWR are quite different. - TWR represents your investment as an imaginary "unit fund" where in- - flows/ out-flows lead to buying or selling "units" of your investment + TWR represents your investment as an imaginary "unit fund" where in- + flows/ out-flows lead to buying or selling "units" of your investment and changes in its value change the value of "investment unit". Change - in "unit price" over the reporting period gives you rate of return of + in "unit price" over the reporting period gives you rate of return of your investment. References: @@ -8194,21 +8199,21 @@ PART 4: COMMANDS o Explanation of TWR - o Examples of computing IRR and TWR and discussion of the limitations + o Examples of computing IRR and TWR and discussion of the limitations of both metrics stats Show journal and performance statistics. - The stats command displays summary information for the whole journal, - or a matched part of it. With a reporting interval, it shows a report + The stats command displays summary information for the whole journal, + or a matched part of it. With a reporting interval, it shows a report for each report period. - At the end, it shows (in the terminal) the overall run time and number - of transactions processed per second. Note these are approximate and - will vary based on machine, current load, data size, hledger version, - haskell lib versions, GHC version.. but they may be of interest. The - stats command's run time is similar to that of a single-column balance + At the end, it shows (in the terminal) the overall run time and number + of transactions processed per second. Note these are approximate and + will vary based on machine, current load, data size, hledger version, + haskell lib versions, GHC version.. but they may be of interest. The + stats command's run time is similar to that of a single-column balance report. Example: @@ -8238,35 +8243,35 @@ PART 4: COMMANDS This command lists the tag names used in the journal, whether on trans- actions, postings, or account declarations. - With a TAGREGEX argument, only tag names matching this regular expres- + With a TAGREGEX argument, only tag names matching this regular expres- sion (case insensitive, infix matched) are shown. - With QUERY arguments, only transactions and accounts matching this + With QUERY arguments, only transactions and accounts matching this query are considered. If the query involves transaction fields (date:, desc:, amt:, ...), the search is restricted to the matched transactions and their accounts. - With the --values flag, the tags' unique non-empty values are listed + With the --values flag, the tags' unique non-empty values are listed instead. With -E/--empty, blank/empty values are also shown. - With --parsed, tags or values are shown in the order they were parsed, - with duplicates included. (Except, tags from account declarations are + With --parsed, tags or values are shown in the order they were parsed, + with duplicates included. (Except, tags from account declarations are always shown first.) - Tip: remember, accounts also acquire tags from their parents, postings + Tip: remember, accounts also acquire tags from their parents, postings also acquire tags from their account and transaction, transactions also acquire tags from their postings. test Run built-in unit tests. - This command runs the unit tests built in to hledger and hledger-lib, - printing the results on stdout. If any test fails, the exit code will + This command runs the unit tests built in to hledger and hledger-lib, + printing the results on stdout. If any test fails, the exit code will be non-zero. - This is mainly used by hledger developers, but you can also use it to - sanity-check the installed hledger executable on your platform. All - tests are expected to pass - if you ever see a failure, please report + This is mainly used by hledger developers, but you can also use it to + sanity-check the installed hledger executable on your platform. All + tests are expected to pass - if you ever see a failure, please report as a bug! This command also accepts tasty test runner options, written after a -- @@ -8275,12 +8280,12 @@ PART 4: COMMANDS $ hledger test -- -pData.Amount --color=never - For help on these, see https://github.com/feuerbach/tasty#options (-- + For help on these, see https://github.com/feuerbach/tasty#options (-- --help currently doesn't show them). PART 5: COMMON TASKS - Here are some quick examples of how to do some basic tasks with + Here are some quick examples of how to do some basic tasks with hledger. Getting help @@ -8290,37 +8295,37 @@ PART 5: COMMON TASKS $ hledger --help # show common options $ hledger CMD --help # show CMD's options, common options and CMD's documentation - You can also view your hledger version's manual in several formats by + You can also view your hledger version's manual in several formats by using the help command. Eg: $ hledger help # show the hledger manual with info, man or $PAGER (best available) $ hledger help journal # show the journal topic in the hledger manual $ hledger help --help # find out more about the help command - To view manuals and introductory docs on the web, visit - https://hledger.org. Chat and mail list support and discussion ar- + To view manuals and introductory docs on the web, visit + https://hledger.org. Chat and mail list support and discussion ar- chives can be found at https://hledger.org/support. Constructing command lines - hledger has a flexible command line interface. We strive to keep it - simple and ergonomic, but if you run into one of the sharp edges + 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: - o command-specific options must go after the command (it's fine to put + o command-specific options must go after the command (it's fine to put common options there too: hledger CMD OPTS ARGS) - o running add-on executables directly simplifies command line parsing + o running add-on executables directly simplifies command line parsing (hledger-ui OPTS ARGS) o enclose "problematic" args in single quotes - o if needed, also add a backslash to hide regular expression metachar- + o if needed, also add a backslash to hide regular expression metachar- acters from the shell o to see how a misbehaving command line is being parsed, add --debug=2. Starting a journal file - hledger looks for your accounting data in a journal file, + hledger looks for your accounting data in a journal file, $HOME/.hledger.journal by default: $ hledger stats @@ -8328,9 +8333,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 @@ -8354,20 +8359,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 + 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 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 @@ -8377,19 +8382,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 @@ -8426,18 +8431,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 @@ -8453,22 +8458,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 + already-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: @@ -8478,26 +8483,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 + 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. 3. Repeat for other asset/liability accounts. - Tip: instead of the register command, use hledger-ui to see a live- + 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 - 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 @@ -8569,7 +8574,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 @@ -8579,7 +8584,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 @@ -8646,9 +8651,9 @@ 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. @@ -8656,7 +8661,7 @@ PART 5: COMMON TASKS REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger chat or + Report bugs at http://bugs.hledger.org (or on the #hledger chat or hledger mail list)