From 32ef1e3dd97c8d426d47e5e38f67320eab1a8f7f Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 26 Jan 2024 22:49:07 -1000 Subject: [PATCH] ;doc: update manuals --- hledger-ui/hledger-ui.1 | 3 - hledger-ui/hledger-ui.info | 71 +- hledger-ui/hledger-ui.txt | 2 - hledger-web/hledger-web.1 | 3 - hledger-web/hledger-web.info | 39 +- hledger-web/hledger-web.txt | 2 - hledger/hledger.1 | 437 +++--- hledger/hledger.info | 1815 ++++++++++++----------- hledger/hledger.txt | 2649 +++++++++++++++++----------------- 9 files changed, 2598 insertions(+), 2423 deletions(-) diff --git a/hledger-ui/hledger-ui.1 b/hledger-ui/hledger-ui.1 index c8219ea23..f2aa3dbbd 100644 --- a/hledger-ui/hledger-ui.1 +++ b/hledger-ui/hledger-ui.1 @@ -113,9 +113,6 @@ Field separator to expect when reading CSV (default: \[aq],\[aq]) \f[CR]\-\-alias=OLD=NEW\f[R] rename accounts named OLD to NEW .TP -\f[CR]\-\-anon\f[R] -anonymize accounts and payees -.TP \f[CR]\-\-pivot FIELDNAME\f[R] use some other field or tag for the account name .TP diff --git a/hledger-ui/hledger-ui.info b/hledger-ui/hledger-ui.info index 205110711..7bce215aa 100644 --- a/hledger-ui/hledger-ui.info +++ b/hledger-ui/hledger-ui.info @@ -148,9 +148,6 @@ File: hledger-ui.info, Node: General input options, Next: General reporting op '--alias=OLD=NEW' rename accounts named OLD to NEW -'--anon' - - anonymize accounts and payees '--pivot FIELDNAME' use some other field or tag for the account name @@ -680,40 +677,40 @@ Node: General help options2951 Ref: #general-help-options3100 Node: General input options3382 Ref: #general-input-options3567 -Node: General reporting options4269 -Ref: #general-reporting-options4433 -Node: MOUSE7823 -Ref: #mouse7918 -Node: KEYS8155 -Ref: #keys8248 -Node: SCREENS12903 -Ref: #screens13001 -Node: Menu13581 -Ref: #menu13674 -Node: Cash accounts13869 -Ref: #cash-accounts14011 -Node: Balance sheet accounts14195 -Ref: #balance-sheet-accounts14376 -Node: Income statement accounts14496 -Ref: #income-statement-accounts14682 -Node: All accounts14846 -Ref: #all-accounts14992 -Node: Register15174 -Ref: #register15298 -Node: Transaction17582 -Ref: #transaction17705 -Node: Error19122 -Ref: #error19216 -Node: TIPS19460 -Ref: #tips19559 -Node: Watch mode19601 -Ref: #watch-mode19708 -Node: Debug output21167 -Ref: #debug-output21278 -Node: ENVIRONMENT21490 -Ref: #environment21600 -Node: BUGS21791 -Ref: #bugs21874 +Node: General reporting options4224 +Ref: #general-reporting-options4388 +Node: MOUSE7778 +Ref: #mouse7873 +Node: KEYS8110 +Ref: #keys8203 +Node: SCREENS12858 +Ref: #screens12956 +Node: Menu13536 +Ref: #menu13629 +Node: Cash accounts13824 +Ref: #cash-accounts13966 +Node: Balance sheet accounts14150 +Ref: #balance-sheet-accounts14331 +Node: Income statement accounts14451 +Ref: #income-statement-accounts14637 +Node: All accounts14801 +Ref: #all-accounts14947 +Node: Register15129 +Ref: #register15253 +Node: Transaction17537 +Ref: #transaction17660 +Node: Error19077 +Ref: #error19171 +Node: TIPS19415 +Ref: #tips19514 +Node: Watch mode19556 +Ref: #watch-mode19663 +Node: Debug output21122 +Ref: #debug-output21233 +Node: ENVIRONMENT21445 +Ref: #environment21555 +Node: BUGS21746 +Ref: #bugs21829  End Tag Table diff --git a/hledger-ui/hledger-ui.txt b/hledger-ui/hledger-ui.txt index 33724240e..2e5bcace9 100644 --- a/hledger-ui/hledger-ui.txt +++ b/hledger-ui/hledger-ui.txt @@ -102,8 +102,6 @@ OPTIONS --alias=OLD=NEW rename accounts named OLD to NEW - --anon anonymize accounts and payees - --pivot FIELDNAME use some other field or tag for the account name diff --git a/hledger-web/hledger-web.1 b/hledger-web/hledger-web.1 index 16609c107..3c76d9ebd 100644 --- a/hledger-web/hledger-web.1 +++ b/hledger-web/hledger-web.1 @@ -160,9 +160,6 @@ Field separator to expect when reading CSV (default: \[aq],\[aq]) \f[CR]\-\-alias=OLD=NEW\f[R] rename accounts named OLD to NEW .TP -\f[CR]\-\-anon\f[R] -anonymize accounts and payees -.TP \f[CR]\-\-pivot FIELDNAME\f[R] use some other field or tag for the account name .TP diff --git a/hledger-web/hledger-web.info b/hledger-web/hledger-web.info index 6cd9600b8..2a7390066 100644 --- a/hledger-web/hledger-web.info +++ b/hledger-web/hledger-web.info @@ -189,9 +189,6 @@ File: hledger-web.info, Node: General input options, Next: General reporting o '--alias=OLD=NEW' rename accounts named OLD to NEW -'--anon' - - anonymize accounts and payees '--pivot FIELDNAME' use some other field or tag for the account name @@ -638,24 +635,24 @@ Node: General help options5257 Ref: #general-help-options5407 Node: General input options5689 Ref: #general-input-options5875 -Node: General reporting options6577 -Ref: #general-reporting-options6742 -Node: PERMISSIONS10132 -Ref: #permissions10271 -Node: EDITING UPLOADING DOWNLOADING11483 -Ref: #editing-uploading-downloading11664 -Node: RELOADING12498 -Ref: #reloading12632 -Node: JSON API13065 -Ref: #json-api13180 -Node: DEBUG OUTPUT18668 -Ref: #debug-output18793 -Node: Debug output18820 -Ref: #debug-output-118921 -Node: ENVIRONMENT19338 -Ref: #environment19457 -Node: BUGS19574 -Ref: #bugs19658 +Node: General reporting options6532 +Ref: #general-reporting-options6697 +Node: PERMISSIONS10087 +Ref: #permissions10226 +Node: EDITING UPLOADING DOWNLOADING11438 +Ref: #editing-uploading-downloading11619 +Node: RELOADING12453 +Ref: #reloading12587 +Node: JSON API13020 +Ref: #json-api13135 +Node: DEBUG OUTPUT18623 +Ref: #debug-output18748 +Node: Debug output18775 +Ref: #debug-output-118876 +Node: ENVIRONMENT19293 +Ref: #environment19412 +Node: BUGS19529 +Ref: #bugs19613  End Tag Table diff --git a/hledger-web/hledger-web.txt b/hledger-web/hledger-web.txt index 010f464c8..13607090a 100644 --- a/hledger-web/hledger-web.txt +++ b/hledger-web/hledger-web.txt @@ -142,8 +142,6 @@ OPTIONS --alias=OLD=NEW rename accounts named OLD to NEW - --anon anonymize accounts and payees - --pivot FIELDNAME use some other field or tag for the account name diff --git a/hledger/hledger.1 b/hledger/hledger.1 index 5c289baa0..315d43a9c 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -343,9 +343,6 @@ Field separator to expect when reading CSV (default: \[aq],\[aq]) \f[CR]\-\-alias=OLD=NEW\f[R] rename accounts named OLD to NEW .TP -\f[CR]\-\-anon\f[R] -anonymize accounts and payees -.TP \f[CR]\-\-pivot FIELDNAME\f[R] use some other field or tag for the account name .TP @@ -992,6 +989,11 @@ $ hledger print \-c \[aq]$1.000,0\[aq] This option can repeated to set the display style for multiple commodities/currencies. Its argument is as described in the commodity directive. +.PP +hledger will occasionally make some additional adjustments to number +formatting, eg adding a trailing decimal mark to disambiguate numbers +with digit group marks; for details, see Amount formatting, +parseability. .SS Colour In terminal output, some commands can produce colour when the terminal supports it: @@ -1667,6 +1669,11 @@ reports. When rounding, hledger uses banker\[aq]s rounding (it rounds to the nearest even digit). So eg 0.5 displayed with zero decimal digits appears as \[dq]0\[dq]. +.SS Number format +hledger will occasionally make some additional adjustments to number +formatting, eg adding a trailing decimal mark to disambiguate numbers +with digit group marks; for details, see Amount formatting, +parseability. .PP .SS Costs After a posting amount, you can note its cost (when buying) or selling @@ -2018,8 +2025,11 @@ by a full colon, in a transaction or posting or account directive\[aq]s comment. (This is an exception to the usual rule that things in comments are ignored.) -Eg, here four different tags are recorded: one on the checking account, -two on the transaction, and one on the expenses posting: +You can write multiple tags separated by comma, and/or you can add more +comment lines and write more tags there. +.PP +Here five different tags are recorded: one on the checking account, two +on the transaction, and two on the expenses posting: .IP .EX account assets:checking ; accounttag: @@ -2027,18 +2037,58 @@ account assets:checking ; accounttag: 2017/1/16 bought groceries ; transactiontag\-1: ; transactiontag\-2: assets:checking $\-1 - expenses:food $1 ; postingtag: + expenses:food $1 ; postingtag:, another\-posting\-tag: .EE .PP -Postings also inherit tags from their transaction and their account. -And transactions also acquire tags from their postings (and -postings\[aq] accounts). -So in the example above, the expenses posting effectively has all four -tags (by inheriting from account and transaction), and the transaction -also has all four tags (by acquiring from the expenses posting). -.PP You can list tag names with \f[CR]hledger tags [NAMEREGEX]\f[R], or match by tag name with a \f[CR]tag:NAMEREGEX\f[R] query. +.SS Tag inheritance +Postings also inherit tags from their transaction and their account. +And transactions also acquire tags from their postings (and +postings\[aq] accounts). +So in the example above, the expenses posting effectively has all five +tags (by inheriting from the account and transaction), and the +transaction also has all five tags (by acquiring from the expenses +posting). +.SS Tag names +Tag names are currently not very clearly specified; any sequence of +non\-whitespace characters followed by a colon may work. +.PP +The following tag names are generated by hledger or have special +significance to hledger, so you may want to avoid using them yourself: +.IP \[bu] 2 +\f[CR]balances\f[R] \-\- a balance assertions transaction generated by +close +.IP \[bu] 2 +\f[CR]retain\f[R] \-\- a retain earnings transaction generated by close +.IP \[bu] 2 +\f[CR]start\f[R] \-\- a opening balances, closing balances or balance +assignment transaction generated by close +.IP \[bu] 2 +\f[CR]generated\-transaction\f[R] \-\- a transaction generated by +\-\-forecast +.IP \[bu] 2 +\f[CR]generated\-posting\f[R] \-\- a posting generated by \-\-auto +.IP \[bu] 2 +\f[CR]modified\f[R] \-\- a transaction which has had postings added by +\-\-auto +.IP \[bu] 2 +\f[CR]type\f[R] \-\- declares an account\[aq]s type in an account +declaration +.IP \[bu] 2 +\f[CR]t\f[R] \-\- stores the (user defined, single letter) type of a 15m +unit of time parsed from timedot format +.PP +Some additional tag names with an underscore prefix are used internally +and not displayed in reports (but can be matched by queries): +.IP \[bu] 2 +\f[CR]_generated\-transaction\f[R] +.IP \[bu] 2 +\f[CR]_generated\-posting\f[R] +.IP \[bu] 2 +\f[CR]_modified\f[R] +.IP \[bu] 2 +\f[CR]_conversion\-matched\f[R] .SS Tag values Tags can have a value, which is any text after the colon up until a comma or end of line (with surrounding whitespace removed). @@ -4206,12 +4256,14 @@ By default they are OR\[aq]d (any one of them can match) When a matcher is preceded by ampersand (\f[CR]&\f[R]) it will be AND\[aq]ed with the previous matcher (both of them must match) .IP \[bu] 2 -When a matcher is preceded by an exclamation mark (\f[CR]!\f[R]), the -matcher is negated (it may not match). +\f[I]Added in 1.32\f[R] When a matcher is preceded by an exclamation +mark (\f[CR]!\f[R]), the matcher is negated (it may not match). .PP Currently there is a limitation: you can\[aq]t use both \f[CR]&\f[R] and \f[CR]!\f[R] on the same line (you can\[aq]t AND a negated matcher). .SS Match groups +\f[I]Added in 1.32\f[R] +.PP Matchers can define match groups: parenthesised portions of the regular expression which are available for reference in field assignments. Groups are enclosed in regular parentheses (\f[CR](\f[R] and @@ -5195,7 +5247,7 @@ one or more dots (period characters), each representing 0.25. These are the dots in \[dq]timedot\[dq]. Spaces are ignored and can be used for grouping/alignment. .IP \[bu] 2 -one or more letters. +\f[I]Added in 1.32\f[R] one or more letters. These are like dots but they also generate a tag \f[CR]t:\f[R] (short for \[dq]type\[dq]) with the letter as its value, and a separate posting for each of the values. @@ -7876,7 +7928,7 @@ memory, use the \f[CR]\-\-align\-all\f[R] flag. This command also supports the output destination and output format options. The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], -\f[CR]tsv\f[R], and \f[CR]json\f[R]. +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), and \f[CR]json\f[R]. .SS aregister and posting dates aregister always shows one line (and date and amount) per transaction. But sometimes transactions have postings with different dates. @@ -7981,8 +8033,9 @@ commodities displayed on the same line or multiple lines (\f[CR]\-\-layout\f[R]) .PP This command supports the output destination and output format options, -with output formats \f[CR]txt\f[R], \f[CR]csv\f[R], \f[CR]tsv\f[R], -\f[CR]json\f[R], and (multi\-period reports only:) \f[CR]html\f[R]. +with output formats \f[CR]txt\f[R], \f[CR]csv\f[R], \f[CR]tsv\f[R] +(\f[I]Added in 1.32\f[R]), \f[CR]json\f[R], and (multi\-period reports +only:) \f[CR]html\f[R]. In \f[CR]txt\f[R] output in a colour\-supporting terminal, negative amounts are shown in red. .PP @@ -9041,7 +9094,8 @@ sign flipped. .PP This command also supports the output destination and output format options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], -\f[CR]tsv\f[R], \f[CR]html\f[R], and \f[CR]json\f[R]. +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]html\f[R], and +\f[CR]json\f[R]. .SS balancesheetequity (bse) .PP @@ -9149,7 +9203,8 @@ but with smarter account detection. .PP This command also supports the output destination and output format options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], -\f[CR]tsv\f[R], \f[CR]html\f[R], and \f[CR]json\f[R]. +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]html\f[R], and +\f[CR]json\f[R]. .SS check Check for various kinds of errors in your data. .PP @@ -9245,133 +9300,150 @@ against the real\-world balance.) .SS close (equity) .PP -A transaction\-generating command which generates several kinds of -\[dq]closing\[dq] and/or \[dq]opening\[dq] transactions useful in -certain situations. -It prints one or two transactions to stdout, but does not write them to -the journal file; you can append or copy them there when you are happy -with the output. +\f[CR]close\f[R] generates several kinds of \[dq]closing\[dq] and/or +\[dq]opening\[dq] transactions, useful in certain situations, including +migrating balances to a new journal file, retaining earnings into +equity, consolidating balances, or viewing lots. +Like \f[CR]print\f[R], it prints valid journal entries. +You can append or copy these to your journal file(s) when you are happy +with how they look. .PP -This command is most often used when migrating balances to a new journal -file, at the start of a new financial year. -It can also be used to \[dq]retain earnings\[dq] (transfer revenues and -expenses to equity), or as a sort of generic mover of balances from any -group of accounts to some other account. -So it currently has six modes, selected by a mode flag. -Use only one of these flags at a time: -.IP "1." 3 -With \f[CR]\-\-close\f[R] (or no mode flag) it prints a \[dq]closing -balances\[dq] transaction that zeroes out all the asset, liability, and -equity account balances, by default (this requires inferred or declared -account types). -Or, it will zero out the accounts matched by any ACCTQUERY arguments you -provide. -All of the balances are transferred to a special \[dq]opening/closing -balances\[dq] equity account. -.IP "2." 3 -With \f[CR]\-\-open\f[R], it prints an opposite \[dq]opening -balances\[dq] transaction that restores the same account balances, -starting from zero. -This mode is similar to Ledger\[aq]s equity command. -.IP "3." 3 -With \f[CR]\-\-migrate\f[R], it prints both the closing and opening -transactions above. -This is a common way to migrate balances to a new file at year end; run -\f[CR]hledger close \-\-migrate \-e NEWYEAR\f[R] (\-e influences the -transaction date) and add the closing transaction at the end of the old -file, and the opening transaction at the start of the new file. -Doing this means you can include past year files in your reports at any -time without disturbing asset/liability/equity balances, because the -closing balances transaction cancels out the following opening balances -transaction. -You will sometimes need to exclude these transactions from reports, eg -to see an end of year balance sheet; a \f[CR]not:opening/closing\f[R] -query argument should do. -You should probably also use this query when \f[CR]close\f[R]\-ing, to -exclude the \[dq]opening/closing balances\[dq] account which might -otherwise cause problems. -Or you can just migrate assets and liabilities: -\f[CR]hledger close type:AL\f[R]. -Most people don\[aq]t need to migrate equity. -And revenues and expenses usually should not be migrated. -.IP "4." 3 -With \f[CR]\-\-assert\f[R] it prints a \[dq]closing balances\[dq] -transaction that just asserts the current balances, without changing -them. -This can be useful as documention and to guard against errors and -changes. -.IP "5." 3 -With \f[CR]\-\-assign\f[R] it prints an \[dq]opening balances\[dq] -transaction that restores the account balances using balance -assignments. +\f[CR]close\f[R] currently has six modes, selected by a single mode +flag: +.SS close \-\-migrate +This is the most common mode. +It prints a \[dq]closing balances\[dq] transaction that zeroes out all +asset and liability balances (by default), and an opposite \[dq]opening +balances\[dq] transaction that restores them again. +The balancing account will be \f[CR]equity:opening/closing balances\f[R] +(or another specified by \f[CR]\-\-close\-acct\f[R] or +\f[CR]\-\-open\-acct\f[R]). +.PP +This is useful when migrating balances to a new journal file at the +start of a new year. +Essentially, you run +\f[CR]hledger close \-\-migrate=NEWYEAR \-e NEWYEAR\f[R] and then copy +the closing transaction to the end of the old file and the opening +transaction to the start of the new file. +The opening transaction sets correct starting balances in the new file +when it is used alone, and the closing transaction keeps balances +correct when you use both old and new files together, by cancelling out +the following opening transaction and preventing buildup of duplicated +opening balances. +Think of the closing/opening pair as \[dq]moving the balances into the +next file\[dq]. +.PP +You can close a different set of accounts by providing a query. +Eg if you want to include equity, you can add +\f[CR]assets liabilities equity\f[R] or \f[CR]type:ALE\f[R] arguments. +(The balancing account is always excluded.) +Revenues and expenses usually are not migrated to a new file directly; +see \f[CR]\-\-retain\f[R] below. +.PP +The generated transactions will have a \f[CR]start:\f[R] tag, with its +value set to \f[CR]\-\-migrate\f[R]\[aq]s \f[CR]NEW\f[R] argument if +any, for easier matching or exclusion. +When \f[CR]NEW\f[R] is not specified, it will be inferred if possible by +incrementing a number (eg a year number) within the default +journal\[aq]s main file name. +The other modes behave similarly. +.SS close \-\-close +This prints just the closing balances transaction of +\f[CR]\-\-migrate\f[R]. +It is the default behaviour if you specify no mode flag. +Using the customisation options below, you can move balances from any +set of accounts to a different account. +.SS close \-\-open +This prints just the opening balances transaction of +\f[CR]\-\-migrate\f[R]. +It is similar to Ledger\[aq]s equity command. +.SS close \-\-assert +This prints a \[dq]closing balances\[dq] transaction (with +\f[CR]balances:\f[R] tag), that just declares balance assertions for the +current balances without changing them. +It could be useful as documention and to guard against changes. +.SS close \-\-assign +This prints an \[dq]opening balances\[dq] transaction that restores the +account balances using balance assignments. Balance assignments work regardless of any previous balance, so a preceding closing balances transaction is not needed. -This is an alternative to \f[CR]\-\-close\f[R] and \f[CR]\-\-open\f[R]: -at year end, \f[CR]hledger close \-\-assert \-e NEWYEAR\f[R] in the old -file (optional, but useful for error checking), and -\f[CR]hledger close \-\-assign \-e NEWYEAR\f[R] in the new file. -This might be more convenient, eg if you are often doing cleanups or -fixes which would break closing/opening transactions. -.IP "6." 3 -With \f[CR]\-\-retain\f[R], it prints a \[dq]retain earnings\[dq] -transaction that transfers revenue and expense balances to -\f[CR]equity:retained earnings\f[R]. -This is a traditional end\-of\-period bookkeeping operation also called -\[dq]closing the books\[dq]; in personal accounting you probably will -not need this but it could be useful if you want to see the accounting -equation (A=L+E) balanced. .PP +However, omitting the closing balances transaction would unbalance +equity. +This is relatively harmless for personal reports, but it disturbs the +accounting equation, removing a source of error detection. +So \f[CR]\-\-migrate\f[R] is generally the best way to set to set +balances in new files, for now. +.SS close \-\-retain +This is like \f[CR]\-\-close\f[R] with different defaults: it prints a +\[dq]retain earnings\[dq] transaction (with \f[CR]retain:\f[R] tag), +that transfers revenue and expense balances to +\f[CR]equity:retained earnings\f[R]. +.PP +This is a different kind of closing, called \[dq]retaining earnings\[dq] +or \[dq]closing the books\[dq]; it is traditionally performed by +businesses at the end of each accounting period, to consolidate revenues +and expenses into the main equity balance. +(\[dq]Revenues\[dq] and \[dq]expenses\[dq] are actually equity by +another name, kept separate temporarily for reporting purposes.) +.PP +In personal accounting you generally don\[aq]t need to do this, unless +you want the \f[CR]balancesheetequity\f[R] report to show a zero total, +demonstrating that the accounting equation (A\-L=E) is satisfied. +.SS close customisation In all modes, the following things can be overridden: .IP \[bu] 2 -the transaction descriptions can be changed with -\f[CR]\-\-close\-desc=DESC\f[R] and \f[CR]\-\-open\-desc=DESC\f[R] +the accounts to be closed/opened, with account query arguments .IP \[bu] 2 -the account to transfer to and from can be changed with -\f[CR]\-\-close\-acct=ACCT\f[R] and \f[CR]\-\-open\-acct=ACCT\f[R] +the balancing account, with \f[CR]\-\-close\-acct=ACCT\f[R] and/or +\f[CR]\-\-open\-acct=ACCT\f[R] .IP \[bu] 2 -the accounts to be closed/opened can be changed with -\f[CR]ACCTQUERY\f[R] (account query arguments). +the transaction descriptions, with \f[CR]\-\-close\-desc=DESC\f[R] and +\f[CR]\-\-open\-desc=DESC\f[R] .IP \[bu] 2 -the closing/opening dates can be changed with \f[CR]\-e DATE\f[R] (a -report end date) +the transaction\[aq]s tag value, with a \f[CR]\-\-MODE=NEW\f[R] option +argument +.IP \[bu] 2 +the closing/opening dates, with \f[CR]\-e OPENDATE\f[R] .PP -By default just one destination/source posting will be used, with its -amount left implicit. -With \f[CR]\-\-x/\-\-explicit\f[R], the amount will be shown explicitly, -and if it involves multiple commodities, a separate posting will be -generated for each of them (similar to \f[CR]print \-x\f[R]). +By default, the closing date is yesterday, or the journal\[aq]s end +date, whichever is later; and the opening date is always one day after +the closing date. +You can change these by specifying a report end date; the closing date +will be the last day of the report period. +Eg \f[CR]\-e 2024\f[R] means \[dq]close on 2023\-12\-31, open on +2024\-01\-01\[dq]. .PP -With \f[CR]\-\-show\-costs\f[R], any amount costs are shown, with -separate postings for each cost. -This is currently the best way to view investment lots. -If you have many currency conversion or investment transactions, it can -generate very large journal entries. +With \f[CR]\-\-x/\-\-explicit\f[R], the balancing amount will be shown +explicitly, and if it involves multiple commodities, a separate posting +will be generated for each of them (similar to \f[CR]print \-x\f[R]). .PP With \f[CR]\-\-interleaved\f[R], each individual transfer is shown with -source and destination postings next to each other. -This could be useful for troubleshooting. +source and destination postings next to each other (perhaps useful for +troubleshooting). .PP -The default closing date is yesterday, or the journal\[aq]s end date, -whichever is later. -You can change this by specifying a report end date with \f[CR]\-e\f[R]. -The last day of the report period will be the closing date, eg -\f[CR]\-e 2024\f[R] means \[dq]close on 2023\-12\-31\[dq]. -The opening date is always the day after the closing date. +With \f[CR]\-\-show\-costs\f[R], balances\[aq] costs are also shown, +with different costs kept separate. +This may generate very large journal entries, if you have many currency +conversions or investment transactions. +\f[CR]close \-\-show\-costs\f[R] is currently the best way to view +investment lots with hledger. +(To move or dispose of lots, see the more capable +\f[CR]hledger\-move\f[R] script.) .SS 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 -there is an opening transaction). -.PP +\f[CR]close\f[R] adds balance assertions verifying that the accounts +have been reset to zero in a closing transaction or restored to their +previous balances in an opening transaction. These provide useful error checking, but you can ignore them temporarily with \f[CR]\-I\f[R], or remove them if you prefer. .PP -You probably should avoid filtering transactions by status or realness -(\f[CR]\-C\f[R], \f[CR]\-R\f[R], \f[CR]status:\f[R]), or generating -postings (\f[CR]\-\-auto\f[R]), with this command, since the balance -assertions would depend on these. +When running \f[CR]close\f[R] you should probably avoid using +\f[CR]\-C\f[R], \f[CR]\-R\f[R], \f[CR]status:\f[R] (filtering by status +or realness) or \f[CR]\-\-auto\f[R] (generating postings), since the +generated balance assertions would then require these. .PP -Note custom posting dates spanning the file boundary will disrupt the -balance assertions: +Transactions with multiple dates (eg posting dates) spanning the file +boundary also can disrupt the balance assertions: .IP .EX 2023\-12\-30 a purchase made in december, cleared in january @@ -9379,9 +9451,9 @@ balance assertions: assets:bank:checking \-5 ; date: 2023\-01\-02 .EE .PP -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: +To solve this you can transfer the money to and from a temporary +account, splitting the multi\-day transaction into two single\-day +transactions: .IP .EX ; in 2022.journal: @@ -9394,7 +9466,8 @@ single\-day transactions: equity:pending 5 = 0 assets:bank:checking \-5 .EE -.SS Example: retain earnings +.SS close examples +.SS Retain earnings Record 2022\[aq]s revenues/expenses as retained earnings on 2022\-12\-31, appending the generated transaction to the journal: .IP @@ -9402,15 +9475,14 @@ Record 2022\[aq]s revenues/expenses as retained earnings on $ hledger close \-\-retain \-f 2022.journal \-p 2022 >> 2022.journal .EE .PP -Note 2022\[aq]s income statement will now show only zeroes, because -revenues and expenses have been moved entirely to equity. -To see them again, you could exclude the retain transaction: +After this, to see 2022\[aq]s revenues and expenses you must exclude the +retain earnings transaction: .IP .EX $ hledger \-f 2022.journal is not:desc:\[aq]retain earnings\[aq] .EE -.SS Example: migrate balances to a new file -Close assets/liabilities/equity on 2022\-12\-31 and re\-open them on +.SS Migrate balances to a new file +Close assets/liabilities on 2022\-12\-31 and re\-open them on 2023\-01\-01: .IP .EX @@ -9419,74 +9491,27 @@ $ hledger close \-\-migrate \-f 2022.journal \-p 2022 # copy/paste the opening transaction to the start of 2023.journal .EE .PP -Now 2022\[aq]s balance sheet will show only zeroes, indicating a -balanced accounting equation. -(Unless you are using \[at]/\[at]\[at] notation \- in that case, try -adding \-\-infer\-equity.) -To see the end\-of\-year balances again, you could exclude the closing -transaction: +After this, to see 2022\[aq]s end\-of\-year balances you must exclude +the closing balances transaction: .IP .EX $ hledger \-f 2022.journal bs not:desc:\[aq]closing balances\[aq] .EE -.SS Example: excluding closing/opening transactions -When combining many files for multi\-year reports, the closing/opening -transactions cause some noise in transaction\-oriented reports like -\f[CR]print\f[R] and \f[CR]register\f[R]. -You can exclude them as shown above, but \f[CR]not:desc:...\f[R] is not -ideal as it depends on consistent descriptions; also you will want to -avoid excluding the very first opening transaction, which could be -awkward. -Here is one alternative, using tags: .PP -Add \f[CR]clopen:\f[R] tags to all opening/closing balances transactions -except the first, like this: +For more flexibility, it helps to tag closing and opening transactions +with eg \f[CR]start:NEWYEAR\f[R], then you can ensure correct balances +by excluding all opening/closing transactions except the first, like so: .IP .EX -; 2021.journal -2021\-06\-01 first opening balances -\&... -2021\-12\-31 closing balances ; clopen:2022 -\&... -.EE -.IP -.EX -; 2022.journal -2022\-01\-01 opening balances ; clopen:2022 -\&... -2022\-12\-31 closing balances ; clopen:2023 -\&... -.EE -.IP -.EX -; 2023.journal -2023\-01\-01 opening balances ; clopen:2023 -\&... -.EE -.PP -Now, assuming a combined journal like: -.IP -.EX -; all.journal -include 2021.journal -include 2022.journal -include 2023.journal -.EE -.PP -The \f[CR]clopen:\f[R] tag can exclude all but the first opening -transaction. -To show a clean multi\-year checking register: -.IP -.EX -$ hledger \-f all.journal areg checking not:tag:clopen -.EE -.PP -And the year values allow more precision. -To show 2022\[aq]s year\-end balance sheet: -.IP -.EX -$ hledger \-f all.journal bs \-e2023 not:tag:clopen=2023 +$ hledger bs \-Y \-f 2021.j \-f 2022.j \-f 2023.j expr:\[aq]tag:start=2021 or not tag:start\[aq] +$ hledger bs \-Y \-f 2021.j \-f 2022.j expr:\[aq]tag:start=2021 or not tag:start\[aq] +$ hledger bs \-Y \-f 2022.j \-f 2023.j expr:\[aq]tag:start=2022 or not tag:start\[aq] +$ hledger bs \-Y \-f 2021.j expr:\[aq]tag:start=2021 or not tag:start\[aq] +$ hledger bs \-Y \-f 2022.j expr:\[aq]tag:start=2022 or not tag:start\[aq] +$ hledger bs \-Y \-f 2023.j # unclosed file, no query needed .EE +.SS More detailed close examples +See examples/multi\-year. .SS codes List the codes seen in transactions, in the order parsed. .PP @@ -9816,7 +9841,8 @@ sign flipped. .PP This command also supports the output destination and output format options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], -\f[CR]tsv\f[R], \f[CR]html\f[R], and \f[CR]json\f[R]. +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]html\f[R], and +\f[CR]json\f[R]. .SS notes List the unique notes that appear in transactions. .PP @@ -9928,9 +9954,9 @@ their symbol placement, decimal mark, and digit group marks will be made consistent. By default, decimal digits are shown as they are written in the journal. .PP -With the \f[CR]\-\-round\f[R] option, \f[CR]print\f[R] will try -increasingly hard to display decimal digits according to the commodity -display styles: +With the \f[CR]\-\-round\f[R] (\f[I]Added in 1.32\f[R]) option, +\f[CR]print\f[R] will try increasingly hard to display decimal digits +according to the commodity display styles: .IP \[bu] 2 \f[CR]\-\-round=none\f[R] show amounts with original precisions (default) @@ -9988,8 +10014,9 @@ the program exit code will be non\-zero. .SS print output format This command also supports the output destination and output format options The output formats supported are \f[CR]txt\f[R], -\f[CR]beancount\f[R], \f[CR]csv\f[R], \f[CR]tsv\f[R], \f[CR]json\f[R] -and \f[CR]sql\f[R]. +\f[CR]beancount\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]csv\f[R], +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), \f[CR]json\f[R] and +\f[CR]sql\f[R]. .PP The \f[CR]beancount\f[R] format tries to produce Beancount\-compatible output, as follows: @@ -10211,7 +10238,7 @@ $ hledger reg \-w $COLUMNS,40 # use terminal width, & description width 40 .PP This command also supports the output destination and output format options The output formats supported are \f[CR]txt\f[R], \f[CR]csv\f[R], -\f[CR]tsv\f[R], and \f[CR]json\f[R]. +\f[CR]tsv\f[R] (\f[I]Added in 1.32\f[R]), and \f[CR]json\f[R]. .SS rewrite Print all transactions, rewriting the postings of matched transactions. For now the only rewrite available is adding new postings, like print diff --git a/hledger/hledger.info b/hledger/hledger.info index 0ab082583..1a18c28f9 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -360,9 +360,6 @@ File: hledger.info, Node: General input options, Next: General reporting optio '--alias=OLD=NEW' rename accounts named OLD to NEW -'--anon' - - anonymize accounts and payees '--pivot FIELDNAME' use some other field or tag for the account name @@ -952,6 +949,11 @@ $ hledger print -c '$1.000,0' commodities/currencies. Its argument is as described in the commodity directive. + hledger will occasionally make some additional adjustments to number +formatting, eg adding a trailing decimal mark to disambiguate numbers +with digit group marks; for details, see Amount formatting, +parseability. +  File: hledger.info, Node: Colour, Next: Box-drawing, Prev: Commodity styles, Up: Output @@ -1566,6 +1568,7 @@ EUR 1E3 * Directives influencing number parsing and display:: * Commodity display style:: * Rounding:: +* Number format::  File: hledger.info, Node: Decimal marks digit group marks, Next: Commodity, Up: Amounts @@ -1679,7 +1682,7 @@ as decimal mark, and two decimal digits). '-c/--commodity-style' command line option.  -File: hledger.info, Node: Rounding, Prev: Commodity display style, Up: Amounts +File: hledger.info, Node: Rounding, Next: Number format, Prev: Commodity display style, Up: Amounts 9.12.5 Rounding --------------- @@ -1692,6 +1695,17 @@ by other reports. When rounding, hledger uses banker's rounding (it rounds to the nearest even digit). So eg 0.5 displayed with zero decimal digits appears as "0". + +File: hledger.info, Node: Number format, Prev: Rounding, Up: Amounts + +9.12.6 Number format +-------------------- + +hledger will occasionally make some additional adjustments to number +formatting, eg adding a trailing decimal mark to disambiguate numbers +with digit group marks; for details, see Amount formatting, +parseability. +  File: hledger.info, Node: Costs, Next: Balance assertions, Prev: Amounts, Up: Journal @@ -2059,35 +2073,77 @@ postings, or accounts, which you can then search or pivot on. They are written as a word (optionally hyphenated) immediately followed by a full colon, in a transaction or posting or account directive's comment. (This is an exception to the usual rule that -things in comments are ignored.) Eg, here four different tags are -recorded: one on the checking account, two on the transaction, and one -on the expenses posting: +things in comments are ignored.) You can write multiple tags separated +by comma, and/or you can add more comment lines and write more tags +there. + + Here five different tags are recorded: one on the checking account, +two on the transaction, and two on the expenses posting: account assets:checking ; accounttag: 2017/1/16 bought groceries ; transactiontag-1: ; transactiontag-2: assets:checking $-1 - expenses:food $1 ; postingtag: - - Postings also inherit tags from their transaction and their account. -And transactions also acquire tags from their postings (and postings' -accounts). So in the example above, the expenses posting effectively -has all four tags (by inheriting from account and transaction), and the -transaction also has all four tags (by acquiring from the expenses -posting). + expenses:food $1 ; postingtag:, another-posting-tag: You can list tag names with 'hledger tags [NAMEREGEX]', or match by tag name with a 'tag:NAMEREGEX' query. * Menu: +* Tag inheritance:: +* Tag names:: * Tag values::  -File: hledger.info, Node: Tag values, Up: Tags +File: hledger.info, Node: Tag inheritance, Next: Tag names, Up: Tags -9.16.1 Tag values +9.16.1 Tag inheritance +---------------------- + +Postings also inherit tags from their transaction and their account. +And transactions also acquire tags from their postings (and postings' +accounts). So in the example above, the expenses posting effectively +has all five tags (by inheriting from the account and transaction), and +the transaction also has all five tags (by acquiring from the expenses +posting). + + +File: hledger.info, Node: Tag names, Next: Tag values, Prev: Tag inheritance, Up: Tags + +9.16.2 Tag names +---------------- + +Tag names are currently not very clearly specified; any sequence of +non-whitespace characters followed by a colon may work. + + The following tag names are generated by hledger or have special +significance to hledger, so you may want to avoid using them yourself: + + * 'balances' - a balance assertions transaction generated by close + * 'retain' - a retain earnings transaction generated by close + * 'start' - a opening balances, closing balances or balance + assignment transaction generated by close + * 'generated-transaction' - a transaction generated by -forecast + * 'generated-posting' - a posting generated by -auto + * 'modified' - a transaction which has had postings added by -auto + * 'type' - declares an account's type in an account declaration + * 't' - stores the (user defined, single letter) type of a 15m unit + of time parsed from timedot format + + Some additional tag names with an underscore prefix are used +internally and not displayed in reports (but can be matched by queries): + + * '_generated-transaction' + * '_generated-posting' + * '_modified' + * '_conversion-matched' + + +File: hledger.info, Node: Tag values, Prev: Tag names, Up: Tags + +9.16.3 Tag values ----------------- Tags can have a value, which is any text after the colon up until a @@ -4241,8 +4297,8 @@ When an if block has multiple matchers, they are combined as follows: * By default they are OR'd (any one of them can match) * When a matcher is preceded by ampersand ('&') it will be AND'ed with the previous matcher (both of them must match) - * When a matcher is preceded by an exclamation mark ('!'), the - matcher is negated (it may not match). + * _Added in 1.32_ When a matcher is preceded by an exclamation mark + ('!'), the matcher is negated (it may not match). Currently there is a limitation: you can't use both '&' and '!' on the same line (you can't AND a negated matcher). @@ -4253,12 +4309,14 @@ File: hledger.info, Node: Match groups, Prev: Combining matchers, Up: Matcher 10.14.3 Match groups -------------------- -Matchers can define match groups: parenthesised portions of the regular -expression which are available for reference in field assignments. -Groups are enclosed in regular parentheses ('(' and ')') and can be -nested. Each group is available in field assignments using the token -'\N', where N is an index into the match groups for this conditional -block (e.g. '\1', '\2', etc.). +_Added in 1.32_ + + Matchers can define match groups: parenthesised portions of the +regular expression which are available for reference in field +assignments. Groups are enclosed in regular parentheses ('(' and ')') +and can be nested. Each group is available in field assignments using +the token '\N', where N is an index into the match groups for this +conditional block (e.g. '\1', '\2', etc.). Example: Warp credit card payment postings to the beginning of the billing period (Month start), to match how they are presented in @@ -5221,11 +5279,11 @@ and/or a transaction comment following a semicolon. These are the dots in "timedot". Spaces are ignored and can be used for grouping/alignment. - * one or more letters. These are like dots but they also - generate a tag 't:' (short for "type") with the letter as its - value, and a separate posting for each of the values. This - provides a second dimension of categorisation, viewable in - reports with '--pivot t'. + * _Added in 1.32_ one or more letters. These are like dots but + they also generate a tag 't:' (short for "type") with the + letter as its value, and a separate posting for each of the + values. This provides a second dimension of categorisation, + viewable in reports with '--pivot t'. * *An optional comment* following a semicolon (a hledger-style posting comment). @@ -7510,8 +7568,8 @@ ensure perfect alignment, at the cost of more time and memory, use the '--align-all' flag. This command also supports the output destination and output format -options. The output formats supported are 'txt', 'csv', 'tsv', and -'json'. +options. The output formats supported are 'txt', 'csv', 'tsv' (_Added +in 1.32_), and 'json'. * Menu: @@ -7632,8 +7690,8 @@ higher-level commands as well. ('--layout') This command supports the output destination and output format -options, with output formats 'txt', 'csv', 'tsv', 'json', and -(multi-period reports only:) 'html'. In 'txt' output in a +options, with output formats 'txt', 'csv', 'tsv' (_Added in 1.32_), +'json', and (multi-period reports only:) 'html'. In 'txt' output in a colour-supporting terminal, negative amounts are shown in red. The '--related'/'-r' flag shows the balance of the _other_ postings @@ -8585,8 +8643,8 @@ smarter account detection, and liabilities displayed with their sign flipped. This command also supports the output destination and output format -options The output formats supported are 'txt', 'csv', 'tsv', 'html', -and 'json'. +options The output formats supported are 'txt', 'csv', 'tsv' (_Added in +1.32_), 'html', and 'json'.  File: hledger.info, Node: balancesheetequity, Next: cashflow, Prev: balancesheet, Up: PART 4 COMMANDS @@ -8692,8 +8750,8 @@ It is similar to 'hledger balance assets not:fixed not:investment not:receivable', but with smarter account detection. This command also supports the output destination and output format -options The output formats supported are 'txt', 'csv', 'tsv', 'html', -and 'json'. +options The output formats supported are 'txt', 'csv', 'tsv' (_Added in +1.32_), 'html', and 'json'.  File: hledger.info, Node: check, Next: close, Prev: cashflow, Up: PART 4 COMMANDS @@ -8829,134 +8887,194 @@ File: hledger.info, Node: close, Next: codes, Prev: check, Up: PART 4 COMMAN (equity) - A transaction-generating command which generates several kinds of -"closing" and/or "opening" transactions useful in certain situations. -It prints one or two transactions to stdout, but does not write them to -the journal file; you can append or copy them there when you are happy -with the output. + 'close' generates several kinds of "closing" and/or "opening" +transactions, useful in certain situations, including migrating balances +to a new journal file, retaining earnings into equity, consolidating +balances, or viewing lots. Like 'print', it prints valid journal +entries. You can append or copy these to your journal file(s) when you +are happy with how they look. - This command is most often used when migrating balances to a new -journal file, at the start of a new financial year. It can also be used -to "retain earnings" (transfer revenues and expenses to equity), or as a -sort of generic mover of balances from any group of accounts to some -other account. So it currently has six modes, selected by a mode flag. -Use only one of these flags at a time: - - 1. With '--close' (or no mode flag) it prints a "closing balances" - transaction that zeroes out all the asset, liability, and equity - account balances, by default (this requires inferred or declared - account types). Or, it will zero out the accounts matched by any - ACCTQUERY arguments you provide. All of the balances are - transferred to a special "opening/closing balances" equity account. - - 2. With '--open', it prints an opposite "opening balances" transaction - that restores the same account balances, starting from zero. This - mode is similar to Ledger's equity command. - - 3. With '--migrate', it prints both the closing and opening - transactions above. This is a common way to migrate balances to a - new file at year end; run 'hledger close --migrate -e NEWYEAR' (-e - influences the transaction date) and add the closing transaction at - the end of the old file, and the opening transaction at the start - of the new file. Doing this means you can include past year files - in your reports at any time without disturbing - asset/liability/equity balances, because the closing balances - transaction cancels out the following opening balances transaction. - You will sometimes need to exclude these transactions from reports, - eg to see an end of year balance sheet; a 'not:opening/closing' - query argument should do. You should probably also use this query - when 'close'-ing, to exclude the "opening/closing balances" account - which might otherwise cause problems. Or you can just migrate - assets and liabilities: 'hledger close type:AL'. Most people don't - need to migrate equity. And revenues and expenses usually should - not be migrated. - - 4. With '--assert' it prints a "closing balances" transaction that - just asserts the current balances, without changing them. This can - be useful as documention and to guard against errors and changes. - - 5. With '--assign' it prints an "opening balances" transaction that - restores the account balances using balance assignments. Balance - assignments work regardless of any previous balance, so a preceding - closing balances transaction is not needed. This is an alternative - to '--close' and '--open': at year end, 'hledger close --assert -e - NEWYEAR' in the old file (optional, but useful for error checking), - and 'hledger close --assign -e NEWYEAR' in the new file. This - might be more convenient, eg if you are often doing cleanups or - fixes which would break closing/opening transactions. - - 6. With '--retain', it prints a "retain earnings" transaction that - transfers revenue and expense balances to 'equity:retained - earnings'. This is a traditional end-of-period bookkeeping - operation also called "closing the books"; in personal accounting - you probably will not need this but it could be useful if you want - to see the accounting equation (A=L+E) balanced. - - In all modes, the following things can be overridden: - - * the transaction descriptions can be changed with - '--close-desc=DESC' and '--open-desc=DESC' - * the account to transfer to and from can be changed with - '--close-acct=ACCT' and '--open-acct=ACCT' - * the accounts to be closed/opened can be changed with 'ACCTQUERY' - (account query arguments). - * the closing/opening dates can be changed with '-e DATE' (a report - end date) - - By default just one destination/source posting will be used, with its -amount left implicit. With '--x/--explicit', the amount will be shown -explicitly, and if it involves multiple commodities, a separate posting -will be generated for each of them (similar to 'print -x'). - - With '--show-costs', any amount costs are shown, with separate -postings for each cost. This is currently the best way to view -investment lots. If you have many currency conversion or investment -transactions, it can generate very large journal entries. - - With '--interleaved', each individual transfer is shown with source -and destination postings next to each other. This could be useful for -troubleshooting. - - 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 -with '-e'. The last day of the report period will be the closing date, -eg '-e 2024' means "close on 2023-12-31". The opening date is always -the day after the closing date. + 'close' currently has six modes, selected by a single mode flag: * Menu: +* close --migrate:: +* close --close:: +* close --open:: +* close --assert:: +* close --assign:: +* close --retain:: +* close customisation:: * close and balance assertions:: -* Example retain earnings:: -* Example migrate balances to a new file:: -* Example excluding closing/opening transactions:: +* close examples::  -File: hledger.info, Node: close and balance assertions, Next: Example retain earnings, Up: close +File: hledger.info, Node: close --migrate, Next: close --close, Up: close -24.11.1 close and balance assertions +24.11.1 close -migrate +---------------------- + +This is the most common mode. It prints a "closing balances" +transaction that zeroes out all asset and liability balances (by +default), and an opposite "opening balances" transaction that restores +them again. The balancing account will be 'equity:opening/closing +balances' (or another specified by '--close-acct' or '--open-acct'). + + This is useful when migrating balances to a new journal file at the +start of a new year. Essentially, you run 'hledger close +--migrate=NEWYEAR -e NEWYEAR' and then copy the closing transaction to +the end of the old file and the opening transaction to the start of the +new file. The opening transaction sets correct starting balances in the +new file when it is used alone, and the closing transaction keeps +balances correct when you use both old and new files together, by +cancelling out the following opening transaction and preventing buildup +of duplicated opening balances. Think of the closing/opening pair as +"moving the balances into the next file". + + You can close a different set of accounts by providing a query. Eg +if you want to include equity, you can add 'assets liabilities equity' +or 'type:ALE' arguments. (The balancing account is always excluded.) +Revenues and expenses usually are not migrated to a new file directly; +see '--retain' below. + + The generated transactions will have a 'start:' tag, with its value +set to '--migrate''s 'NEW' argument if any, for easier matching or +exclusion. When 'NEW' is not specified, it will be inferred if possible +by incrementing a number (eg a year number) within the default journal's +main file name. The other modes behave similarly. + + +File: hledger.info, Node: close --close, Next: close --open, Prev: close --migrate, Up: close + +24.11.2 close -close +-------------------- + +This prints just the closing balances transaction of '--migrate'. It is +the default behaviour if you specify no mode flag. Using the +customisation options below, you can move balances from any set of +accounts to a different account. + + +File: hledger.info, Node: close --open, Next: close --assert, Prev: close --close, Up: close + +24.11.3 close -open +------------------- + +This prints just the opening balances transaction of '--migrate'. It is +similar to Ledger's equity command. + + +File: hledger.info, Node: close --assert, Next: close --assign, Prev: close --open, Up: close + +24.11.4 close -assert +--------------------- + +This prints a "closing balances" transaction (with 'balances:' tag), +that just declares balance assertions for the current balances without +changing them. It could be useful as documention and to guard against +changes. + + +File: hledger.info, Node: close --assign, Next: close --retain, Prev: close --assert, Up: close + +24.11.5 close -assign +--------------------- + +This prints an "opening balances" transaction that restores the account +balances using balance assignments. Balance assignments work regardless +of any previous balance, so a preceding closing balances transaction is +not needed. + + However, omitting the closing balances transaction would unbalance +equity. This is relatively harmless for personal reports, but it +disturbs the accounting equation, removing a source of error detection. +So '--migrate' is generally the best way to set to set balances in new +files, for now. + + +File: hledger.info, Node: close --retain, Next: close customisation, Prev: close --assign, Up: close + +24.11.6 close -retain +--------------------- + +This is like '--close' with different defaults: it prints a "retain +earnings" transaction (with 'retain:' tag), that transfers revenue and +expense balances to 'equity:retained earnings'. + + This is a different kind of closing, called "retaining earnings" or +"closing the books"; it is traditionally performed by businesses at the +end of each accounting period, to consolidate revenues and expenses into +the main equity balance. ("Revenues" and "expenses" are actually equity +by another name, kept separate temporarily for reporting purposes.) + + In personal accounting you generally don't need to do this, unless +you want the 'balancesheetequity' report to show a zero total, +demonstrating that the accounting equation (A-L=E) is satisfied. + + +File: hledger.info, Node: close customisation, Next: close and balance assertions, Prev: close --retain, Up: close + +24.11.7 close customisation +--------------------------- + +In all modes, the following things can be overridden: + + * the accounts to be closed/opened, with account query arguments + * the balancing account, with '--close-acct=ACCT' and/or + '--open-acct=ACCT' + * the transaction descriptions, with '--close-desc=DESC' and + '--open-desc=DESC' + * the transaction's tag value, with a '--MODE=NEW' option argument + * the closing/opening dates, with '-e OPENDATE' + + By default, the closing date is yesterday, or the journal's end date, +whichever is later; and the opening date is always one day after the +closing date. You can change these by specifying a report end date; the +closing date will be the last day of the report period. Eg '-e 2024' +means "close on 2023-12-31, open on 2024-01-01". + + With '--x/--explicit', the balancing amount will be shown explicitly, +and if it involves multiple commodities, a separate posting will be +generated for each of them (similar to 'print -x'). + + With '--interleaved', each individual transfer is shown with source +and destination postings next to each other (perhaps useful for +troubleshooting). + + With '--show-costs', balances' costs are also shown, with different +costs kept separate. This may generate very large journal entries, if +you have many currency conversions or investment transactions. 'close +--show-costs' is currently the best way to view investment lots with +hledger. (To move or dispose of lots, see the more capable +'hledger-move' script.) + + +File: hledger.info, Node: close and balance assertions, Next: close examples, Prev: close customisation, Up: close + +24.11.8 close and balance assertions ------------------------------------ -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). +'close' adds balance assertions verifying that the accounts have been +reset to zero in a closing transaction or restored to their previous +balances in an opening transaction. These provide useful error +checking, but you can ignore them temporarily with '-I', or remove them +if you prefer. - These provide useful error checking, but you can ignore them -temporarily with '-I', or remove them if you prefer. + When running 'close' you should probably avoid using '-C', '-R', +'status:' (filtering by status or realness) or '--auto' (generating +postings), since the generated balance assertions would then require +these. - 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 -balance assertions: + Transactions with multiple dates (eg posting dates) spanning the file +boundary also can disrupt the balance assertions: 2023-12-30 a purchase made in december, cleared in january expenses:food 5 assets:bank:checking -5 ; date: 2023-01-02 - To solve that you can transfer the money to and from a temporary -account, in effect splitting the multi-day transaction into two -single-day transactions: + To solve this you can transfer the money to and from a temporary +account, splitting the multi-day transaction into two single-day +transactions: ; in 2022.journal: 2022-12-30 a purchase made in december, cleared in january @@ -8969,91 +9087,69 @@ single-day transactions: assets:bank:checking -5  -File: hledger.info, Node: Example retain earnings, Next: Example migrate balances to a new file, Prev: close and balance assertions, Up: close +File: hledger.info, Node: close examples, Prev: close and balance assertions, Up: close -24.11.2 Example: retain earnings --------------------------------- +24.11.9 close examples +---------------------- + +* Menu: + +* Retain earnings:: +* Migrate balances to a new file:: +* More detailed close examples:: + + +File: hledger.info, Node: Retain earnings, Next: Migrate balances to a new file, Up: close examples + +24.11.9.1 Retain earnings +......................... Record 2022's revenues/expenses as retained earnings on 2022-12-31, appending the generated transaction to the journal: $ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal - Note 2022's income statement will now show only zeroes, because -revenues and expenses have been moved entirely to equity. To see them -again, you could exclude the retain transaction: + After this, to see 2022's revenues and expenses you must exclude the +retain earnings transaction: $ hledger -f 2022.journal is not:desc:'retain earnings'  -File: hledger.info, Node: Example migrate balances to a new file, Next: Example excluding closing/opening transactions, Prev: Example retain earnings, Up: close +File: hledger.info, Node: Migrate balances to a new file, Next: More detailed close examples, Prev: Retain earnings, Up: close examples -24.11.3 Example: migrate balances to a new file ------------------------------------------------ +24.11.9.2 Migrate balances to a new file +........................................ -Close assets/liabilities/equity on 2022-12-31 and re-open them on -2023-01-01: +Close assets/liabilities on 2022-12-31 and re-open them on 2023-01-01: $ hledger close --migrate -f 2022.journal -p 2022 # copy/paste the closing transaction to the end of 2022.journal # copy/paste the opening transaction to the start of 2023.journal - 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 the end-of-year balances again, -you could exclude the closing transaction: + After this, to see 2022's end-of-year balances you must exclude the +closing balances transaction: $ hledger -f 2022.journal bs not:desc:'closing balances' + For more flexibility, it helps to tag closing and opening +transactions with eg 'start:NEWYEAR', then you can ensure correct +balances by excluding all opening/closing transactions except the first, +like so: + +$ hledger bs -Y -f 2021.j -f 2022.j -f 2023.j expr:'tag:start=2021 or not tag:start' +$ hledger bs -Y -f 2021.j -f 2022.j expr:'tag:start=2021 or not tag:start' +$ hledger bs -Y -f 2022.j -f 2023.j expr:'tag:start=2022 or not tag:start' +$ hledger bs -Y -f 2021.j expr:'tag:start=2021 or not tag:start' +$ hledger bs -Y -f 2022.j expr:'tag:start=2022 or not tag:start' +$ hledger bs -Y -f 2023.j # unclosed file, no query needed +  -File: hledger.info, Node: Example excluding closing/opening transactions, Prev: Example migrate balances to a new file, Up: close +File: hledger.info, Node: More detailed close examples, Prev: Migrate balances to a new file, Up: close examples -24.11.4 Example: excluding closing/opening transactions -------------------------------------------------------- +24.11.9.3 More detailed close examples +...................................... -When combining many files for multi-year reports, the closing/opening -transactions cause some noise in transaction-oriented reports like -'print' and 'register'. You can exclude them as shown above, but -'not:desc:...' is not ideal as it depends on consistent descriptions; -also you will want to avoid excluding the very first opening -transaction, which could be awkward. Here is one alternative, using -tags: - - Add 'clopen:' tags to all opening/closing balances transactions -except the first, like this: - -; 2021.journal -2021-06-01 first opening balances -... -2021-12-31 closing balances ; clopen:2022 -... - -; 2022.journal -2022-01-01 opening balances ; clopen:2022 -... -2022-12-31 closing balances ; clopen:2023 -... - -; 2023.journal -2023-01-01 opening balances ; clopen:2023 -... - - Now, assuming a combined journal like: - -; all.journal -include 2021.journal -include 2022.journal -include 2023.journal - - 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 - - And the year values allow more precision. To show 2022's year-end -balance sheet: - -$ hledger -f all.journal bs -e2023 not:tag:clopen=2023 +See examples/multi-year.  File: hledger.info, Node: codes, Next: commodities, Prev: close, Up: PART 4 COMMANDS @@ -9417,8 +9513,8 @@ with smarter account detection, and revenues/income displayed with their sign flipped. This command also supports the output destination and output format -options The output formats supported are 'txt', 'csv', 'tsv', 'html', -and 'json'. +options The output formats supported are 'txt', 'csv', 'tsv' (_Added in +1.32_), 'html', and 'json'.  File: hledger.info, Node: notes, Next: payees, Prev: incomestatement, Up: PART 4 COMMANDS @@ -9560,8 +9656,9 @@ their symbol placement, decimal mark, and digit group marks will be made consistent. By default, decimal digits are shown as they are written in the journal. - With the '--round' option, 'print' will try increasingly hard to -display decimal digits according to the commodity display styles: + With the '--round' (_Added in 1.32_) option, 'print' will try +increasingly hard to display decimal digits according to the commodity +display styles: * '--round=none' show amounts with original precisions (default) * '--round=soft' add/remove decimal zeros in amounts (except costs) @@ -9623,8 +9720,8 @@ File: hledger.info, Node: print output format, Prev: print other features, Up --------------------------- This command also supports the output destination and output format -options The output formats supported are 'txt', 'beancount', 'csv', -'tsv', 'json' and 'sql'. +options The output formats supported are 'txt', 'beancount' (_Added in +1.32_), 'csv', 'tsv' (_Added in 1.32_), 'json' and 'sql'. The 'beancount' format tries to produce Beancount-compatible output, as follows: @@ -9820,8 +9917,8 @@ $ 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', 'tsv', and -'json'. +options The output formats supported are 'txt', 'csv', 'tsv' (_Added in +1.32_), and 'json'.  File: hledger.info, Node: rewrite, Next: roi, Prev: register, Up: PART 4 COMMANDS @@ -10840,636 +10937,658 @@ Node: General help options11259 Ref: #general-help-options11405 Node: General input options11687 Ref: #general-input-options11869 -Node: General reporting options12571 -Ref: #general-reporting-options12732 -Node: Command line tips16122 -Ref: #command-line-tips16252 -Node: Option repetition16511 -Ref: #option-repetition16655 -Node: Special characters16759 -Ref: #special-characters16932 -Node: Single escaping shell metacharacters17095 -Ref: #single-escaping-shell-metacharacters17336 -Node: Double escaping regular expression metacharacters17939 -Ref: #double-escaping-regular-expression-metacharacters18250 -Node: Triple escaping for add-on commands18776 -Ref: #triple-escaping-for-add-on-commands19036 -Node: Less escaping19680 -Ref: #less-escaping19834 -Node: Unicode characters20158 -Ref: #unicode-characters20333 -Node: Regular expressions21745 -Ref: #regular-expressions21918 -Node: hledger's regular expressions25014 -Ref: #hledgers-regular-expressions25173 -Node: Argument files26559 -Ref: #argument-files26695 -Node: Output27192 -Ref: #output27304 -Node: Output destination27431 -Ref: #output-destination27562 -Node: Output format27987 -Ref: #output-format28133 -Node: CSV output29730 -Ref: #csv-output29846 -Node: HTML output29949 -Ref: #html-output30087 -Node: JSON output30181 -Ref: #json-output30319 -Node: SQL output31241 -Ref: #sql-output31357 -Node: Commodity styles32092 -Ref: #commodity-styles32232 -Node: Colour32831 -Ref: #colour32949 -Node: Box-drawing33353 -Ref: #box-drawing33471 -Node: Paging33761 -Ref: #paging33875 -Node: Debug output34828 -Ref: #debug-output34934 -Node: Environment35597 -Ref: #environment35721 -Node: PART 2 DATA FORMATS36265 -Ref: #part-2-data-formats36408 -Node: Journal36408 -Ref: #journal36517 -Node: Journal cheatsheet37174 -Ref: #journal-cheatsheet37313 -Node: About journal format41298 -Ref: #about-journal-format41458 -Node: Comments43074 -Ref: #comments43204 -Node: Transactions44020 -Ref: #transactions44143 -Node: Dates45157 -Ref: #dates45264 -Node: Simple dates45309 -Ref: #simple-dates45425 -Node: Posting dates45925 -Ref: #posting-dates46043 -Node: Status47012 -Ref: #status47113 -Node: Code48821 -Ref: #code48924 -Node: Description49156 -Ref: #description49287 -Node: Payee and note49607 -Ref: #payee-and-note49713 -Node: Transaction comments50048 -Ref: #transaction-comments50201 -Node: Postings50564 -Ref: #postings50697 -Node: Account names51692 -Ref: #account-names51822 -Node: Amounts53496 -Ref: #amounts53611 -Node: Decimal marks digit group marks54596 -Ref: #decimal-marks-digit-group-marks54771 -Node: Commodity55630 -Ref: #commodity55817 -Node: Directives influencing number parsing and display56769 -Ref: #directives-influencing-number-parsing-and-display57028 -Node: Commodity display style57480 -Ref: #commodity-display-style57686 -Node: Rounding59096 -Ref: #rounding59214 -Node: Costs59664 -Ref: #costs59780 -Node: Other cost/lot notations61976 -Ref: #other-costlot-notations62108 -Node: Balance assertions64697 -Ref: #balance-assertions64848 -Node: Assertions and ordering65930 -Ref: #assertions-and-ordering66119 -Node: Assertions and multiple included files66819 -Ref: #assertions-and-multiple-included-files67079 -Node: Assertions and multiple -f files67579 -Ref: #assertions-and-multiple--f-files67830 -Node: Assertions and commodities68227 -Ref: #assertions-and-commodities68448 -Node: Assertions and costs69628 -Ref: #assertions-and-costs69831 -Node: Assertions and subaccounts70272 -Ref: #assertions-and-subaccounts70492 -Node: Assertions and virtual postings70816 -Ref: #assertions-and-virtual-postings71054 -Node: Assertions and auto postings71186 -Ref: #assertions-and-auto-postings71416 -Node: Assertions and precision72061 -Ref: #assertions-and-precision72243 -Node: Posting comments72510 -Ref: #posting-comments72656 -Node: Tags73033 -Ref: #tags73147 -Node: Tag values74340 -Ref: #tag-values74429 -Node: Directives75188 -Ref: #directives75315 -Node: Directives and multiple files76645 -Ref: #directives-and-multiple-files76823 -Node: Directive effects77590 -Ref: #directive-effects77744 -Node: account directive80757 -Ref: #account-directive80913 -Node: Account comments82311 -Ref: #account-comments82461 -Node: Account subdirectives82969 -Ref: #account-subdirectives83160 -Node: Account error checking83302 -Ref: #account-error-checking83500 -Node: Account display order84689 -Ref: #account-display-order84877 -Node: Account types85978 -Ref: #account-types86119 -Node: alias directive89746 -Ref: #alias-directive89907 -Node: Basic aliases90957 -Ref: #basic-aliases91088 -Node: Regex aliases91832 -Ref: #regex-aliases91989 -Node: Combining aliases92879 -Ref: #combining-aliases93057 -Node: Aliases and multiple files94333 -Ref: #aliases-and-multiple-files94537 -Node: end aliases directive95116 -Ref: #end-aliases-directive95335 -Node: Aliases can generate bad account names95484 -Ref: #aliases-can-generate-bad-account-names95732 -Node: Aliases and account types96317 -Ref: #aliases-and-account-types96509 -Node: commodity directive97205 -Ref: #commodity-directive97379 -Node: Commodity directive syntax98564 -Ref: #commodity-directive-syntax98749 -Node: Commodity error checking100200 -Ref: #commodity-error-checking100381 -Node: decimal-mark directive100675 -Ref: #decimal-mark-directive100857 -Node: include directive101254 -Ref: #include-directive101418 -Node: P directive102330 -Ref: #p-directive102475 -Node: payee directive103364 -Ref: #payee-directive103513 -Node: tag directive103986 -Ref: #tag-directive104141 -Node: Periodic transactions104609 -Ref: #periodic-transactions104774 -Node: Periodic rule syntax106763 -Ref: #periodic-rule-syntax106941 -Node: Periodic rules and relative dates107586 -Ref: #periodic-rules-and-relative-dates107852 -Node: Two spaces between period expression and description!108363 -Ref: #two-spaces-between-period-expression-and-description108640 -Node: Auto postings109324 -Ref: #auto-postings109472 -Node: Auto postings and multiple files112302 -Ref: #auto-postings-and-multiple-files112466 -Node: Auto postings and dates112867 -Ref: #auto-postings-and-dates113115 -Node: Auto postings and transaction balancing / inferred amounts / balance assertions113290 -Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions113646 -Node: Auto posting tags114149 -Ref: #auto-posting-tags114431 -Node: Auto postings on forecast transactions only115067 -Ref: #auto-postings-on-forecast-transactions-only115313 -Node: Other syntax115560 -Ref: #other-syntax115676 -Node: Balance assignments116303 -Ref: #balance-assignments116459 -Node: Balance assignments and costs117831 -Ref: #balance-assignments-and-costs118043 -Node: Balance assignments and multiple files118253 -Ref: #balance-assignments-and-multiple-files118483 -Node: Bracketed posting dates118676 -Ref: #bracketed-posting-dates118860 -Node: D directive119374 -Ref: #d-directive119542 -Node: apply account directive121142 -Ref: #apply-account-directive121322 -Node: Y directive122009 -Ref: #y-directive122169 -Node: Secondary dates122997 -Ref: #secondary-dates123151 -Node: Star comments123965 -Ref: #star-comments124125 -Node: Valuation expressions124657 -Ref: #valuation-expressions124834 -Node: Virtual postings124956 -Ref: #virtual-postings125133 -Node: Other Ledger directives126570 -Ref: #other-ledger-directives126733 -Node: CSV127299 -Ref: #csv127392 -Node: CSV rules cheatsheet129472 -Ref: #csv-rules-cheatsheet129601 -Node: source131399 -Ref: #source131522 -Node: separator132402 -Ref: #separator132515 -Node: skip133055 -Ref: #skip133163 -Node: date-format133707 -Ref: #date-format133828 -Node: timezone134552 -Ref: #timezone134675 -Node: newest-first135680 -Ref: #newest-first135818 -Node: intra-day-reversed136395 -Ref: #intra-day-reversed136549 -Node: decimal-mark136997 -Ref: #decimal-mark137138 -Node: fields list137477 -Ref: #fields-list137616 -Node: Field assignment139287 -Ref: #field-assignment139431 -Node: Field names140508 -Ref: #field-names140639 -Node: date field141842 -Ref: #date-field141960 -Node: date2 field142008 -Ref: #date2-field142149 -Node: status field142205 -Ref: #status-field142348 -Node: code field142397 -Ref: #code-field142542 -Node: description field142587 -Ref: #description-field142747 -Node: comment field142806 -Ref: #comment-field142961 -Node: account field143254 -Ref: #account-field143404 -Node: amount field143974 -Ref: #amount-field144123 -Node: currency field146815 -Ref: #currency-field146968 -Node: balance field147225 -Ref: #balance-field147357 -Node: if block147729 -Ref: #if-block147850 -Node: Matchers149258 -Ref: #matchers149372 -Node: What matchers match150169 -Ref: #what-matchers-match150318 -Node: Combining matchers150758 -Ref: #combining-matchers150926 -Node: Match groups151412 -Ref: #match-groups151540 -Node: if table152287 -Ref: #if-table152409 -Node: balance-type153971 -Ref: #balance-type154100 -Node: include154800 -Ref: #include154927 -Node: Working with CSV155371 -Ref: #working-with-csv155518 -Node: Rapid feedback155925 -Ref: #rapid-feedback156058 -Node: Valid CSV156510 -Ref: #valid-csv156656 -Node: File Extension157388 -Ref: #file-extension157561 -Node: Reading CSV from standard input158125 -Ref: #reading-csv-from-standard-input158349 -Node: Reading multiple CSV files158513 -Ref: #reading-multiple-csv-files158744 -Node: Reading files specified by rule158985 -Ref: #reading-files-specified-by-rule159213 -Node: Valid transactions160384 -Ref: #valid-transactions160583 -Node: Deduplicating importing161211 -Ref: #deduplicating-importing161406 -Node: Setting amounts162442 -Ref: #setting-amounts162613 -Node: Amount signs164971 -Ref: #amount-signs165141 -Node: Setting currency/commodity166038 -Ref: #setting-currencycommodity166242 -Node: Amount decimal places167416 -Ref: #amount-decimal-places167622 -Node: Referencing other fields167934 -Ref: #referencing-other-fields168147 -Node: How CSV rules are evaluated169044 -Ref: #how-csv-rules-are-evaluated169261 -Node: Well factored rules170714 -Ref: #well-factored-rules170882 -Node: CSV rules examples171206 -Ref: #csv-rules-examples171341 -Node: Bank of Ireland171406 -Ref: #bank-of-ireland171543 -Node: Coinbase173005 -Ref: #coinbase173143 -Node: Amazon174190 -Ref: #amazon174315 -Node: Paypal176034 -Ref: #paypal176142 -Node: Timeclock183786 -Ref: #timeclock183891 -Node: Timedot186069 -Ref: #timedot186192 -Node: Timedot examples189297 -Ref: #timedot-examples189403 -Node: PART 3 REPORTING CONCEPTS191574 -Ref: #part-3-reporting-concepts191756 -Node: Amount formatting parseability191756 -Ref: #amount-formatting-parseability191953 -Node: Time periods194158 -Ref: #time-periods194297 -Node: Report start & end date194415 -Ref: #report-start-end-date194567 -Node: Smart dates196226 -Ref: #smart-dates196379 -Node: Report intervals198247 -Ref: #report-intervals198402 -Node: Date adjustment198820 -Ref: #date-adjustment198980 -Node: Period expressions199831 -Ref: #period-expressions199972 -Node: Period expressions with a report interval201736 -Ref: #period-expressions-with-a-report-interval201970 -Node: More complex report intervals202184 -Ref: #more-complex-report-intervals202429 -Node: Multiple weekday intervals204230 -Ref: #multiple-weekday-intervals204419 -Node: Depth205241 -Ref: #depth205343 -Node: Queries205639 -Ref: #queries205741 -Node: Query types207371 -Ref: #query-types207492 -Node: Combining query terms210726 -Ref: #combining-query-terms210903 -Node: Queries and command options212171 -Ref: #queries-and-command-options212370 -Node: Queries and valuation212619 -Ref: #queries-and-valuation212814 -Node: Querying with account aliases213043 -Ref: #querying-with-account-aliases213254 -Node: Querying with cost or value213384 -Ref: #querying-with-cost-or-value213561 -Node: Pivoting213862 -Ref: #pivoting213976 -Node: Generating data215753 -Ref: #generating-data215885 -Node: Forecasting217468 -Ref: #forecasting217593 -Node: --forecast218124 -Ref: #forecast218255 -Node: Inspecting forecast transactions219225 -Ref: #inspecting-forecast-transactions219427 -Node: Forecast reports220557 -Ref: #forecast-reports220730 -Node: Forecast tags221666 -Ref: #forecast-tags221826 -Node: Forecast period in detail222286 -Ref: #forecast-period-in-detail222480 -Node: Forecast troubleshooting223374 -Ref: #forecast-troubleshooting223542 -Node: Budgeting224445 -Ref: #budgeting224565 -Node: Cost reporting225002 -Ref: #cost-reporting225136 -Node: Recording costs225797 -Ref: #recording-costs225933 -Node: Reporting at cost227524 -Ref: #reporting-at-cost227699 -Node: Equity conversion postings228289 -Ref: #equity-conversion-postings228503 -Node: Inferring equity conversion postings230934 -Ref: #inferring-equity-conversion-postings231197 -Node: Combining costs and equity conversion postings231949 -Ref: #combining-costs-and-equity-conversion-postings232259 -Node: Requirements for detecting equity conversion postings233174 -Ref: #requirements-for-detecting-equity-conversion-postings233496 -Node: Infer cost and equity by default ?234696 -Ref: #infer-cost-and-equity-by-default234925 -Node: Value reporting235133 -Ref: #value-reporting235275 -Node: -V Value236049 -Ref: #v-value236181 -Node: -X Value in specified commodity236376 -Ref: #x-value-in-specified-commodity236577 -Node: Valuation date236726 -Ref: #valuation-date236903 -Node: Finding market price237686 -Ref: #finding-market-price237897 -Node: --infer-market-prices market prices from transactions239066 -Ref: #infer-market-prices-market-prices-from-transactions239348 -Node: Valuation commodity242110 -Ref: #valuation-commodity242329 -Node: Simple valuation examples243542 -Ref: #simple-valuation-examples243746 -Node: --value Flexible valuation244405 -Ref: #value-flexible-valuation244615 -Node: More valuation examples246259 -Ref: #more-valuation-examples246474 -Node: Interaction of valuation and queries247744 -Ref: #interaction-of-valuation-and-queries247991 -Node: Effect of valuation on reports248463 -Ref: #effect-of-valuation-on-reports248666 -Node: PART 4 COMMANDS256363 -Ref: #part-4-commands256512 -Node: Commands overview256891 -Ref: #commands-overview257025 -Node: DATA ENTRY257204 -Ref: #data-entry257328 -Node: DATA CREATION257527 -Ref: #data-creation257681 -Node: DATA MANAGEMENT257799 -Ref: #data-management257964 -Node: REPORTS FINANCIAL258085 -Ref: #reports-financial258260 -Node: REPORTS VERSATILE258565 -Ref: #reports-versatile258738 -Node: REPORTS BASIC258991 -Ref: #reports-basic259143 -Node: HELP259652 -Ref: #help259774 -Node: ADD-ONS259884 -Ref: #add-ons259990 -Node: accounts260569 -Ref: #accounts260702 -Node: activity262589 -Ref: #activity262708 -Node: add263082 -Ref: #add263192 -Node: aregister266178 -Ref: #aregister266299 -Node: aregister and posting dates269187 -Ref: #aregister-and-posting-dates269332 -Node: balance270088 -Ref: #balance270214 -Node: balance features271199 -Ref: #balance-features271339 -Node: Simple balance report273305 -Ref: #simple-balance-report273490 -Node: Balance report line format275115 -Ref: #balance-report-line-format275317 -Node: Filtered balance report277475 -Ref: #filtered-balance-report277667 -Node: List or tree mode277994 -Ref: #list-or-tree-mode278162 -Node: Depth limiting279507 -Ref: #depth-limiting279673 -Node: Dropping top-level accounts280274 -Ref: #dropping-top-level-accounts280474 -Node: Showing declared accounts280784 -Ref: #showing-declared-accounts280983 -Node: Sorting by amount281514 -Ref: #sorting-by-amount281681 -Node: Percentages282351 -Ref: #percentages282510 -Node: Multi-period balance report283058 -Ref: #multi-period-balance-report283258 -Node: Balance change end balance285515 -Ref: #balance-change-end-balance285724 -Node: Balance report types287152 -Ref: #balance-report-types287333 -Node: Calculation type287831 -Ref: #calculation-type287986 -Node: Accumulation type288535 -Ref: #accumulation-type288715 -Node: Valuation type289617 -Ref: #valuation-type289805 -Node: Combining balance report types290806 -Ref: #combining-balance-report-types291000 -Node: Budget report292838 -Ref: #budget-report293000 -Node: Using the budget report295143 -Ref: #using-the-budget-report295316 -Node: Budget date surprises297419 -Ref: #budget-date-surprises297619 -Node: Selecting budget goals298783 -Ref: #selecting-budget-goals298986 -Node: Budgeting vs forecasting299731 -Ref: #budgeting-vs-forecasting299908 -Node: Balance report layout301179 -Ref: #balance-report-layout301359 -Node: Useful balance reports309544 -Ref: #useful-balance-reports309704 -Node: balancesheet310789 -Ref: #balancesheet310934 -Node: balancesheetequity312246 -Ref: #balancesheetequity312404 -Node: cashflow313785 -Ref: #cashflow313916 -Node: check315336 -Ref: #check315450 -Node: Default checks316254 -Ref: #default-checks316380 -Node: Strict checks316877 -Ref: #strict-checks317022 -Node: Other checks317502 -Ref: #other-checks317644 -Node: Custom checks318177 -Ref: #custom-checks318334 -Node: More about specific checks318751 -Ref: #more-about-specific-checks318913 -Node: close319619 -Ref: #close319730 -Node: close and balance assertions325057 -Ref: #close-and-balance-assertions325235 -Node: Example retain earnings326386 -Ref: #example-retain-earnings326603 -Node: Example migrate balances to a new file327035 -Ref: #example-migrate-balances-to-a-new-file327300 -Node: Example excluding closing/opening transactions327876 -Ref: #example-excluding-closingopening-transactions328125 -Node: codes329343 -Ref: #codes329460 -Node: commodities330324 -Ref: #commodities330452 -Node: demo330522 -Ref: #demo330643 -Node: descriptions331559 -Ref: #descriptions331689 -Node: diff331980 -Ref: #diff332095 -Node: files333137 -Ref: #files333246 -Node: help333387 -Ref: #help-1333496 -Node: import334869 -Ref: #import334992 -Node: Deduplication336100 -Ref: #deduplication336225 -Node: Import testing338244 -Ref: #import-testing338409 -Node: Importing balance assignments339252 -Ref: #importing-balance-assignments339458 -Node: Commodity display styles340107 -Ref: #commodity-display-styles340280 -Node: incomestatement340409 -Ref: #incomestatement340551 -Node: notes341864 -Ref: #notes341986 -Node: payees342348 -Ref: #payees342463 -Node: prices342982 -Ref: #prices343097 -Node: print343750 -Ref: #print343865 -Node: print explicitness344841 -Ref: #print-explicitness344984 -Node: print amount style345763 -Ref: #print-amount-style345933 -Node: print parseability346985 -Ref: #print-parseability347157 -Node: print other features347906 -Ref: #print-other-features348085 -Node: print output format348606 -Ref: #print-output-format348754 -Node: register351857 -Ref: #register351979 -Node: Custom register output357010 -Ref: #custom-register-output357141 -Node: rewrite358470 -Ref: #rewrite358588 -Node: Re-write rules in a file360486 -Ref: #re-write-rules-in-a-file360649 -Node: Diff output format361798 -Ref: #diff-output-format361981 -Node: rewrite vs print --auto363073 -Ref: #rewrite-vs.-print---auto363233 -Node: roi363789 -Ref: #roi363896 -Node: Spaces and special characters in --inv and --pnl365708 -Ref: #spaces-and-special-characters-in---inv-and---pnl365948 -Node: Semantics of --inv and --pnl366436 -Ref: #semantics-of---inv-and---pnl366675 -Node: IRR and TWR explained368525 -Ref: #irr-and-twr-explained368685 -Node: stats371938 -Ref: #stats372046 -Node: tags373433 -Ref: #tags-1373540 -Node: test374549 -Ref: #test374642 -Node: PART 5 COMMON TASKS375384 -Ref: #part-5-common-tasks375530 -Node: Getting help375828 -Ref: #getting-help375969 -Node: Constructing command lines376729 -Ref: #constructing-command-lines376930 -Node: Starting a journal file377587 -Ref: #starting-a-journal-file377789 -Node: Setting LEDGER_FILE378991 -Ref: #setting-ledger_file379183 -Node: Setting opening balances380140 -Ref: #setting-opening-balances380341 -Node: Recording transactions383482 -Ref: #recording-transactions383671 -Node: Reconciling384227 -Ref: #reconciling384379 -Node: Reporting386636 -Ref: #reporting386785 -Node: Migrating to a new file390770 -Ref: #migrating-to-a-new-file390927 -Node: BUGS391226 -Ref: #bugs391316 -Node: Troubleshooting392195 -Ref: #troubleshooting392295 +Node: General reporting options12526 +Ref: #general-reporting-options12687 +Node: Command line tips16077 +Ref: #command-line-tips16207 +Node: Option repetition16466 +Ref: #option-repetition16610 +Node: Special characters16714 +Ref: #special-characters16887 +Node: Single escaping shell metacharacters17050 +Ref: #single-escaping-shell-metacharacters17291 +Node: Double escaping regular expression metacharacters17894 +Ref: #double-escaping-regular-expression-metacharacters18205 +Node: Triple escaping for add-on commands18731 +Ref: #triple-escaping-for-add-on-commands18991 +Node: Less escaping19635 +Ref: #less-escaping19789 +Node: Unicode characters20113 +Ref: #unicode-characters20288 +Node: Regular expressions21700 +Ref: #regular-expressions21873 +Node: hledger's regular expressions24969 +Ref: #hledgers-regular-expressions25128 +Node: Argument files26514 +Ref: #argument-files26650 +Node: Output27147 +Ref: #output27259 +Node: Output destination27386 +Ref: #output-destination27517 +Node: Output format27942 +Ref: #output-format28088 +Node: CSV output29685 +Ref: #csv-output29801 +Node: HTML output29904 +Ref: #html-output30042 +Node: JSON output30136 +Ref: #json-output30274 +Node: SQL output31196 +Ref: #sql-output31312 +Node: Commodity styles32047 +Ref: #commodity-styles32187 +Node: Colour33003 +Ref: #colour33121 +Node: Box-drawing33525 +Ref: #box-drawing33643 +Node: Paging33933 +Ref: #paging34047 +Node: Debug output35000 +Ref: #debug-output35106 +Node: Environment35769 +Ref: #environment35893 +Node: PART 2 DATA FORMATS36437 +Ref: #part-2-data-formats36580 +Node: Journal36580 +Ref: #journal36689 +Node: Journal cheatsheet37346 +Ref: #journal-cheatsheet37485 +Node: About journal format41470 +Ref: #about-journal-format41630 +Node: Comments43246 +Ref: #comments43376 +Node: Transactions44192 +Ref: #transactions44315 +Node: Dates45329 +Ref: #dates45436 +Node: Simple dates45481 +Ref: #simple-dates45597 +Node: Posting dates46097 +Ref: #posting-dates46215 +Node: Status47184 +Ref: #status47285 +Node: Code48993 +Ref: #code49096 +Node: Description49328 +Ref: #description49459 +Node: Payee and note49779 +Ref: #payee-and-note49885 +Node: Transaction comments50220 +Ref: #transaction-comments50373 +Node: Postings50736 +Ref: #postings50869 +Node: Account names51864 +Ref: #account-names51994 +Node: Amounts53668 +Ref: #amounts53783 +Node: Decimal marks digit group marks54786 +Ref: #decimal-marks-digit-group-marks54961 +Node: Commodity55820 +Ref: #commodity56007 +Node: Directives influencing number parsing and display56959 +Ref: #directives-influencing-number-parsing-and-display57218 +Node: Commodity display style57670 +Ref: #commodity-display-style57876 +Node: Rounding59286 +Ref: #rounding59426 +Node: Number format59876 +Ref: #number-format59994 +Node: Costs60208 +Ref: #costs60324 +Node: Other cost/lot notations62520 +Ref: #other-costlot-notations62652 +Node: Balance assertions65241 +Ref: #balance-assertions65392 +Node: Assertions and ordering66474 +Ref: #assertions-and-ordering66663 +Node: Assertions and multiple included files67363 +Ref: #assertions-and-multiple-included-files67623 +Node: Assertions and multiple -f files68123 +Ref: #assertions-and-multiple--f-files68374 +Node: Assertions and commodities68771 +Ref: #assertions-and-commodities68992 +Node: Assertions and costs70172 +Ref: #assertions-and-costs70375 +Node: Assertions and subaccounts70816 +Ref: #assertions-and-subaccounts71036 +Node: Assertions and virtual postings71360 +Ref: #assertions-and-virtual-postings71598 +Node: Assertions and auto postings71730 +Ref: #assertions-and-auto-postings71960 +Node: Assertions and precision72605 +Ref: #assertions-and-precision72787 +Node: Posting comments73054 +Ref: #posting-comments73200 +Node: Tags73577 +Ref: #tags73691 +Node: Tag inheritance74691 +Ref: #tag-inheritance74813 +Node: Tag names75176 +Ref: #tag-names75305 +Node: Tag values76427 +Ref: #tag-values76534 +Node: Directives77293 +Ref: #directives77420 +Node: Directives and multiple files78750 +Ref: #directives-and-multiple-files78928 +Node: Directive effects79695 +Ref: #directive-effects79849 +Node: account directive82862 +Ref: #account-directive83018 +Node: Account comments84416 +Ref: #account-comments84566 +Node: Account subdirectives85074 +Ref: #account-subdirectives85265 +Node: Account error checking85407 +Ref: #account-error-checking85605 +Node: Account display order86794 +Ref: #account-display-order86982 +Node: Account types88083 +Ref: #account-types88224 +Node: alias directive91851 +Ref: #alias-directive92012 +Node: Basic aliases93062 +Ref: #basic-aliases93193 +Node: Regex aliases93937 +Ref: #regex-aliases94094 +Node: Combining aliases94984 +Ref: #combining-aliases95162 +Node: Aliases and multiple files96438 +Ref: #aliases-and-multiple-files96642 +Node: end aliases directive97221 +Ref: #end-aliases-directive97440 +Node: Aliases can generate bad account names97589 +Ref: #aliases-can-generate-bad-account-names97837 +Node: Aliases and account types98422 +Ref: #aliases-and-account-types98614 +Node: commodity directive99310 +Ref: #commodity-directive99484 +Node: Commodity directive syntax100669 +Ref: #commodity-directive-syntax100854 +Node: Commodity error checking102305 +Ref: #commodity-error-checking102486 +Node: decimal-mark directive102780 +Ref: #decimal-mark-directive102962 +Node: include directive103359 +Ref: #include-directive103523 +Node: P directive104435 +Ref: #p-directive104580 +Node: payee directive105469 +Ref: #payee-directive105618 +Node: tag directive106091 +Ref: #tag-directive106246 +Node: Periodic transactions106714 +Ref: #periodic-transactions106879 +Node: Periodic rule syntax108868 +Ref: #periodic-rule-syntax109046 +Node: Periodic rules and relative dates109691 +Ref: #periodic-rules-and-relative-dates109957 +Node: Two spaces between period expression and description!110468 +Ref: #two-spaces-between-period-expression-and-description110745 +Node: Auto postings111429 +Ref: #auto-postings111577 +Node: Auto postings and multiple files114407 +Ref: #auto-postings-and-multiple-files114571 +Node: Auto postings and dates114972 +Ref: #auto-postings-and-dates115220 +Node: Auto postings and transaction balancing / inferred amounts / balance assertions115395 +Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions115751 +Node: Auto posting tags116254 +Ref: #auto-posting-tags116536 +Node: Auto postings on forecast transactions only117172 +Ref: #auto-postings-on-forecast-transactions-only117418 +Node: Other syntax117665 +Ref: #other-syntax117781 +Node: Balance assignments118408 +Ref: #balance-assignments118564 +Node: Balance assignments and costs119936 +Ref: #balance-assignments-and-costs120148 +Node: Balance assignments and multiple files120358 +Ref: #balance-assignments-and-multiple-files120588 +Node: Bracketed posting dates120781 +Ref: #bracketed-posting-dates120965 +Node: D directive121479 +Ref: #d-directive121647 +Node: apply account directive123247 +Ref: #apply-account-directive123427 +Node: Y directive124114 +Ref: #y-directive124274 +Node: Secondary dates125102 +Ref: #secondary-dates125256 +Node: Star comments126070 +Ref: #star-comments126230 +Node: Valuation expressions126762 +Ref: #valuation-expressions126939 +Node: Virtual postings127061 +Ref: #virtual-postings127238 +Node: Other Ledger directives128675 +Ref: #other-ledger-directives128838 +Node: CSV129404 +Ref: #csv129497 +Node: CSV rules cheatsheet131577 +Ref: #csv-rules-cheatsheet131706 +Node: source133504 +Ref: #source133627 +Node: separator134507 +Ref: #separator134620 +Node: skip135160 +Ref: #skip135268 +Node: date-format135812 +Ref: #date-format135933 +Node: timezone136657 +Ref: #timezone136780 +Node: newest-first137785 +Ref: #newest-first137923 +Node: intra-day-reversed138500 +Ref: #intra-day-reversed138654 +Node: decimal-mark139102 +Ref: #decimal-mark139243 +Node: fields list139582 +Ref: #fields-list139721 +Node: Field assignment141392 +Ref: #field-assignment141536 +Node: Field names142613 +Ref: #field-names142744 +Node: date field143947 +Ref: #date-field144065 +Node: date2 field144113 +Ref: #date2-field144254 +Node: status field144310 +Ref: #status-field144453 +Node: code field144502 +Ref: #code-field144647 +Node: description field144692 +Ref: #description-field144852 +Node: comment field144911 +Ref: #comment-field145066 +Node: account field145359 +Ref: #account-field145509 +Node: amount field146079 +Ref: #amount-field146228 +Node: currency field148920 +Ref: #currency-field149073 +Node: balance field149330 +Ref: #balance-field149462 +Node: if block149834 +Ref: #if-block149955 +Node: Matchers151363 +Ref: #matchers151477 +Node: What matchers match152274 +Ref: #what-matchers-match152423 +Node: Combining matchers152863 +Ref: #combining-matchers153031 +Node: Match groups153533 +Ref: #match-groups153661 +Node: if table154429 +Ref: #if-table154551 +Node: balance-type156113 +Ref: #balance-type156242 +Node: include156942 +Ref: #include157069 +Node: Working with CSV157513 +Ref: #working-with-csv157660 +Node: Rapid feedback158067 +Ref: #rapid-feedback158200 +Node: Valid CSV158652 +Ref: #valid-csv158798 +Node: File Extension159530 +Ref: #file-extension159703 +Node: Reading CSV from standard input160267 +Ref: #reading-csv-from-standard-input160491 +Node: Reading multiple CSV files160655 +Ref: #reading-multiple-csv-files160886 +Node: Reading files specified by rule161127 +Ref: #reading-files-specified-by-rule161355 +Node: Valid transactions162526 +Ref: #valid-transactions162725 +Node: Deduplicating importing163353 +Ref: #deduplicating-importing163548 +Node: Setting amounts164584 +Ref: #setting-amounts164755 +Node: Amount signs167113 +Ref: #amount-signs167283 +Node: Setting currency/commodity168180 +Ref: #setting-currencycommodity168384 +Node: Amount decimal places169558 +Ref: #amount-decimal-places169764 +Node: Referencing other fields170076 +Ref: #referencing-other-fields170289 +Node: How CSV rules are evaluated171186 +Ref: #how-csv-rules-are-evaluated171403 +Node: Well factored rules172856 +Ref: #well-factored-rules173024 +Node: CSV rules examples173348 +Ref: #csv-rules-examples173483 +Node: Bank of Ireland173548 +Ref: #bank-of-ireland173685 +Node: Coinbase175147 +Ref: #coinbase175285 +Node: Amazon176332 +Ref: #amazon176457 +Node: Paypal178176 +Ref: #paypal178284 +Node: Timeclock185928 +Ref: #timeclock186033 +Node: Timedot188211 +Ref: #timedot188334 +Node: Timedot examples191455 +Ref: #timedot-examples191561 +Node: PART 3 REPORTING CONCEPTS193732 +Ref: #part-3-reporting-concepts193914 +Node: Amount formatting parseability193914 +Ref: #amount-formatting-parseability194111 +Node: Time periods196316 +Ref: #time-periods196455 +Node: Report start & end date196573 +Ref: #report-start-end-date196725 +Node: Smart dates198384 +Ref: #smart-dates198537 +Node: Report intervals200405 +Ref: #report-intervals200560 +Node: Date adjustment200978 +Ref: #date-adjustment201138 +Node: Period expressions201989 +Ref: #period-expressions202130 +Node: Period expressions with a report interval203894 +Ref: #period-expressions-with-a-report-interval204128 +Node: More complex report intervals204342 +Ref: #more-complex-report-intervals204587 +Node: Multiple weekday intervals206388 +Ref: #multiple-weekday-intervals206577 +Node: Depth207399 +Ref: #depth207501 +Node: Queries207797 +Ref: #queries207899 +Node: Query types209529 +Ref: #query-types209650 +Node: Combining query terms212884 +Ref: #combining-query-terms213061 +Node: Queries and command options214329 +Ref: #queries-and-command-options214528 +Node: Queries and valuation214777 +Ref: #queries-and-valuation214972 +Node: Querying with account aliases215201 +Ref: #querying-with-account-aliases215412 +Node: Querying with cost or value215542 +Ref: #querying-with-cost-or-value215719 +Node: Pivoting216020 +Ref: #pivoting216134 +Node: Generating data217911 +Ref: #generating-data218043 +Node: Forecasting219626 +Ref: #forecasting219751 +Node: --forecast220282 +Ref: #forecast220413 +Node: Inspecting forecast transactions221383 +Ref: #inspecting-forecast-transactions221585 +Node: Forecast reports222715 +Ref: #forecast-reports222888 +Node: Forecast tags223824 +Ref: #forecast-tags223984 +Node: Forecast period in detail224444 +Ref: #forecast-period-in-detail224638 +Node: Forecast troubleshooting225532 +Ref: #forecast-troubleshooting225700 +Node: Budgeting226603 +Ref: #budgeting226723 +Node: Cost reporting227160 +Ref: #cost-reporting227294 +Node: Recording costs227955 +Ref: #recording-costs228091 +Node: Reporting at cost229682 +Ref: #reporting-at-cost229857 +Node: Equity conversion postings230447 +Ref: #equity-conversion-postings230661 +Node: Inferring equity conversion postings233092 +Ref: #inferring-equity-conversion-postings233355 +Node: Combining costs and equity conversion postings234107 +Ref: #combining-costs-and-equity-conversion-postings234417 +Node: Requirements for detecting equity conversion postings235332 +Ref: #requirements-for-detecting-equity-conversion-postings235654 +Node: Infer cost and equity by default ?236854 +Ref: #infer-cost-and-equity-by-default237083 +Node: Value reporting237291 +Ref: #value-reporting237433 +Node: -V Value238207 +Ref: #v-value238339 +Node: -X Value in specified commodity238534 +Ref: #x-value-in-specified-commodity238735 +Node: Valuation date238884 +Ref: #valuation-date239061 +Node: Finding market price239844 +Ref: #finding-market-price240055 +Node: --infer-market-prices market prices from transactions241224 +Ref: #infer-market-prices-market-prices-from-transactions241506 +Node: Valuation commodity244268 +Ref: #valuation-commodity244487 +Node: Simple valuation examples245700 +Ref: #simple-valuation-examples245904 +Node: --value Flexible valuation246563 +Ref: #value-flexible-valuation246773 +Node: More valuation examples248417 +Ref: #more-valuation-examples248632 +Node: Interaction of valuation and queries249902 +Ref: #interaction-of-valuation-and-queries250149 +Node: Effect of valuation on reports250621 +Ref: #effect-of-valuation-on-reports250824 +Node: PART 4 COMMANDS258521 +Ref: #part-4-commands258670 +Node: Commands overview259049 +Ref: #commands-overview259183 +Node: DATA ENTRY259362 +Ref: #data-entry259486 +Node: DATA CREATION259685 +Ref: #data-creation259839 +Node: DATA MANAGEMENT259957 +Ref: #data-management260122 +Node: REPORTS FINANCIAL260243 +Ref: #reports-financial260418 +Node: REPORTS VERSATILE260723 +Ref: #reports-versatile260896 +Node: REPORTS BASIC261149 +Ref: #reports-basic261301 +Node: HELP261810 +Ref: #help261932 +Node: ADD-ONS262042 +Ref: #add-ons262148 +Node: accounts262727 +Ref: #accounts262860 +Node: activity264747 +Ref: #activity264866 +Node: add265240 +Ref: #add265350 +Node: aregister268336 +Ref: #aregister268457 +Node: aregister and posting dates271363 +Ref: #aregister-and-posting-dates271508 +Node: balance272264 +Ref: #balance272390 +Node: balance features273375 +Ref: #balance-features273515 +Node: Simple balance report275499 +Ref: #simple-balance-report275684 +Node: Balance report line format277309 +Ref: #balance-report-line-format277511 +Node: Filtered balance report279669 +Ref: #filtered-balance-report279861 +Node: List or tree mode280188 +Ref: #list-or-tree-mode280356 +Node: Depth limiting281701 +Ref: #depth-limiting281867 +Node: Dropping top-level accounts282468 +Ref: #dropping-top-level-accounts282668 +Node: Showing declared accounts282978 +Ref: #showing-declared-accounts283177 +Node: Sorting by amount283708 +Ref: #sorting-by-amount283875 +Node: Percentages284545 +Ref: #percentages284704 +Node: Multi-period balance report285252 +Ref: #multi-period-balance-report285452 +Node: Balance change end balance287709 +Ref: #balance-change-end-balance287918 +Node: Balance report types289346 +Ref: #balance-report-types289527 +Node: Calculation type290025 +Ref: #calculation-type290180 +Node: Accumulation type290729 +Ref: #accumulation-type290909 +Node: Valuation type291811 +Ref: #valuation-type291999 +Node: Combining balance report types293000 +Ref: #combining-balance-report-types293194 +Node: Budget report295032 +Ref: #budget-report295194 +Node: Using the budget report297337 +Ref: #using-the-budget-report297510 +Node: Budget date surprises299613 +Ref: #budget-date-surprises299813 +Node: Selecting budget goals300977 +Ref: #selecting-budget-goals301180 +Node: Budgeting vs forecasting301925 +Ref: #budgeting-vs-forecasting302102 +Node: Balance report layout303373 +Ref: #balance-report-layout303553 +Node: Useful balance reports311738 +Ref: #useful-balance-reports311898 +Node: balancesheet312983 +Ref: #balancesheet313128 +Node: balancesheetequity314458 +Ref: #balancesheetequity314616 +Node: cashflow315997 +Ref: #cashflow316128 +Node: check317566 +Ref: #check317680 +Node: Default checks318484 +Ref: #default-checks318610 +Node: Strict checks319107 +Ref: #strict-checks319252 +Node: Other checks319732 +Ref: #other-checks319874 +Node: Custom checks320407 +Ref: #custom-checks320564 +Node: More about specific checks320981 +Ref: #more-about-specific-checks321143 +Node: close321849 +Ref: #close321960 +Node: close --migrate322613 +Ref: #close---migrate322740 +Node: close --close324379 +Ref: #close---close324523 +Node: close --open324759 +Ref: #close---open324900 +Node: close --assert325010 +Ref: #close---assert325156 +Node: close --assign325377 +Ref: #close---assign325525 +Node: close --retain326051 +Ref: #close---retain326204 +Node: close customisation326949 +Ref: #close-customisation327128 +Node: close and balance assertions328595 +Ref: #close-and-balance-assertions328792 +Node: close examples329968 +Ref: #close-examples330109 +Node: Retain earnings330207 +Ref: #retain-earnings330366 +Node: Migrate balances to a new file330712 +Ref: #migrate-balances-to-a-new-file330938 +Node: More detailed close examples332066 +Ref: #more-detailed-close-examples332264 +Node: codes332290 +Ref: #codes332407 +Node: commodities333271 +Ref: #commodities333399 +Node: demo333469 +Ref: #demo333590 +Node: descriptions334506 +Ref: #descriptions334636 +Node: diff334927 +Ref: #diff335042 +Node: files336084 +Ref: #files336193 +Node: help336334 +Ref: #help-1336443 +Node: import337816 +Ref: #import337939 +Node: Deduplication339047 +Ref: #deduplication339172 +Node: Import testing341191 +Ref: #import-testing341356 +Node: Importing balance assignments342199 +Ref: #importing-balance-assignments342405 +Node: Commodity display styles343054 +Ref: #commodity-display-styles343227 +Node: incomestatement343356 +Ref: #incomestatement343498 +Node: notes344829 +Ref: #notes344951 +Node: payees345313 +Ref: #payees345428 +Node: prices345947 +Ref: #prices346062 +Node: print346715 +Ref: #print346830 +Node: print explicitness347806 +Ref: #print-explicitness347949 +Node: print amount style348728 +Ref: #print-amount-style348898 +Node: print parseability349968 +Ref: #print-parseability350140 +Node: print other features350889 +Ref: #print-other-features351068 +Node: print output format351589 +Ref: #print-output-format351737 +Node: register354876 +Ref: #register354998 +Node: Custom register output360029 +Ref: #custom-register-output360160 +Node: rewrite361507 +Ref: #rewrite361625 +Node: Re-write rules in a file363523 +Ref: #re-write-rules-in-a-file363686 +Node: Diff output format364835 +Ref: #diff-output-format365018 +Node: rewrite vs print --auto366110 +Ref: #rewrite-vs.-print---auto366270 +Node: roi366826 +Ref: #roi366933 +Node: Spaces and special characters in --inv and --pnl368745 +Ref: #spaces-and-special-characters-in---inv-and---pnl368985 +Node: Semantics of --inv and --pnl369473 +Ref: #semantics-of---inv-and---pnl369712 +Node: IRR and TWR explained371562 +Ref: #irr-and-twr-explained371722 +Node: stats374975 +Ref: #stats375083 +Node: tags376470 +Ref: #tags-1376577 +Node: test377586 +Ref: #test377679 +Node: PART 5 COMMON TASKS378421 +Ref: #part-5-common-tasks378567 +Node: Getting help378865 +Ref: #getting-help379006 +Node: Constructing command lines379766 +Ref: #constructing-command-lines379967 +Node: Starting a journal file380624 +Ref: #starting-a-journal-file380826 +Node: Setting LEDGER_FILE382028 +Ref: #setting-ledger_file382220 +Node: Setting opening balances383177 +Ref: #setting-opening-balances383378 +Node: Recording transactions386519 +Ref: #recording-transactions386708 +Node: Reconciling387264 +Ref: #reconciling387416 +Node: Reporting389673 +Ref: #reporting389822 +Node: Migrating to a new file393807 +Ref: #migrating-to-a-new-file393964 +Node: BUGS394263 +Ref: #bugs394353 +Node: Troubleshooting395232 +Ref: #troubleshooting395332  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index d22bfc9b2..23a023d80 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -251,8 +251,6 @@ Options --alias=OLD=NEW rename accounts named OLD to NEW - --anon anonymize accounts and payees - --pivot FIELDNAME use some other field or tag for the account name @@ -713,32 +711,37 @@ Output ties/currencies. Its argument is as described in the commodity direc- tive. + hledger will occasionally make some additional adjustments to number + formatting, eg adding a trailing decimal mark to disambiguate numbers + with digit group marks; for details, see Amount formatting, parseabil- + ity. + Colour - In terminal output, some commands can produce colour when the terminal + In terminal output, some commands can produce colour when the terminal supports it: - o if the --color/--colour option is given a value of yes or always (or + o if the --color/--colour option is given a value of yes or always (or no or never), colour will (or will not) be used; - o otherwise, if the NO_COLOR environment variable is set, colour will + o otherwise, if the NO_COLOR environment variable is set, colour will not be used; - o otherwise, colour will be used if the output (terminal or file) sup- + o otherwise, colour will be used if the output (terminal or file) sup- ports it. Box-drawing - In terminal output, you can enable unicode box-drawing characters to + In terminal output, you can enable unicode box-drawing characters to render prettier tables: - o if the --pretty option is given a value of yes or always (or no or + o if the --pretty option is given a value of yes or always (or no or never), unicode characters will (or will not) be used; o otherwise, unicode characters will not be used. Paging - When showing long output in the terminal, hledger will try to use the - pager specified by the PAGER environment variable, or less, or more. - (A pager is a helper program that shows one page at a time rather than + When showing long output in the terminal, hledger will try to use the + pager specified by the PAGER environment variable, or less, or more. + (A pager is a helper program that shows one page at a time rather than scrolling everything off screen). Currently it does this only for help output, not for reports; specifically, @@ -748,23 +751,23 @@ Output o when viewing manuals with hledger help or hledger --man. - Note the pager is expected to handle ANSI codes, which hledger uses eg + Note the pager is expected to handle ANSI codes, which hledger uses eg for bold emphasis. For the common pager less (and its more compatibil- - ity mode), we add R to the LESS and MORE environment variables to make - this work. If you use a different pager, you might need to configure + ity mode), we add R to the LESS and MORE environment variables to make + this work. If you use a different pager, you might need to configure it similarly, to avoid seeing junk on screen (let us know). Otherwise, - you can set the NO_COLOR environment variable to 1 to disable all ANSI + you can set the NO_COLOR environment variable to 1 to disable all ANSI output (see Colour). Debug output We intend hledger to be relatively easy to troubleshoot, introspect and - develop. You can add --debug[=N] to any hledger command line to see - additional debug output. N ranges from 1 (least output, the default) - to 9 (maximum output). Typically you would start with 1 and increase - until you are seeing enough. Debug output goes to stderr, and is not + develop. You can add --debug[=N] to any hledger command line to see + additional debug output. N ranges from 1 (least output, the default) + to 9 (maximum output). Typically you would start with 1 and increase + until you are seeing enough. Debug output goes to stderr, and is not affected by -o/--output-file (unless you redirect stderr to stdout, eg: - 2>&1). It will be interleaved with normal output, which can help re- - veal when parts of the code are evaluated. To capture debug output in + 2>&1). It will be interleaved with normal output, which can help re- + veal when parts of the code are evaluated. To capture debug output in a log file instead, you can usually redirect stderr, eg: hledger bal --debug=3 2>hledger.log @@ -772,20 +775,20 @@ Output Environment These environment variables affect hledger: - COLUMNS This is normally set by your terminal; some hledger commands - (register) will format their output to this width. If not set, they + COLUMNS This is normally set by your terminal; some hledger commands + (register) will format their output to this width. If not set, they will try to use the available terminal width. - LEDGER_FILE The main journal file to use when not specified with + LEDGER_FILE The main journal file to use when not specified with -f/--file. Default: $HOME/.hledger.journal. - NO_COLOR If this environment variable is set (with any value), hledger - will not use ANSI color codes in terminal output, unless overridden by + NO_COLOR If this environment variable is set (with any value), hledger + will not use ANSI color codes in terminal output, unless overridden by an explicit --color/--colour option. PART 2: DATA FORMATS Journal - hledger's default file format, representing a General Journal. Here's + hledger's default file format, representing a General Journal. Here's a cheatsheet/mini-tutorial, or you can skip ahead to About journal for- mat. @@ -880,40 +883,40 @@ Journal About journal format hledger's usual data source is a plain text file containing journal en- - tries in hledger journal format. This file represents a standard ac- - counting general journal. I use file names ending in .journal, but + tries in hledger journal format. This file represents a standard ac- + counting general journal. I use file names ending in .journal, but that's not required. The journal file contains a number of transaction entries, each describing a transfer of money (or any commodity) between two or more named accounts, in a simple format readable by both hledger and humans. - hledger's journal format is compatible with most of Ledger's journal + hledger's journal format is compatible with most of Ledger's journal format, but not all of it. The differences and interoperation tips are - described at hledger and Ledger. With some care, and by avoiding in- - compatible features, you can keep your hledger journal readable by - Ledger and vice versa. This can useful eg for comparing the behaviour + described at hledger and Ledger. With some care, and by avoiding in- + compatible features, you can keep your hledger journal readable by + Ledger and vice versa. This can useful eg for comparing the behaviour of one app against the other. You can use hledger without learning any more about this file; just use the add or web or import commands to create and update it. Many users, though, edit the journal file with a text editor, and track - changes with a version control system such as git. Editor addons such - as ledger-mode or hledger-mode for Emacs, vim-ledger for Vim, and + changes with a version control system such as git. Editor addons such + as ledger-mode or hledger-mode for Emacs, vim-ledger for Vim, and hledger-vscode for Visual Studio Code, make this easier, adding colour, formatting, tab completion, and useful commands. See Editor configura- tion at hledger.org for the full list. - Here's a description of each part of the file format (and hledger's + Here's a description of each part of the file format (and hledger's data model). A hledger journal file can contain three kinds of thing: file comments, - transactions, and/or directives (counting periodic transaction rules + transactions, and/or directives (counting periodic transaction rules and auto posting rules as directives). Comments Lines in the journal will be ignored if they begin with a hash (#) or a - semicolon (;). (See also Other syntax.) hledger will also ignore re- + semicolon (;). (See also Other syntax.) hledger will also ignore re- gions beginning with a comment line and ending with an end comment line (or file end). Here's a suggestion for choosing between them: @@ -935,15 +938,15 @@ Journal end comment Some hledger entries can have same-line comments attached to them, from - ; (semicolon) to end of line. See Transaction comments, Posting com- + ; (semicolon) to end of line. See Transaction comments, Posting com- ments, and Account comments below. Transactions - Transactions are the main unit of information in a journal file. They - represent events, typically a movement of some quantity of commodities + Transactions are the main unit of information in a journal file. They + represent events, typically a movement of some quantity of commodities between two or more named accounts. - Each transaction is recorded as a journal entry, beginning with a sim- + Each transaction is recorded as a journal entry, beginning with a sim- ple date in column 0. This can be followed by any of the following op- tional fields, separated by spaces: @@ -953,11 +956,11 @@ Journal o a description (any remaining text until end of line or a semicolon) - o a comment (any remaining text following a semicolon until end of + o a comment (any remaining text following a semicolon until end of line, and any following indented lines beginning with a semicolon) o 0 or more indented posting lines, describing what was transferred and - the accounts involved (indented comment lines are also allowed, but + the accounts involved (indented comment lines are also allowed, but not blank lines or non-indented lines). Here's a simple journal file containing one transaction: @@ -968,22 +971,22 @@ Journal Dates Simple dates - Dates in the journal file use simple dates format: YYYY-MM-DD or + Dates in the journal file use simple dates format: YYYY-MM-DD or YYYY/MM/DD or YYYY.MM.DD, with leading zeros optional. The year may be - omitted, in which case it will be inferred from the context: the cur- - rent transaction, the default year set with a Y directive, or the cur- + omitted, in which case it will be inferred from the context: the cur- + rent transaction, the default year set with a Y directive, or the cur- rent date when the command is run. Some examples: 2010-01-31, 2010/01/31, 2010.1.31, 1/31. - (The UI also accepts simple dates, as well as the more flexible smart + (The UI also accepts simple dates, as well as the more flexible smart dates documented in the hledger manual.) Posting dates - You can give individual postings a different date from their parent - transaction, by adding a posting comment containing a tag (see below) + You can give individual postings a different date from their parent + transaction, by adding a posting comment containing a tag (see below) like date:DATE. This is probably the best way to control posting dates - precisely. Eg in this example the expense should appear in May re- - ports, and the deduction from checking should be reported on 6/1 for + precisely. Eg in this example the expense should appear in May re- + ports, and the deduction from checking should be reported on 6/1 for easy bank reconciliation: 2015/5/30 @@ -996,15 +999,15 @@ Journal $ hledger -f t.j register checking 2015-06-01 assets:checking $-10 $-10 - DATE should be a simple date; if the year is not specified it will use + DATE should be a simple date; if the year is not specified it will use the year of the transaction's date. - The date: tag must have a valid simple date value if it is present, eg + The date: tag must have a valid simple date value if it is present, eg a date: tag with no value is not allowed. Status - Transactions, or individual postings within a transaction, can have a - status mark, which is a single character before the transaction de- - scription or posting account name, separated from it by a space, indi- + Transactions, or individual postings within a transaction, can have a + status mark, which is a single character before the transaction de- + scription or posting account name, separated from it by a space, indi- cating one of three statuses: mark status @@ -1013,23 +1016,23 @@ Journal ! pending * cleared - When reporting, you can filter by status with the -U/--unmarked, - -P/--pending, and -C/--cleared flags; or the status:, status:!, and + When reporting, you can filter by status with the -U/--unmarked, + -P/--pending, and -C/--cleared flags; or the status:, status:!, and status:* queries; or the U, P, C keys in hledger-ui. - Note, in Ledger and in older versions of hledger, the "unmarked" state - is called "uncleared". As of hledger 1.3 we have renamed it to un- + Note, in Ledger and in older versions of hledger, the "unmarked" state + is called "uncleared". As of hledger 1.3 we have renamed it to un- marked for clarity. - To replicate Ledger and old hledger's behaviour of also matching pend- + To replicate Ledger and old hledger's behaviour of also matching pend- ing, combine -U and -P. - Status marks are optional, but can be helpful eg for reconciling with + Status marks are optional, but can be helpful eg for reconciling with real-world accounts. Some editor modes provide highlighting and short- - cuts for working with status. Eg in Emacs ledger-mode, you can toggle + cuts for working with status. Eg in Emacs ledger-mode, you can toggle transaction status with C-c C-e, or posting status with C-c C-c. - What "uncleared", "pending", and "cleared" actually mean is up to you. + What "uncleared", "pending", and "cleared" actually mean is up to you. Here's one suggestion: status meaning @@ -1040,35 +1043,35 @@ Journal cleared complete, reconciled as far as possible, and considered cor- rect - With this scheme, you would use -PC to see the current balance at your + With this scheme, you would use -PC to see the current balance at your bank, -U to see things which will probably hit your bank soon (like un- - cashed checks), and no flags to see the most up-to-date state of your + cashed checks), and no flags to see the most up-to-date state of your finances. Code - After the status mark, but before the description, you can optionally - write a transaction "code", enclosed in parentheses. This is a good - place to record a check number, or some other important transaction id + After the status mark, but before the description, you can optionally + write a transaction "code", enclosed in parentheses. This is a good + place to record a check number, or some other important transaction id or reference number. Description - A transaction's description is the rest of the line following the date - and status mark (or until a comment begins). Sometimes called the + A transaction's description is the rest of the line following the date + and status mark (or until a comment begins). Sometimes called the "narration" in traditional bookkeeping, it can be used for whatever you - wish, or left blank. Transaction descriptions can be queried, unlike + wish, or left blank. Transaction descriptions can be queried, unlike comments. Payee and note You can optionally include a | (pipe) character in descriptions to sub- divide the description into separate fields for payee/payer name on the left (up to the first |) and an additional note field on the right (af- - ter the first |). This may be worthwhile if you need to do more pre- + ter the first |). This may be worthwhile if you need to do more pre- cise querying and pivoting by payee or by note. Transaction comments - Text following ;, after a transaction description, and/or on indented - lines immediately below it, form comments for that transaction. They - are reproduced by print but otherwise ignored, except they may contain + Text following ;, after a transaction description, and/or on indented + lines immediately below it, form comments for that transaction. They + are reproduced by print but otherwise ignored, except they may contain tags, which are not ignored. 2012-01-01 something ; a transaction comment @@ -1077,43 +1080,43 @@ Journal assets Postings - A posting is an addition of some amount to, or removal of some amount - from, an account. Each posting line begins with at least one space or + A posting is an addition of some amount to, or removal of some amount + from, an account. Each posting line begins with at least one space or tab (2 or 4 spaces is common), followed by: o (optional) a status character (empty, !, or *), followed by a space - o (required) an account name (any text, optionally containing single + o (required) an account name (any text, optionally containing single spaces, until end of line or a double space) o (optional) two or more spaces or tabs followed by an amount. - Positive amounts are being added to the account, negative amounts are + Positive amounts are being added to the account, negative amounts are being removed. The amounts within a transaction must always sum up to zero. As a con- - venience, one amount may be left blank; it will be inferred so as to + venience, one amount may be left blank; it will be inferred so as to balance the transaction. - Be sure to note the unusual two-space delimiter between account name - and amount. This makes it easy to write account names containing - spaces. But if you accidentally leave only one space (or tab) before + Be sure to note the unusual two-space delimiter between account name + and amount. This makes it easy to write account names containing + spaces. But if you accidentally leave only one space (or tab) before the amount, the amount will be considered part of the account name. Account names - Accounts are the main way of categorising things in hledger. As in - Double Entry Bookkeeping, they can represent real world accounts (such + Accounts are the main way of categorising things in hledger. As in + Double Entry Bookkeeping, they can represent real world accounts (such as a bank account), or more abstract categories such as "money borrowed from Frank" or "money spent on electricity". - You can use any account names you like, but we usually start with the + You can use any account names you like, but we usually start with the traditional accounting categories, which in english are assets, liabil- ities, equity, revenues, expenses. (You might see these referred to as A, L, E, R, X for short.) - For more precise reporting, we usually divide the top level accounts + For more precise reporting, we usually divide the top level accounts into more detailed subaccounts, by writing a full colon between account - name parts. For example, from the account names assets:bank:checking + name parts. For example, from the account names assets:bank:checking and expenses:food, hledger will infer this hierarchy of five accounts: assets @@ -1131,33 +1134,33 @@ Journal food hledger reports can summarise the account tree to any depth, so you can - go as deep as you like with subcategories, but keeping your account + go as deep as you like with subcategories, but keeping your account names relatively simple may be best when starting out. Account names may be capitalised or not; they may contain letters, num- - bers, symbols, or single spaces. Note, when an account name and an - amount are written on the same line, they must be separated by two or + bers, symbols, or single spaces. Note, when an account name and an + amount are written on the same line, they must be separated by two or more spaces (or tabs). - Parentheses or brackets enclosing the full account name indicate vir- - tual postings, described below. Parentheses or brackets internal to + Parentheses or brackets enclosing the full account name indicate vir- + tual postings, described below. Parentheses or brackets internal to the account name have no special meaning. - Account names can be altered temporarily or permanently by account + Account names can be altered temporarily or permanently by account aliases. Amounts - After the account name, there is usually an amount. (Important: be- + After the account name, there is usually an amount. (Important: be- tween account name and amount, there must be two or more spaces.) - hledger's amount format is flexible, supporting several international - formats. Here are some examples. Amounts have a number (the "quan- + hledger's amount format is flexible, supporting several international + formats. Here are some examples. Amounts have a number (the "quan- tity"): 1 ..and usually a currency symbol or commodity name (more on this below), - to the left or right of the quantity, with or without a separating + to the left or right of the quantity, with or without a separating space: $1 @@ -1165,13 +1168,13 @@ Journal 3 "green apples" Amounts can be preceded by a minus sign (or a plus sign, though plus is - the default), The sign can be written before or after a left-side com- + the default), The sign can be written before or after a left-side com- modity symbol: -$1 $-1 - One or more spaces between the sign and the number are acceptable when + One or more spaces between the sign and the number are acceptable when parsing (but they won't be displayed in output): + $1 @@ -1188,8 +1191,8 @@ Journal 1.23 1,23 - In the integer part of the quantity (left of the decimal mark), groups - of digits can optionally be separated by a digit group mark - a space, + In the integer part of the quantity (left of the decimal mark), groups + of digits can optionally be separated by a digit group mark - a space, comma, or period (different from the decimal mark): $1,000,000.00 @@ -1197,40 +1200,40 @@ Journal INR 9,99,99,999.00 1 000 000.9455 - hledger is not biased towards period or comma decimal marks, so a num- - ber containing just one period or comma, like 1,000 or 1.000, is am- - biguous. In such cases hledger assumes it is a decimal mark, parsing + hledger is not biased towards period or comma decimal marks, so a num- + ber containing just one period or comma, like 1,000 or 1.000, is am- + biguous. In such cases hledger assumes it is a decimal mark, parsing both of these as 1. To disambiguate these and ensure accurate number parsing, especially if - you use digit group marks, we recommend declaring the decimal mark. - You can declare it for each file with decimal-mark directives, or for + you use digit group marks, we recommend declaring the decimal mark. + You can declare it for each file with decimal-mark directives, or for each commodity with commodity directives (described below). Commodity - Amounts in hledger have both a "quantity", which is a signed decimal + Amounts in hledger have both a "quantity", which is a signed decimal number, and a "commodity", which is a currency symbol, stock ticker, or any word or phrase describing something you are tracking. If the commodity name contains non-letters (spaces, numbers, or punctu- - ation), you must always write it inside double quotes ("green apples", + ation), you must always write it inside double quotes ("green apples", "ABC123"). - If you write just a bare number, that too will have a commodity, with + If you write just a bare number, that too will have a commodity, with name ""; we call that the "no-symbol commodity". - Actually, hledger combines these single-commodity amounts into more - powerful multi-commodity amounts, which are what it works with most of - the time. A multi-commodity amount could be, eg: 1 USD, 2 EUR, 3.456 - TSLA. In practice, you will only see multi-commodity amounts in + Actually, hledger combines these single-commodity amounts into more + powerful multi-commodity amounts, which are what it works with most of + the time. A multi-commodity amount could be, eg: 1 USD, 2 EUR, 3.456 + TSLA. In practice, you will only see multi-commodity amounts in hledger's output; you can't write them directly in the journal file. - (If you are writing scripts or working with hledger's internals, these + (If you are writing scripts or working with hledger's internals, these are the Amount and MixedAmount types.) Directives influencing number parsing and display - You can add decimal-mark and commodity directives to the journal, to - declare and control these things more explicitly and precisely. These + You can add decimal-mark and commodity directives to the journal, to + declare and control these things more explicitly and precisely. These are described below, but here's a quick example: # the decimal mark character used by all amounts in this file (all commodities) @@ -1244,22 +1247,22 @@ Journal Commodity display style For the amounts in each commodity, hledger chooses a consistent display - style (symbol placement, decimal mark and digit group marks, number of + style (symbol placement, decimal mark and digit group marks, number of decimal digits) to use in most reports. This is inferred as follows: - First, if there's a D directive declaring a default commodity, that - commodity symbol and amount format is applied to all no-symbol amounts + First, if there's a D directive declaring a default commodity, that + commodity symbol and amount format is applied to all no-symbol amounts in the journal. - Then each commodity's display style is determined from its commodity - directive. We recommend always declaring commodities with commodity + Then each commodity's display style is determined from its commodity + directive. We recommend always declaring commodities with commodity directives, since they help ensure consistent display styles and preci- - sions, and bring other benefits such as error checking for commodity + sions, and bring other benefits such as error checking for commodity symbols. - But if a commodity directive is not present, hledger infers a commod- - ity's display styles from its amounts as they are written in the jour- - nal (excluding cost amounts and amounts in periodic transaction rules + But if a commodity directive is not present, hledger infers a commod- + ity's display styles from its amounts as they are written in the jour- + nal (excluding cost amounts and amounts in periodic transaction rules or auto posting rules). It uses o the symbol placement and decimal mark of the first amount seen @@ -1268,7 +1271,7 @@ Journal o and the maximum number of decimal digits seen across all amounts. - And as fallback if no applicable amounts are found, it would use a de- + And as fallback if no applicable amounts are found, it would use a de- fault style, like $1000.00 (symbol on the left with no space, period as decimal mark, and two decimal digits). @@ -1277,13 +1280,19 @@ Journal Rounding Amounts are stored internally as decimal numbers with up to 255 decimal - places. They are displayed with their original journal precisions by - print and print-like reports, and rounded to their display precision + places. They are displayed with their original journal precisions by + print and print-like reports, and rounded to their display precision (the number of decimal digits specified by the commodity display style) - by other reports. When rounding, hledger uses banker's rounding (it + by other reports. When rounding, hledger uses banker's rounding (it rounds to the nearest even digit). So eg 0.5 displayed with zero deci- mal digits appears as "0". + Number format + hledger will occasionally make some additional adjustments to number + formatting, eg adding a trailing decimal mark to disambiguate numbers + with digit group marks; for details, see Amount formatting, parseabil- + ity. + Costs After a posting amount, you can note its cost (when buying) or selling price (when selling) in another commodity, by writing either @ UNIT- @@ -1581,51 +1590,90 @@ Journal They are written as a word (optionally hyphenated) immediately followed by a full colon, in a transaction or posting or account directive's comment. (This is an exception to the usual rule that things in com- - ments are ignored.) Eg, here four different tags are recorded: one on - the checking account, two on the transaction, and one on the expenses - posting: + ments are ignored.) You can write multiple tags separated by comma, + and/or you can add more comment lines and write more tags there. + + Here five different tags are recorded: one on the checking account, two + on the transaction, and two on the expenses posting: account assets:checking ; accounttag: 2017/1/16 bought groceries ; transactiontag-1: ; transactiontag-2: assets:checking $-1 - expenses:food $1 ; postingtag: + expenses:food $1 ; postingtag:, another-posting-tag: + You can list tag names with hledger tags [NAMEREGEX], or match by tag + name with a tag:NAMEREGEX query. + + Tag inheritance Postings also inherit tags from their transaction and their account. And transactions also acquire tags from their postings (and postings' accounts). So in the example above, the expenses posting effectively - has all four tags (by inheriting from account and transaction), and the - transaction also has all four tags (by acquiring from the expenses + has all five tags (by inheriting from the account and transaction), and + the transaction also has all five tags (by acquiring from the expenses posting). - You can list tag names with hledger tags [NAMEREGEX], or match by tag - name with a tag:NAMEREGEX query. + Tag names + Tag names are currently not very clearly specified; any sequence of + non-whitespace characters followed by a colon may work. + + The following tag names are generated by hledger or have special sig- + nificance to hledger, so you may want to avoid using them yourself: + + o balances -- a balance assertions transaction generated by close + + o retain -- a retain earnings transaction generated by close + + o start -- a opening balances, closing balances or balance assignment + transaction generated by close + + o generated-transaction -- a transaction generated by --forecast + + o generated-posting -- a posting generated by --auto + + o modified -- a transaction which has had postings added by --auto + + o type -- declares an account's type in an account declaration + + o t -- stores the (user defined, single letter) type of a 15m unit of + time parsed from timedot format + + Some additional tag names with an underscore prefix are used internally + and not displayed in reports (but can be matched by queries): + + o _generated-transaction + + o _generated-posting + + o _modified + + o _conversion-matched Tag values - Tags can have a value, which is any text after the colon up until a - comma or end of line (with surrounding whitespace removed). Note this - means that hledger tag values can not contain commas. Eg in the fol- + Tags can have a value, which is any text after the colon up until a + comma or end of line (with surrounding whitespace removed). Note this + means that hledger tag values can not contain commas. Eg in the fol- lowing posting, the three tags' values are "value 1", "value 2", and "" (empty) respectively: expenses:food $10 ; foo, tag1: value 1 , tag2:value 2, bar tag3: , baz - Note that tags can be repeated, and are additive rather than overrid- - ing: when the same tag name is seen again with a new value, the new - name:value pair is added to the tags. (It is not possible to override + Note that tags can be repeated, and are additive rather than overrid- + ing: when the same tag name is seen again with a new value, the new + name:value pair is added to the tags. (It is not possible to override a tag's value or remove a tag.) - You can list a tag's values with hledger tags TAGNAME --values, or + You can list a tag's values with hledger tags TAGNAME --values, or match by tag value with a tag:NAMEREGEX=VALUEREGEX query. Directives - Besides transactions, there is something else you can put in a journal - file: directives. These are declarations, beginning with a keyword, - that modify hledger's behaviour. Some directives can have more spe- - cific subdirectives, indented below them. hledger's directives are + Besides transactions, there is something else you can put in a journal + file: directives. These are declarations, beginning with a keyword, + that modify hledger's behaviour. Some directives can have more spe- + cific subdirectives, indented below them. hledger's directives are similar to Ledger's in many cases, but there are also many differences. - Directives are not required, but can be useful. Here are the main di- + Directives are not required, but can be useful. Here are the main di- rectives: purpose directive @@ -1633,16 +1681,16 @@ Journal READING DATA: Rewrite account names alias Comment out sections of the file comment - Declare file's decimal mark, to help decimal-mark + Declare file's decimal mark, to help decimal-mark parse amounts accurately Include other data files include GENERATING DATA: - Generate recurring transactions or bud- ~ + Generate recurring transactions or bud- ~ get goals - Generate extra postings on existing = + Generate extra postings on existing = transactions CHECKING FOR ERRORS: - Define valid entities to provide more account, commodity, payee, tag + Define valid entities to provide more account, commodity, payee, tag error checking REPORTING: Declare accounts' type and display order account @@ -1650,23 +1698,23 @@ Journal Declare market prices P Directives and multiple files - Directives vary in their scope, ie which journal entries and which in- + Directives vary in their scope, ie which journal entries and which in- put files they affect. Most often, a directive will affect the follow- - ing entries and included files if any, until the end of the current + ing entries and included files if any, until the end of the current file - and no further. You might find this inconvenient! For example, - alias directives do not affect parent or sibling files. But there are + alias directives do not affect parent or sibling files. But there are usually workarounds; for example, put alias directives in your top-most file, before including other files. - The restriction, though it may be annoying at first, is in a good + The restriction, though it may be annoying at first, is in a good cause; it allows reports to be stable and deterministic, independent of - the order of input. Without it, reports could show different numbers - depending on the order of -f options, or the positions of include di- + the order of input. Without it, reports could show different numbers + depending on the order of -f options, or the positions of include di- rectives in your files. Directive effects - Here are all hledger's directives, with their effects and scope sum- - marised - nine main directives, plus four others which we consider + Here are all hledger's directives, with their effects and scope sum- + marised - nine main directives, plus four others which we consider non-essential: di- what it does ends @@ -1674,93 +1722,93 @@ Journal tive file end? -------------------------------------------------------------------------------------- - ac- Declares an account, for checking all entries in all files; and N + ac- Declares an account, for checking all entries in all files; and N count its display order and type. Subdirectives: any text, ignored. - alias Rewrites account names, in following entries until end of cur- Y + alias Rewrites account names, in following entries until end of cur- Y rent file or end aliases. Command line equivalent: --alias - com- Ignores part of the journal file, until end of current file or Y + com- Ignores part of the journal file, until end of current file or Y ment end comment. com- Declares up to four things: 1. a commodity symbol, for checking N,Y,N,N - mod- all amounts in all files 2. the decimal mark for parsing + mod- all amounts in all files 2. the decimal mark for parsing ity amounts of this commodity, in the following entries until end of current file (if there is no decimal-mark directive) 3. and the - display style for amounts of this commodity 4. which is also - the precision to use for balanced-transaction checking in this - commodity. Takes precedence over D. Subdirectives: format - (Ledger-compatible syntax). Command line equivalent: -c/--com- + display style for amounts of this commodity 4. which is also + the precision to use for balanced-transaction checking in this + commodity. Takes precedence over D. Subdirectives: format + (Ledger-compatible syntax). Command line equivalent: -c/--com- modity-style - deci- Declares the decimal mark, for parsing amounts of all commodi- Y + deci- Declares the decimal mark, for parsing amounts of all commodi- Y mal-mark ties in following entries until next decimal-mark or end of cur- - rent file. Included files can override. Takes precedence over + rent file. Included files can override. Takes precedence over commodity and D. - include Includes entries and directives from another file, as if they N - were written inline. Command line alternative: multiple + include Includes entries and directives from another file, as if they N + were written inline. Command line alternative: multiple -f/--file payee Declares a payee name, for checking all entries in all files. N P Declares the market price of a commodity on some date, for value N reports. - ~ Declares a periodic transaction rule that generates future N - (tilde) transactions with --forecast and budget goals with balance + ~ Declares a periodic transaction rule that generates future N + (tilde) transactions with --forecast and budget goals with balance --budget. Other syntax: - apply Prepends a common parent account to all account names, in fol- Y + apply Prepends a common parent account to all account names, in fol- Y account lowing entries until end of current file or end apply account. - D Sets a default commodity to use for no-symbol amounts;and, if Y,Y,N,N - there is no commodity directive for this commodity: its decimal + D Sets a default commodity to use for no-symbol amounts;and, if Y,Y,N,N + there is no commodity directive for this commodity: its decimal mark, balancing precision, and display style, as above. - Y Sets a default year to use for any yearless dates, in following Y + Y Sets a default year to use for any yearless dates, in following Y entries until end of current file. - = Declares an auto posting rule that generates extra postings on partly - (equals) matched transactions with --auto, in current, parent, and child + = Declares an auto posting rule that generates extra postings on partly + (equals) matched transactions with --auto, in current, parent, and child files (but not sibling files, see #1212). - Other Other directives from Ledger's file format are accepted but ig- + Other Other directives from Ledger's file format are accepted but ig- Ledger nored. direc- tives account directive account directives can be used to declare accounts (ie, the places that - amounts are transferred from and to). Though not required, these dec- + amounts are transferred from and to). Though not required, these dec- larations can provide several benefits: o They can document your intended chart of accounts, providing a refer- ence. - o In strict mode, they restrict which accounts may be posted to by + o In strict mode, they restrict which accounts may be posted to by transactions, which helps detect typos. - o They control account display order in reports, allowing non-alpha- + o They control account display order in reports, allowing non-alpha- betic sorting (eg Revenues to appear above Expenses). - o They help with account name completion (in hledger add, hledger-web, + o They help with account name completion (in hledger add, hledger-web, hledger-iadd, ledger-mode, etc.) o They can store additional account information as comments, or as tags which can be used to filter or pivot reports. - o They can help hledger know your accounts' types (asset, liability, - equity, revenue, expense), affecting reports like balancesheet and + o They can help hledger know your accounts' types (asset, liability, + equity, revenue, expense), affecting reports like balancesheet and incomestatement. - They are written as the word account followed by a hledger-style ac- + They are written as the word account followed by a hledger-style ac- count name, eg: account assets:bank:checking Note, however, that accounts declared in account directives are not al- - lowed to have surrounding brackets and parentheses, unlike accounts + lowed to have surrounding brackets and parentheses, unlike accounts used in postings. So the following journal will not parse: account (assets:bank:checking) Account comments Text following two or more spaces and ; at the end of an account direc- - tive line, and/or following ; on indented lines immediately below it, - form comments for that account. They are ignored except they may con- + tive line, and/or following ; on indented lines immediately below it, + form comments for that account. They are ignored except they may con- tain tags, which are not ignored. - The two-space requirement for same-line account comments is because ; + The two-space requirement for same-line account comments is because ; is allowed in account names. account assets:bank:checking ; same-line comment, at least 2 spaces before the semicolon @@ -1768,41 +1816,41 @@ Journal ; some tags - type:A, acctnum:12345 Account subdirectives - Ledger-style indented subdirectives are also accepted, but currently + Ledger-style indented subdirectives are also accepted, but currently ignored: account assets:bank:checking format subdirective is ignored Account error checking - By default, accounts need not be declared; they come into existence - when a posting references them. This is convenient, but it means - hledger can't warn you when you mis-spell an account name in the jour- + By default, accounts need not be declared; they come into existence + when a posting references them. This is convenient, but it means + hledger can't warn you when you mis-spell an account name in the jour- nal. Usually you'll find that error later, as an extra account in bal- ance reports, or an incorrect balance when reconciling. - In strict mode, enabled with the -s/--strict flag, hledger will report - an error if any transaction uses an account name that has not been de- + In strict mode, enabled with the -s/--strict flag, hledger will report + an error if any transaction uses an account name that has not been de- clared by an account directive. Some notes: - o The declaration is case-sensitive; transactions must use the correct + o The declaration is case-sensitive; transactions must use the correct account name capitalisation. - o The account directive's scope is "whole file and below" (see direc- + o The account directive's scope is "whole file and below" (see direc- tives). This means it affects all of the current file, and any files - it includes, but not parent or sibling files. The position of ac- - count directives within the file does not matter, though it's usual + it includes, but not parent or sibling files. The position of ac- + count directives within the file does not matter, though it's usual to put them at the top. - o Accounts can only be declared in journal files, but will affect in- + o Accounts can only be declared in journal files, but will affect in- cluded files of all types. - o It's currently not possible to declare "all possible subaccounts" + o It's currently not possible to declare "all possible subaccounts" with a wildcard; every account posted to must be declared. Account display order - The order in which account directives are written influences the order - in which accounts appear in reports, hledger-ui, hledger-web etc. By + The order in which account directives are written influences the order + in which accounts appear in reports, hledger-ui, hledger-web etc. By default accounts appear in alphabetical order, but if you add these ac- count directives to the journal file: @@ -1828,24 +1876,24 @@ Journal account other:zoo - would influence the position of zoo among other's subaccounts, but not + would influence the position of zoo among other's subaccounts, but not the position of other among the top-level accounts. This means: - o you will sometimes declare parent accounts (eg account other above) + o you will sometimes declare parent accounts (eg account other above) that you don't intend to post to, just to customize their display or- der - o sibling accounts stay together (you couldn't display x:y in between + o sibling accounts stay together (you couldn't display x:y in between a:b and a:c). Account types hledger knows that accounts come in several types: assets, liabilities, - expenses and so on. This enables easy reports like balancesheet and + expenses and so on. This enables easy reports like balancesheet and incomestatement, and filtering by account type with the type: query. As a convenience, hledger will detect these account types automatically - if you are using common english-language top-level account names (de- - scribed below). But generally we recommend you declare types explic- + if you are using common english-language top-level account names (de- + scribed below). But generally we recommend you declare types explic- itly, by adding a type: tag to your top-level account directives. Sub- accounts will inherit the type of their parent. The tag's value should be one of the five main account types: @@ -1854,10 +1902,10 @@ Journal o L or Liability (things you owe) - o E or Equity (investment/ownership; balanced counterpart of assets & + o E or Equity (investment/ownership; balanced counterpart of assets & liabilities) - o R or Revenue (what you received money from, AKA income; technically + o R or Revenue (what you received money from, AKA income; technically part of Equity) o X or Expense (what you spend money on; technically part of Equity) @@ -1867,7 +1915,7 @@ Journal o C or Cash (a subtype of Asset, indicating liquid assets for the cash- flow report) - o V or Conversion (a subtype of Equity, for conversions (see Cost re- + o V or Conversion (a subtype of Equity, for conversions (see Cost re- porting).) Here is a typical set of account type declarations: @@ -1885,7 +1933,7 @@ Journal Here are some tips for working with account types. - o The rules for inferring types from account names are as follows. + o The rules for inferring types from account names are as follows. These are just a convenience that sometimes help new users get going; if they don't work for you, just ignore them and declare your account types. See also Regular expressions. @@ -1900,25 +1948,25 @@ Journal ^(income|revenue)s?(:|$) | Revenue ^expenses?(:|$) | Expense - o If you declare any account types, it's a good idea to declare an ac- + o If you declare any account types, it's a good idea to declare an ac- count for all of the account types, because a mixture of declared and name-inferred types can disrupt certain reports. - o Certain uses of account aliases can disrupt account types. See + o Certain uses of account aliases can disrupt account types. See Rewriting accounts > Aliases and account types. o As mentioned above, subaccounts will inherit a type from their parent - account. More precisely, an account's type is decided by the first + account. More precisely, an account's type is decided by the first of these that exists: 1. A type: declaration for this account. - 2. A type: declaration in the parent accounts above it, preferring + 2. A type: declaration in the parent accounts above it, preferring the nearest. 3. An account type inferred from this account's name. - 4. An account type inferred from a parent account's name, preferring + 4. An account type inferred from a parent account's name, preferring the nearest parent. 5. Otherwise, it will have no type. @@ -1944,7 +1992,7 @@ Journal o customising reports Account aliases also rewrite account names in account directives. They - do not affect account names being entered via hledger add or + do not affect account names being entered via hledger add or hledger-web. Account aliases are very powerful. They are generally easy to use cor- @@ -1954,9 +2002,9 @@ Journal See also Rewrite account names. Basic aliases - To set an account alias, use the alias directive in your journal file. - This affects all subsequent journal entries in the current file or its - included files (but note: not sibling or parent files). The spaces + To set an account alias, use the alias directive in your journal file. + This affects all subsequent journal entries in the current file or its + included files (but note: not sibling or parent files). The spaces around the = are optional: alias OLD = NEW @@ -1964,17 +2012,17 @@ Journal Or, you can use the --alias 'OLD=NEW' option on the command line. This affects all entries. It's useful for trying out aliases interactively. - OLD and NEW are case sensitive full account names. hledger will re- - place any occurrence of the old account name with the new one. Subac- + OLD and NEW are case sensitive full account names. hledger will re- + place any occurrence of the old account name with the new one. Subac- counts are also affected. Eg: alias checking = assets:bank:wells fargo:checking ; rewrites "checking" to "assets:bank:wells fargo:checking", or "checking:a" to "assets:bank:wells fargo:checking:a" Regex aliases - There is also a more powerful variant that uses a regular expression, - indicated by wrapping the pattern in forward slashes. (This is the - only place where hledger requires forward slashes around a regular ex- + There is also a more powerful variant that uses a regular expression, + indicated by wrapping the pattern in forward slashes. (This is the + only place where hledger requires forward slashes around a regular ex- pression.) Eg: @@ -1985,13 +2033,13 @@ Journal $ hledger --alias '/REGEX/=REPLACEMENT' ... - Any part of an account name matched by REGEX will be replaced by RE- + Any part of an account name matched by REGEX will be replaced by RE- PLACEMENT. REGEX is case-insensitive as usual. - If you need to match a forward slash, escape it with a backslash, eg + If you need to match a forward slash, escape it with a backslash, eg /\/=:. - If REGEX contains parenthesised match groups, these can be referenced + If REGEX contains parenthesised match groups, these can be referenced by the usual backslash and number in REPLACEMENT: alias /^(.+):bank:([^:]+):(.*)/ = \1:\2 \3 @@ -2001,21 +2049,21 @@ Journal option argument), so it can contain trailing whitespace. Combining aliases - You can define as many aliases as you like, using journal directives + You can define as many aliases as you like, using journal directives and/or command line options. - Recursive aliases - where an account name is rewritten by one alias, - then by another alias, and so on - are allowed. Each alias sees the + Recursive aliases - where an account name is rewritten by one alias, + then by another alias, and so on - are allowed. Each alias sees the effect of previously applied aliases. - In such cases it can be important to understand which aliases will be - applied and in which order. For (each account name in) each journal + In such cases it can be important to understand which aliases will be + applied and in which order. For (each account name in) each journal entry, we apply: - 1. alias directives preceding the journal entry, most recently parsed + 1. alias directives preceding the journal entry, most recently parsed first (ie, reading upward from the journal entry, bottom to top) - 2. --alias options, in the order they appeared on the command line + 2. --alias options, in the order they appeared on the command line (left to right). In other words, for (an account name in) a given journal entry: @@ -2026,20 +2074,20 @@ Journal o aliases defined after/below the entry do not affect it. - This gives nearby aliases precedence over distant ones, and helps pro- - vide semantic stability - aliases will keep working the same way inde- + This gives nearby aliases precedence over distant ones, and helps pro- + vide semantic stability - aliases will keep working the same way inde- pendent of which files are being read and in which order. - In case of trouble, adding --debug=6 to the command line will show + In case of trouble, adding --debug=6 to the command line will show which aliases are being applied when. Aliases and multiple files - As explained at Directives and multiple files, alias directives do not + As explained at Directives and multiple files, alias directives do not affect parent or sibling files. Eg in this command, hledger -f a.aliases -f b.journal - account aliases defined in a.aliases will not affect b.journal. In- + account aliases defined in a.aliases will not affect b.journal. In- cluding the aliases doesn't work either: include a.aliases @@ -2067,7 +2115,7 @@ Journal end aliases Aliases can generate bad account names - Be aware that account aliases can produce malformed account names, + Be aware that account aliases can produce malformed account names, which could cause confusing reports or invalid print output. For exam- ple, you could erase all account names: @@ -2079,8 +2127,8 @@ Journal 2021-01-01 1 - The above print output is not a valid journal. Or you could insert an - illegal double space, causing print output that would give a different + The above print output is not a valid journal. Or you could insert an + illegal double space, causing print output that would give a different journal when reparsed: 2021-01-01 @@ -2097,15 +2145,15 @@ Journal types) is renamed by an alias, normally the account type remains in ef- fect. - However, renaming in a way that reshapes the account tree (eg renaming - parent accounts but not their children, or vice versa) could prevent + However, renaming in a way that reshapes the account tree (eg renaming + parent accounts but not their children, or vice versa) could prevent child accounts from inheriting the account type of their parents. - Secondly, if an account's type is being inferred from its name, renam- + Secondly, if an account's type is being inferred from its name, renam- ing it by an alias could prevent or alter that. - If you are using account aliases and the type: query is not matching - accounts as you expect, try troubleshooting with the accounts command, + If you are using account aliases and the type: query is not matching + accounts as you expect, try troubleshooting with the accounts command, eg something like: $ hledger accounts --alias assets=bassetts type:a @@ -2113,31 +2161,31 @@ Journal commodity directive The commodity directive performs several functions: - 1. It declares which commodity symbols may be used in the journal, en- - abling useful error checking with strict mode or the check command. + 1. It declares which commodity symbols may be used in the journal, en- + abling useful error checking with strict mode or the check command. (See Commodity error checking below.) 2. It declares the precision with which this commodity's amounts should be compared when checking for balanced transactions. - 3. It declares how this commodity's amounts should be displayed, eg - their symbol placement, digit group mark if any, digit group sizes, - decimal mark (period or comma), and the number of decimal places. + 3. It declares how this commodity's amounts should be displayed, eg + their symbol placement, digit group mark if any, digit group sizes, + decimal mark (period or comma), and the number of decimal places. (See Commodity display style above.) - 4. It sets which decimal mark (period or comma) to expect when parsing - subsequent amounts in this commodity (if there is no decimal-mark - directive in effect. See Decimal marks, digit group marks above. + 4. It sets which decimal mark (period or comma) to expect when parsing + subsequent amounts in this commodity (if there is no decimal-mark + directive in effect. See Decimal marks, digit group marks above. For related dev discussion, see #793.) - Declaring commodities solves several common parsing/display problems, - so we recommend it. Generally you should put commodity directives at - the top of your journal file (because function 4 is position-sensi- + Declaring commodities solves several common parsing/display problems, + so we recommend it. Generally you should put commodity directives at + the top of your journal file (because function 4 is position-sensi- tive). Commodity directive syntax A commodity directive is normally the word commodity followed by a sam- - ple amount (and optionally a comment). Only the amount's symbol and + ple amount (and optionally a comment). Only the amount's symbol and format is significant. Eg: commodity $1000.00 @@ -2146,19 +2194,19 @@ Journal Commodities do not have tags (tags in the comment will be ignored). - A commodity directive's sample amount must always include a period or - comma decimal mark (this rule helps disambiguate decimal marks and - digit group marks). If you don't want to show any decimal digits, + A commodity directive's sample amount must always include a period or + comma decimal mark (this rule helps disambiguate decimal marks and + digit group marks). If you don't want to show any decimal digits, write the decimal mark at the end: commodity 1000. AAAA ; show AAAA with no decimals - Commodity symbols containing spaces, numbers, or punctuation must be + Commodity symbols containing spaces, numbers, or punctuation must be enclosed in double quotes, as usual: commodity 1.0000 "AAAA 2023" - Commodity directives normally include a sample amount, but can declare + Commodity directives normally include a sample amount, but can declare only a symbol (ie, just function 1 above): commodity $ @@ -2167,7 +2215,7 @@ Journal commodity "" ; the no-symbol commodity Commodity directives may also be written with an indented format subdi- - rective, as in Ledger. The symbol is repeated and must be the same in + rective, as in Ledger. The symbol is repeated and must be the same in both places. Other subdirectives are currently ignored: ; display indian rupees with currency name on the left, @@ -2178,10 +2226,10 @@ Journal an unsupported subdirective ; ignored by hledger Commodity error checking - In strict mode (-s/--strict) (or when you run hledger check commodi- - ties), hledger will report an error if an undeclared commodity symbol - is used. (With one exception: zero amounts are always allowed to have - no commodity symbol.) It works like account error checking (described + In strict mode (-s/--strict) (or when you run hledger check commodi- + ties), hledger will report an error if an undeclared commodity symbol + is used. (With one exception: zero amounts are always allowed to have + no commodity symbol.) It works like account error checking (described above). decimal-mark directive @@ -2195,20 +2243,20 @@ Journal decimal-mark , - This prevents any ambiguity when parsing numbers in the file, so we - recommend it, especially if the file contains digit group marks (eg + This prevents any ambiguity when parsing numbers in the file, so we + recommend it, especially if the file contains digit group marks (eg thousands separators). include directive - You can pull in the content of additional files by writing an include + You can pull in the content of additional files by writing an include directive, like this: include FILEPATH - Only journal files can include, and only journal, timeclock or timedot + Only journal files can include, and only journal, timeclock or timedot files can be included (not CSV files, currently). - If the file path does not begin with a slash, it is relative to the + If the file path does not begin with a slash, it is relative to the current file's folder. A tilde means home directory, eg: include ~/main.journal. @@ -2217,27 +2265,27 @@ Journal *.journal. There is limited support for recursive wildcards: **/ (the slash is re- - quired) matches 0 or more subdirectories. It's not super convenient - since you have to avoid include cycles and including directories, but + quired) matches 0 or more subdirectories. It's not super convenient + since you have to avoid include cycles and including directories, but this can be done, eg: include */**/*.journal. The path may also be prefixed to force a specific file format, overrid- - ing the file extension (as described in Data formats): include time- + ing the file extension (as described in Data formats): include time- dot:~/notes/2023*.md. P directive The P directive declares a market price, which is a conversion rate be- - tween two commodities on a certain date. This allows value reports to + tween two commodities on a certain date. This allows value reports to convert amounts of one commodity to their value in another, on or after - that date. These prices are often obtained from a stock exchange, + that date. These prices are often obtained from a stock exchange, cryptocurrency exchange, the or foreign exchange market. The format is: P DATE COMMODITY1SYMBOL COMMODITY2AMOUNT - DATE is a simple date, COMMODITY1SYMBOL is the symbol of the commodity - being priced, and COMMODITY2AMOUNT is the amount (symbol and quantity) + DATE is a simple date, COMMODITY1SYMBOL is the symbol of the commodity + being priced, and COMMODITY2AMOUNT is the amount (symbol and quantity) of commodity 2 that one unit of commodity 1 is worth on this date. Ex- amples: @@ -2247,15 +2295,15 @@ Journal # and $1.40 from 2010-01-01 onward: P 2010-01-01 $1.40 - The -V, -X and --value flags use these market prices to show amount + The -V, -X and --value flags use these market prices to show amount values in another commodity. See Value reporting. payee directive payee PAYEE NAME This directive can be used to declare a limited set of payees which may - appear in transaction descriptions. The "payees" check will report an - error if any transaction refers to a payee that has not been declared. + appear in transaction descriptions. The "payees" check will report an + error if any transaction refers to a payee that has not been declared. Eg: payee Whole Foods ; a comment @@ -2271,58 +2319,58 @@ Journal tag directive tag TAGNAME - This directive can be used to declare a limited set of tag names al- + This directive can be used to declare a limited set of tag names al- lowed in tags. TAGNAME should be a valid tag name (no spaces). Eg: tag item-id Any indented subdirectives are currently ignored. - The "tags" check will report an error if any undeclared tag name is + The "tags" check will report an error if any undeclared tag name is used. It is quite easy to accidentally create a tag through normal use - of colons in comments(#comments]; if you want to prevent this, you can + of colons in comments(#comments]; if you want to prevent this, you can declare and check your tags . Periodic transactions - The ~ directive declares a "periodic rule" which generates temporary + The ~ directive declares a "periodic rule" which generates temporary extra transactions, usually recurring at some interval, when hledger is run with the --forecast flag. These "forecast transactions" are useful - for forecasting future activity. They exist only for the duration of + for forecasting future activity. They exist only for the duration of the report, and only when --forecast is used; they are not saved in the journal file by hledger. - Periodic rules also have a second use: with the --budget flag they set + Periodic rules also have a second use: with the --budget flag they set budget goals for budgeting. - Periodic rules can be a little tricky, so before you use them, read + Periodic rules can be a little tricky, so before you use them, read this whole section, or at least the following tips: - 1. Two spaces accidentally added or omitted will cause you trouble - + 1. Two spaces accidentally added or omitted will cause you trouble - read about this below. - 2. For troubleshooting, show the generated transactions with hledger - print --forecast tag:generated or hledger register --forecast + 2. For troubleshooting, show the generated transactions with hledger + print --forecast tag:generated or hledger register --forecast tag:generated. - 3. Forecasted transactions will begin only after the last non-fore- + 3. Forecasted transactions will begin only after the last non-fore- casted transaction's date. - 4. Forecasted transactions will end 6 months from today, by default. + 4. Forecasted transactions will end 6 months from today, by default. See below for the exact start/end rules. - 5. period expressions can be tricky. Their documentation needs im- + 5. period expressions can be tricky. Their documentation needs im- provement, but is worth studying. - 6. Some period expressions with a repeating interval must begin on a - natural boundary of that interval. Eg in weekly from DATE, DATE - must be a monday. ~ weekly from 2019/10/1 (a tuesday) will give an + 6. Some period expressions with a repeating interval must begin on a + natural boundary of that interval. Eg in weekly from DATE, DATE + must be a monday. ~ weekly from 2019/10/1 (a tuesday) will give an error. 7. Other period expressions with an interval are automatically expanded - to cover a whole number of that interval. (This is done to improve + to cover a whole number of that interval. (This is done to improve reports, but it also affects periodic transactions. Yes, it's a bit - inconsistent with the above.) Eg: ~ every 10th day of month from - 2023/01, which is equivalent to ~ every 10th day of month from + inconsistent with the above.) Eg: ~ every 10th day of month from + 2023/01, which is equivalent to ~ every 10th day of month from 2023/01/01, will be adjusted to start on 2019/12/10. Periodic rule syntax @@ -2340,14 +2388,14 @@ Journal expenses:utilities $400 assets:bank:checking - The period expression is the same syntax used for specifying multi-pe- - riod reports, just interpreted differently; there, it specifies report + The period expression is the same syntax used for specifying multi-pe- + riod reports, just interpreted differently; there, it specifies report periods; here it specifies recurrence dates (the periods' start dates). Periodic rules and relative dates - Partial or relative dates (like 12/31, 25, tomorrow, last week, next - quarter) are usually not recommended in periodic rules, since the re- - sults will change as time passes. If used, they will be interpreted + Partial or relative dates (like 12/31, 25, tomorrow, last week, next + quarter) are usually not recommended in periodic rules, since the re- + sults will change as time passes. If used, they will be interpreted relative to, in order of preference: 1. the first day of the default year specified by a recent Y directive @@ -2356,11 +2404,11 @@ Journal 3. or the date on which you are running the report. - They will not be affected at all by report period or forecast period + They will not be affected at all by report period or forecast period dates. Two spaces between period expression and description! - If the period expression is followed by a transaction description, + If the period expression is followed by a transaction description, these must be separated by two or more spaces. This helps hledger know where the period expression ends, so that descriptions can not acciden- tally alter their meaning, as in this example: @@ -2374,51 +2422,51 @@ Journal So, - o Do write two spaces between your period expression and your transac- + o Do write two spaces between your period expression and your transac- tion description, if any. - o Don't accidentally write two spaces in the middle of your period ex- + o Don't accidentally write two spaces in the middle of your period ex- pression. Auto postings The = directive declares an "auto posting rule", which adds extra post- - ings to existing transactions. (Remember, postings are the account + ings to existing transactions. (Remember, postings are the account name & amount lines below a transaction's date & description.) - In the journal, an auto posting rule looks quite like a transaction, - but instead of date and description it has = (mnemonic: "match") and a + In the journal, an auto posting rule looks quite like a transaction, + but instead of date and description it has = (mnemonic: "match") and a query, like this: = QUERY ACCOUNT AMOUNT ... - Queries are just like command line queries; an account name substring - is most common. Query terms containing spaces should be enclosed in + Queries are just like command line queries; an account name substring + is most common. Query terms containing spaces should be enclosed in single or double quotes. - Each = rule works like this: when hledger is run with the --auto flag, - wherever the QUERY matches a posting in the journal, the rule's post- + Each = rule works like this: when hledger is run with the --auto flag, + wherever the QUERY matches a posting in the journal, the rule's post- ings are added to that transaction, immediately below the matched post- - ing. Note these generated postings are temporary, existing only for - the duration of the report, and only when --auto is used; they are not + ing. Note these generated postings are temporary, existing only for + the duration of the report, and only when --auto is used; they are not saved in the journal file by hledger. Generated postings' amounts can depend on the matched posting's amount. - So auto postings can be useful for, eg, adding tax postings with a + So auto postings can be useful for, eg, adding tax postings with a standard percentage. AMOUNT can be: - o a number with no commodity symbol, like 2. The matched posting's + o a number with no commodity symbol, like 2. The matched posting's commodity symbol will be added to this. - o a normal amount with a commodity symbol, like $2. This will be used + o a normal amount with a commodity symbol, like $2. This will be used as-is. - o an asterisk followed by a number, like *2. This will multiply the + o an asterisk followed by a number, like *2. This will multiply the matched posting's amount (and total price, if any) by the number. - o an asterisk followed by an amount with commodity symbol, like *$2. - This multiplies and also replaces the commodity symbol with this new + o an asterisk followed by an amount with commodity symbol, like *$2. + This multiplies and also replaces the commodity symbol with this new one. Some examples: @@ -2453,38 +2501,38 @@ Journal assets:checking $20 Note that depending fully on generated data such as this has some draw- - backs - it's less portable, less future-proof, less auditable by oth- + backs - it's less portable, less future-proof, less auditable by oth- ers, and less robust (eg your balance assertions will depend on whether - you use or don't use --auto). An alternative is to use auto postings + you use or don't use --auto). An alternative is to use auto postings in "one time" fashion - use them to help build a complex journal entry, - view it with hledger print --auto, and then copy that output into the + view it with hledger print --auto, and then copy that output into the journal file to make it permanent. Auto postings and multiple files An auto posting rule can affect any transaction in the current file, or - in any parent file or child file. Note, currently it will not affect + in any parent file or child file. Note, currently it will not affect sibling files (when multiple -f/--file are used - see #1212). Auto postings and dates - A posting date (or secondary date) in the matched posting, or (taking - precedence) a posting date in the auto posting rule itself, will also + A posting date (or secondary date) in the matched posting, or (taking + precedence) a posting date in the auto posting rule itself, will also be used in the generated posting. Auto postings and transaction balancing / inferred amounts / balance asser- tions Currently, auto postings are added: - o after missing amounts are inferred, and transactions are checked for + o after missing amounts are inferred, and transactions are checked for balancedness, o but before balance assertions are checked. - Note this means that journal entries must be balanced both before and + Note this means that journal entries must be balanced both before and after auto postings are added. This changed in hledger 1.12+; see #893 for background. - This also means that you cannot have more than one auto-posting with a - missing amount applied to a given transaction, as it will be unable to + This also means that you cannot have more than one auto-posting with a + missing amount applied to a given transaction, as it will be unable to infer amounts. Auto posting tags @@ -2493,11 +2541,11 @@ Journal o generated-posting:= QUERY - shows this was generated by an auto post- ing rule, and the query - o _generated-posting:= QUERY - a hidden tag, which does not appear in + o _generated-posting:= QUERY - a hidden tag, which does not appear in hledger's output. This can be used to match postings generated "just now", rather than generated in the past and saved to the journal. - Also, any transaction that has been changed by auto posting rules will + Also, any transaction that has been changed by auto posting rules will have these tags added: o modified: - this transaction was modified @@ -2506,24 +2554,24 @@ Journal tion was modified "just now". Auto postings on forecast transactions only - Tip: you can can make auto postings that will apply to forecast trans- - actions but not recorded transactions, by adding tag:_generated-trans- - action to their QUERY. This can be useful when generating new journal + Tip: you can can make auto postings that will apply to forecast trans- + actions but not recorded transactions, by adding tag:_generated-trans- + action to their QUERY. This can be useful when generating new journal entries to be saved in the journal. Other syntax - hledger journal format supports quite a few other features, mainly to - make interoperating with or converting from Ledger easier. Note some - of the features below are powerful and can be useful in special cases, - but in general, features in this section are considered less important - or even not recommended for most users. Downsides are mentioned to + hledger journal format supports quite a few other features, mainly to + make interoperating with or converting from Ledger easier. Note some + of the features below are powerful and can be useful in special cases, + but in general, features in this section are considered less important + or even not recommended for most users. Downsides are mentioned to help you decide if you want to use them. Balance assignments - Ledger-style balance assignments are also supported. These are like - balance assertions, but with no posting amount on the left side of the - equals sign; instead it is calculated automatically so as to satisfy - the assertion. This can be a convenience during data entry, eg when + Ledger-style balance assignments are also supported. These are like + balance assertions, but with no posting amount on the left side of the + equals sign; instead it is calculated automatically so as to satisfy + the assertion. This can be a convenience during data entry, eg when setting opening balances: ; starting a new journal, set asset account balances @@ -2541,15 +2589,15 @@ Journal expenses:misc The calculated amount depends on the account's balance in the commodity - at that point (which depends on the previously-dated postings of the - commodity to that account since the last balance assertion or assign- + at that point (which depends on the previously-dated postings of the + commodity to that account since the last balance assertion or assign- ment). - Downsides: using balance assignments makes your journal less explicit; + Downsides: using balance assignments makes your journal less explicit; to know the exact amount posted, you have to run hledger or do the cal- - culations yourself, instead of just reading it. Also balance assign- + culations yourself, instead of just reading it. Also balance assign- ments' forcing of balances can hide errors. These things make your fi- - nancial data less portable, less future-proof, and less trustworthy in + nancial data less portable, less future-proof, and less trustworthy in an audit. Balance assignments and costs @@ -2564,31 +2612,31 @@ Journal (a) $1 @ 2 = $1 @ 2 Balance assignments and multiple files - Balance assignments handle multiple files like balance assertions. - They see balance from other files previously included from the current + Balance assignments handle multiple files like balance assertions. + They see balance from other files previously included from the current file, but not from previous sibling or parent files. Bracketed posting dates - For setting posting dates and secondary posting dates, Ledger's brack- + For setting posting dates and secondary posting dates, Ledger's brack- eted date syntax is also supported: [DATE], [DATE=DATE2] or [=DATE2] in - posting comments. hledger will attempt to parse any square-bracketed - sequence of the 0123456789/-.= characters in this way. With this syn- - tax, DATE infers its year from the transaction and DATE2 infers its + posting comments. hledger will attempt to parse any square-bracketed + sequence of the 0123456789/-.= characters in this way. With this syn- + tax, DATE infers its year from the transaction and DATE2 infers its year from DATE. - Downsides: another syntax to learn, redundant with hledger's + Downsides: another syntax to learn, redundant with hledger's date:/date2: tags, and confusingly similar to Ledger's lot date syntax. D directive D AMOUNT - This directive sets a default commodity, to be used for any subsequent - commodityless amounts (ie, plain numbers) seen while parsing the jour- - nal. This effect lasts until the next D directive, or the end of the + This directive sets a default commodity, to be used for any subsequent + commodityless amounts (ie, plain numbers) seen while parsing the jour- + nal. This effect lasts until the next D directive, or the end of the journal. - For compatibility/historical reasons, D also acts like a commodity di- - rective (setting the commodity's decimal mark for parsing and display + For compatibility/historical reasons, D also acts like a commodity di- + rective (setting the commodity's decimal mark for parsing and display style for output). So its argument is not just a commodity symbol, but a full amount demonstrating the style. The amount must include a deci- mal mark (either period or comma). Eg: @@ -2603,23 +2651,23 @@ Journal Interactions with other directives: - For setting a commodity's display style, a commodity directive has + For setting a commodity's display style, a commodity directive has highest priority, then a D directive. - For detecting a commodity's decimal mark during parsing, decimal-mark + For detecting a commodity's decimal mark during parsing, decimal-mark has highest priority, then commodity, then D. - For checking commodity symbols with the check command, a commodity di- + For checking commodity symbols with the check command, a commodity di- rective is required (hledger check commodities ignores D directives). - Downsides: omitting commodity symbols makes your financial data less - explicit, less portable, and less trustworthy in an audit. It is usu- - ally an unsustainable shortcut; sooner or later you will want to track - multiple commodities. D is overloaded with functions redundant with + Downsides: omitting commodity symbols makes your financial data less + explicit, less portable, and less trustworthy in an audit. It is usu- + ally an unsustainable shortcut; sooner or later you will want to track + multiple commodities. D is overloaded with functions redundant with commodity and decimal-mark. And it works differently from Ledger's D. apply account directive - This directive sets a default parent account, which will be prepended + This directive sets a default parent account, which will be prepended to all accounts in following entries, until an end apply account direc- tive or end of current file. Eg: @@ -2641,10 +2689,10 @@ Journal Account names entered via hledger add or hledger-web are not affected. - Account aliases, if any, are applied after the parent account is + Account aliases, if any, are applied after the parent account is prepended. - Downsides: this can make your financial data less explicit, less + Downsides: this can make your financial data less explicit, less portable, and less trustworthy in an audit. Y directive @@ -2654,7 +2702,7 @@ Journal year YEAR apply year YEAR - The space is optional. This sets a default year to be used for subse- + The space is optional. This sets a default year to be used for subse- quent dates which don't specify a year. Eg: Y2009 ; set default year to 2009 @@ -2675,57 +2723,57 @@ Journal Downsides: omitting the year (from primary transaction dates, at least) makes your financial data less explicit, less portable, and less trust- - worthy in an audit. Such dates can get separated from their corre- - sponding Y directive, eg when evaluating a region of the journal in - your editor. A missing Y directive makes reports dependent on today's + worthy in an audit. Such dates can get separated from their corre- + sponding Y directive, eg when evaluating a region of the journal in + your editor. A missing Y directive makes reports dependent on today's date. Secondary dates A secondary date is written after the primary date, following an equals - sign. If the year is omitted, the primary date's year is assumed. - When running reports, the primary (left) date is used by default, but - with the --date2 flag (or --aux-date or --effective), the secondary + sign. If the year is omitted, the primary date's year is assumed. + When running reports, the primary (left) date is used by default, but + with the --date2 flag (or --aux-date or --effective), the secondary (right) date will be used instead. - The meaning of secondary dates is up to you, but it's best to follow a - consistent rule. Eg "primary = the bank's clearing date, secondary = + The meaning of secondary dates is up to you, but it's best to follow a + consistent rule. Eg "primary = the bank's clearing date, secondary = date the transaction was initiated, if different". - Downsides: makes your financial data more complicated, less portable, + Downsides: makes your financial data more complicated, less portable, and less trustworthy in an audit. Keeping the meaning of the two dates - consistent requires discipline, and you have to remember which report- - ing mode is appropriate for a given report. Posting dates are simpler + consistent requires discipline, and you have to remember which report- + ing mode is appropriate for a given report. Posting dates are simpler and better. Star comments - Lines beginning with * (star/asterisk) are also comment lines. This + Lines beginning with * (star/asterisk) are also comment lines. This feature allows Emacs users to insert org headings in their journal, al- lowing them to fold/unfold/navigate it like an outline when viewed with org mode. - Downsides: another, unconventional comment syntax to learn. Decreases - your journal's portability. And switching to Emacs org mode just for - folding/unfolding meant losing the benefits of ledger mode; nowadays - you can add outshine mode to ledger mode to get folding without losing + Downsides: another, unconventional comment syntax to learn. Decreases + your journal's portability. And switching to Emacs org mode just for + folding/unfolding meant losing the benefits of ledger mode; nowadays + you can add outshine mode to ledger mode to get folding without losing ledger mode's features. Valuation expressions - Ledger allows a valuation function or value to be written in double + Ledger allows a valuation function or value to be written in double parentheses after an amount. hledger ignores these. Virtual postings - A posting with parentheses around the account name ((some:account)) is - called a unbalanced virtual posting. Such postings do not participate - in transaction balancing. (And if you write them without an amount, a - zero amount is always inferred.) These can occasionally be convenient - for special circumstances, but they violate double entry bookkeeping - and make your data less portable across applications, so many people + A posting with parentheses around the account name ((some:account)) is + called a unbalanced virtual posting. Such postings do not participate + in transaction balancing. (And if you write them without an amount, a + zero amount is always inferred.) These can occasionally be convenient + for special circumstances, but they violate double entry bookkeeping + and make your data less portable across applications, so many people avoid using them at all. - A posting with brackets around the account name ([some:account]) is - called a balanced virtual posting. The balanced virtual postings in a + A posting with brackets around the account name ([some:account]) is + called a balanced virtual posting. The balanced virtual postings in a transaction must add up to zero, just like ordinary postings, but sepa- - rately from them. These are not part of double entry bookkeeping ei- + rately from them. These are not part of double entry bookkeeping ei- ther, but they are at least balanced. An example: 2022-01-01 buy food with cash, update budget envelope subaccounts, & something else @@ -2736,13 +2784,13 @@ Journal [assets:checking:available] $10 ; <- (something:else) $5 ; <- this is not required to balance - Ordinary postings, whose account names are neither parenthesised nor - bracketed, are called real postings. You can exclude virtual postings + Ordinary postings, whose account names are neither parenthesised nor + bracketed, are called real postings. You can exclude virtual postings from reports with the -R/--real flag or a real:1 query. Other Ledger directives These other Ledger directives are currently accepted but ignored. This - allows hledger to read more Ledger files, but be aware that hledger's + allows hledger to read more Ledger files, but be aware that hledger's reports may differ from Ledger's if you use these. apply fixed COMM AMT @@ -2763,35 +2811,35 @@ Journal value EXPR --command-line-flags - See also https://hledger.org/ledger.html for a detailed hledger/Ledger + See also https://hledger.org/ledger.html for a detailed hledger/Ledger syntax comparison. CSV - hledger can read CSV files (Character Separated Value - usually comma, - semicolon, or tab) containing dated records, automatically converting + hledger can read CSV files (Character Separated Value - usually comma, + semicolon, or tab) containing dated records, automatically converting each record into a transaction. (To learn about writing CSV, see CSV output.) - For best error messages when reading CSV/TSV/SSV files, make sure they + For best error messages when reading CSV/TSV/SSV files, make sure they have a corresponding .csv, .tsv or .ssv file extension or use a hledger file prefix (see File Extension below). Each CSV file must be described by a corresponding rules file. - This contains rules describing the CSV data (header line, fields lay- - out, date format etc.), how to construct hledger transactions from it, - and how to categorise transactions based on description or other at- + This contains rules describing the CSV data (header line, fields lay- + out, date format etc.), how to construct hledger transactions from it, + and how to categorise transactions based on description or other at- tributes. - By default hledger looks for a rules file named like the CSV file with - an extra .rules extension, in the same directory. Eg when asked to + By default hledger looks for a rules file named like the CSV file with + an extra .rules extension, in the same directory. Eg when asked to read foo/FILE.csv, hledger looks for foo/FILE.csv.rules. You can spec- - ify a different rules file with the --rules-file option. If no rules - file is found, hledger will create a sample rules file, which you'll + ify a different rules file with the --rules-file option. If no rules + file is found, hledger will create a sample rules file, which you'll need to adjust. - At minimum, the rules file must identify the date and amount fields, - and often it also specifies the date format and how many header lines + At minimum, the rules file must identify the date and amount fields, + and often it also specifies the date format and how many header lines there are. Here's a simple CSV file and a rules file for it: Date, Description, Id, Amount @@ -2808,56 +2856,56 @@ CSV income:unknown -10.23 There's an introductory Importing CSV data tutorial on hledger.org, and - more CSV rules examples below, and a larger collection at + more CSV rules examples below, and a larger collection at https://github.com/simonmichael/hledger/tree/master/examples/csv. CSV rules cheatsheet The following kinds of rule can appear in the rules file, in any order. (Blank lines and lines beginning with # or ; or * are ignored.) - source optionally declare which file to read data + source optionally declare which file to read data from - separator declare the field separator, instead of rely- + separator declare the field separator, instead of rely- ing on file extension skip skip one or more header lines at start of file date-format declare how to parse CSV dates/date-times - timezone declare the time zone of ambiguous CSV + timezone declare the time zone of ambiguous CSV date-times - newest-first improve txn order when: there are multiple + newest-first improve txn order when: there are multiple records, newest first, all with the same date - intra-day-reversed improve txn order when: same-day txns are in + intra-day-reversed improve txn order when: same-day txns are in opposite order to the overall file - decimal-mark declare the decimal mark used in CSV amounts, + decimal-mark declare the decimal mark used in CSV amounts, when ambiguous - fields list name CSV fields for easy reference, and op- + fields list name CSV fields for easy reference, and op- tionally assign their values to hledger fields - Field assignment assign a CSV value or interpolated text value + Field assignment assign a CSV value or interpolated text value to a hledger field if block conditionally assign values to hledger fields, or skip a record or end (skip rest of file) if table conditionally assign values to hledger fields, using compact syntax - balance-type select which type of balance assertions/as- + balance-type select which type of balance assertions/as- signments to generate include inline another CSV rules file - Working with CSV tips can be found below, including How CSV rules are + Working with CSV tips can be found below, including How CSV rules are evaluated. source - If you tell hledger to read a csv file with -f foo.csv, it will look - for rules in foo.csv.rules. Or, you can tell it to read the rules - file, with -f foo.csv.rules, and it will look for data in foo.csv + If you tell hledger to read a csv file with -f foo.csv, it will look + for rules in foo.csv.rules. Or, you can tell it to read the rules + file, with -f foo.csv.rules, and it will look for data in foo.csv (since 1.30). - These are mostly equivalent, but the second method provides some extra - features. For one, the data file can be missing, without causing an - error; it is just considered empty. And, you can specify a different + These are mostly equivalent, but the second method provides some extra + features. For one, the data file can be missing, without causing an + error; it is just considered empty. And, you can specify a different data file by adding a "source" rule: source ./Checking1.csv - If you specify just a file name with no path, hledger will look for it + If you specify just a file name with no path, hledger will look for it in your system's downloads directory (~/Downloads, currently): source Checking1.csv @@ -2870,9 +2918,9 @@ CSV See also "Working with CSV > Reading files specified by rule". separator - You can use the separator rule to read other kinds of character-sepa- - rated data. The argument is any single separator character, or the - words tab or space (case insensitive). Eg, for comma-separated values + You can use the separator rule to read other kinds of character-sepa- + rated data. The argument is any single separator character, or the + words tab or space (case insensitive). Eg, for comma-separated values (CSV): separator , @@ -2885,32 +2933,32 @@ CSV separator TAB - If the input file has a .csv, .ssv or .tsv file extension (or a csv:, + If the input file has a .csv, .ssv or .tsv file extension (or a csv:, ssv:, tsv: prefix), the appropriate separator will be inferred automat- ically, and you won't need this rule. skip skip N - The word skip followed by a number (or no number, meaning 1) tells - hledger to ignore this many non-empty lines at the start of the input - data. You'll need this whenever your CSV data contains header lines. - Note, empty and blank lines are skipped automatically, so you don't + The word skip followed by a number (or no number, meaning 1) tells + hledger to ignore this many non-empty lines at the start of the input + data. You'll need this whenever your CSV data contains header lines. + Note, empty and blank lines are skipped automatically, so you don't need to count those. - skip has a second meaning: it can be used inside if blocks (described - below), to skip one or more records whenever the condition is true. + skip has a second meaning: it can be used inside if blocks (described + below), to skip one or more records whenever the condition is true. Records skipped in this way are ignored, except they are still required to be valid CSV. date-format date-format DATEFMT - This is a helper for the date (and date2) fields. If your CSV dates - are not formatted like YYYY-MM-DD, YYYY/MM/DD or YYYY.MM.DD, you'll - need to add a date-format rule describing them with a strptime-style - date parsing pattern - see https://hackage.haskell.org/pack- - age/time/docs/Data-Time-Format.html#v:formatTime. The pattern must + This is a helper for the date (and date2) fields. If your CSV dates + are not formatted like YYYY-MM-DD, YYYY/MM/DD or YYYY.MM.DD, you'll + need to add a date-format rule describing them with a strptime-style + date parsing pattern - see https://hackage.haskell.org/pack- + age/time/docs/Data-Time-Format.html#v:formatTime. The pattern must parse the CSV date value completely. Some examples: # MM/DD/YY @@ -2930,33 +2978,33 @@ CSV timezone timezone TIMEZONE - When CSV contains date-times that are implicitly in some time zone + When CSV contains date-times that are implicitly in some time zone other than yours, but containing no explicit time zone information, you - can use this rule to declare the CSV's native time zone, which helps + can use this rule to declare the CSV's native time zone, which helps prevent off-by-one dates. - When the CSV date-times do contain time zone information, you don't - need this rule; instead, use %Z in date-format (or %z, %EZ, %Ez; see + When the CSV date-times do contain time zone information, you don't + need this rule; instead, use %Z in date-format (or %z, %EZ, %Ez; see the formatTime link above). In either of these cases, hledger will do a time-zone-aware conversion, localising the CSV date-times to your current system time zone. If you prefer to localise to some other time zone, eg for reproducibility, you - can (on unix at least) set the output timezone with the TZ environment + can (on unix at least) set the output timezone with the TZ environment variable, eg: $ TZ=-1000 hledger print -f foo.csv # or TZ=-1000 hledger import foo.csv - timezone currently does not understand timezone names, except "UTC", - "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", or "PDT". For + timezone currently does not understand timezone names, except "UTC", + "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", or "PDT". For others, use numeric format: +HHMM or -HHMM. newest-first hledger tries to ensure that the generated transactions will be ordered chronologically, including same-day transactions. Usually it can - auto-detect how the CSV records are ordered. But if it encounters CSV + auto-detect how the CSV records are ordered. But if it encounters CSV where all records are on the same date, it assumes that the records are - oldest first. If in fact the CSV's records are normally newest first, + oldest first. If in fact the CSV's records are normally newest first, like: 2022-10-01, txn 3... @@ -2970,9 +3018,9 @@ CSV newest-first intra-day-reversed - If CSV records within a single day are ordered opposite to the overall - record order, you can add the intra-day-reversed rule to improve the - order of journal entries. Eg, here the overall record order is newest + If CSV records within a single day are ordered opposite to the overall + record order, you can add the intra-day-reversed rule to improve the + order of journal entries. Eg, here the overall record order is newest first, but same-day records are oldest first: 2022-10-02, txn 3... @@ -2990,10 +3038,10 @@ CSV decimal-mark , - hledger automatically accepts either period or comma as a decimal mark - when parsing numbers (cf Amounts). However if any numbers in the CSV - contain digit group marks, such as thousand-separating commas, you - should declare the decimal mark explicitly with this rule, to avoid + hledger automatically accepts either period or comma as a decimal mark + when parsing numbers (cf Amounts). However if any numbers in the CSV + contain digit group marks, such as thousand-separating commas, you + should declare the decimal mark explicitly with this rule, to avoid misparsed numbers. fields list @@ -3002,17 +3050,17 @@ CSV A fields list (the word fields followed by comma-separated field names) is optional, but convenient. It does two things: - 1. It names the CSV field in each column. This can be convenient if - you are referencing them in other rules, so you can say %SomeField + 1. It names the CSV field in each column. This can be convenient if + you are referencing them in other rules, so you can say %SomeField instead of remembering %13. - 2. Whenever you use one of the special hledger field names (described - below), it assigns the CSV value in this position to that hledger - field. This is the quickest way to populate hledger's fields and + 2. Whenever you use one of the special hledger field names (described + below), it assigns the CSV value in this position to that hledger + field. This is the quickest way to populate hledger's fields and build a transaction. - Here's an example that says "use the 1st, 2nd and 4th fields as the - transaction's date, description and amount; name the last two fields + Here's an example that says "use the 1st, 2nd and 4th fields as the + transaction's date, description and amount; name the last two fields for later reference; and ignore the others": fields date, description, , amount, , , somefield, anotherfield @@ -3022,35 +3070,35 @@ CSV o There must be least two items in the list (at least one comma). - o Field names may not contain spaces. Spaces before/after field names + o Field names may not contain spaces. Spaces before/after field names are optional. o Field names may contain _ (underscore) or - (hyphen). - o Fields you don't care about can be given a dummy name or an empty + o Fields you don't care about can be given a dummy name or an empty name. - If the CSV contains column headings, it's convenient to use these for - your field names, suitably modified (eg lower-cased with spaces re- + If the CSV contains column headings, it's convenient to use these for + your field names, suitably modified (eg lower-cased with spaces re- placed by underscores). - Sometimes you may want to alter a CSV field name to avoid assigning to - a hledger field with the same name. Eg you could call the CSV's "bal- - ance" field balance_ to avoid directly setting hledger's balance field + Sometimes you may want to alter a CSV field name to avoid assigning to + a hledger field with the same name. Eg you could call the CSV's "bal- + ance" field balance_ to avoid directly setting hledger's balance field (and generating a balance assertion). Field assignment HLEDGERFIELD FIELDVALUE - Field assignments are the more flexible way to assign CSV values to + Field assignments are the more flexible way to assign CSV values to hledger fields. They can be used instead of or in addition to a fields list (see above). - To assign a value to a hledger field, write the field name (any of the - standard hledger field/pseudo-field names, defined below), a space, - followed by a text value on the same line. This text value may inter- - polate CSV fields, referenced either by their 1-based position in the - CSV record (%N) or by the name they were given in the fields list + To assign a value to a hledger field, write the field name (any of the + standard hledger field/pseudo-field names, defined below), a space, + followed by a text value on the same line. This text value may inter- + polate CSV fields, referenced either by their 1-based position in the + CSV record (%N) or by the name they were given in the fields list (%CSVFIELD), and regular expression match groups (\N). Some examples: @@ -3063,26 +3111,26 @@ CSV Tips: - o Interpolation strips outer whitespace (so a CSV value like " 1 " be- + o Interpolation strips outer whitespace (so a CSV value like " 1 " be- comes 1 when interpolated) (#1051). - o Interpolations always refer to a CSV field - you can't interpolate a + o Interpolations always refer to a CSV field - you can't interpolate a hledger field. (See Referencing other fields below). Field names - Note the two kinds of field names mentioned here, and used only in + Note the two kinds of field names mentioned here, and used only in hledger CSV rules files: - 1. CSV field names (CSVFIELD in these docs): you can optionally name - the CSV columns for easy reference (since hledger doesn't yet auto- + 1. CSV field names (CSVFIELD in these docs): you can optionally name + the CSV columns for easy reference (since hledger doesn't yet auto- matically recognise column headings in a CSV file), by writing arbi- trary names in a fields list, eg: fields When, What, Some_Id, Net, Total, Foo, Bar - 2. Special hledger field names (HLEDGERFIELD in these docs): you must - set at least some of these to generate the hledger transaction from - a CSV record, by writing them as the left hand side of a field as- + 2. Special hledger field names (HLEDGERFIELD in these docs): you must + set at least some of these to generate the hledger transaction from + a CSV record, by writing them as the left hand side of a field as- signment, eg: date %When @@ -3097,7 +3145,7 @@ CSV currency $ comment %Foo %Bar - Here are all the special hledger field names available, and what hap- + Here are all the special hledger field names available, and what hap- pens when you assign values to them: date field @@ -3120,7 +3168,7 @@ CSV commentN, where N is a number, sets the Nth posting's comment. - You can assign multi-line comments by writing literal \n in the code. + You can assign multi-line comments by writing literal \n in the code. A comment starting with \n will begin on a new line. Comments can contain tags, as usual. @@ -3129,98 +3177,98 @@ CSV Assigning to accountN, where N is 1 to 99, sets the account name of the Nth posting, and causes that posting to be generated. - Most often there are two postings, so you'll want to set account1 and - account2. Typically account1 is associated with the CSV file, and is - set once with a top-level assignment, while account2 is set based on + Most often there are two postings, so you'll want to set account1 and + account2. Typically account1 is associated with the CSV file, and is + set once with a top-level assignment, while account2 is set based on each transaction's description, in conditional rules. - If a posting's account name is left unset but its amount is set (see - below), a default account name will be chosen (like "expenses:unknown" + If a posting's account name is left unset but its amount is set (see + below), a default account name will be chosen (like "expenses:unknown" or "income:unknown"). amount field - There are several ways to set posting amounts from CSV, useful in dif- + There are several ways to set posting amounts from CSV, useful in dif- ferent situations. - 1. amount is the oldest and simplest. Assigning to this sets the + 1. amount is the oldest and simplest. Assigning to this sets the amount of the first and second postings. In the second posting, the - amount will be negated; also, if it has a cost attached, it will be + amount will be negated; also, if it has a cost attached, it will be converted to cost. - 2. amount-in and amount-out work exactly like the above, but should be - used when the CSV has two amount fields (such as "Debit" and + 2. amount-in and amount-out work exactly like the above, but should be + used when the CSV has two amount fields (such as "Debit" and "Credit", or "Inflow" and "Outflow"). Whichever field has a - non-zero value will be used as the amount of the first and second + non-zero value will be used as the amount of the first and second postings. Here are some tips to avoid confusion: - o It's not "amount-in for posting 1 and amount-out for posting 2", - it is "extract a single amount from the amount-in or amount-out + o It's not "amount-in for posting 1 and amount-out for posting 2", + it is "extract a single amount from the amount-in or amount-out field, and use that for posting 1 and (negated) for posting 2". - o Don't use both amount and amount-in/amount-out in the same rules + o Don't use both amount and amount-in/amount-out in the same rules file; choose based on whether the amount is in a single CSV field or spread across two fields. - o In each record, at most one of the two CSV fields should contain - a non-zero amount; the other field must contain a zero or noth- + o In each record, at most one of the two CSV fields should contain + a non-zero amount; the other field must contain a zero or noth- ing. - o hledger assumes both CSV fields contain unsigned numbers, and it + o hledger assumes both CSV fields contain unsigned numbers, and it automatically negates the amount-out values. - o If the data doesn't fit these requirements, you'll probably need + o If the data doesn't fit these requirements, you'll probably need an if rule (see below). 3. amountN (where N is a number from 1 to 99) sets the amount of only a - single posting: the Nth posting in the transaction. You'll usually - need at least two such assignments to make a balanced transaction. + single posting: the Nth posting in the transaction. You'll usually + need at least two such assignments to make a balanced transaction. You can also generate more than two postings, to represent more com- - plex transactions. The posting numbers don't have to be consecu- - tive; with if rules, higher posting numbers can be useful to ensure + plex transactions. The posting numbers don't have to be consecu- + tive; with if rules, higher posting numbers can be useful to ensure a certain order of postings. - 4. amountN-in and amountN-out work exactly like the above, but should - be used when the CSV has two amount fields. This is analogous to + 4. amountN-in and amountN-out work exactly like the above, but should + be used when the CSV has two amount fields. This is analogous to amount-in and amount-out, and those tips also apply here. 5. Remember that a fields list can also do assignments. So in a fields - list if you name a CSV field "amount", that counts as assigning to - amount. (If you don't want that, call it something else in the + list if you name a CSV field "amount", that counts as assigning to + amount. (If you don't want that, call it something else in the fields list, like "amount_".) - 6. The above don't handle every situation; if you need more flexibil- + 6. The above don't handle every situation; if you need more flexibil- ity, use an if rule to set amounts conditionally. See "Working with - CSV > Setting amounts" below for more on this and on amount-setting + CSV > Setting amounts" below for more on this and on amount-setting generally. currency field - currency sets a currency symbol, to be prepended to all postings' - amounts. You can use this if the CSV amounts do not have a currency + currency sets a currency symbol, to be prepended to all postings' + amounts. You can use this if the CSV amounts do not have a currency symbol, eg if it is in a separate column. currencyN prepends a currency symbol to just the Nth posting's amount. balance field - balanceN sets a balance assertion amount (or if the posting amount is + balanceN sets a balance assertion amount (or if the posting amount is left empty, a balance assignment) on posting N. balance is a compatibility spelling for hledger <1.17; it is equivalent to balance1. - You can adjust the type of assertion/assignment with the balance-type + You can adjust the type of assertion/assignment with the balance-type rule (see below). See Tips below for more about setting amounts and currency. if block - Rules can be applied conditionally, depending on patterns in the CSV - data. This allows flexibility; in particular, it is how you can cate- - gorise transactions, selecting an appropriate account name based on - their description (for example). There are two ways to write condi- - tional rules: "if blocks", described here, and "if tables", described + Rules can be applied conditionally, depending on patterns in the CSV + data. This allows flexibility; in particular, it is how you can cate- + gorise transactions, selecting an appropriate account name based on + their description (for example). There are two ways to write condi- + tional rules: "if blocks", described here, and "if tables", described below. - An if block is the word if and one or more "matcher" expressions (can + An if block is the word if and one or more "matcher" expressions (can be a word or phrase), one per line, starting either on the same or next line; followed by one or more indented rules. Eg, @@ -3236,11 +3284,11 @@ CSV RULE RULE - If any of the matchers succeeds, all of the indented rules will be ap- - plied. They are usually field assignments, but the following special + If any of the matchers succeeds, all of the indented rules will be ap- + plied. They are usually field assignments, but the following special rules may also be used within an if block: - o skip - skips the matched CSV record (generating no transaction from + o skip - skips the matched CSV record (generating no transaction from it) o end - skips the rest of the current CSV file. @@ -3266,27 +3314,27 @@ CSV Matchers There are two kinds: - 1. A record matcher is a word or single-line text fragment or regular - expression (REGEX), which hledger will try to match case-insensi- + 1. A record matcher is a word or single-line text fragment or regular + expression (REGEX), which hledger will try to match case-insensi- tively anywhere within the CSV record. Eg: whole foods - 2. A field matcher is preceded with a percent sign and CSV field name - (%CSVFIELD REGEX). hledger will try to match these just within the + 2. A field matcher is preceded with a percent sign and CSV field name + (%CSVFIELD REGEX). hledger will try to match these just within the named CSV field. Eg: %date 2023 - The regular expression is (as usual in hledger) a POSIX extended regu- - lar expression, that also supports GNU word boundaries (\b, \B, \<, - \>), and nothing else. If you have trouble, see "Regular expressions" + The regular expression is (as usual in hledger) a POSIX extended regu- + lar expression, that also supports GNU word boundaries (\b, \B, \<, + \>), and nothing else. If you have trouble, see "Regular expressions" in the hledger manual (https://hledger.org/hledger.html#regular-expres- sions). What matchers match With record matchers, it's important to know that the record matched is - not the original CSV record, but a modified one: separators will be - converted to commas, and enclosing double quotes (but not enclosing - whitespace) are removed. So for example, when reading an SSV file, if + not the original CSV record, but a modified one: separators will be + converted to commas, and enclosing double quotes (but not enclosing + whitespace) are removed. So for example, when reading an SSV file, if the original record was: 2023-01-01; "Acme, Inc."; 1,000 @@ -3300,16 +3348,18 @@ CSV o By default they are OR'd (any one of them can match) - o When a matcher is preceded by ampersand (&) it will be AND'ed with + o When a matcher is preceded by ampersand (&) it will be AND'ed with the previous matcher (both of them must match) - o When a matcher is preceded by an exclamation mark (!), the matcher is - negated (it may not match). + o Added in 1.32 When a matcher is preceded by an exclamation mark (!), + the matcher is negated (it may not match). Currently there is a limitation: you can't use both & and ! on the same line (you can't AND a negated matcher). Match groups + Added in 1.32 + Matchers can define match groups: parenthesised portions of the regular expression which are available for reference in field assignments. Groups are enclosed in regular parentheses (( and )) and can be nested. @@ -4125,27 +4175,28 @@ Timedot These are the dots in "timedot". Spaces are ignored and can be used for grouping/alignment. - o one or more letters. These are like dots but they also generate a - tag t: (short for "type") with the letter as its value, and a sepa- - rate posting for each of the values. This provides a second dimen- - sion of categorisation, viewable in reports with --pivot t. + o Added in 1.32 one or more letters. These are like dots but they + also generate a tag t: (short for "type") with the letter as its + value, and a separate posting for each of the values. This pro- + vides a second dimension of categorisation, viewable in reports + with --pivot t. - o An optional comment following a semicolon (a hledger-style posting + o An optional comment following a semicolon (a hledger-style posting comment). - There is some flexibility to help with keeping time log data and notes + There is some flexibility to help with keeping time log data and notes in the same file: o Blank lines and lines beginning with # or ; are ignored. - o After the first date line, lines which do not contain a double space + o After the first date line, lines which do not contain a double space are parsed as postings with zero amount. (hledger's register reports will show these if you add -E). - o Before the first date line, lines beginning with * (eg org headings) - are ignored. And from the first date line onward, Emacs org mode + o Before the first date line, lines beginning with * (eg org headings) + are ignored. And from the first date line onward, Emacs org mode heading prefixes at the start of lines (one or more *'s followed by a - space) will be ignored. This means the time log can also be a org + space) will be ignored. This means the time log can also be a org outline. Timedot examples @@ -4253,9 +4304,9 @@ Timedot PART 3: REPORTING CONCEPTS Amount formatting, parseability If you're wondering why your print report sometimes shows trailing dec- - imal marks, with no decimal digits; it does this when showing amounts + imal marks, with no decimal digits; it does this when showing amounts that have digit group marks but no decimal digits, to disambiguate them - and allow them to be re-parsed reliably (see also Decimal marks, digit + and allow them to be re-parsed reliably (see also Decimal marks, digit group marks. Eg: commodity $1,000.00 @@ -4268,7 +4319,7 @@ Amount formatting, parseability (a) $1,000. If this is a problem (eg when exporting to Ledger), you can avoid it by - disabling digit group marks, eg with -c/--commodity (for each affected + disabling digit group marks, eg with -c/--commodity (for each affected commodity): $ hledger print -c '$1000.00' @@ -4284,19 +4335,19 @@ Amount formatting, parseability More generally: hledger output falls into three rough categories, which format amounts a little bit differently to suit different consumers: - 1. "hledger-readable output" - should be readable by hledger (and by + 1. "hledger-readable output" - should be readable by hledger (and by humans) - o This is produced by reports that show full journal entries: print, + o This is produced by reports that show full journal entries: print, import, close, rewrite etc. - o It shows amounts with their original journal precisions, which may + o It shows amounts with their original journal precisions, which may not be consistent. - o It adds a trailing decimal mark when needed to avoid showing ambigu- + o It adds a trailing decimal mark when needed to avoid showing ambigu- ous amounts. - o It can be parsed reliably (by hledger and ledger2beancount at least, + o It can be parsed reliably (by hledger and ledger2beancount at least, but perhaps not by Ledger..) 2. "human-readable output" - usually for humans @@ -4308,13 +4359,13 @@ Amount formatting, parseability o It shows ambiguous amounts unmodified. - o It can be parsed reliably in the context of a known report (when you + o It can be parsed reliably in the context of a known report (when you know decimals are consistently not being shown, you can assume a sin- gle mark is a digit group mark). 3. "machine-readable output" - usually for other software - o This is produced by all reports when an output format like csv, tsv, + o This is produced by all reports when an output format like csv, tsv, json, or sql is selected. o It shows amounts as 1 or 2 do, but without digit group marks. @@ -4325,39 +4376,39 @@ Amount formatting, parseability Time periods Report start & end date By default, most hledger reports will show the full span of time repre- - sented by the journal. The report start date will be the earliest + sented by the journal. The report start date will be the earliest transaction or posting date, and the report end date will be the latest transaction, posting, or market price date. - Often you will want to see a shorter time span, such as the current - month. You can specify a start and/or end date using -b/--begin, + Often you will want to see a shorter time span, such as the current + month. You can specify a start and/or end date using -b/--begin, -e/--end, -p/--period or a date: query (described below). All of these accept the smart date syntax (below). Some notes: - o End dates are exclusive, as in Ledger, so you should write the date + o End dates are exclusive, as in Ledger, so you should write the date after the last day you want to see in the report. - o As noted in reporting options: among start/end dates specified with + o As noted in reporting options: among start/end dates specified with options, the last (i.e. right-most) option takes precedence. - o The effective report start and end dates are the intersection of the - start/end dates from options and that from date: queries. That is, - date:2019-01 date:2019 -p'2000 to 2030' yields January 2019, the + o The effective report start and end dates are the intersection of the + start/end dates from options and that from date: queries. That is, + date:2019-01 date:2019 -p'2000 to 2030' yields January 2019, the smallest common time span. - o In some cases a report interval will adjust start/end dates to fall + o In some cases a report interval will adjust start/end dates to fall on interval boundaries (see below). Examples: -b 2016/3/17 begin on St. Patrick's day 2016 - -e 12/1 end at the start of december 1st of the current year + -e 12/1 end at the start of december 1st of the current year (11/30 will be the last date included) -b thismonth all transactions on or after the 1st of the current month -p thismonth all transactions in the current month - date:2016/3/17.. the above written as queries instead (.. can also be re- + date:2016/3/17.. the above written as queries instead (.. can also be re- placed with -) date:..12/1 date:thismonth.. @@ -4365,11 +4416,11 @@ Time periods Smart dates hledger's user interfaces accept a "smart date" syntax for added conve- - nience. Smart dates optionally can be relative to today's date, be - written with english words, and have less-significant parts omitted + nience. Smart dates optionally can be relative to today's date, be + written with english words, and have less-significant parts omitted (missing parts are inferred as 1). Some examples: - 2004/10/1, 2004-01-01, exact date, several separators allowed. Year + 2004/10/1, 2004-01-01, exact date, several separators allowed. Year 2004.9.1 is 4+ digits, month is 1-12, day is 1-31 2004 start of year 2004/10 start of month @@ -4393,26 +4444,26 @@ Time periods 20181201 8 digit YYYYMMDD with valid year month and day 201812 6 digit YYYYMM with valid year and month - Some counterexamples - malformed digit sequences might give surprising + Some counterexamples - malformed digit sequences might give surprising results: - 201813 6 digits with an invalid month is parsed as start of + 201813 6 digits with an invalid month is parsed as start of 6-digit year - 20181301 8 digits with an invalid month is parsed as start of + 20181301 8 digits with an invalid month is parsed as start of 8-digit year 20181232 8 digits with an invalid day gives an error 201801012 9+ digits beginning with a valid YYYYMMDD gives an error - "Today's date" can be overridden with the --today option, in case it's + "Today's date" can be overridden with the --today option, in case it's needed for testing or for recreating old reports. (Except for periodic transaction rules, which are not affected by --today.) Report intervals - A report interval can be specified so that reports like register, bal- + A report interval can be specified so that reports like register, bal- ance or activity become multi-period, showing each subperiod as a sepa- rate row or column. - The following standard intervals can be enabled with command-line + The following standard intervals can be enabled with command-line flags: o -D/--daily @@ -4425,47 +4476,47 @@ Time periods o -Y/--yearly - More complex intervals can be specified using -p/--period, described + More complex intervals can be specified using -p/--period, described below. Date adjustment - When there is a report interval (other than daily), report start/end - dates which have been inferred, eg from the journal, are automatically - adjusted to natural period boundaries. This is convenient for produc- + When there is a report interval (other than daily), report start/end + dates which have been inferred, eg from the journal, are automatically + adjusted to natural period boundaries. This is convenient for produc- ing simple periodic reports. More precisely: - o an inferred start date will be adjusted earlier if needed to fall on + o an inferred start date will be adjusted earlier if needed to fall on a natural period boundary - o an inferred end date will be adjusted later if needed to make the + o an inferred end date will be adjusted later if needed to make the last period the same length as the others. By contrast, start/end dates which have been specified explicitly, with - -b, -e, -p or date:, will not be adjusted (since hledger 1.29). This - makes it possible to specify non-standard report periods, but it also - means that if you are specifying a start date, you should pick one - that's on a period boundary if you want to see simple report period + -b, -e, -p or date:, will not be adjusted (since hledger 1.29). This + makes it possible to specify non-standard report periods, but it also + means that if you are specifying a start date, you should pick one + that's on a period boundary if you want to see simple report period headings. Period expressions - The -p/--period option specifies a period expression, which is a com- + The -p/--period option specifies a period expression, which is a com- pact way of expressing a start date, end date, and/or report interval. - Here's a period expression with a start and end date (specifying the + Here's a period expression with a start and end date (specifying the first quarter of 2009): -p "from 2009/1/1 to 2009/4/1" - Several keywords like "from" and "to" are supported for readability; - these are optional. "to" can also be written as ".." or "-". The - spaces are also optional, as long as you don't run two dates together. + Several keywords like "from" and "to" are supported for readability; + these are optional. "to" can also be written as ".." or "-". The + spaces are also optional, as long as you don't run two dates together. So the following are equivalent to the above: -p "2009/1/1 2009/4/1" -p2009/1/1to2009/4/1 -p2009/1/1..2009/4/1 - Dates are smart dates, so if the current year is 2009, these are also + Dates are smart dates, so if the current year is 2009, these are also equivalent to the above: -p "1/1 4/1" @@ -4477,28 +4528,28 @@ Time periods -p "from 2009/1/1" everything after january 1, 2009 - -p "since 2009/1" the same, since is a syn- + -p "since 2009/1" the same, since is a syn- onym -p "from 2009" the same - -p "to 2009" everything before january + -p "to 2009" everything before january 1, 2009 You can also specify a period by writing a single partial or full date: -p "2009" the year 2009; equivalent to "2009/1/1 to 2010/1/1" - -p "2009/1" the month of january 2009; equivalent to "2009/1/1 to + -p "2009/1" the month of january 2009; equivalent to "2009/1/1 to 2009/2/1" - -p "2009/1/1" the first day of 2009; equivalent to "2009/1/1 to + -p "2009/1/1" the first day of 2009; equivalent to "2009/1/1 to 2009/1/2" or by using the "Q" quarter-year syntax (case insensitive): - -p "2009Q1" first quarter of 2009, equivalent to "2009/1/1 to + -p "2009Q1" first quarter of 2009, equivalent to "2009/1/1 to 2009/4/1" -p "q4" fourth quarter of the current year Period expressions with a report interval - A period expression can also begin with a report interval, separated + A period expression can also begin with a report interval, separated from the start/end dates (if any) by a space or the word in: -p "weekly from 2009/1/1 to 2009/4/1" @@ -4521,10 +4572,10 @@ Time periods Weekly on a custom day: - o every Nth day of week (th, nd, rd, or st are all accepted after the + o every Nth day of week (th, nd, rd, or st are all accepted after the number) - o every WEEKDAYNAME (full or three-letter english weekday name, case + o every WEEKDAYNAME (full or three-letter english weekday name, case insensitive) Monthly on a custom day: @@ -4537,7 +4588,7 @@ Time periods o every MM/DD [of year] (month number and day of month number) - o every MONTHNAME DDth [of year] (full or three-letter english month + o every MONTHNAME DDth [of year] (full or three-letter english month name, case insensitive, and day of month number) o every DDth MONTHNAME [of year] (equivalent to the above) @@ -4550,21 +4601,21 @@ Time periods 2009/03" -p "every 2nd day of week" periods will go from Tue to Tue -p "every Tue" same - -p "every 15th day" period boundaries will be on 15th of each + -p "every 15th day" period boundaries will be on 15th of each month - -p "every 2nd Monday" period boundaries will be on second Monday + -p "every 2nd Monday" period boundaries will be on second Monday of each month - -p "every 11/05" yearly periods with boundaries on 5th of + -p "every 11/05" yearly periods with boundaries on 5th of November -p "every 5th November" same -p "every Nov 5th" same - Show historical balances at end of the 15th day of each month (N is an + Show historical balances at end of the 15th day of each month (N is an end date, exclusive as always): $ hledger balance -H -p "every 16th day" - Group postings from the start of wednesday to end of the following + Group postings from the start of wednesday to end of the following tuesday (N is both (inclusive) start date and (exclusive) end date): $ hledger register checking -p "every 3rd day of week" @@ -4575,10 +4626,10 @@ Time periods o every WEEKDAYNAME,WEEKDAYNAME,... (full or three-letter english week- day names, case insensitive) - Also, weekday and weekendday are shorthand for mon,tue,wed,thu,fri and + Also, weekday and weekendday are shorthand for mon,tue,wed,thu,fri and sat,sun. - This is mainly intended for use with --forecast, to generate periodic + This is mainly intended for use with --forecast, to generate periodic transactions on arbitrary days of the week. It may be less useful with -p, since it divides each week into subperiods of unequal length, which is unusual. (Related: #1632) @@ -4587,35 +4638,35 @@ Time periods -p "every dates will be Mon, Wed, Fri; periods will be mon,wed,fri" Mon-Tue, Wed-Thu, Fri-Sun - -p "every weekday" dates will be Mon, Tue, Wed, Thu, Fri; periods will + -p "every weekday" dates will be Mon, Tue, Wed, Thu, Fri; periods will be Mon, Tue, Wed, Thu, Fri-Sun -p "every weekend- dates will be Sat, Sun; periods will be Sat, Sun-Fri day" Depth - With the --depth NUM option (short form: -NUM), reports will show ac- - counts only to the specified depth, hiding deeper subaccounts. Use - this when you want a summary with less detail. This flag has the same + With the --depth NUM option (short form: -NUM), reports will show ac- + counts only to the specified depth, hiding deeper subaccounts. Use + this when you want a summary with less detail. This flag has the same effect as a depth: query argument: depth:2, --depth=2 or -2 are equiva- lent. Queries One of hledger's strengths is being able to quickly report on a precise - subset of your data. Most hledger commands accept query arguments, to + subset of your data. Most hledger commands accept query arguments, to restrict their scope. Multiple query terms can be provided to build up a more complex query. - o By default, a query term is interpreted as a case-insensitive sub- + o By default, a query term is interpreted as a case-insensitive sub- string pattern for matching account names: car:fuel dining groceries - o Patterns containing spaces or other special characters must be en- + o Patterns containing spaces or other special characters must be en- closed in single or double quotes: 'personal care' - o These patterns are actually regular expressions, so you can add reg- - exp metacharacters for more precision (see "Regular expressions" + o These patterns are actually regular expressions, so you can add reg- + exp metacharacters for more precision (see "Regular expressions" above for details): '^expenses\b' @@ -4636,15 +4687,15 @@ Queries not:status:'*' not:desc:'opening|closing' not:cur:USD - o Terms with different types are AND-ed, terms with the same type are - OR-ed (mostly; see "Combining query terms" below). The following + o Terms with different types are AND-ed, terms with the same type are + OR-ed (mostly; see "Combining query terms" below). The following query: date:2022 desc:amazon desc:amzn is interpreted as: - date is in 2022 AND ( transaction description contains "amazon" OR + date is in 2022 AND ( transaction description contains "amazon" OR "amzn" ) Query types @@ -4652,15 +4703,15 @@ Queries prefixed with not: to convert them into a negative match. acct:REGEX or REGEX - Match account names containing this case insensitive regular expres- + Match account names containing this case insensitive regular expres- sion. This is the default query type, so we usually don't bother writ- ing the "acct:" prefix. amt:N, amt:N, amt:>=N - Match postings with a single-commodity amount equal to, less than, or - greater than N. (Postings with multi-commodity amounts are not tested + Match postings with a single-commodity amount equal to, less than, or + greater than N. (Postings with multi-commodity amounts are not tested and will always match.) The comparison has two modes: if N is preceded - by a + or - sign (or is 0), the two signed numbers are compared. Oth- + by a + or - sign (or is 0), the two signed numbers are compared. Oth- erwise, the absolute magnitudes are compared, ignoring sign. code:REGEX @@ -4668,10 +4719,10 @@ Queries cur:REGEX Match postings or transactions including any amounts whose cur- - rency/commodity symbol is fully matched by REGEX. (For a partial - match, use .*REGEX.*). Note, to match special characters which are - regex-significant, you need to escape them with \. And for characters - which are significant to your shell you may need one more level of es- + rency/commodity symbol is fully matched by REGEX. (For a partial + match, use .*REGEX.*). Note, to match special characters which are + regex-significant, you need to escape them with \. And for characters + which are significant to your shell you may need one more level of es- caping. So eg to match the dollar sign: hledger print cur:\\$. @@ -4679,21 +4730,21 @@ Queries Match transaction descriptions. date:PERIODEXPR - Match dates (or with the --date2 flag, secondary dates) within the + Match dates (or with the --date2 flag, secondary dates) within the specified period. PERIODEXPR is a period expression with no report in- terval. Examples: date:2016, date:thismonth, date:2/1-2/15, date:2021-07-27..nextquarter. date2:PERIODEXPR - Match secondary dates within the specified period (independent of the + Match secondary dates within the specified period (independent of the --date2 flag). depth:N - Match (or display, depending on command) accounts at or above this + Match (or display, depending on command) accounts at or above this depth. expr:"TERM AND NOT (TERM OR TERM)" (eg) - Match with a boolean combination of queries (which must be enclosed in + Match with a boolean combination of queries (which must be enclosed in quotes). See Combining query terms below. note:REGEX @@ -4701,7 +4752,7 @@ Queries whole description if there's no |). payee:REGEX - Match transaction payee/payer names (the part of the description left + Match transaction payee/payer names (the part of the description left of |, or the whole description if there's no |). real:, real:0 @@ -4711,11 +4762,11 @@ Queries Match unmarked, pending, or cleared transactions respectively. type:TYPECODES - Match by account type (see Declaring accounts > Account types). TYPE- - CODES is one or more of the single-letter account type codes ALERXCV, + Match by account type (see Declaring accounts > Account types). TYPE- + CODES is one or more of the single-letter account type codes ALERXCV, case insensitive. Note type:A and type:E will also match their respec- - tive subtypes C (Cash) and V (Conversion). Certain kinds of account - alias can disrupt account types, see Rewriting accounts > Aliases and + tive subtypes C (Cash) and V (Conversion). Certain kinds of account + alias can disrupt account types, see Rewriting accounts > Aliases and account types. tag:REGEX[=REGEX] @@ -4731,11 +4782,11 @@ Queries o Transactions also acquire the tags of their postings. (inacct:ACCTNAME - A special query term used automatically in hledger-web only: tells + A special query term used automatically in hledger-web only: tells hledger-web to show the transaction register for an account.) Combining query terms - When given multiple space-separated query terms, most commands select + When given multiple space-separated query terms, most commands select things which match: o any of the description terms AND @@ -4756,13 +4807,13 @@ Queries o match all the other terms. - We also support more complex boolean queries with the 'expr:' prefix. - This allows one to combine queries using one of three operators: AND, + 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:'. Examples of such queries are: - o Match transactions with 'cool' in the description AND with the 'A' + o Match transactions with 'cool' in the description AND with the 'A' tag expr:"desc:cool AND tag:A" @@ -4772,22 +4823,22 @@ Queries 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 + 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:2023 is equivalent to -p 2023, etc. When - you mix command options and query arguments, generally the resulting + you mix command options and query arguments, generally the resulting query is their intersection. Queries and valuation - When amounts are converted to other commodities in cost or value re- - ports, cur: and amt: match the old commodity symbol and the old amount - quantity, not the new ones (except in hledger 1.22.0 where it's re- + When amounts are converted to other commodities in cost or value re- + ports, cur: and amt: match the old commodity symbol and the old amount + quantity, not the new ones (except in hledger 1.22.0 where it's re- versed, see #1625). Querying with account aliases @@ -4795,21 +4846,21 @@ 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 re- + When amounts are converted to other commodities in cost or value re- ports, note that cur: matches the new commodity symbol, and not the old - one, and amt: matches the new quantity, and not the old one. Note: - this changed in hledger 1.22, previously it was the reverse, see the + one, and amt: matches the new quantity, and not the old one. Note: + this changed in hledger 1.22, previously it was the reverse, see the discussion at #1625. Pivoting - Normally, hledger groups and sums amounts within each account. The - --pivot FIELD option substitutes some other transaction field for ac- - count names, causing amounts to be grouped and summed by that field's - value instead. FIELD can be any of the transaction fields acct, sta- - tus, code, desc, payee, note, or a tag name. When pivoting on a tag - and a posting has multiple values of that tag, only the first value is - displayed. Values containing colon:separated:parts will be displayed - hierarchically, like account names. Multiple, colon-delimited fields + Normally, hledger groups and sums amounts within each account. The + --pivot FIELD option substitutes some other transaction field for ac- + count names, causing amounts to be grouped and summed by that field's + value instead. FIELD can be any of the transaction fields acct, sta- + tus, code, desc, payee, note, or a tag name. When pivoting on a tag + and a posting has multiple values of that tag, only the first value is + displayed. Values containing colon:separated:parts will be displayed + hierarchically, like account names. Multiple, colon-delimited fields can be pivoted simultaneously, generating a hierarchical account name. Some examples: @@ -4841,7 +4892,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:. @@ -4859,66 +4910,66 @@ Pivoting Generating data hledger has several features for generating data, such as: - o Periodic transaction rules can generate single or repeating transac- - tions following a template. These are usually dated in the future, - eg to help with forecasting. They are activated by the --forecast + o Periodic transaction rules can generate single or repeating transac- + tions following a template. These are usually dated in the future, + eg to help with forecasting. They are activated by the --forecast option. - o The balance command's --budget option uses these same periodic rules + o The balance command's --budget option uses these same periodic rules to generate goals for the budget report. - o Auto posting rules can generate extra postings on certain matched + o Auto posting rules can generate extra postings on certain matched transactions. They are always applied to forecast transactions; with - the --auto flag they are applied to transactions recorded in the + the --auto flag they are applied to transactions recorded in the journal as well. - o The --infer-equity flag infers missing conversion equity postings - from @/@@ costs. And the inverse --infer-costs flag infers missing + o The --infer-equity flag infers missing conversion equity postings + from @/@@ costs. And the inverse --infer-costs flag infers missing @/@@ costs from conversion equity postings. Generated data of this kind is temporary, existing only at report time. - But you can see it in the output of hledger print, and you can save - that to your journal, in effect converting it from temporary generated - data to permanent recorded data. This could be useful as a data entry + But you can see it in the output of hledger print, and you can save + that to your journal, in effect converting it from temporary generated + data to permanent recorded data. This could be useful as a data entry aid. - If you are wondering what data is being generated and why, add the - --verbose-tags flag. In hledger print output you will see extra tags - like generated-transaction, generated-posting, and modified on gener- - ated/modified data. Also, even without --verbose-tags, generated data + If you are wondering what data is being generated and why, add the + --verbose-tags flag. In hledger print output you will see extra tags + like generated-transaction, generated-posting, and modified on gener- + ated/modified data. Also, even without --verbose-tags, generated data always has equivalen hidden tags (with an underscore prefix), so eg you could match generated transactions with tag:_generated-transaction. Forecasting - Forecasting, or speculative future reporting, can be useful for esti- + Forecasting, or speculative future reporting, can be useful for esti- mating future balances, or for exploring different future scenarios. The simplest and most flexible way to do it with hledger is to manually record a bunch of future-dated transactions. You could keep these in a - separate future.journal and include that with -f only when you want to + separate future.journal and include that with -f only when you want to see them. --forecast - There is another way: with the --forecast option, hledger can generate - temporary "forecast transactions" for reporting purposes, according to - periodic transaction rules defined in the journal. Each rule can gen- - erate multiple recurring transactions, so by changing one rule you can + There is another way: with the --forecast option, hledger can generate + temporary "forecast transactions" for reporting purposes, according to + periodic transaction rules defined in the journal. Each rule can gen- + erate multiple recurring transactions, so by changing one rule you can change many forecasted transactions. - Forecast transactions usually start after ordinary transactions end. + Forecast transactions usually start after ordinary transactions end. By default, they begin after your latest-dated ordinary transaction, or - today, whichever is later, and they end six months from today. (The + today, whichever is later, and they end six months from today. (The exact rules are a little more complicated, and are given below.) This is the "forecast period", which need not be the same as the report - period. You can override it - eg to forecast farther into the future, + period. You can override it - eg to forecast farther into the future, or to force forecast transactions to overlap your ordinary transactions - - by giving the --forecast option a period expression argument, like - --forecast=..2099 or --forecast=2023-02-15... Note that the = is re- + - by giving the --forecast option a period expression argument, like + --forecast=..2099 or --forecast=2023-02-15... Note that the = is re- quired. Inspecting forecast transactions - print is the best command for inspecting and troubleshooting forecast + print is the best command for inspecting and troubleshooting forecast transactions. Eg: ~ monthly from 2022-12-20 rent @@ -4952,7 +5003,7 @@ Forecasting expenses:rent $1000 Here there are no ordinary transactions, so the forecasted transactions - begin on the first occurence after today's date. (You won't normally + begin on the first occurence after today's date. (You won't normally use --today; it's just to make these examples reproducible.) Forecast reports @@ -4976,19 +5027,19 @@ Forecasting || $1000 $1000 $1000 $1000 $1000 Forecast tags - Forecast transactions generated by --forecast have a hidden tag, _gen- - erated-transaction. So if you ever need to match forecast transac- + Forecast transactions generated by --forecast have a hidden tag, _gen- + erated-transaction. So if you ever need to match forecast transac- tions, you could use tag:_generated-transaction (or just tag:generated) in a query. - For troubleshooting, you can add the --verbose-tags flag. Then, visi- + For troubleshooting, you can add the --verbose-tags flag. Then, visi- ble generated-transaction tags will be added also, so you can view them - with the print command. Their value indicates which periodic rule was + with the print command. Their value indicates which periodic rule was responsible. Forecast period, in detail Forecast start/end dates are chosen so as to do something useful by de- - fault in almost all situations, while also being flexible. Here are + fault in almost all situations, while also being flexible. Here are (with luck) the exact rules, to help with troubleshooting: The forecast period starts on: @@ -5020,7 +5071,7 @@ Forecasting o otherwise: 180 days (~6 months) from today. Forecast troubleshooting - When --forecast is not doing what you expect, one of these tips should + When --forecast is not doing what you expect, one of these tips should help: o Remember to use the --forecast option. @@ -5030,22 +5081,22 @@ Forecasting o Test with print --forecast. - o Check for typos or too-restrictive start/end dates in your periodic + o Check for typos or too-restrictive start/end dates in your periodic transaction rule. - o Leave at least 2 spaces between the rule's period expression and de- + o Leave at least 2 spaces between the rule's period expression and de- scription fields. - o Check for future-dated ordinary transactions suppressing forecasted + o Check for future-dated ordinary transactions suppressing forecasted transactions. o Try setting explicit report start and/or end dates with -b, -e, -p or date: - o Try adding the -E flag to encourage display of empty periods/zero + o Try adding the -E flag to encourage display of empty periods/zero transactions. - o Try setting explicit forecast start and/or end dates with --fore- + o Try setting explicit forecast start and/or end dates with --fore- cast=START..END o Consult Forecast period, in detail, above. @@ -5053,30 +5104,30 @@ Forecasting o Check inside the engine: add --debug=2 (eg). Budgeting - With the balance command's --budget report, each periodic transaction - rule generates recurring budget goals in specified accounts, and goals - and actual performance can be compared. See the balance command's doc + With the balance command's --budget report, each periodic transaction + rule generates recurring budget goals in specified accounts, and goals + and actual performance can be compared. See the balance command's doc below. - You can generate budget goals and forecast transactions at the same - time, from the same or different periodic transaction rules: hledger + You can generate budget goals and forecast transactions at the same + time, from the same or different periodic transaction rules: hledger bal -M --budget --forecast ... See also: Budgeting and Forecasting. Cost reporting In some transactions - for example a currency conversion, or a purchase - or sale of stock - one commodity is exchanged for another. In these - transactions there is a conversion rate, also called the cost (when - buying) or selling price (when selling). In hledger docs we just say + or sale of stock - one commodity is exchanged for another. In these + transactions there is a conversion rate, also called the cost (when + buying) or selling price (when selling). In hledger docs we just say "cost", for convenience; feel free to mentally translate to "conversion rate" or "selling price" if helpful. Recording costs - We'll explore several ways of recording transactions involving costs. + We'll explore several ways of recording transactions involving costs. These are also summarised at hledger Cookbook > Cost notation. - Costs can be recorded explicitly in the journal, using the @ UNITCOST + Costs can be recorded explicitly in the journal, using the @ UNITCOST or @@ TOTALCOST notation described in Journal > Costs: Variant 1 @@ -5091,11 +5142,11 @@ Cost reporting assets:dollars $-135 assets:euros 100 @@ $135 ; $135 total cost - Typically, writing the unit cost (variant 1) is preferable; it can be + Typically, writing the unit cost (variant 1) is preferable; it can be more effort, requiring more attention to decimal digits; but it reveals the per-unit cost basis, and makes stock sales easier. - Costs can also be left implicit, and hledger will infer the cost that + Costs can also be left implicit, and hledger will infer the cost that is consistent with a balanced transaction: Variant 3 @@ -5104,49 +5155,49 @@ Cost reporting assets:dollars $-135 assets:euros 100 - Here, hledger will attach a @@ 100 cost to the first amount (you can - see it with hledger print -x). This form looks convenient, but there + Here, hledger will attach a @@ 100 cost to the first amount (you can + see it with hledger print -x). This form looks convenient, but there are downsides: - o It sacrifices some error checking. For example, if you accidentally + o It sacrifices some error checking. For example, if you accidentally wrote 10 instead of 100, hledger would not be able to detect the mis- take. - o It is sensitive to the order of postings - if they were reversed, a + o It is sensitive to the order of postings - if they were reversed, a different entry would be inferred and reports would be different. o The per-unit cost basis is not easy to read. - So generally this kind of entry is not recommended. You can make sure + So generally this kind of entry is not recommended. You can make sure you have none of these by using -s (strict mode), or by running hledger check balanced. Reporting at cost - Now when you add the -B/--cost flag to reports ("B" is from Ledger's - -B/--basis/--cost flag), any amounts which have been annotated with - costs will be converted to their cost's commodity (in the report out- + Now when you add the -B/--cost flag to reports ("B" is from Ledger's + -B/--basis/--cost flag), any amounts which have been annotated with + costs will be converted to their cost's commodity (in the report out- put). Ie they will be displayed "at cost" or "at sale price". Some things to note: - o Costs are attached to specific posting amounts in specific transac- - tions, and once recorded they do not change. This contrasts with + o Costs are attached to specific posting amounts in specific transac- + tions, and once recorded they do not change. This contrasts with market prices, which are ambient and fluctuating. - o Conversion to cost is performed before conversion to market value + o Conversion to cost is performed before conversion to market value (described below). Equity conversion postings - There is a problem with the entries above - they are not conventional - Double Entry Bookkeeping (DEB) notation, and because of the "magical" - transformation of one commodity into another, they cause an imbalance + There is a problem with the entries above - they are not conventional + Double Entry Bookkeeping (DEB) notation, and because of the "magical" + transformation of one commodity into another, they cause an imbalance in the Accounting Equation. This shows up as a non-zero grand total in balance reports like hledger bse. - For most hledger users, this doesn't matter in practice and can safely + For most hledger users, this doesn't matter in practice and can safely be ignored ! But if you'd like to learn more, keep reading. - Conventional DEB uses an extra pair of equity postings to balance the + Conventional DEB uses an extra pair of equity postings to balance the transaction. Of course you can do this in hledger as well: Variant 4 @@ -5157,10 +5208,10 @@ Cost reporting equity:conversion $135 equity:conversion -100 - Now the transaction is perfectly balanced according to standard DEB, + Now the transaction is perfectly balanced according to standard DEB, and hledger bse's total will not be disrupted. - And, hledger can still infer the cost for cost reporting, but it's not + And, hledger can still infer the cost for cost reporting, but it's not done by default - you must add the --infer-costs flag like so: $ hledger print --infer-costs @@ -5182,14 +5233,14 @@ Cost reporting o Instead of -B you must remember to type -B --infer-costs. - o --infer-costs works only where hledger can identify the two eq- - uity:conversion postings and match them up with the two non-equity - postings. So writing the journal entry in a particular format be- + o --infer-costs works only where hledger can identify the two eq- + uity:conversion postings and match them up with the two non-equity + postings. So writing the journal entry in a particular format be- comes more important. More on this below. Inferring equity conversion postings Can we go in the other direction ? Yes, if you have transactions writ- - ten with the @/@@ cost notation, hledger can infer the missing equity + ten with the @/@@ cost notation, hledger can infer the missing equity postings, if you add the --infer-equity flag. Eg: 2022-01-01 @@ -5203,15 +5254,15 @@ Cost reporting equity:conversion:$-: -100 equity:conversion:$-:$ $135.00 - The equity account names will be "equity:conversion:A-B:A" and "eq- - uity:conversion:A-B:B" where A is the alphabetically first commodity + The equity account names will be "equity:conversion:A-B:A" and "eq- + uity:conversion:A-B:B" where A is the alphabetically first commodity symbol. You can customise the "equity:conversion" part by declaring an account with the V/Conversion account type. Combining costs and equity conversion postings Finally, you can use both the @/@@ cost notation and equity postings at - the same time. This in theory gives the best of all worlds - preserv- - ing the accounting equation, revealing the per-unit cost basis, and + the same time. This in theory gives the best of all worlds - preserv- + ing the accounting equation, revealing the per-unit cost basis, and providing more flexibility in how you write the entry: Variant 5 @@ -5222,15 +5273,15 @@ Cost reporting equity:conversion -100 assets:euros 100 @ $1.35 - All the other variants above can (usually) be rewritten to this final + All the other variants above can (usually) be rewritten to this final form with: $ hledger print -x --infer-costs --infer-equity Downsides: - o The precise format of the journal entry becomes more important. If - hledger can't detect and match up the cost and equity postings, it + o The precise format of the journal entry becomes more important. If + hledger can't detect and match up the cost and equity postings, it will give a transaction balancing error. o The add command does not yet accept this kind of entry (#2056). @@ -5238,34 +5289,34 @@ Cost reporting o This is the most verbose form. Requirements for detecting equity conversion postings - --infer-costs has certain requirements (unlike --infer-equity, which + --infer-costs has certain requirements (unlike --infer-equity, which always works). It will infer costs only in transactions with: - o Two non-equity postings, in different commodities. Their order is + o Two non-equity postings, in different commodities. Their order is significant: the cost will be added to the first of them. - o Two postings to equity conversion accounts, next to one another, + o Two postings to equity conversion accounts, next to one another, which balance the two non-equity postings. This balancing is checked - to the same precision (number of decimal places) used in the conver- + to the same precision (number of decimal places) used in the conver- sion posting's amount. Equity conversion accounts are: o any accounts declared with account type V/Conversion, or their sub- accounts - o otherwise, accounts named equity:conversion, equity:trade, or eq- + o otherwise, accounts named equity:conversion, equity:trade, or eq- uity:trading, or their subaccounts. - And multiple such four-posting groups can coexist within a single - transaction. When --infer-costs fails, it does not infer a cost in - that transaction, and does not raise an error (ie, it infers costs + And multiple such four-posting groups can coexist within a single + transaction. When --infer-costs fails, it does not infer a cost in + that transaction, and does not raise an error (ie, it infers costs where it can). - Reading variant 5 journal entries, combining cost notation and equity - postings, has all the same requirements. When reading such an entry + Reading variant 5 journal entries, combining cost notation and equity + postings, has all the same requirements. When reading such an entry fails, hledger raises an "unbalanced transaction" error. Infer cost and equity by default ? - Should --infer-costs and --infer-equity be enabled by default ? Try + Should --infer-costs and --infer-equity be enabled by default ? Try using them always, eg with a shell alias: alias h="hledger --infer-equity --infer-costs" @@ -5273,101 +5324,101 @@ Cost reporting and let us know what problems you find. Value reporting - Instead of reporting amounts in their original commodity, hledger can + Instead of reporting amounts in their original commodity, hledger can convert them to cost/sale amount (using the conversion rate recorded in - the transaction), and/or to market value (using some market price on a - certain date). This is controlled by the --value=TYPE[,COMMODITY] op- - tion, which will be described below. We also provide the simpler -V + the transaction), and/or to market value (using some market price on a + certain date). This is controlled by the --value=TYPE[,COMMODITY] op- + tion, which will be described below. We also provide the simpler -V and -X COMMODITY options, and often one of these is all you need: -V: Value - The -V/--market flag converts amounts to market value in their default + The -V/--market flag converts amounts to market value in their default valuation commodity, using the market prices in effect on the valuation date(s), if any. More on these in a minute. -X: Value in specified commodity The -X/--exchange=COMM option is like -V, except you tell it which cur- - rency you want to convert to, and it tries to convert everything to + rency you want to convert to, and it tries to convert everything to that. Valuation date - Market prices can change from day to day. hledger will use the prices - on a particular valuation date (or on more than one date). By default + Market prices can change from day to day. hledger will use the prices + on a particular valuation date (or on more than one date). By default hledger uses "end" dates for valuation. More specifically: - o For single period reports (including normal print and register re- + o For single period reports (including normal print and register re- ports): o If an explicit report end date is specified, that is used - o Otherwise the latest transaction date or P directive date is used + o Otherwise the latest transaction date or P directive date is used (even if it's in the future) o For multiperiod reports, each period is valued on its last day. - This can be customised with the --value option described below, which + This can be customised with the --value option described below, which can select either "then", "end", "now", or "custom" dates. (Note, this has a bug in hledger-ui <=1.31: turning on valuation with the V key al- ways resets it to "end".) Finding market price - To convert a commodity A to its market value in another commodity B, - hledger looks for a suitable market price (exchange rate) as follows, + To convert a commodity A to its market value in another commodity B, + hledger looks for a suitable market price (exchange rate) as follows, in this order of preference: - 1. A declared market price or inferred market price: A's latest market + 1. A declared market price or inferred market price: A's latest market price in B on or before the valuation date as declared by a P direc- tive, or (with the --infer-market-prices flag) inferred from costs. 2. A reverse market price: the inverse of a declared or inferred market price from B to A. - 3. A forward chain of market prices: a synthetic price formed by com- + 3. A forward chain of market prices: a synthetic price formed by com- bining the shortest chain of "forward" (only 1 above) market prices, leading from A to B. - 4. Any chain of market prices: a chain of any market prices, including - both forward and reverse prices (1 and 2 above), leading from A to + 4. Any chain of market prices: a chain of any market prices, including + both forward and reverse prices (1 and 2 above), leading from A to B. - There is a limit to the length of these price chains; if hledger - reaches that length without finding a complete chain or exhausting all - possibilities, it will give up (with a "gave up" message visible in + There is a limit to the length of these price chains; if hledger + reaches that length without finding a complete chain or exhausting all + possibilities, it will give up (with a "gave up" message visible in --debug=2 output). That limit is currently 1000. - Amounts for which no suitable market price can be found, are not con- + Amounts for which no suitable market price can be found, are not con- verted. --infer-market-prices: market prices from transactions Normally, market value in hledger is fully controlled by, and requires, P directives in your journal. Since adding and updating those can be a - chore, and since transactions usually take place at close to market - value, why not use the recorded costs as additional market prices (as - Ledger does) ? Adding the --infer-market-prices flag to -V, -X or + chore, and since transactions usually take place at close to market + value, why not use the recorded costs as additional market prices (as + Ledger does) ? Adding the --infer-market-prices flag to -V, -X or --value enables this. - So for example, hledger bs -V --infer-market-prices will get market - prices both from P directives and from transactions. If both occur on + So for example, hledger bs -V --infer-market-prices will get market + prices both from P directives and from transactions. If both occur on the same day, the P directive takes precedence. There is a downside: value reports can sometimes be affected in confus- - ing/undesired ways by your journal entries. If this happens to you, - read all of this Value reporting section carefully, and try adding + ing/undesired ways by your journal entries. If this happens to you, + read all of this Value reporting section carefully, and try adding --debug or --debug=2 to troubleshoot. --infer-market-prices can infer market prices from: o multicommodity transactions with explicit prices (@/@@) - o multicommodity transactions with implicit prices (no @, two commodi- - ties, unbalanced). (With these, the order of postings matters. + o multicommodity transactions with implicit prices (no @, two commodi- + ties, unbalanced). (With these, the order of postings matters. hledger print -x can be useful for troubleshooting.) o multicommodity transactions with equity postings, if cost is inferred with --infer-costs. - There is a limitation (bug) currently: when a valuation commodity is - not specified, prices inferred with --infer-market-prices do not help + There is a limitation (bug) currently: when a valuation commodity is + not specified, prices inferred with --infer-market-prices do not help select a default valuation commodity, as P prices would. So conversion might not happen because no valuation commodity was detected (--debug=2 will show this). To be safe, specify the valuation commmodity, eg: @@ -5377,8 +5428,8 @@ Value reporting o --value=then,EUR --infer-market-prices, not --value=then --infer-mar- ket-prices - Signed costs and market prices can be confusing. For reference, here - is the current behaviour, since hledger 1.25. (If you think it should + Signed costs and market prices can be confusing. For reference, here + is the current behaviour, since hledger 1.25. (If you think it should work differently, see #1870.) 2022-01-01 Positive Unit prices @@ -5408,7 +5459,7 @@ Value reporting b B -1 @@ A -1 All of the transactions above are considered balanced (and on each day, - the two transactions are considered equivalent). Here are the market + the two transactions are considered equivalent). Here are the market prices inferred for B: $ hledger -f- --infer-market-prices prices @@ -5421,34 +5472,34 @@ Value reporting Valuation commodity When you specify a valuation commodity (-X COMM or --value TYPE,COMM): - hledger will convert all amounts to COMM, wherever it can find a suit- + hledger will convert all amounts to COMM, wherever it can find a suit- able market price (including by reversing or chaining prices). - When you leave the valuation commodity unspecified (-V or --value + When you leave the valuation commodity unspecified (-V or --value TYPE): - For each commodity A, hledger picks a default valuation commodity as + For each commodity A, hledger picks a default valuation commodity as follows, in this order of preference: 1. The price commodity from the latest P-declared market price for A on or before valuation date. 2. The price commodity from the latest P-declared market price for A on - any date. (Allows conversion to proceed when there are inferred + any date. (Allows conversion to proceed when there are inferred prices before the valuation date.) - 3. If there are no P directives at all (any commodity or date) and the - --infer-market-prices flag is used: the price commodity from the + 3. If there are no P directives at all (any commodity or date) and the + --infer-market-prices flag is used: the price commodity from the latest transaction-inferred price for A on or before valuation date. This means: - o If you have P directives, they determine which commodities -V will + o If you have P directives, they determine which commodities -V will convert, and to what. - o If you have no P directives, and use the --infer-market-prices flag, + o If you have no P directives, and use the --infer-market-prices flag, costs determine it. - Amounts for which no valuation commodity can be found are not con- + Amounts for which no valuation commodity can be found are not con- verted. Simple valuation examples @@ -5475,7 +5526,7 @@ Value reporting $ hledger -f t.j bal -N euros -V -e 2016/11/4 $110.00 assets:euros - What are they worth after 2016/12/21 ? (no report end date specified, + What are they worth after 2016/12/21 ? (no report end date specified, defaults to today) $ hledger -f t.j bal -N euros -V @@ -5495,31 +5546,31 @@ Value reporting The TYPE part selects cost or value and valuation date: --value=then - Convert amounts to their value in the default valuation commod- + Convert amounts to their value in the default valuation commod- ity, using market prices on each posting's date. --value=end - Convert amounts to their value in the default valuation commod- - ity, using market prices on the last day of the report period - (or if unspecified, the journal's end date); or in multiperiod + Convert amounts to their value in the default valuation commod- + ity, using market prices on the last day of the report period + (or if unspecified, the journal's end date); or in multiperiod reports, market prices on the last day of each subperiod. --value=now - Convert amounts to their value in the default valuation commod- - ity using current market prices (as of when report is gener- + Convert amounts to their value in the default valuation commod- + ity using current market prices (as of when report is gener- ated). --value=YYYY-MM-DD - Convert amounts to their value in the default valuation commod- + Convert amounts to their value in the default valuation commod- ity using market prices on this date. To select a different valuation commodity, add the optional ,COMM part: - a comma, then the target commodity's symbol. Eg: --value=now,EUR. + a comma, then the target commodity's symbol. Eg: --value=now,EUR. hledger will do its best to convert amounts to this commodity, deducing market prices as described above. 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 @@ -5557,7 +5608,7 @@ Value reporting 2000-02-01 (a) 2 B - With no report period specified, that shows the value as of the last + With no report period specified, that shows the value as of the last day of the journal (2000-03-01): $ hledger -f- print --value=end @@ -5595,7 +5646,7 @@ Value reporting (a) 1 B Interaction of valuation and queries - When matching postings based on queries in the presence of valuation, + When matching postings based on queries in the presence of valuation, the following happens. 1. The query is separated into two parts: @@ -5609,15 +5660,15 @@ Value reporting 3. Valuation is applied to the postings. - 4. The postings are matched to the other parts of the query based on + 4. The postings are matched to the other parts of the query based on post-valued amounts. 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 + Here is a reference for how valuation is supposed to affect each part + of hledger's reports (and a glossary). (It's wide, you'll have to + scroll sideways.) It may be useful when troubleshooting. If you find problems, please report them, ideally with a reproducible example. Re- lated: #329, #1083. @@ -5625,8 +5676,8 @@ Value reporting type --value=now -------------------------------------------------------------------------------------------- print - posting cost value at re- value at posting value at re- value at - amounts port end or date port or DATE/today + posting cost value at re- value at posting value at re- value at + amounts port end or date port or DATE/today today journal end balance unchanged unchanged unchanged unchanged unchanged asser- @@ -5642,7 +5693,7 @@ Value reporting (-H) with port or posting was made port or report journal journal interval start start - posting cost value at re- value at posting value at re- value at + posting cost value at re- value at posting value at re- value at amounts port or date port or DATE/today journal end journal end summary summarised value at pe- sum of postings value at pe- value at @@ -5658,8 +5709,8 @@ Value reporting balance (bs, bse, cf, is) - balance sums of value at re- value at posting value at re- value at - changes costs port end or date port or DATE/today of + balance sums of value at re- value at posting value at re- value at + changes costs port end or date port or DATE/today of today of journal end sums of post- sums of of sums of ings postings postings @@ -5667,7 +5718,7 @@ Value reporting amounts changes changes changes ances changes (--bud- get) - grand to- sum of dis- sum of dis- sum of displayed sum of dis- sum of dis- + grand to- sum of dis- sum of dis- sum of displayed sum of dis- sum of dis- tal played val- played val- valued played val- played values ues ues ues @@ -5693,7 +5744,7 @@ Value reporting end bal- sums of same as sums of values of period end value at ances costs of --value=end postings from be- balances, DATE/today of (bal -H, postings fore period start valued at sums of post- - is --H, from before to period end at period ends ings + is --H, from before to period end at period ends ings bs, cf) report start respective post- to period ing dates end @@ -5702,10 +5753,10 @@ Value reporting (--bud- balances balances ances balances get) row to- sums, aver- sums, aver- sums, averages of sums, aver- sums, aver- - tals, row ages of dis- ages of dis- displayed values ages of dis- ages of dis- + tals, row ages of dis- ages of dis- displayed values ages of dis- ages of dis- averages played val- played val- played val- played values (-T, -A) ues ues ues - column sums of dis- sums of dis- sums of displayed sums of dis- sums of dis- + column sums of dis- sums of dis- sums of displayed sums of dis- sums of dis- totals played val- played val- values played val- played values ues ues ues grand to- sum, average sum, average sum, average of sum, average sum, average @@ -5721,29 +5772,29 @@ Value reporting 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). @@ -5785,7 +5836,7 @@ PART 4: COMMANDS o print - show transactions or export journal data - o register (reg) - show postings in one or more accounts & running to- + o register (reg) - show postings in one or more accounts & running to- tal o roi - show return on investments @@ -5822,7 +5873,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 @@ -5835,7 +5886,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. @@ -5843,38 +5894,38 @@ PART 4: COMMANDS accounts Show account names. - This command lists account names. By default it shows all known ac- - counts, either used in transactions or declared with account direc- + This command lists account names. By default it shows all known ac- + counts, either used in transactions or declared with account direc- tives. With query arguments, only matched account names and account names ref- erenced by matched postings are shown. - Or it can show just the used accounts (--used/-u), the declared ac- - counts (--declared/-d), the accounts declared but not used (--unused), + Or it can show just the used accounts (--used/-u), the declared ac- + counts (--declared/-d), the accounts declared but not used (--unused), the accounts used but not declared (--undeclared), or the first account matched by an account name pattern, if any (--find). - It shows a flat list by default. With --tree, it uses indentation to - show the account hierarchy. In flat mode you can add --drop N to omit - the first few account name components. Account names can be + 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 ac- - count's declaration, if any, and the account's overall declaration or- + With --positions, it also shows the file and line number of each ac- + count's declaration, if any, and the account's overall declaration or- der; these may be useful when troubleshooting account display order. - With --directives, it adds the account keyword, showing valid account + With --directives, it adds the account keyword, showing valid account directives which can be pasted into a journal file. This is useful to- - gether with --undeclared when updating your account declarations to + gether with --undeclared when updating your account declarations to satisfy hledger check accounts. - The --find flag can be used to look up a single account name, in the - 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: @@ -5895,8 +5946,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: @@ -5908,36 +5959,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 de- - scription) recent transaction (filtered by the query, if any) as a + o add tries to provide useful defaults, using the most similar (by de- + scription) recent transaction (filtered by the query, if any) as a template. o You can also set the initial defaults with command line arguments. 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. @@ -5946,7 +5997,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): @@ -5977,83 +6028,84 @@ PART 4: COMMANDS Date [2015/05/22]: $ If you enter a number with no commodity symbol, and you have declared a - default commodity with a D directive, you might expect add to add this + default commodity with a D directive, you might expect add to add this symbol for you. It does not do this; we assume that if you are using a - D directive you prefer not to see the commodity symbol repeated on + D directive you prefer not to see the commodity symbol repeated on amounts in the journal. aregister (areg) - Show the transactions and running historical balance of a single ac- + Show the transactions and running historical balance of a single ac- count, with each transaction displayed as one line. aregister shows the overall transactions affecting a particular account - (and any subaccounts). Each report line represents one transaction in + (and any subaccounts). Each report line represents one transaction in this account. Transactions before the report start date are always in- cluded in the running balance (--historical mode is always on). - This is a more "real world", bank-like view than the register command - (which shows individual postings, possibly from multiple accounts, not + This is a more "real world", bank-like view than the register command + (which shows individual postings, possibly from multiple accounts, not necessarily in historical mode). As a quick rule of thumb: - use areg- ister for reviewing and reconciling real-world asset/liability accounts - use register for reviewing detailed revenues/expenses. - aregister requires one argument: the account to report on. You can - write either the full account name, or a case-insensitive regular ex- + aregister requires one argument: the account to report on. You can + write either the full account name, or a case-insensitive regular ex- pression which will select the alphabetically first matched account. When there are multiple matches, the alphabetically-first choice can be - surprising; eg if you have assets:per:checking 1 and assets:biz:check- - 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 op- - tions. The output formats supported are txt, csv, tsv, and json. + tions. The output formats supported are txt, csv, tsv (Added in 1.32), + and json. aregister and posting dates - aregister always shows one line (and date and amount) per transaction. - But sometimes transactions have postings with different dates. Also, - not all of a transaction's postings may be within the report period. + aregister always shows one line (and date and amount) per transaction. + But sometimes transactions have postings with different dates. Also, + not all of a transaction's postings may be within the report period. To resolve this, aregister shows the earliest of the transaction's date and posting dates that is in-period, and the sum of the in-period post- - ings. In other words it will show a combined line item with just the - earliest date, and the running balance will (temporarily, until the + ings. In other words it will show a combined line item with just the + earliest date, and the running balance will (temporarily, until the transaction's last posting) be inaccurate. Use register -H if you need to see the individual postings. @@ -6066,19 +6118,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.. @@ -6131,7 +6183,7 @@ PART 4: COMMANDS ..with.. - o totals (-T), averages (-A), percentages (-%), inverted sign (--in- + o totals (-T), averages (-A), percentages (-%), inverted sign (--in- vert) o rows and columns swapped (--transpose) @@ -6143,9 +6195,9 @@ 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, tsv, json, and (multi-period reports - only:) html. In txt output in a colour-supporting terminal, negative - amounts are shown in red. + with output formats txt, csv, tsv (Added in 1.32), json, and (multi-pe- + riod reports only:) html. In txt output in a colour-supporting termi- + nal, negative amounts are shown in red. The --related/-r flag shows the balance of the other postings in the transactions of the postings which would normally be shown. @@ -6986,18 +7038,19 @@ PART 4: COMMANDS flipped. This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv, html, and json. + tions The output formats supported are txt, csv, tsv (Added in 1.32), + html, and json. balancesheetequity (bse) - This command displays a balance sheet, showing historical ending bal- - ances of asset, liability and equity accounts. Amounts are shown with + This command displays a balance sheet, showing historical ending bal- + ances of asset, liability and equity accounts. Amounts are shown with normal positive sign, as in conventional financial statements. - This report shows accounts declared with the Asset, Cash, Liability or - Equity type (see account types). Or if no such accounts are declared, - it shows top-level accounts named asset, liability or equity (case in- + This report shows accounts declared with the Asset, Cash, Liability or + Equity type (see account types). Or if no such accounts are declared, + it shows top-level accounts named asset, liability or equity (case in- sensitive, plurals allowed) and their subaccounts. Example: @@ -7027,9 +7080,9 @@ 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 op- @@ -7038,15 +7091,15 @@ PART 4: COMMANDS 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 al- + o under a top-level account named asset (case insensitive, plural al- lowed) o whose name contains some variation of cash, bank, checking or saving. @@ -7075,12 +7128,13 @@ 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 op- - tions The output formats supported are txt, csv, tsv, html, and json. + tions The output formats supported are txt, csv, tsv (Added in 1.32), + html, and json. check Check for various kinds of errors in your data. @@ -7172,124 +7226,145 @@ PART 4: COMMANDS close (equity) - A transaction-generating command which generates several kinds of - "closing" and/or "opening" transactions useful in certain situations. - It prints one or two transactions to stdout, but does not write them to - the journal file; you can append or copy them there when you are happy - with the output. + close generates several kinds of "closing" and/or "opening" transac- + tions, useful in certain situations, including migrating balances to a + new journal file, retaining earnings into equity, consolidating bal- + ances, or viewing lots. Like print, it prints valid journal entries. + You can append or copy these to your journal file(s) when you are happy + with how they look. - This command is most often used when migrating balances to a new jour- - nal file, at the start of a new financial year. It can also be used to - "retain earnings" (transfer revenues and expenses to equity), or as a - sort of generic mover of balances from any group of accounts to some - other account. So it currently has six modes, selected by a mode flag. - Use only one of these flags at a time: + close currently has six modes, selected by a single mode flag: - 1. With --close (or no mode flag) it prints a "closing balances" trans- - action that zeroes out all the asset, liability, and equity account - balances, by default (this requires inferred or declared account - types). Or, it will zero out the accounts matched by any ACCTQUERY - arguments you provide. All of the balances are transferred to a - special "opening/closing balances" equity account. + close --migrate + This is the most common mode. It prints a "closing balances" transac- + tion that zeroes out all asset and liability balances (by default), and + an opposite "opening balances" transaction that restores them again. + The balancing account will be equity:opening/closing balances (or an- + other specified by --close-acct or --open-acct). - 2. With --open, it prints an opposite "opening balances" transaction - that restores the same account balances, starting from zero. This - mode is similar to Ledger's equity command. + This is useful when migrating balances to a new journal file at the + start of a new year. Essentially, you run hledger close --mi- + grate=NEWYEAR -e NEWYEAR and then copy the closing transaction to the + end of the old file and the opening transaction to the start of the new + file. The opening transaction sets correct starting balances in the + new file when it is used alone, and the closing transaction keeps bal- + ances correct when you use both old and new files together, by can- + celling out the following opening transaction and preventing buildup of + duplicated opening balances. Think of the closing/opening pair as + "moving the balances into the next file". - 3. With --migrate, it prints both the closing and opening transactions - above. This is a common way to migrate balances to a new file at - year end; run hledger close --migrate -e NEWYEAR (-e influences the - transaction date) and add the closing transaction at the end of the - old file, and the opening transaction at the start of the new file. - Doing this means you can include past year files in your reports at - any time without disturbing asset/liability/equity balances, because - the closing balances transaction cancels out the following opening - balances transaction. You will sometimes need to exclude these - transactions from reports, eg to see an end of year balance sheet; a - not:opening/closing query argument should do. You should probably - also use this query when close-ing, to exclude the "opening/closing - balances" account which might otherwise cause problems. Or you can - just migrate assets and liabilities: hledger close type:AL. Most - people don't need to migrate equity. And revenues and expenses usu- - ally should not be migrated. + You can close a different set of accounts by providing a query. Eg if + you want to include equity, you can add assets liabilities equity or + type:ALE arguments. (The balancing account is always excluded.) Rev- + enues and expenses usually are not migrated to a new file directly; see + --retain below. - 4. With --assert it prints a "closing balances" transaction that just - asserts the current balances, without changing them. This can be - useful as documention and to guard against errors and changes. + The generated transactions will have a start: tag, with its value set + to --migrate's NEW argument if any, for easier matching or exclusion. + When NEW is not specified, it will be inferred if possible by incre- + menting a number (eg a year number) within the default journal's main + file name. The other modes behave similarly. - 5. With --assign it prints an "opening balances" transaction that re- - stores the account balances using balance assignments. Balance as- - signments work regardless of any previous balance, so a preceding - closing balances transaction is not needed. This is an alternative - to --close and --open: at year end, hledger close --assert -e - NEWYEAR in the old file (optional, but useful for error checking), - and hledger close --assign -e NEWYEAR in the new file. This might - be more convenient, eg if you are often doing cleanups or fixes - which would break closing/opening transactions. + close --close + This prints just the closing balances transaction of --migrate. It is + the default behaviour if you specify no mode flag. Using the customi- + sation options below, you can move balances from any set of accounts to + a different account. - 6. With --retain, it prints a "retain earnings" transaction that trans- - fers revenue and expense balances to equity:retained earnings. This - is a traditional end-of-period bookkeeping operation also called - "closing the books"; in personal accounting you probably will not - need this but it could be useful if you want to see the accounting - equation (A=L+E) balanced. + close --open + This prints just the opening balances transaction of --migrate. It is + similar to Ledger's equity command. + close --assert + This prints a "closing balances" transaction (with balances: tag), that + just declares balance assertions for the current balances without + changing them. It could be useful as documention and to guard against + changes. + + close --assign + This prints an "opening balances" transaction that restores the account + balances using balance assignments. Balance assignments work regard- + less of any previous balance, so a preceding closing balances transac- + tion is not needed. + + However, omitting the closing balances transaction would unbalance eq- + uity. This is relatively harmless for personal reports, but it dis- + turbs the accounting equation, removing a source of error detection. + So --migrate is generally the best way to set to set balances in new + files, for now. + + close --retain + This is like --close with different defaults: it prints a "retain earn- + ings" transaction (with retain: tag), that transfers revenue and ex- + pense balances to equity:retained earnings. + + This is a different kind of closing, called "retaining earnings" or + "closing the books"; it is traditionally performed by businesses at the + end of each accounting period, to consolidate revenues and expenses + into the main equity balance. ("Revenues" and "expenses" are actually + equity by another name, kept separate temporarily for reporting pur- + poses.) + + In personal accounting you generally don't need to do this, unless you + want the balancesheetequity report to show a zero total, demonstrating + that the accounting equation (A-L=E) is satisfied. + + close customisation In all modes, the following things can be overridden: - o the transaction descriptions can be changed with --close-desc=DESC - and --open-desc=DESC + o the accounts to be closed/opened, with account query arguments - o the account to transfer to and from can be changed with - --close-acct=ACCT and --open-acct=ACCT + o the balancing account, with --close-acct=ACCT and/or --open-acct=ACCT - o the accounts to be closed/opened can be changed with ACCTQUERY (ac- - count query arguments). + o the transaction descriptions, with --close-desc=DESC and + --open-desc=DESC - o the closing/opening dates can be changed with -e DATE (a report end - date) + o the transaction's tag value, with a --MODE=NEW option argument - By default just one destination/source posting will be used, with its - amount left implicit. With --x/--explicit, the amount will be shown - explicitly, and if it involves multiple commodities, a separate posting - will be generated for each of them (similar to print -x). + o the closing/opening dates, with -e OPENDATE - With --show-costs, any amount costs are shown, with separate postings - for each cost. This is currently the best way to view investment lots. - If you have many currency conversion or investment transactions, it can - generate very large journal entries. + By default, the closing date is yesterday, or the journal's end date, + whichever is later; and the opening date is always one day after the + closing date. You can change these by specifying a report end date; + the closing date will be the last day of the report period. Eg -e 2024 + means "close on 2023-12-31, open on 2024-01-01". + + With --x/--explicit, the balancing amount will be shown explicitly, and + if it involves multiple commodities, a separate posting will be gener- + ated for each of them (similar to print -x). With --interleaved, each individual transfer is shown with source and - destination postings next to each other. This could be useful for - troubleshooting. + destination postings next to each other (perhaps useful for trou- + bleshooting). - 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 with -e. The last day of the report period will be the closing - date, eg -e 2024 means "close on 2023-12-31". The opening date is al- - ways the day after the closing date. + With --show-costs, balances' costs are also shown, with different costs + kept separate. This may generate very large journal entries, if you + have many currency conversions or investment transactions. close + --show-costs is currently the best way to view investment lots with + hledger. (To move or dispose of lots, see the more capable + hledger-move script.) 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 - there is an opening transaction). + close adds balance assertions verifying that the accounts have been re- + set to zero in a closing transaction or restored to their previous bal- + ances in an opening transaction. These provide useful error checking, + but you can ignore them temporarily with -I, or remove them if you pre- + fer. - These provide useful error checking, but you can ignore them temporar- - ily with -I, or remove them if you prefer. + When running close you should probably avoid using -C, -R, status: + (filtering by status or realness) or --auto (generating postings), + since the generated balance assertions would then require these. - 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 - balance assertions: + Transactions with multiple dates (eg posting dates) spanning the file + boundary also can disrupt the balance assertions: 2023-12-30 a purchase made in december, cleared in january expenses:food 5 assets:bank:checking -5 ; date: 2023-01-02 - To solve that you can transfer the money to and from a temporary ac- - count, in effect splitting the multi-day transaction into two sin- - gle-day transactions: + To solve this you can transfer the money to and from a temporary ac- + count, splitting the multi-day transaction into two single-day transac- + tions: ; in 2022.journal: 2022-12-30 a purchase made in december, cleared in january @@ -7301,76 +7376,43 @@ PART 4: COMMANDS equity:pending 5 = 0 assets:bank:checking -5 - Example: retain earnings + close examples + Retain earnings Record 2022's revenues/expenses as retained earnings on 2022-12-31, ap- pending the generated transaction to the journal: $ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal - Note 2022's income statement will now show only zeroes, because rev- - enues and expenses have been moved entirely to equity. To see them - again, you could exclude the retain transaction: + After this, to see 2022's revenues and expenses you must exclude the + retain earnings transaction: $ hledger -f 2022.journal is not:desc:'retain earnings' - Example: migrate balances to a new file - Close assets/liabilities/equity on 2022-12-31 and re-open them on - 2023-01-01: + Migrate balances to a new file + Close assets/liabilities on 2022-12-31 and re-open them on 2023-01-01: $ hledger close --migrate -f 2022.journal -p 2022 # copy/paste the closing transaction to the end of 2022.journal # copy/paste the opening transaction to the start of 2023.journal - 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 the end-of-year balances - again, you could exclude the closing transaction: + After this, to see 2022's end-of-year balances you must exclude the + closing balances transaction: $ hledger -f 2022.journal bs not:desc:'closing balances' - Example: excluding closing/opening transactions - When combining many files for multi-year reports, the closing/opening - transactions cause some noise in transaction-oriented reports like - print and register. You can exclude them as shown above, but - not:desc:... is not ideal as it depends on consistent descriptions; - also you will want to avoid excluding the very first opening transac- - tion, which could be awkward. Here is one alternative, using tags: + For more flexibility, it helps to tag closing and opening transactions + with eg start:NEWYEAR, then you can ensure correct balances by exclud- + ing all opening/closing transactions except the first, like so: - Add clopen: tags to all opening/closing balances transactions except - the first, like this: + $ hledger bs -Y -f 2021.j -f 2022.j -f 2023.j expr:'tag:start=2021 or not tag:start' + $ hledger bs -Y -f 2021.j -f 2022.j expr:'tag:start=2021 or not tag:start' + $ hledger bs -Y -f 2022.j -f 2023.j expr:'tag:start=2022 or not tag:start' + $ hledger bs -Y -f 2021.j expr:'tag:start=2021 or not tag:start' + $ hledger bs -Y -f 2022.j expr:'tag:start=2022 or not tag:start' + $ hledger bs -Y -f 2023.j # unclosed file, no query needed - ; 2021.journal - 2021-06-01 first opening balances - ... - 2021-12-31 closing balances ; clopen:2022 - ... - - ; 2022.journal - 2022-01-01 opening balances ; clopen:2022 - ... - 2022-12-31 closing balances ; clopen:2023 - ... - - ; 2023.journal - 2023-01-01 opening balances ; clopen:2023 - ... - - Now, assuming a combined journal like: - - ; all.journal - include 2021.journal - include 2022.journal - include 2023.journal - - 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 - - And the year values allow more precision. To show 2022's year-end bal- - ance sheet: - - $ hledger -f all.journal bs -e2023 not:tag:clopen=2023 + More detailed close examples + See examples/multi-year. codes List the codes seen in transactions, in the order parsed. @@ -7662,14 +7704,15 @@ PART 4: COMMANDS sign flipped. This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv, html, and json. + tions The output formats supported are txt, csv, tsv (Added in 1.32), + html, and json. notes List the unique notes that appear in transactions. This command lists the unique notes that appear in transactions, in al- - phabetic order. You can add a query to select a subset of transac- - tions. The note is the part of the transaction description after a | + phabetic order. You can add a query to select a subset of transac- + tions. The note is the part of the transaction description after a | character (or if there is no |, the whole description). Example: @@ -7681,14 +7724,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: @@ -7699,19 +7742,19 @@ PART 4: COMMANDS Person A prices - Print the market prices declared with P directives. With --infer-mar- - ket-prices, also show any additional prices inferred from costs. With + Print the market prices declared with P directives. With --infer-mar- + ket-prices, also show any additional prices inferred from costs. With --show-reverse, also show additional prices inferred by reversing known prices. - Price amounts are always displayed with their full precision, except + Price amounts are always displayed with their full precision, except for reverse prices which are limited to 8 decimal digits. Prices can be filtered by a date:, cur: or amt: query. Generally if you run this command with --infer-market-prices --show-re- - verse, it will show the same prices used internally to calculate value - reports. But if in doubt, you can inspect those directly by running + verse, it will show the same prices used internally to calculate value + reports. But if in doubt, you can inspect those directly by running the value report with --debug=2. print @@ -7720,9 +7763,9 @@ PART 4: COMMANDS The print command displays full journal entries (transactions) from the journal file, sorted by date (or with --date2, by secondary date). - Directives and inter-transaction comments are not shown, currently. + Directives and inter-transaction comments are not shown, currently. This means the print command is somewhat lossy, and if you are using it - to reformat/regenerate your journal you should take care to also copy + to reformat/regenerate your journal you should take care to also copy over the directives and inter-transaction comments. Eg: @@ -7742,33 +7785,34 @@ PART 4: COMMANDS assets:cash $-2 print explicitness - Normally, whether posting amounts are implicit or explicit is pre- + Normally, whether posting amounts are implicit or explicit is pre- served. For example, when an amount is omitted in the journal, it will - not appear in the output. Similarly, if a conversion cost is implied + not appear in the output. Similarly, if a conversion cost is implied but not written, it will not appear in the output. - You can use the -x/--explicit flag to force explicit display of all - amounts and costs. This can be useful for troubleshooting or for mak- - ing your journal more readable and robust against data entry errors. + You can use the -x/--explicit flag to force explicit display of all + amounts and costs. This can be useful for troubleshooting or for mak- + ing your journal more readable and robust against data entry errors. -x is also implied by using any of -B,-V,-X,--value. - The -x/--explicit flag will cause any postings with a multi-commodity - amount (which can arise when a multi-commodity transaction has an im- - plicit amount) to be split into multiple single-commodity postings, + The -x/--explicit flag will cause any postings with a multi-commodity + amount (which can arise when a multi-commodity transaction has an im- + plicit amount) to be split into multiple single-commodity postings, keeping the output parseable. print amount style - Amounts are shown right-aligned within each transaction (but not - aligned across all transactions; you can do that with ledger-mode in + Amounts are shown right-aligned within each transaction (but not + aligned across all transactions; you can do that with ledger-mode in Emacs). - Amounts will be (mostly) normalised to their commodity display style: - their symbol placement, decimal mark, and digit group marks will be - made consistent. By default, decimal digits are shown as they are + Amounts will be (mostly) normalised to their commodity display style: + their symbol placement, decimal mark, and digit group marks will be + made consistent. By default, decimal digits are shown as they are written in the journal. - With the --round option, print will try increasingly hard to display - decimal digits according to the commodity display styles: + With the --round (Added in 1.32) option, print will try increasingly + hard to display decimal digits according to the commodity display + styles: o --round=none show amounts with original precisions (default) @@ -7819,8 +7863,8 @@ PART 4: COMMANDS print output format This command also supports the output destination and output format op- - tions The output formats supported are txt, beancount, csv, tsv, json - and sql. + tions The output formats supported are txt, beancount (Added in 1.32), + csv, tsv (Added in 1.32), json and sql. The beancount format tries to produce Beancount-compatible output, as follows: @@ -8011,17 +8055,18 @@ PART 4: COMMANDS $ hledger reg -w $COLUMNS,40 # use terminal width, & description width 40 This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv, and json. + tions The output formats supported are txt, csv, tsv (Added in 1.32), + and json. rewrite Print all transactions, rewriting the postings of matched transactions. - For now the only rewrite available is adding new postings, like print + 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: @@ -8037,7 +8082,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: @@ -8047,16 +8092,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 in- + factor for an amount of original matched posting. If the amount in- cludes a commodity name, the new posting amount will be in the new com- - modity; otherwise, it will be in the matched posting amount's commod- + modity; otherwise, it will be in the matched posting amount's commod- ity. Re-write rules in a file - During the run this tool will execute so called "Automated Transac- + During the run this tool will execute so called "Automated Transac- tions" found in any journal it process. I.e instead of specifying this operations in command line you can put them in a journal file. @@ -8071,7 +8116,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. @@ -8084,12 +8129,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' @@ -8113,10 +8158,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: @@ -8124,55 +8169,55 @@ 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 ac- - count name) to select your investment(s) with --inv, and another query + At a minimum, you need to supply a query (which could be just an ac- + count name) to select your investment(s) with --inv, and another query to identify your profit and loss transactions with --pnl. - If you do not record changes in the value of your investment manually, - or do not require computation of time-weighted return (TWR), --pnl + If you do not record changes in the value of your investment manually, + or do not require computation of time-weighted return (TWR), --pnl could be an empty query (--pnl "" or --pnl STR where STR does not match any of your accounts). - This command will compute and display the internalized rate of return - (IRR, also known as money-weighted rate of return) and time-weighted - rate of return (TWR) for your investments for the time period re- - quested. IRR is always annualized due to the way it is computed, but - TWR is reported both as a rate over the chosen reporting period and as + This command will compute and display the internalized rate of return + (IRR, also known as money-weighted rate of return) and time-weighted + rate of return (TWR) for your investments for the time period re- + quested. IRR is always annualized due to the way it is computed, but + TWR is reported both as a rate over the chosen reporting period and as an annual rate. - Price directives will be taken into account if you supply appropriate + Price directives will be taken into account if you supply appropriate --cost or --value flags (see VALUATION). Note, in some cases this report can fail, for these reasons: - o Error (NotBracketed): No solution for Internal Rate of Return (IRR). - Possible causes: IRR is huge (>1000000%), balance of investment be- + o Error (NotBracketed): No solution for Internal Rate of Return (IRR). + Possible causes: IRR is huge (>1000000%), balance of investment be- comes negative at some point in time. - o Error (SearchFailed): Failed to find solution for Internal Rate of + o Error (SearchFailed): Failed to find solution for Internal Rate of Return (IRR). Either search does not converge to a solution, or con- verges too slowly. Examples: - o Using roi to compute total return of investment in stocks: + o Using roi to compute total return of investment in stocks: https://github.com/simonmichael/hledger/blob/master/examples/invest- ing/roi-unrealised.ledger @@ -8182,28 +8227,28 @@ 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 as- - sets, or otherwise converting between your investment commodity and + sets, or otherwise converting between your investment commodity and any other commodity. Example: 2019-01-01 Investing in Snake Oil @@ -8220,12 +8265,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 re- + All non-investment postings are assumed to be "cash flow", unless they + match --pnl query. Changes in value of your investment due to "profit + and loss" postings will be considered as part of your investment re- turn. - Example: if you use --inv snake --pnl equity:unrealized, then postings + Example: if you use --inv snake --pnl equity:unrealized, then postings in the example below would be classifed as: 2019-01-01 Snake Oil #1 @@ -8242,58 +8287,58 @@ 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, and the - time between them. Investment at a particular fixed interest rate is - going to give you more interest than the same amount invested at the - same interest rate, but made later in time. If you are withdrawing - from your investment, your future gains would be smaller (in absolute - numbers), and will be a smaller percentage of your initial investment, + Internal rate of return, or "IRR" (also called "money-weighted rate of + return") takes into account effects of in-flows and out-flows, and the + time between them. Investment at a particular fixed interest rate is + going to give you more interest than the same amount invested at the + same interest rate, but made later in time. If you are withdrawing + from your investment, your future gains would be smaller (in absolute + numbers), and will be a smaller percentage of your initial investment, so your IRR will be smaller. And if you are adding to your investment, you will receive bigger absolute gains, which will be a bigger percent- age of your initial investment, so your IRR will be larger. - As mentioned before, in-flows and out-flows would be any cash that you + As mentioned before, in-flows and out-flows would be any cash that you personally put in or withdraw, and for the "roi" command, these are the - postings that match the query in the--inv argument and NOT match the + postings that match the query in the--inv argument and NOT match the query in the--pnl argument. - If you manually record changes in the value of your investment as - transactions that balance them against "profit and loss" (or "unreal- - ized gains") account or use price directives, then in order for IRR to - compute the precise effect of your in-flows and out-flows on the rate - of return, you will need to record the value of your investement on or + If you manually record changes in the value of your investment as + transactions that balance them against "profit and loss" (or "unreal- + ized gains") account or use price directives, then in order for IRR to + compute the precise effect of your in-flows and out-flows on the rate + of return, you will need to record the value of your investement on or close to the days when in- or out-flows occur. - In technical terms, IRR uses the same approach as computation of net + In technical terms, IRR uses the same approach as computation of net present value, and tries to find a discount rate that makes net present value of all the cash flows of your investment to add up to zero. This - could be hard to wrap your head around, especially if you haven't done + could be hard to wrap your head around, especially if you haven't done discounted cash flow analysis before. Implementation of IRR in hledger should produce results that match the =XIRR formula in Excel. - Second way to compute rate of return that roi command implements is - called "time-weighted rate of return" or "TWR". Like IRR, it will ac- - count for the effect of your in-flows and out-flows, but unlike IRR it - will try to compute the true rate of return of the underlying asset, - compensating for the effect that deposits and withdrawas have on the + Second way to compute rate of return that roi command implements is + called "time-weighted rate of return" or "TWR". Like IRR, it will ac- + count for the effect of your in-flows and out-flows, but unlike IRR it + will try to compute the true rate of return of the underlying asset, + compensating for the effect that deposits and withdrawas have on the apparent rate of growth of your investment. - TWR represents your investment as an imaginary "unit fund" where - in-flows/ out-flows lead to buying or selling "units" of your invest- - ment and changes in its value change the value of "investment unit". - Change in "unit price" over the reporting period gives you rate of re- - turn of your investment, and make TWR less sensitive than IRR to the + TWR represents your investment as an imaginary "unit fund" where + in-flows/ out-flows lead to buying or selling "units" of your invest- + ment and changes in its value change the value of "investment unit". + Change in "unit price" over the reporting period gives you rate of re- + turn of your investment, and make TWR less sensitive than IRR to the effects of cash in-flows and out-flows. References: @@ -8306,21 +8351,21 @@ PART 4: COMMANDS o IRR vs TWR - o Examples of computing IRR and TWR and discussion of the limitations + o Examples of computing IRR and TWR and discussion of the limitations of both metrics 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: @@ -8341,7 +8386,7 @@ PART 4: COMMANDS Run time : 0.12 s Throughput : 8342 txns/s - This command supports the -o/--output-file option (but not -O/--out- + This command supports the -o/--output-file option (but not -O/--out- put-format selection). tags @@ -8350,35 +8395,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 -- @@ -8387,11 +8432,11 @@ 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 @@ -8401,37 +8446,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 + To view manuals and introductory docs on the web, visit + https://hledger.org. Chat and mail list support and discussion archives can be found at https://hledger.org/support. Constructing command lines - hledger has a flexible command line interface. We strive to keep it - simple and ergonomic, but if you run into one of the sharp edges de- + hledger has a flexible command line interface. We strive to keep it + simple and ergonomic, but if you run into one of the sharp edges de- scribed in OPTIONS, here are some tips that might help: - o command-specific options must go after the command (it's fine to put + o command-specific options must go after the command (it's fine to put common options there too: hledger CMD OPTS ARGS) - o running add-on executables directly simplifies command line parsing + o running add-on executables directly simplifies command line parsing (hledger-ui OPTS ARGS) o enclose "problematic" args in single quotes - o if needed, also add a backslash to hide regular expression metachar- + o if needed, also add a backslash to hide regular expression metachar- acters from the shell o to see how a misbehaving command line is being parsed, add --debug=2. Starting a journal file - hledger looks for your accounting data in a journal file, + hledger looks for your accounting data in a journal file, $HOME/.hledger.journal by default: $ hledger stats @@ -8439,9 +8484,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 - (see below). It's a good practice to keep this important file under - version control, and to start a new file each year. So you could do + You can override this by setting the LEDGER_FILE environment variable + (see below). It's a good practice to keep this important file under + version control, and to start a new file each year. So you could do something like this: $ mkdir ~/finance @@ -8467,28 +8512,28 @@ PART 5: COMMON TASKS Setting LEDGER_FILE How to set LEDGER_FILE permanently depends on your setup: - On unix and mac, running these commands in the terminal will work for + On unix and mac, running these commands in the terminal will work for many people; adapt as needed: $ echo 'export LEDGER_FILE=~/finance/2023.journal' >> ~/.profile $ source ~/.profile - When correctly configured, in a new terminal window env | grep + When correctly configured, in a new terminal window env | grep LEDGER_FILE will show your file, and so will hledger files. - On mac, this additional step might be helpful for GUI applications - (like Emacs started from the dock): add an entry to ~/.MacOSX/environ- + On mac, this additional step might be helpful for GUI applications + (like Emacs started from the dock): add an entry to ~/.MacOSX/environ- ment.plist like { "LEDGER_FILE" : "~/finance/2023.journal" } - and then run killall Dock in a terminal window (or restart the ma- + and then run killall Dock in a terminal window (or restart the ma- chine). On Windows, see https://www.java.com/en/download/help/path.html, or try - running these commands in a powershell window (let us know if it per- + running these commands in a powershell window (let us know if it per- sists across a reboot, and if you need to be an Administrator): > CD @@ -8496,20 +8541,20 @@ PART 5: COMMON TASKS > SETX LEDGER_FILE "C:\Users\USERNAME\finance\2023.journal" Setting opening balances - Pick a starting date for which you can look up the balances of some - real-world assets (bank accounts, wallet..) and liabilities (credit + Pick a starting date for which you can look up the balances of some + real-world assets (bank accounts, wallet..) and liabilities (credit cards..). - To avoid a lot of data entry, you may want to start with just one or + To avoid a lot of data entry, you may want to start with just one or two accounts, like your checking account or cash wallet; and pick a re- - cent starting date, like today or the start of the week. You can al- - ways come back later and add more accounts and older transactions, eg + cent starting date, like today or the start of the week. You can al- + ways come back later and add more accounts and older transactions, eg going back to january 1st. - Add an opening balances transaction to the journal, declaring the bal- + Add an opening balances transaction to the journal, declaring the bal- ances on this date. Here are two ways to do it: - o The first way: open the journal in any text editor and save an entry + o The first way: open the journal in any text editor and save an entry like this: 2023-01-01 * opening balances @@ -8519,19 +8564,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 @@ -8568,18 +8613,18 @@ PART 5: COMMON TASKS Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2023-01-01]: . - If you're using version control, this could be a good time to commit + If you're using version control, this could be a good time to commit the journal. Eg: $ git commit -m 'initial balances' 2023.journal Recording transactions - As you spend or receive money, you can record these transactions using - one of the methods above (text editor, hledger add) or by using the - hledger-iadd or hledger-web add-ons, or by using the import command to + As you spend or receive money, you can record these transactions using + one of the methods above (text editor, hledger add) or by using the + hledger-iadd or hledger-web add-ons, or by using the import command to convert CSV data downloaded from your bank. - Here are some simple transactions, see the hledger_journal(5) manual + Here are some simple transactions, see the hledger_journal(5) manual and hledger.org for more ideas: 2023/1/10 * gift received @@ -8595,22 +8640,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 al- - ready-recorded transactions. A register report can be helpful - (hledger reg cash). If you can't find the error, add an adjustment + 1. Reconcile cash. Count what's in your wallet. Compare with what + hledger reports (hledger bal cash). If they are different, try to + remember the missing transaction, or look for the error in the al- + ready-recorded transactions. A register report can be helpful + (hledger reg cash). If you can't find the error, add an adjustment transaction. Eg if you have $105 after the above, and can't explain the missing $2, it could be: @@ -8620,26 +8665,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 re- - ported by hledger reg checking -C. This will be easier if you gen- - erally record transaction dates quite similar to your bank's clear- + action history and running balance from your bank with the one re- + ported by hledger reg checking -C. This will be easier if you gen- + erally record transaction dates quite similar to your bank's clear- ing dates. 3. Repeat for other asset/liability accounts. - Tip: instead of the register command, use hledger-ui to see a live-up- + Tip: instead of the register command, use hledger-ui to see a live-up- dating register while you edit the journal: hledger-ui --watch --regis- ter checking -C - After reconciling, it could be a good time to mark the reconciled - transactions' status as "cleared and confirmed", if you want to track - that, by adding the * marker. Eg in the paycheck transaction above, + After reconciling, it could be a good time to mark the reconciled + transactions' status as "cleared and confirmed", if you want to track + that, by adding the * marker. Eg in the paycheck transaction above, insert * between 2023-01-15 and paycheck - If you're using version control, this can be another good time to com- + If you're using version control, this can be another good time to com- mit: $ git commit -m 'txns' 2023.journal @@ -8711,7 +8756,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 @@ -8721,7 +8766,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 @@ -8788,70 +8833,70 @@ PART 5: COMMON TASKS 2023-01-13 **** Migrating to a new file - At the end of the year, you may want to continue your journal in a new + At the end of the year, you may want to continue your journal in a new file, so that old transactions don't slow down or clutter your reports, - and to help ensure the integrity of your accounting history. See the + and to help ensure the integrity of your accounting history. See the close command. If using version control, don't forget to git add the new file. BUGS We welcome bug reports in the hledger issue tracker (shortcut: - http://bugs.hledger.org), or on the #hledger chat or hledger mail list + http://bugs.hledger.org), or on the #hledger chat or hledger mail list (https://hledger.org/support). Some known issues and limitations: - The need to precede add-on command options with -- when invoked from + The need to precede add-on command options with -- when invoked from hledger is awkward. (See Command options, Constructing command lines.) - A UTF-8-aware system locale must be configured to work with non-ascii + A UTF-8-aware system locale must be configured to work with non-ascii data. (See Unicode characters, Troubleshooting.) On Microsoft Windows, depending whether you are running in a CMD window or a Cygwin/MSYS/Mintty window and how you installed hledger, non-ascii characters and colours may not be supported, and the tab key may not be - supported by hledger add. (Running in a WSL window should resolve + supported by hledger add. (Running in a WSL window should resolve these.) When processing large data files, hledger uses more memory than Ledger. Troubleshooting - Here are some common issues you might encounter when you run hledger, - and how to resolve them (and remember also you can usually get quick + Here are some common issues you might encounter when you run hledger, + and how to resolve them (and remember also you can usually get quick Support): PATH issues: I get an error like "No command 'hledger' found" Depending how you installed hledger, the executables may not be in your - shell's PATH. Eg on unix systems, stack installs hledger in ~/.lo- + shell's PATH. Eg on unix systems, stack installs hledger in ~/.lo- cal/bin and cabal installs it in ~/.cabal/bin. You may need to add one - of these directories to your shell's PATH, and/or open a new terminal + of these directories to your shell's PATH, and/or open a new terminal window. - LEDGER_FILE issues: I configured LEDGER_FILE but hledger is not using + LEDGER_FILE issues: I configured LEDGER_FILE but hledger is not using it - o LEDGER_FILE should be a real environment variable, not just a shell + o LEDGER_FILE should be a real environment variable, not just a shell variable. Eg on unix, the command env | grep LEDGER_FILE should show - it. You may need to use export (see https://stackover- + it. You may need to use export (see https://stackover- flow.com/a/7411509). - o You may need to force your shell to see the new configuration. A + o You may need to force your shell to see the new configuration. A simple way is to close your terminal window and open a new one. - LANG issues: I get errors like "Illegal byte sequence" or "Invalid or + LANG issues: I get errors like "Illegal byte sequence" or "Invalid or incomplete multibyte or wide character" or "commitAndReleaseBuffer: in- valid argument (invalid character)" - Programs compiled with GHC (hledger, haskell build tools, etc.) need - the system locale to be UTF-8-aware, or they will fail when they en- - counter non-ascii characters. To fix it, set the LANG environment - variable to a locale which supports UTF-8 and which is installed on + Programs compiled with GHC (hledger, haskell build tools, etc.) need + the system locale to be UTF-8-aware, or they will fail when they en- + counter non-ascii characters. To fix it, set the LANG environment + variable to a locale which supports UTF-8 and which is installed on your system. - On unix, locale -a lists the installed locales. Look for one which - mentions utf8, UTF-8 or similar. Some examples: C.UTF-8, en_US.utf-8, - fr_FR.utf8. If necessary, use your system package manager to install - one. Then select it by setting the LANG environment variable. Note, - exact spelling and capitalisation of the locale name may be important: + On unix, locale -a lists the installed locales. Look for one which + mentions utf8, UTF-8 or similar. Some examples: C.UTF-8, en_US.utf-8, + fr_FR.utf8. If necessary, use your system package manager to install + one. Then select it by setting the LANG environment variable. Note, + exact spelling and capitalisation of the locale name may be important: Here's one common way to configure this permanently for your shell: $ echo "export LANG=en_US.utf8" >>~/.profile @@ -8864,7 +8909,7 @@ BUGS # close and re-open terminal window COMPATIBILITY ISSUES: hledger gives an error with my Ledger file - Not all of Ledger's journal file syntax or feature set is supported. + Not all of Ledger's journal file syntax or feature set is supported. See hledger and Ledger for full details.