From 986a55218b9819ce6a2d1e9f11fe5b6278840a71 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 12 Jun 2025 19:06:40 -1000 Subject: [PATCH] ;doc: update embedded manuals --- hledger-ui/hledger-ui.1 | 3 + hledger-ui/hledger-ui.info | 33 +- hledger-ui/hledger-ui.txt | 3 + hledger-web/hledger-web.1 | 3 + hledger-web/hledger-web.info | 19 +- hledger-web/hledger-web.txt | 3 + hledger/hledger.1 | 96 +- hledger/hledger.info | 830 +++++++++--------- hledger/hledger.txt | 1593 +++++++++++++++++----------------- 9 files changed, 1325 insertions(+), 1258 deletions(-) diff --git a/hledger-ui/hledger-ui.1 b/hledger-ui/hledger-ui.1 index 70ddc0609..6f68ff1ef 100644 --- a/hledger-ui/hledger-ui.1 +++ b/hledger-ui/hledger-ui.1 @@ -89,6 +89,9 @@ General input/data transformation flags: hledger\-ui, also make future\-dated transactions visible at startup. \-I \-\-ignore\-assertions don\[aq]t check balance assertions by default + \-\-txn\-balancing=... how to check that transactions are balanced: + \[aq]old\[aq]: use global display precision + \[aq]exact\[aq]: use transaction precision (default) \-\-infer\-costs infer conversion equity postings from costs \-\-infer\-equity infer costs from conversion equity postings \-\-infer\-market\-prices infer market prices from costs diff --git a/hledger-ui/hledger-ui.info b/hledger-ui/hledger-ui.info index 6b7f6b374..bf47a6cfc 100644 --- a/hledger-ui/hledger-ui.info +++ b/hledger-ui/hledger-ui.info @@ -100,6 +100,9 @@ General input/data transformation flags: hledger-ui, also make future-dated transactions visible at startup. -I --ignore-assertions don't check balance assertions by default + --txn-balancing=... how to check that transactions are balanced: + 'old': use global display precision + 'exact': use transaction precision (default) --infer-costs infer conversion equity postings from costs --infer-equity infer costs from conversion equity postings --infer-market-prices infer market prices from costs @@ -563,21 +566,21 @@ with the UI unresponsive. Tag Table: Node: Top221 Node: OPTIONS1872 -Node: MOUSE8546 -Node: KEYS8878 -Node: SCREENS13882 -Node: Menu screen14622 -Node: Cash accounts screen14938 -Node: Balance sheet accounts screen15299 -Node: Income statement accounts screen15635 -Node: All accounts screen16020 -Node: Register screen16383 -Node: Transaction screen18826 -Node: Error screen20401 -Node: WATCH MODE20767 -Node: --watch problems21665 -Node: ENVIRONMENT23018 -Node: BUGS23251 +Node: MOUSE8758 +Node: KEYS9090 +Node: SCREENS14094 +Node: Menu screen14834 +Node: Cash accounts screen15150 +Node: Balance sheet accounts screen15511 +Node: Income statement accounts screen15847 +Node: All accounts screen16232 +Node: Register screen16595 +Node: Transaction screen19038 +Node: Error screen20613 +Node: WATCH MODE20979 +Node: --watch problems21877 +Node: ENVIRONMENT23230 +Node: BUGS23463  End Tag Table diff --git a/hledger-ui/hledger-ui.txt b/hledger-ui/hledger-ui.txt index 70e89e3c4..5d724b6c7 100644 --- a/hledger-ui/hledger-ui.txt +++ b/hledger-ui/hledger-ui.txt @@ -78,6 +78,9 @@ OPTIONS hledger-ui, also make future-dated transactions visible at startup. -I --ignore-assertions don't check balance assertions by default + --txn-balancing=... how to check that transactions are balanced: + 'old': use global display precision + 'exact': use transaction precision (default) --infer-costs infer conversion equity postings from costs --infer-equity infer costs from conversion equity postings --infer-market-prices infer market prices from costs diff --git a/hledger-web/hledger-web.1 b/hledger-web/hledger-web.1 index f285903e6..28061c333 100644 --- a/hledger-web/hledger-web.1 +++ b/hledger-web/hledger-web.1 @@ -139,6 +139,9 @@ General input/data transformation flags: hledger\-ui, also make future\-dated transactions visible at startup. \-I \-\-ignore\-assertions don\[aq]t check balance assertions by default + \-\-txn\-balancing=... how to check that transactions are balanced: + \[aq]old\[aq]: use global display precision + \[aq]exact\[aq]: use transaction precision (default) \-\-infer\-costs infer conversion equity postings from costs \-\-infer\-equity infer costs from conversion equity postings \-\-infer\-market\-prices infer market prices from costs diff --git a/hledger-web/hledger-web.info b/hledger-web/hledger-web.info index 63673b92c..90f3ebc70 100644 --- a/hledger-web/hledger-web.info +++ b/hledger-web/hledger-web.info @@ -144,6 +144,9 @@ General input/data transformation flags: hledger-ui, also make future-dated transactions visible at startup. -I --ignore-assertions don't check balance assertions by default + --txn-balancing=... how to check that transactions are balanced: + 'old': use global display precision + 'exact': use transaction precision (default) --infer-costs infer conversion equity postings from costs --infer-equity infer costs from conversion equity postings --infer-market-prices infer market prices from costs @@ -526,14 +529,14 @@ We welcome bug reports in the hledger issue tracker Tag Table: Node: Top223 Node: OPTIONS2581 -Node: PERMISSIONS11270 -Node: EDITING UPLOADING DOWNLOADING12420 -Node: RELOADING13435 -Node: JSON API14002 -Node: DEBUG OUTPUT19651 -Node: Debug output19803 -Node: ENVIRONMENT20321 -Node: BUGS20557 +Node: PERMISSIONS11482 +Node: EDITING UPLOADING DOWNLOADING12632 +Node: RELOADING13647 +Node: JSON API14214 +Node: DEBUG OUTPUT19863 +Node: Debug output20015 +Node: ENVIRONMENT20533 +Node: BUGS20769  End Tag Table diff --git a/hledger-web/hledger-web.txt b/hledger-web/hledger-web.txt index dbbb18042..48916e440 100644 --- a/hledger-web/hledger-web.txt +++ b/hledger-web/hledger-web.txt @@ -121,6 +121,9 @@ OPTIONS hledger-ui, also make future-dated transactions visible at startup. -I --ignore-assertions don't check balance assertions by default + --txn-balancing=... how to check that transactions are balanced: + 'old': use global display precision + 'exact': use transaction precision (default) --infer-costs infer conversion equity postings from costs --infer-equity infer costs from conversion equity postings --infer-market-prices infer market prices from costs diff --git a/hledger/hledger.1 b/hledger/hledger.1 index 1e1ad8ec0..791a60f97 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -379,6 +379,9 @@ General input/data transformation flags: hledger\-ui, also make future\-dated transactions visible at startup. \-I \-\-ignore\-assertions don\[aq]t check balance assertions by default + \-\-txn\-balancing=... how to check that transactions are balanced: + \[aq]old\[aq]: use global display precision + \[aq]exact\[aq]: use transaction precision (default) \-\-infer\-costs infer conversion equity postings from costs \-\-infer\-equity infer costs from conversion equity postings \-\-infer\-market\-prices infer market prices from costs @@ -2298,44 +2301,52 @@ they may contain tags, which are not ignored. .EE .SS Transaction balancing How exactly does hledger decide when a transaction is balanced ? -The general goal is that if you look at the journal entry and calculate -the amounts\[aq] sum perfectly with pencil and paper, hledger should -agree with you. +Especially when it involves costs, which often are not exact, because of +repeating decimals, or imperfect data from financial institutions ? +In each commodity, hledger sums the transaction\[aq]s posting amounts, +after converting any with costs; then it checks if that sum is zero, +when rounded to a suitable number of decimal digits \- which we call the +\f[I]balancing precision\f[R]. .PP -Real world transactions, especially for investments or cryptocurrencies, -often involve imprecise costs, complex decimals, and/or -infinitely\-recurring decimals, which are difficult or inconvenient to -handle on a computer. -So to be a practical accounting system, hledger allows some imprecision -when checking transaction balancedness. -The question is, how much imprecision should be allowed ? +Since version 1.50, hledger infers balancing precision in each +transaction from the amounts in that transaction\[aq]s journal entry +(like Ledger). +Ie, when checking the balance of commodity A, it uses the highest +decimal precision seen for A in the journal entry (excluding cost +amounts). +This makes transaction balancing robust; any imbalances must be visibly +accounted for in the journal entry, display precision can be freely +increased with \f[CR]\-c\f[R], and compatibility with Ledger and +Beancount journals is good. .PP -hledger currently decides it based on the commodity display styles: if -the postings\[aq] sum would appear to be zero when displayed with the -standard display precisions, the transaction is considered balanced. -.PP -Or equivalently: if the journal entry is displayed with amounts rounded -to the standard display precisions (with -\f[CR]hledger print \-\-round=hard\f[R]), and a human with pencil and -paper would agree that those displayed amounts add up to zero, the -transaction is considered balanced. -.PP -This has some advantages: it is fairly intuitive, general not -hard\-coded, yet configurable when needed. -On the downside it means that transaction balancedness is related to -commodity display precisions, so eg when using -\f[CR]\-c/\-\-commodity\-style\f[R] to display things with more than -usual precision, you might need to fix some of your journal entries (ie, -add decimal digits to make them balance more precisely). -.PP -Other PTA tools (Ledger, Beancount..) -have their own ways of doing it. -Possible improvements are discussed at #1964. -.PP -Note: if you have multiple journal files, and are relying on commodity -directives to make imprecise journal entries balance, the -directives\[aq] placement might be important \- see \f[CR]commodity\f[R] -directive. +Note that hledger versions before 1.50 worked differently: they allowed +display precision to override the balancing precision. +This masked small imbalances and caused fragility (see issue #2402). +As a result, some journal entries (or CSV rules) that worked with +hledger <1.50, are now rejected with an \[dq]unbalanced transaction\[dq] +error. +If you hit this problem, it\[aq]s easy to fix: +.IP \[bu] 2 +You can restore the old behaviour, by adding +\f[CR]\-\-txn\-balancing=old\f[R] to the command or to your +\f[CR]\[ti]/.hledger.conf\f[R] file. +This lets you keep using old journals unchanged, though without the +above benefits. +.IP \[bu] 2 +Or you can fix the problem entries (recommended). +There are three ways, use whichever seems best: +.RS 2 +.IP "1." 3 +make cost amounts more precise (add more/better decimal digits) +.IP "2." 3 +or make non\-cost amounts less precise (remove unnecessary decimal +digits that are raising the precision) +.IP "3." 3 +or add a posting to absorb the imbalance (eg +\[dq]expenses:rounding\[dq]. +Remember that one posting may omit the amount; that\[aq]s convenient +here.) +.RE .SS Tags Tags are a way to add extra labels or data fields to transactions, postings, or accounts. @@ -8439,10 +8450,19 @@ T} \f[CR]\-H\f[R] but with a zero starting balance. .SH PART 4: COMMANDS .PP -Here are the standard commands, which you can list by running -\f[CR]hledger\f[R]. +Here are hledger\[aq]s standard subcommands. +You can list these by running \f[CR]hledger\f[R]. If you have installed more add\-on commands, they also will be listed. .PP +In the following command docs, each command\[aq]s specific options are +shown. +Most commands also support the general options described above, though +some of them might have no effect. +(Usually if there\[aq]s a sensible way for a general option to affect a +command, it will.) +You can list all of a command\[aq]s options by running +\f[CR]hledger CMD \-h\f[R]. +.PP \f[B]Help commands\f[R] .IP \[bu] 2 commands \- show the hledger commands list (default) diff --git a/hledger/hledger.info b/hledger/hledger.info index 20a183d51..5ad7478f4 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -394,6 +394,9 @@ General input/data transformation flags: hledger-ui, also make future-dated transactions visible at startup. -I --ignore-assertions don't check balance assertions by default + --txn-balancing=... how to check that transactions are balanced: + 'old': use global display precision + 'exact': use transaction precision (default) --infer-costs infer conversion equity postings from costs --infer-equity infer costs from conversion equity postings --infer-market-prices infer market prices from costs @@ -2355,41 +2358,45 @@ File: hledger.info, Node: Transaction balancing, Next: Tags, Prev: Posting co 8.14 Transaction balancing ========================== -How exactly does hledger decide when a transaction is balanced ? The -general goal is that if you look at the journal entry and calculate the -amounts' sum perfectly with pencil and paper, hledger should agree with -you. +How exactly does hledger decide when a transaction is balanced ? +Especially when it involves costs, which often are not exact, because of +repeating decimals, or imperfect data from financial institutions ? In +each commodity, hledger sums the transaction's posting amounts, after +converting any with costs; then it checks if that sum is zero, when +rounded to a suitable number of decimal digits - which we call the +_balancing precision_. - Real world transactions, especially for investments or -cryptocurrencies, often involve imprecise costs, complex decimals, -and/or infinitely-recurring decimals, which are difficult or -inconvenient to handle on a computer. So to be a practical accounting -system, hledger allows some imprecision when checking transaction -balancedness. The question is, how much imprecision should be allowed ? + Since version 1.50, hledger infers balancing precision in each +transaction from the amounts in that transaction's journal entry (like +Ledger). Ie, when checking the balance of commodity A, it uses the +highest decimal precision seen for A in the journal entry (excluding +cost amounts). This makes transaction balancing robust; any imbalances +must be visibly accounted for in the journal entry, display precision +can be freely increased with '-c', and compatibility with Ledger and +Beancount journals is good. - hledger currently decides it based on the commodity display styles: -if the postings' sum would appear to be zero when displayed with the -standard display precisions, the transaction is considered balanced. + Note that hledger versions before 1.50 worked differently: they +allowed display precision to override the balancing precision. This +masked small imbalances and caused fragility (see issue #2402). As a +result, some journal entries (or CSV rules) that worked with hledger +<1.50, are now rejected with an "unbalanced transaction" error. If you +hit this problem, it's easy to fix: - Or equivalently: if the journal entry is displayed with amounts -rounded to the standard display precisions (with 'hledger print ---round=hard'), and a human with pencil and paper would agree that those -displayed amounts add up to zero, the transaction is considered -balanced. + * You can restore the old behaviour, by adding '--txn-balancing=old' + to the command or to your '~/.hledger.conf' file. This lets you + keep using old journals unchanged, though without the above + benefits. - This has some advantages: it is fairly intuitive, general not -hard-coded, yet configurable when needed. On the downside it means that -transaction balancedness is related to commodity display precisions, so -eg when using '-c/--commodity-style' to display things with more than -usual precision, you might need to fix some of your journal entries (ie, -add decimal digits to make them balance more precisely). + * Or you can fix the problem entries (recommended). There are three + ways, use whichever seems best: - Other PTA tools (Ledger, Beancount..) have their own ways of doing -it. Possible improvements are discussed at #1964. - - Note: if you have multiple journal files, and are relying on -commodity directives to make imprecise journal entries balance, the -directives' placement might be important - see 'commodity' directive. + 1. make cost amounts more precise (add more/better decimal + digits) + 2. or make non-cost amounts less precise (remove unnecessary + decimal digits that are raising the precision) + 3. or add a posting to absorb the imbalance (eg + "expenses:rounding". Remember that one posting may omit the + amount; that's convenient here.)  File: hledger.info, Node: Tags, Next: Directives, Prev: Transaction balancing, Up: Journal @@ -8112,8 +8119,15 @@ File: hledger.info, Node: PART 4 COMMANDS, Next: Help commands, Prev: Value r 23 PART 4: COMMANDS ******************* -Here are the standard commands, which you can list by running 'hledger'. -If you have installed more add-on commands, they also will be listed. +Here are hledger's standard subcommands. You can list these by running +'hledger'. If you have installed more add-on commands, they also will +be listed. + + In the following command docs, each command's specific options are +shown. Most commands also support the general options described above, +though some of them might have no effect. (Usually if there's a +sensible way for a general option to affect a command, it will.) You +can list all of a command's options by running 'hledger CMD -h'. *Help commands* @@ -12798,382 +12812,382 @@ Node: Strict mode9203 Node: Commands10037 Node: Add-on commands11319 Node: Options12537 -Node: Special characters19280 -Node: Escaping shell special characters20230 -Node: Escaping on Windows21474 -Node: Escaping regular expression special characters22207 -Node: Escaping add-on arguments23194 -Node: Escaping in other situations24223 -Node: Using a wild card25182 -Node: Unicode characters25561 -Node: Regular expressions26982 -Node: hledger's regular expressions30241 -Node: Argument files31882 -Node: Config files32585 -Node: Shell completions35886 -Node: Output36375 -Node: Output destination36566 -Node: Output format37124 -Node: Text output38910 -Node: Box-drawing characters39889 -Node: Colour40389 -Node: Paging40975 -Node: HTML output42501 -Node: CSV / TSV output42919 -Node: FODS output43173 -Node: Beancount output43977 -Node: Beancount account names45478 -Node: Beancount commodity names46019 -Node: Beancount virtual postings46666 -Node: Beancount metadata46982 -Node: Beancount costs47762 -Node: Beancount operating currency48178 -Node: SQL output48628 -Node: JSON output49419 -Node: Commodity styles50236 -Node: Debug output51123 -Node: Environment51955 -Node: PART 2 DATA FORMATS52612 -Node: Journal52755 -Node: Journal cheatsheet55233 -Node: Comments61484 -Node: Transactions62428 -Node: Dates63565 -Node: Simple dates63717 -Node: Posting dates64333 -Node: Status65420 -Node: Code67186 -Node: Description67521 -Node: Payee and note68208 -Node: Transaction comments69299 -Node: Postings69815 -Node: Debits and credits70978 -Node: The two space delimiter71588 -Node: Account names72153 -Node: Amounts73957 -Node: Decimal marks74986 -Node: Digit group marks76090 -Node: Commodity76725 -Node: Costs77842 -Node: Balance assertions80094 -Node: Assertions and ordering81342 -Node: Assertions and multiple files82061 -Node: Assertions and costs83229 -Node: Assertions and commodities83876 -Node: Assertions and subaccounts85535 -Node: Assertions and status86195 -Node: Assertions and virtual postings86615 -Node: Assertions and auto postings86980 -Node: Assertions and precision87855 -Node: Assertions and hledger add88339 -Node: Posting comments89087 -Node: Transaction balancing89627 -Node: Tags91629 -Node: Querying with tags92923 -Node: Displaying tags93722 -Node: When to use tags ?94118 -Node: Tag names94782 -Node: Special tags95335 -Node: Directives96900 -Node: Directives and multiple files98357 -Node: Directive effects99302 -Node: account directive102458 -Node: Account comments103908 -Node: Account error checking104567 -Node: Account display order106104 -Node: Account types107302 -Node: alias directive110577 -Node: Basic aliases111788 -Node: Regex aliases112663 -Node: Combining aliases113710 -Node: Aliases and multiple files115164 -Node: end aliases directive115947 -Node: Aliases can generate bad account names116315 -Node: Aliases and account types117148 -Node: commodity directive118040 -Node: Commodity directive syntax119627 -Node: Commodity error checking121276 -Node: decimal-mark directive121751 -Node: include directive122330 -Node: P directive123406 -Node: payee directive124440 -Node: tag directive125062 -Node: Periodic transactions125674 -Node: Periodic rule syntax127828 -Node: Periodic rules and relative dates128651 -Node: Two spaces between period expression and description!129428 -Node: Auto postings130389 -Node: Auto postings and multiple files133549 -Node: Auto postings and dates133954 -Node: Auto postings and transaction balancing / inferred amounts / balance assertions134395 -Node: Auto posting tags135241 -Node: Auto postings on forecast transactions only136136 -Node: Other syntax136606 -Node: Balance assignments137378 -Node: Balance assignments and costs138906 -Node: Balance assignments and multiple files139328 -Node: Bracketed posting dates139751 -Node: D directive140449 -Node: apply account directive142222 -Node: Y directive143089 -Node: Secondary dates144077 -Node: Star comments145562 -Node: Valuation expressions146254 -Node: Virtual postings146553 -Node: Other Ledger directives148177 -Node: Other cost/lot notations148939 -Node: CSV151780 -Node: CSV rules cheatsheet153934 -Node: source155961 -Node: encoding156961 -Node: separator158003 -Node: skip158656 -Node: date-format159306 -Node: timezone160149 -Node: newest-first161275 -Node: intra-day-reversed161988 -Node: decimal-mark162588 -Node: fields list163068 -Node: Field assignment164876 -Node: Field names166095 -Node: date field167427 -Node: date2 field167591 -Node: status field167786 -Node: code field167976 -Node: description field168164 -Node: comment field168381 -Node: account field168938 -Node: amount field169656 -Node: currency field172495 -Node: balance field172903 -Node: if block173426 -Node: Matchers174953 -Node: Multiple matchers176943 -Node: Match groups177751 -Node: if table178644 -Node: balance-type180707 -Node: include181534 -Node: Working with CSV182103 -Node: Rapid feedback182655 -Node: Valid CSV183238 -Node: File Extension184114 -Node: Reading CSV from standard input184849 -Node: Reading multiple CSV files185235 -Node: Reading files specified by rule185711 -Node: Valid transactions187108 -Node: Deduplicating importing187933 -Node: Setting amounts189162 -Node: Amount signs191689 -Node: Setting currency/commodity192754 -Node: Amount decimal places194130 -Node: Referencing other fields195387 -Node: How CSV rules are evaluated196495 -Node: Well factored rules199212 -Node: CSV rules examples199702 -Node: Bank of Ireland199900 -Node: Coinbase201497 -Node: Amazon202680 -Node: Paypal204522 -Node: Timeclock212272 -Node: Timedot215097 -Node: Timedot examples218574 -Node: PART 3 REPORTING CONCEPTS220851 -Node: Time periods221015 -Node: Report start & end date221288 -Node: Smart dates222764 -Node: Report intervals224707 -Node: Date adjustments225281 -Node: Start date adjustment225501 -Node: End date adjustment226404 -Node: Period headings227149 -Node: Period expressions228082 -Node: Period expressions with a report interval229987 -Node: More complex report intervals230435 -Node: Multiple weekday intervals232551 -Node: Depth233562 -Node: Queries235397 -Node: Query types238069 -Node: acct query238444 -Node: amt query238755 -Node: code query239452 -Node: cur query239647 -Node: desc query240253 -Node: date query240436 -Node: date2 query240832 -Node: depth query241123 -Node: note query241459 -Node: payee query241725 -Node: real query242006 -Node: status query242211 -Node: type query242451 -Node: tag query242984 -Node: Negative queries243613 -Node: not query243795 -Node: Space-separated queries244082 -Node: Boolean queries244770 -Node: expr query246088 -Node: any query246768 -Node: all query247221 -Node: Queries and command options247767 -Node: Queries and account aliases248215 -Node: Queries and valuation248540 -Node: Pivoting248902 -Node: Generating data251178 -Node: Forecasting252978 -Node: --forecast253634 -Node: Inspecting forecast transactions254735 -Node: Forecast reports256068 -Node: Forecast tags257177 -Node: Forecast period in detail257797 -Node: Forecast troubleshooting258885 -Node: Budgeting259956 -Node: Amount formatting260516 -Node: Commodity display style260760 -Node: Rounding262601 -Node: Trailing decimal marks263206 -Node: Amount parseability264139 -Node: Cost reporting265748 -Node: Recording costs266579 -Node: Reporting at cost268306 -Node: Equity conversion postings269071 -Node: Inferring equity conversion postings271716 -Node: Combining costs and equity conversion postings272858 -Node: Requirements for detecting equity conversion postings274083 -Node: Infer cost and equity by default ?275605 -Node: Value reporting276042 -Node: -V Value276978 -Node: -X Value in specified commodity277305 -Node: Valuation date277655 -Node: Finding market price278615 -Node: --infer-market-prices market prices from transactions279995 -Node: Valuation commodity283039 -Node: --value Flexible valuation284472 -Node: Valuation examples286315 -Node: Interaction of valuation and queries288447 -Node: Effect of valuation on reports289164 -Node: PART 4 COMMANDS297062 -Node: Help commands299497 -Node: commands299683 -Node: demo299891 -Node: help301125 -Node: User interface commands302830 -Node: repl303041 -Node: Examples305305 -Node: run305863 -Node: Examples 2308278 -Node: ui309302 -Node: web309439 -Node: Data entry commands309567 -Node: add309765 -Node: import312220 -Node: Import preview313254 -Node: Overlap detection314202 -Node: First import317088 -Node: Importing balance assignments318283 -Node: Import and commodity styles319338 -Node: Import special cases319776 -Node: Basic report commands321111 -Node: accounts321412 -Node: codes324345 -Node: commodities325367 -Node: descriptions325611 -Node: files326078 -Node: notes326375 -Node: payees326887 -Node: prices327671 -Node: stats328563 -Node: tags330304 -Node: Standard report commands331611 -Node: print331916 -Node: print explicitness334727 -Node: print amount style335647 -Node: print parseability336885 -Node: print other features337804 -Node: print output format338765 -Node: aregister342050 -Node: aregister and posting dates346603 -Node: register347504 -Node: Custom register output354745 -Node: balancesheet355930 -Node: balancesheetequity360895 -Node: cashflow366230 -Node: incomestatement371043 -Node: Advanced report commands375892 -Node: balance376100 -Node: balance features381521 -Node: Simple balance report383624 -Node: Balance report line format385434 -Node: Filtered balance report387794 -Node: List or tree mode388313 -Node: Depth limiting389826 -Node: Dropping top-level accounts390593 -Node: Showing declared accounts391103 -Node: Sorting by amount391833 -Node: Percentages392687 -Node: Multi-period balance report393394 -Node: Balance change end balance396146 -Node: Balance report modes397783 -Node: Calculation mode398462 -Node: Accumulation mode399166 -Node: Valuation mode400267 -Node: Combining balance report modes401611 -Node: Budget report403641 -Node: Using the budget report405941 -Node: Budget date surprises408217 -Node: Selecting budget goals409581 -Node: Budgeting vs forecasting410529 -Node: Balance report layout412206 -Node: Wide layout413411 -Node: Tall layout415816 -Node: Bare layout417122 -Node: Tidy layout419186 -Node: Balance report output420730 -Node: Some useful balance reports421504 -Node: roi422764 -Node: Spaces and special characters in --inv and --pnl425011 -Node: Semantics of --inv and --pnl425737 -Node: IRR and TWR explained427824 -Node: Chart commands431235 -Node: activity431416 -Node: Data generation commands431913 -Node: close432119 -Node: close --clopen434682 -Node: close --close436856 -Node: close --open437380 -Node: close --assert437630 -Node: close --assign437957 -Node: close --retain438636 -Node: close customisation439493 -Node: close and balance assertions441137 -Node: close examples442659 -Node: Retain earnings442896 -Node: Migrate balances to a new file443399 -Node: More detailed close examples444761 -Node: rewrite444983 -Node: Re-write rules in a file447555 -Node: Diff output format448865 -Node: rewrite vs print --auto450138 -Node: Maintenance commands450852 -Node: check451071 -Node: Basic checks452153 -Node: Strict checks453174 -Node: Other checks454111 -Node: Custom checks455863 -Node: diff456318 -Node: setup457526 -Node: test460393 -Node: PART 5 COMMON TASKS461296 -Node: Getting help461529 -Node: Constructing command lines462438 -Node: Starting a journal file463276 -Node: Setting LEDGER_FILE464660 -Node: Setting opening balances465918 -Node: Recording transactions469240 -Node: Reconciling469965 -Node: Reporting472354 -Node: Migrating to a new file476468 -Node: BUGS476917 -Node: Troubleshooting477885 +Node: Special characters19492 +Node: Escaping shell special characters20442 +Node: Escaping on Windows21686 +Node: Escaping regular expression special characters22419 +Node: Escaping add-on arguments23406 +Node: Escaping in other situations24435 +Node: Using a wild card25394 +Node: Unicode characters25773 +Node: Regular expressions27194 +Node: hledger's regular expressions30453 +Node: Argument files32094 +Node: Config files32797 +Node: Shell completions36098 +Node: Output36587 +Node: Output destination36778 +Node: Output format37336 +Node: Text output39122 +Node: Box-drawing characters40101 +Node: Colour40601 +Node: Paging41187 +Node: HTML output42713 +Node: CSV / TSV output43131 +Node: FODS output43385 +Node: Beancount output44189 +Node: Beancount account names45690 +Node: Beancount commodity names46231 +Node: Beancount virtual postings46878 +Node: Beancount metadata47194 +Node: Beancount costs47974 +Node: Beancount operating currency48390 +Node: SQL output48840 +Node: JSON output49631 +Node: Commodity styles50448 +Node: Debug output51335 +Node: Environment52167 +Node: PART 2 DATA FORMATS52824 +Node: Journal52967 +Node: Journal cheatsheet55445 +Node: Comments61696 +Node: Transactions62640 +Node: Dates63777 +Node: Simple dates63929 +Node: Posting dates64545 +Node: Status65632 +Node: Code67398 +Node: Description67733 +Node: Payee and note68420 +Node: Transaction comments69511 +Node: Postings70027 +Node: Debits and credits71190 +Node: The two space delimiter71800 +Node: Account names72365 +Node: Amounts74169 +Node: Decimal marks75198 +Node: Digit group marks76302 +Node: Commodity76937 +Node: Costs78054 +Node: Balance assertions80306 +Node: Assertions and ordering81554 +Node: Assertions and multiple files82273 +Node: Assertions and costs83441 +Node: Assertions and commodities84088 +Node: Assertions and subaccounts85747 +Node: Assertions and status86407 +Node: Assertions and virtual postings86827 +Node: Assertions and auto postings87192 +Node: Assertions and precision88067 +Node: Assertions and hledger add88551 +Node: Posting comments89299 +Node: Transaction balancing89839 +Node: Tags92047 +Node: Querying with tags93341 +Node: Displaying tags94140 +Node: When to use tags ?94536 +Node: Tag names95200 +Node: Special tags95753 +Node: Directives97318 +Node: Directives and multiple files98775 +Node: Directive effects99720 +Node: account directive102876 +Node: Account comments104326 +Node: Account error checking104985 +Node: Account display order106522 +Node: Account types107720 +Node: alias directive110995 +Node: Basic aliases112206 +Node: Regex aliases113081 +Node: Combining aliases114128 +Node: Aliases and multiple files115582 +Node: end aliases directive116365 +Node: Aliases can generate bad account names116733 +Node: Aliases and account types117566 +Node: commodity directive118458 +Node: Commodity directive syntax120045 +Node: Commodity error checking121694 +Node: decimal-mark directive122169 +Node: include directive122748 +Node: P directive123824 +Node: payee directive124858 +Node: tag directive125480 +Node: Periodic transactions126092 +Node: Periodic rule syntax128246 +Node: Periodic rules and relative dates129069 +Node: Two spaces between period expression and description!129846 +Node: Auto postings130807 +Node: Auto postings and multiple files133967 +Node: Auto postings and dates134372 +Node: Auto postings and transaction balancing / inferred amounts / balance assertions134813 +Node: Auto posting tags135659 +Node: Auto postings on forecast transactions only136554 +Node: Other syntax137024 +Node: Balance assignments137796 +Node: Balance assignments and costs139324 +Node: Balance assignments and multiple files139746 +Node: Bracketed posting dates140169 +Node: D directive140867 +Node: apply account directive142640 +Node: Y directive143507 +Node: Secondary dates144495 +Node: Star comments145980 +Node: Valuation expressions146672 +Node: Virtual postings146971 +Node: Other Ledger directives148595 +Node: Other cost/lot notations149357 +Node: CSV152198 +Node: CSV rules cheatsheet154352 +Node: source156379 +Node: encoding157379 +Node: separator158421 +Node: skip159074 +Node: date-format159724 +Node: timezone160567 +Node: newest-first161693 +Node: intra-day-reversed162406 +Node: decimal-mark163006 +Node: fields list163486 +Node: Field assignment165294 +Node: Field names166513 +Node: date field167845 +Node: date2 field168009 +Node: status field168204 +Node: code field168394 +Node: description field168582 +Node: comment field168799 +Node: account field169356 +Node: amount field170074 +Node: currency field172913 +Node: balance field173321 +Node: if block173844 +Node: Matchers175371 +Node: Multiple matchers177361 +Node: Match groups178169 +Node: if table179062 +Node: balance-type181125 +Node: include181952 +Node: Working with CSV182521 +Node: Rapid feedback183073 +Node: Valid CSV183656 +Node: File Extension184532 +Node: Reading CSV from standard input185267 +Node: Reading multiple CSV files185653 +Node: Reading files specified by rule186129 +Node: Valid transactions187526 +Node: Deduplicating importing188351 +Node: Setting amounts189580 +Node: Amount signs192107 +Node: Setting currency/commodity193172 +Node: Amount decimal places194548 +Node: Referencing other fields195805 +Node: How CSV rules are evaluated196913 +Node: Well factored rules199630 +Node: CSV rules examples200120 +Node: Bank of Ireland200318 +Node: Coinbase201915 +Node: Amazon203098 +Node: Paypal204940 +Node: Timeclock212690 +Node: Timedot215515 +Node: Timedot examples218992 +Node: PART 3 REPORTING CONCEPTS221269 +Node: Time periods221433 +Node: Report start & end date221706 +Node: Smart dates223182 +Node: Report intervals225125 +Node: Date adjustments225699 +Node: Start date adjustment225919 +Node: End date adjustment226822 +Node: Period headings227567 +Node: Period expressions228500 +Node: Period expressions with a report interval230405 +Node: More complex report intervals230853 +Node: Multiple weekday intervals232969 +Node: Depth233980 +Node: Queries235815 +Node: Query types238487 +Node: acct query238862 +Node: amt query239173 +Node: code query239870 +Node: cur query240065 +Node: desc query240671 +Node: date query240854 +Node: date2 query241250 +Node: depth query241541 +Node: note query241877 +Node: payee query242143 +Node: real query242424 +Node: status query242629 +Node: type query242869 +Node: tag query243402 +Node: Negative queries244031 +Node: not query244213 +Node: Space-separated queries244500 +Node: Boolean queries245188 +Node: expr query246506 +Node: any query247186 +Node: all query247639 +Node: Queries and command options248185 +Node: Queries and account aliases248633 +Node: Queries and valuation248958 +Node: Pivoting249320 +Node: Generating data251596 +Node: Forecasting253396 +Node: --forecast254052 +Node: Inspecting forecast transactions255153 +Node: Forecast reports256486 +Node: Forecast tags257595 +Node: Forecast period in detail258215 +Node: Forecast troubleshooting259303 +Node: Budgeting260374 +Node: Amount formatting260934 +Node: Commodity display style261178 +Node: Rounding263019 +Node: Trailing decimal marks263624 +Node: Amount parseability264557 +Node: Cost reporting266166 +Node: Recording costs266997 +Node: Reporting at cost268724 +Node: Equity conversion postings269489 +Node: Inferring equity conversion postings272134 +Node: Combining costs and equity conversion postings273276 +Node: Requirements for detecting equity conversion postings274501 +Node: Infer cost and equity by default ?276023 +Node: Value reporting276460 +Node: -V Value277396 +Node: -X Value in specified commodity277723 +Node: Valuation date278073 +Node: Finding market price279033 +Node: --infer-market-prices market prices from transactions280413 +Node: Valuation commodity283457 +Node: --value Flexible valuation284890 +Node: Valuation examples286733 +Node: Interaction of valuation and queries288865 +Node: Effect of valuation on reports289582 +Node: PART 4 COMMANDS297480 +Node: Help commands300269 +Node: commands300455 +Node: demo300663 +Node: help301897 +Node: User interface commands303602 +Node: repl303813 +Node: Examples306077 +Node: run306635 +Node: Examples 2309050 +Node: ui310074 +Node: web310211 +Node: Data entry commands310339 +Node: add310537 +Node: import312992 +Node: Import preview314026 +Node: Overlap detection314974 +Node: First import317860 +Node: Importing balance assignments319055 +Node: Import and commodity styles320110 +Node: Import special cases320548 +Node: Basic report commands321883 +Node: accounts322184 +Node: codes325117 +Node: commodities326139 +Node: descriptions326383 +Node: files326850 +Node: notes327147 +Node: payees327659 +Node: prices328443 +Node: stats329335 +Node: tags331076 +Node: Standard report commands332383 +Node: print332688 +Node: print explicitness335499 +Node: print amount style336419 +Node: print parseability337657 +Node: print other features338576 +Node: print output format339537 +Node: aregister342822 +Node: aregister and posting dates347375 +Node: register348276 +Node: Custom register output355517 +Node: balancesheet356702 +Node: balancesheetequity361667 +Node: cashflow367002 +Node: incomestatement371815 +Node: Advanced report commands376664 +Node: balance376872 +Node: balance features382293 +Node: Simple balance report384396 +Node: Balance report line format386206 +Node: Filtered balance report388566 +Node: List or tree mode389085 +Node: Depth limiting390598 +Node: Dropping top-level accounts391365 +Node: Showing declared accounts391875 +Node: Sorting by amount392605 +Node: Percentages393459 +Node: Multi-period balance report394166 +Node: Balance change end balance396918 +Node: Balance report modes398555 +Node: Calculation mode399234 +Node: Accumulation mode399938 +Node: Valuation mode401039 +Node: Combining balance report modes402383 +Node: Budget report404413 +Node: Using the budget report406713 +Node: Budget date surprises408989 +Node: Selecting budget goals410353 +Node: Budgeting vs forecasting411301 +Node: Balance report layout412978 +Node: Wide layout414183 +Node: Tall layout416588 +Node: Bare layout417894 +Node: Tidy layout419958 +Node: Balance report output421502 +Node: Some useful balance reports422276 +Node: roi423536 +Node: Spaces and special characters in --inv and --pnl425783 +Node: Semantics of --inv and --pnl426509 +Node: IRR and TWR explained428596 +Node: Chart commands432007 +Node: activity432188 +Node: Data generation commands432685 +Node: close432891 +Node: close --clopen435454 +Node: close --close437628 +Node: close --open438152 +Node: close --assert438402 +Node: close --assign438729 +Node: close --retain439408 +Node: close customisation440265 +Node: close and balance assertions441909 +Node: close examples443431 +Node: Retain earnings443668 +Node: Migrate balances to a new file444171 +Node: More detailed close examples445533 +Node: rewrite445755 +Node: Re-write rules in a file448327 +Node: Diff output format449637 +Node: rewrite vs print --auto450910 +Node: Maintenance commands451624 +Node: check451843 +Node: Basic checks452925 +Node: Strict checks453946 +Node: Other checks454883 +Node: Custom checks456635 +Node: diff457090 +Node: setup458298 +Node: test461165 +Node: PART 5 COMMON TASKS462068 +Node: Getting help462301 +Node: Constructing command lines463210 +Node: Starting a journal file464048 +Node: Setting LEDGER_FILE465432 +Node: Setting opening balances466690 +Node: Recording transactions470012 +Node: Reconciling470737 +Node: Reporting473126 +Node: Migrating to a new file477240 +Node: BUGS477689 +Node: Troubleshooting478657  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index 05697b2e6..178c920cc 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -277,6 +277,9 @@ Options hledger-ui, also make future-dated transactions visible at startup. -I --ignore-assertions don't check balance assertions by default + --txn-balancing=... how to check that transactions are balanced: + 'old': use global display precision + 'exact': use transaction precision (default) --infer-costs infer conversion equity postings from costs --infer-equity infer costs from conversion equity postings --infer-market-prices infer market prices from costs @@ -1789,40 +1792,45 @@ Journal ; a second comment line for posting 2 Transaction balancing - How exactly does hledger decide when a transaction is balanced ? The - general goal is that if you look at the journal entry and calculate the - amounts' sum perfectly with pencil and paper, hledger should agree with - you. + How exactly does hledger decide when a transaction is balanced ? Espe- + cially when it involves costs, which often are not exact, because of + repeating decimals, or imperfect data from financial institutions ? In + each commodity, hledger sums the transaction's posting amounts, after + converting any with costs; then it checks if that sum is zero, when + rounded to a suitable number of decimal digits - which we call the bal- + ancing precision. - Real world transactions, especially for investments or cryptocurren- - cies, often involve imprecise costs, complex decimals, and/or infi- - nitely-recurring decimals, which are difficult or inconvenient to han- - dle on a computer. So to be a practical accounting system, hledger al- - lows some imprecision when checking transaction balancedness. The - question is, how much imprecision should be allowed ? + Since version 1.50, hledger infers balancing precision in each transac- + tion from the amounts in that transaction's journal entry (like + Ledger). Ie, when checking the balance of commodity A, it uses the + highest decimal precision seen for A in the journal entry (excluding + cost amounts). This makes transaction balancing robust; any imbalances + must be visibly accounted for in the journal entry, display precision + can be freely increased with -c, and compatibility with Ledger and + Beancount journals is good. - hledger currently decides it based on the commodity display styles: if - the postings' sum would appear to be zero when displayed with the stan- - dard display precisions, the transaction is considered balanced. + Note that hledger versions before 1.50 worked differently: they allowed + display precision to override the balancing precision. This masked + small imbalances and caused fragility (see issue #2402). As a result, + some journal entries (or CSV rules) that worked with hledger <1.50, are + now rejected with an "unbalanced transaction" error. If you hit this + problem, it's easy to fix: - Or equivalently: if the journal entry is displayed with amounts rounded - to the standard display precisions (with hledger print --round=hard), - and a human with pencil and paper would agree that those displayed - amounts add up to zero, the transaction is considered balanced. + o You can restore the old behaviour, by adding --txn-balancing=old to + the command or to your ~/.hledger.conf file. This lets you keep us- + ing old journals unchanged, though without the above benefits. - This has some advantages: it is fairly intuitive, general not - hard-coded, yet configurable when needed. On the downside it means - that transaction balancedness is related to commodity display preci- - sions, so eg when using -c/--commodity-style to display things with - more than usual precision, you might need to fix some of your journal - entries (ie, add decimal digits to make them balance more precisely). + o Or you can fix the problem entries (recommended). There are three + ways, use whichever seems best: - Other PTA tools (Ledger, Beancount..) have their own ways of doing it. - Possible improvements are discussed at #1964. + 1. make cost amounts more precise (add more/better decimal digits) - Note: if you have multiple journal files, and are relying on commodity - directives to make imprecise journal entries balance, the directives' - placement might be important - see commodity directive. + 2. or make non-cost amounts less precise (remove unnecessary decimal + digits that are raising the precision) + + 3. or add a posting to absorb the imbalance (eg "expenses:rounding". + Remember that one posting may omit the amount; that's convenient + here.) Tags Tags are a way to add extra labels or data fields to transactions, @@ -6477,8 +6485,15 @@ Value reporting starting balance. PART 4: COMMANDS - Here are the standard commands, which you can list by running hledger. - If you have installed more add-on commands, they also will be listed. + Here are hledger's standard subcommands. You can list these by running + hledger. If you have installed more add-on commands, they also will be + listed. + + In the following command docs, each command's specific options are + shown. Most commands also support the general options described above, + though some of them might have no effect. (Usually if there's a sensi- + ble way for a general option to affect a command, it will.) You can + list all of a command's options by running hledger CMD -h. Help commands @@ -6532,7 +6547,7 @@ PART 4: COMMANDS o aregister (areg) - show transactions in a particular account - 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 balancesheet (bs) - show assets, liabilities and net worth @@ -6585,19 +6600,19 @@ Help commands -s --speed=SPEED playback speed (1 is original speed, .5 is half, 2 is double, etc (default: 2)) - Run this command with no argument to list the demos. To play a demo, + Run this command with no argument to list the demos. To play a demo, write its number or a prefix or substring of its title. Tips: Make your terminal window large enough to see the demo clearly. - Use the -s/--speed SPEED option to set your preferred playback speed, + Use the -s/--speed SPEED option to set your preferred playback speed, eg -s4 to play at 4x original speed or -s.5 to play at half speed. The default speed is 2x. - Other asciinema options can be added following a double dash, eg -- + Other asciinema options can be added following a double dash, eg -- -i.1 to limit pauses or -- -h to list asciinema's other options. - During playback, several keys are available: SPACE to pause/unpause, . + During playback, several keys are available: SPACE to pause/unpause, . to step forward (while paused), CTRL-c quit. Examples: @@ -6609,7 +6624,7 @@ Help commands This command is experimental: there aren't many useful demos yet. help - Show the hledger user manual with info, man, or a pager. With a (case + Show the hledger user manual with info, man, or a pager. With a (case insensitive) TOPIC argument, try to open it at that section heading. Flags: @@ -6618,23 +6633,23 @@ Help commands -p show the manual with $PAGER or less (less is always used if TOPIC is specified) - This command shows the hledger manual built in to your hledger exe- - cutable. It can be useful when offline, or when you prefer the termi- + This command shows the hledger manual built in to your hledger exe- + cutable. It can be useful when offline, or when you prefer the termi- nal to a web browser, or when the appropriate hledger manual or viewers are not installed properly on your system. - By default it chooses the best viewer found in $PATH, trying in this - order: info, man, $PAGER, less, more, stdout. (If a TOPIC is speci- - fied, $PAGER and more are not tried.) You can force the use of info, - man, or a pager with the -i, -m, or -p flags. If no viewer can be - found, or if running non-interactively, it just prints the manual to + By default it chooses the best viewer found in $PATH, trying in this + order: info, man, $PAGER, less, more, stdout. (If a TOPIC is speci- + fied, $PAGER and more are not tried.) You can force the use of info, + man, or a pager with the -i, -m, or -p flags. If no viewer can be + found, or if running non-interactively, it just prints the manual to stdout. - When using info, TOPIC can match either the full heading or a prefix. + When using info, TOPIC can match either the full heading or a prefix. If your info --version is < 6, you'll need to upgrade it, eg with 'brew install texinfo' on mac. - When using man or less, TOPIC must match the full heading. For a pre- + When using man or less, TOPIC must match the full heading. For a pre- fix match, you can write 'TOPIC.*'. Examples @@ -6646,7 +6661,7 @@ Help commands User interface commands repl - Start an interactive prompt, where you can run any of hledger's com- + Start an interactive prompt, where you can run any of hledger's com- mands. Data files are parsed just once, so the commands run faster. Flags: @@ -6654,21 +6669,21 @@ User interface commands This command is experimental and could change in the future. - hledger repl starts a read-eval-print loop (REPL) where you can enter - commands interactively. As with the run command, each input file (or + hledger repl starts a read-eval-print loop (REPL) where you can enter + commands interactively. As with the run command, each input file (or each input file/input options combination) is parsed just once, so com- - mands will run more quickly than if you ran them individually at the + mands will run more quickly than if you ran them individually at the command line. Also like run, the input file(s) specified for the repl command will be - the default input for all interactive commands. You can override this - temporarily by specifying an -f option in particular commands. But - note that commands will not see any changes made to input files (eg by + the default input for all interactive commands. You can override this + temporarily by specifying an -f option in particular commands. But + note that commands will not see any changes made to input files (eg by add) until you exit and restart the REPL. The command syntax is the same as with run: - o enter one hledger command at a time, without the usual hledger first + o enter one hledger command at a time, without the usual hledger first word o empty lines and comment text from # to end of line are ignored @@ -6677,7 +6692,7 @@ User interface commands o type exit or quit or control-D to exit the REPL. - While it is running, the REPL remembers your command history, and you + While it is running, the REPL remembers your command history, and you can navigate in the usual ways: o Keypad or Emacs navigation keys to edit the current command line @@ -6688,9 +6703,9 @@ User interface commands o TAB to complete file paths. - Generally repl command lines should feel much like the normal hledger - CLI, but you may find differences. repl is a little stricter; eg it - requires full command names or official abbreviations (as seen in the + Generally repl command lines should feel much like the normal hledger + CLI, but you may find differences. repl is a little stricter; eg it + requires full command names or official abbreviations (as seen in the commands list). The commands and help commands, and the command help flags (CMD --tldr, @@ -6699,7 +6714,7 @@ User interface commands You can type control-C to cancel a long-running command (but only once; typing it a second time will exit the REPL). - And in most shells you can type control-Z to temporarily exit to the + And in most shells you can type control-Z to temporarily exit to the shell (and then fg to return to the REPL). Examples @@ -6729,8 +6744,8 @@ User interface commands ... run - Run a sequence of hledger commands, provided as files or command line - arguments. Data files are parsed just once, so the commands run + Run a sequence of hledger commands, provided as files or command line + arguments. Data files are parsed just once, so the commands run faster. Flags: @@ -6740,52 +6755,52 @@ User interface commands You can use run in three ways: - o hledger run -- CMD1 -- CMD2 -- CMD3 - read commands from the command + o hledger run -- CMD1 -- CMD2 -- CMD3 - read commands from the command line, separated by -- - o hledger run SCRIPTFILE1 SCRIPTFILE2 - read commands from one or more + o hledger run SCRIPTFILE1 SCRIPTFILE2 - read commands from one or more files o cat SCRIPTFILE1 | hledger run - read commands from standard input. run first loads the input file(s) specified by LEDGER_FILE or by -f op- tions, in the usual way. Then it runs each command in turn, each using - the same input data. But if you want a particular command to use dif- - ferent input, you can specify an -f option within that command. This + the same input data. But if you want a particular command to use dif- + ferent input, you can specify an -f option within that command. This will override (not add to) the default input, just for that command. Each input file (more precisely, each combination of input file and in- - put options) is parsed only once. This means that commands will not - see any changes made to these files, until the next run. But the com- - mands will run more quickly than if run individually (typically about + put options) is parsed only once. This means that commands will not + see any changes made to these files, until the next run. But the com- + mands will run more quickly than if run individually (typically about twice as fast). Command scripts, whether in a file or written on the command line, have a simple syntax: - o each line may contain a single hledger command and its arguments, + o each line may contain a single hledger command and its arguments, without the usual hledger first word o empty lines are ignored o text from # to end of line is a comment, and ignored - o you can use single or double quotes to quote arguments when needed, + o you can use single or double quotes to quote arguments when needed, as on the command line - o these extra commands are available: echo TEXT prints some text, and + o these extra commands are available: echo TEXT prints some text, and exit or quit ends the run. - On unix systems you can use #!/usr/bin/env hledger run in the first - line of a command file to make it a runnable script. If that gives an + On unix systems you can use #!/usr/bin/env hledger run in the first + line of a command file to make it a runnable script. If that gives an error, use #!/usr/bin/env -S hledger run. It's ok to use the run command recursively within a command script. - You may find some differences in behaviour between run command lines - and normal hledger command lines. run is a little stricter; eg it re- - quires full command names or official abbreviations (as seen in the - commands list), and command options must be written after the command + You may find some differences in behaviour between run command lines + and normal hledger command lines. run is a little stricter; eg it re- + quires full command names or official abbreviations (as seen in the + commands list), and command options must be written after the command name. Examples @@ -6793,8 +6808,8 @@ User interface commands hledger -f some.journal run -- balance assets --depth 2 -- balance liabilities -f /some/other.journal --depth 3 --transpose -- stats - This would load some.journal, run balance assets --depth 2 on it, then - run balance liabilities --depth 3 --transpose on /some/other.journal, + This would load some.journal, run balance assets --depth 2 on it, then + run balance liabilities --depth 3 --transpose on /some/other.journal, and finally run stats on some.journal Run commands from standard input: @@ -6836,30 +6851,30 @@ Data entry commands Flags: --no-new-accounts don't allow creating new accounts - 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 A parenthesised transaction code may be entered following a date. @@ -6868,15 +6883,15 @@ Data entry 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. Notes: o If you enter a number with no commodity symbol, and you have declared - a default commodity with a D directive, you might expect add to add - this symbol for you. It does not do this; we assume that if you are - using a D directive you prefer not to see the commodity symbol re- + a default commodity with a D directive, you might expect add to add + this symbol for you. It does not do this; we assume that if you are + using a D directive you prefer not to see the commodity symbol re- peated on amounts in the journal. Examples: @@ -6897,22 +6912,22 @@ Data entry commands There is a detailed tutorial at https://hledger.org/add.html. import - Import new transactions from one or more data files to the main jour- + Import new transactions from one or more data files to the main jour- nal. Flags: --catchup just mark all transactions as already imported --dry-run just show the transactions to be imported - This command detects new transactions in one or more data files speci- + This command detects new transactions in one or more data files speci- fied as arguments, and appends them to the main journal. - You can import from any input file format hledger supports, but + You can import from any input file format hledger supports, but CSV/SSV/TSV files, downloaded from financial institutions, are the most common import source. - The import destination is the default journal file, or another speci- - fied in the usual way with $LEDGER_FILE or -f/--file. It should be in + The import destination is the default journal file, or another speci- + fied in the usual way with $LEDGER_FILE or -f/--file. It should be in journal format. Examples: @@ -6922,44 +6937,44 @@ Data entry commands $ hledger import *.csv Import preview - It's useful to preview the import by running first with --dry-run, to + It's useful to preview the import by running first with --dry-run, to sanity check the range of dates being imported, and to check the effect of your conversion rules if converting from CSV. Eg: $ hledger import bank.csv --dry-run The dry run output is valid journal format, so hledger can re-parse it. - If the output is large, you could show just the uncategorised transac- + If the output is large, you could show just the uncategorised transac- tions like so: $ hledger import --dry-run bank.csv | hledger -f- -I print unknown - You could also run this repeatedly to see the effect of edits to your + You could also run this repeatedly to see the effect of edits to your conversion rules: $ watchexec -- 'hledger import --dry-run bank.csv | hledger -f- -I print unknown' - Once the conversion and dates look good enough to import to your jour- + Once the conversion and dates look good enough to import to your jour- nal, perhaps with some manual fixups to follow, you would do the actual import: $ hledger import bank.csv Overlap detection - Reading CSV files is built in to hledger, and not specific to import; - so you could also import by doing hledger -f bank.csv print + Reading CSV files is built in to hledger, and not specific to import; + so you could also import by doing hledger -f bank.csv print >>$LEDGER_FILE. - But import is easier and provides some advantages. The main one is - that it avoids re-importing transactions it has seen on previous runs. + But import is easier and provides some advantages. The main one is + that it avoids re-importing transactions it has seen on previous runs. This means you don't have to worry about overlapping data in successive - downloads of your bank CSV; just download and import as often as you + downloads of your bank CSV; just download and import as often as you like, and only the new transactions will be imported each time. - We don't call this "deduplication", as it's generally not possible to - reliably detect duplicates in bank CSV. Instead, import remembers the - latest date processed previously in each CSV file (saving it in a hid- - den file), and skips any records prior to that date. This works well + We don't call this "deduplication", as it's generally not possible to + reliably detect duplicates in bank CSV. Instead, import remembers the + latest date processed previously in each CSV file (saving it in a hid- + den file), and skips any records prior to that date. This works well for most real-world CSV, where: 1. the data file name is stable (does not change) across imports @@ -6970,115 +6985,115 @@ Data entry commands 4. the newest items have the newest dates - (Occasional violations of 2-4 are often harmless; you can reduce the + (Occasional violations of 2-4 are often harmless; you can reduce the chance of disruption by downloading and importing more often.) - Overlap detection is automatic, and shouldn't require much attention - from you, except perhaps at first import (see below). But here's how + Overlap detection is automatic, and shouldn't require much attention + from you, except perhaps at first import (see below). But here's how it works: o For each FILE being imported from: - 1. hledger reads a file named .latest.FILE file in the same direc- - tory, if any. This file contains the latest record date previ- - ously imported from FILE, in YYYY-MM-DD format. If multiple - records with that date were imported, the date is repeated on N + 1. hledger reads a file named .latest.FILE file in the same direc- + tory, if any. This file contains the latest record date previ- + ously imported from FILE, in YYYY-MM-DD format. If multiple + records with that date were imported, the date is repeated on N lines. - 2. hledger reads records from FILE. If a latest date was found in - step 1, any records before that date, and the first N records on + 2. hledger reads records from FILE. If a latest date was found in + step 1, any records before that date, and the first N records on that date, are skipped. - o After a successful import from all FILEs, without error and without + o After a successful import from all FILEs, without error and without --dry-run, hledger updates each FILE's .latest.FILE for next time. If this goes wrong, it's relatively easy to repair: - o You'll notice it before import when you preview with import + o You'll notice it before import when you preview with import --dry-run. - o Or after import when you try to reconcile your hledger account bal- + o Or after import when you try to reconcile your hledger account bal- ances with your bank. - o hledger print -f FILE.csv will show all recently downloaded transac- + o hledger print -f FILE.csv will show all recently downloaded transac- tions. Compare these with your journal. Copy/paste if needed. o Update your conversion rules and print again, if needed. - o You can manually update or remove the .latest file, or use import + o You can manually update or remove the .latest file, or use import --catchup FILE. - o Download and import more often, eg twice a week, at least while you - are learning. It's easier to review and troubleshoot when there are + o Download and import more often, eg twice a week, at least while you + are learning. It's easier to review and troubleshoot when there are fewer transactions. First import - The first time you import from a file, when no corresponding .latest + The first time you import from a file, when no corresponding .latest file has been created yet, all of the records will be imported. - But perhaps you have been entering the data manually, so you know that + But perhaps you have been entering the data manually, so you know that all of these transactions are already recorded in the journal. In this - case you can run hledger import --catchup once. This will create a - .latest file containing the latest CSV record date, so that none of + case you can run hledger import --catchup once. This will create a + .latest file containing the latest CSV record date, so that none of those records will be re-imported. - Or, if you know that some but not all of the transactions are in the - journal, you can create the .latest file yourself. Eg, let's say you - previously recorded foobank transactions up to 2024-10-31 in the jour- - nal. Then in the directory where you'll be saving foobank.csv, you + Or, if you know that some but not all of the transactions are in the + journal, you can create the .latest file yourself. Eg, let's say you + previously recorded foobank transactions up to 2024-10-31 in the jour- + nal. Then in the directory where you'll be saving foobank.csv, you would create a .latest.foobank.csv file containing 2024-10-31 - Or if you had three foobank transactions recorded with that date, you + Or if you had three foobank transactions recorded with that date, you would repeat the date that many times: 2024-10-31 2024-10-31 2024-10-31 - Then hledger import foobank.csv [--dry-run] will import only the newer + Then hledger import foobank.csv [--dry-run] will import only the newer records. Importing balance assignments - Journal entries added by import will have all posting amounts made ex- + Journal entries added by import will have all posting amounts made ex- plicit (like print -x). - This means that any balance assignments in the imported entries would - need to be evaluated. But this generally isn't possible, as the main + This means that any balance assignments in the imported entries would + need to be evaluated. But this generally isn't possible, as the main file's account balances are not visible during import. So try to avoid generating balance assignments with your CSV rules, or importing from a - journal that contains balance assignments. (Balance assignments are + journal that contains balance assignments. (Balance assignments are best avoided anyway.) - But if you must use them, eg because your CSV includes only balances: - you can import with print, which leaves implicit amounts implicit. + But if you must use them, eg because your CSV includes only balances: + you can import with print, which leaves implicit amounts implicit. (print can also do overlap detection like import, with the --new flag): $ hledger print --new -f bank.csv >> $LEDGER_FILE - (If you think import should preserve implicit balances, please test + (If you think import should preserve implicit balances, please test that and send a pull request.) Import and commodity styles - Amounts in entries added by import will be formatted according to the - journal's canonical commodity styles, as declared by commodity direc- + Amounts in entries added by import will be formatted according to the + journal's canonical commodity styles, as declared by commodity direc- tives or inferred from the journal's amounts. Related: CSV > Amount decimal places. Import special cases If you have a download whose file name varies, you could rename it to a - fixed name after each download. Or you could use a CSV source rule - with a suitable glob pattern, and import from the .rules file instead + fixed name after each download. Or you could use a CSV source rule + with a suitable glob pattern, and import from the .rules file instead of the data file. - Here's a situation where you would need to run import with care: say - you download bank.csv, but forget to import it or delete it. And next + Here's a situation where you would need to run import with care: say + you download bank.csv, but forget to import it or delete it. And next month you download it again. This time your web browser may save it as - bank (2).csv. So now each of these may have data not included in the + bank (2).csv. So now each of these may have data not included in the other. And a source rule with a glob pattern would match only the most - recent file. So in this case you should import from each one in turn, + recent file. So in this case you should import from each one in turn, in the correct order, taking care to use the same filename each time: $ hledger import bank.csv @@ -7086,13 +7101,13 @@ Data entry commands $ hledger import bank.csv Here are two kinds of "deduplication" which import does not handle (and - generally should not, since these can happen legitimately in financial + generally should not, since these can happen legitimately in financial data): - o Two or more of the new CSV records are identical, and generate iden- + o Two or more of the new CSV records are identical, and generate iden- tical new journal entries. - o A new CSV record generates a journal entry identical to one(s) al- + o A new CSV record generates a journal entry identical to one(s) al- ready in the journal. Basic report commands @@ -7115,38 +7130,38 @@ Basic report commands -t --tree list/tree mode: show accounts as a tree --drop=N flat mode: omit N leading account name parts - 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: @@ -7170,13 +7185,13 @@ Basic report commands Flags: no command-specific flags - This command prints the value of each transaction's code field, in the - order transactions were parsed. The transaction code is an optional - value written in parentheses between the date and description, often + This command prints the value of each transaction's code field, in the + order transactions were parsed. The transaction code is an optional + value written in parentheses between the date and description, often used to store a cheque number, order number or similar. Transactions aren't required to have a code, and missing or empty codes - will not be shown by default. With the -E/--empty flag, they will be + will not be shown by default. With the -E/--empty flag, they will be printed as blank lines. You can add a query to select a subset of transactions. @@ -7223,7 +7238,7 @@ Basic report commands no command-specific flags This command lists the unique descriptions that appear in transactions, - in alphabetic order. You can add a query to select a subset of trans- + in alphabetic order. You can add a query to select a subset of trans- actions. Example: @@ -7234,7 +7249,7 @@ Basic report commands Person A files - List all files included in the journal. With a REGEX argument, only + List all files included in the journal. With a REGEX argument, only file names matching the regular expression (case sensitive) are shown. Flags: @@ -7247,8 +7262,8 @@ Basic report commands no command-specific flags 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: @@ -7264,14 +7279,14 @@ Basic report commands --declared show payees declared with payee directives --used show payees referenced by 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: @@ -7282,8 +7297,8 @@ Basic report 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. @@ -7291,14 +7306,14 @@ Basic report commands --show-reverse also show the 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. stats @@ -7309,10 +7324,10 @@ Basic report commands -o --output-file=FILE write output to FILE. The stats command shows summary information for the whole journal, or a - matched part of it. With a reporting interval, it shows a report for + matched part of it. With a reporting interval, it shows a report for each report period. - The default output is fairly impersonal, though it reveals the main + The default output is fairly impersonal, though it reveals the main file name. With -v/--verbose, more details are shown, like file paths, included files, and commodity names. @@ -7324,8 +7339,8 @@ Basic report commands o live: the peak memory in use by the program to do its work - o alloc: the peak memory allocation from the OS as seen by GHC. Mea- - suring this externally, eg with GNU time, is more accurate; usually + o alloc: the peak memory allocation from the OS as seen by GHC. Mea- + suring this externally, eg with GNU time, is more accurate; usually that will be a larger number; sometimes (with swapping?) smaller. The stats command's run time is similar to that of a balance report. @@ -7346,7 +7361,7 @@ Basic report commands Market prices : 1000 Runtime stats : 0.12 s elapsed, 8266 txns/s, 4 MB live, 16 MB alloc - This command supports the -o/--output-file option (but not -O/--out- + This command supports the -o/--output-file option (but not -O/--out- put-format). tags @@ -7360,22 +7375,22 @@ Basic report 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. @@ -7414,9 +7429,9 @@ Standard report 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: @@ -7436,55 +7451,55 @@ Standard report 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 (Added in 1.32) option, print will try increasingly - hard to display decimal digits according to the commodity display + With the --round (Added in 1.32) option, print will try increasingly + hard to display decimal digits according to the commodity display styles: o --round=none show amounts with original precisions (default) o --round=soft add/remove decimal zeros in amounts (except costs) - o --round=hard round amounts (except costs), possibly hiding signifi- + o --round=hard round amounts (except costs), possibly hiding signifi- cant digits o --round=all round all amounts and costs - soft is good for non-lossy cleanup, formatting amounts more consis- + soft is good for non-lossy cleanup, formatting amounts more consis- tently where it's safe to do so. - hard and all can cause print to show invalid unbalanced journal en- - tries; they may be useful eg for stronger cleanup, with manual fixups + hard and all can cause print to show invalid unbalanced journal en- + tries; they may be useful eg for stronger cleanup, with manual fixups when needed. print parseability - print's output is usually a valid hledger journal, and you can process + print's output is usually a valid hledger journal, and you can process it again with a second hledger command. This can be useful for certain - kinds of search (though the same can be achieved with expr: queries + kinds of search (though the same can be achieved with expr: queries now): # Show running total of food expenses paid from cash. @@ -7493,7 +7508,7 @@ Standard report commands There are some situations where print's output can become unparseable: - o Value reporting affects posting amounts but not balance assertion or + o Value reporting affects posting amounts but not balance assertion or balance assignment amounts, potentially causing those to fail. o Auto postings can generate postings with too many missing amounts. @@ -7503,45 +7518,45 @@ Standard report commands print, other features With -B/--cost, amounts with costs are shown converted to cost. - With --invert, posting amounts are shown with their sign flipped. It - could be useful if you have accidentally recorded some transactions + With --invert, posting amounts are shown with their sign flipped. It + could be useful if you have accidentally recorded some transactions with the wrong signs. With --new, print shows only transactions it has not seen on a previous - run. This uses the same deduplication system as the import command. + run. This uses the same deduplication system as the import command. (See import's docs for details.) With -m DESC/--match=DESC, print shows one recent transaction whose de- - scription is most similar to DESC. DESC should contain at least two - characters. If there is no similar-enough match, no transaction will + scription is most similar to DESC. DESC should contain at least two + characters. If there is no similar-enough match, no transaction will be shown and the program exit code will be non-zero. - With --location, print adds the source file and line number to every + With --location, print adds the source file and line number to every transaction, as a tag. print output format This command also supports the output destination and output format op- - tions The output formats supported are txt, beancount (Added in 1.32), + 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 + The beancount format tries to produce Beancount-compatible output, as follows: - o Transaction and postings with unmarked status are converted to + o Transaction and postings with unmarked status are converted to cleared (*) status. - o Transactions' payee and note are backslash-escaped and dou- + o Transactions' payee and note are backslash-escaped and dou- ble-quote-escaped and wrapped in double quotes. o Transaction tags are copied to Beancount #tag format. - o Commodity symbols are converted to upper case, and a small number of - currency symbols like $ are converted to the corresponding currency + o Commodity symbols are converted to upper case, and a small number of + currency symbols like $ are converted to the corresponding currency names. o Account name parts are capitalised and unsupported characters are re- placed with -. If an account name part does not begin with a letter, - or if the first part is not Assets, Liabilities, Equity, Income, or + or if the first part is not Assets, Liabilities, Equity, Income, or Expenses, an error is raised. (Use --alias options to bring your ac- counts into compliance.) @@ -7574,26 +7589,26 @@ Standard report commands "5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","","" "5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","","" - o There is one CSV record per posting, with the parent transaction's + o There is one CSV record per posting, with the parent transaction's fields repeated. o The "txnidx" (transaction index) field shows which postings belong to - the same transaction. (This number might change if transactions are - reordered within the file, files are parsed/included in a different + the same transaction. (This number might change if transactions are + reordered within the file, files are parsed/included in a different order, etc.) - o The amount is separated into "commodity" (the symbol) and "amount" + o The amount is separated into "commodity" (the symbol) and "amount" (numeric quantity) fields. o The numeric amount is repeated in either the "credit" or "debit" col- - umn, for convenience. (Those names are not accurate in the account- - ing sense; it just puts negative amounts under credit and zero or + umn, for convenience. (Those names are not accurate in the account- + ing sense; it just puts negative amounts under credit and zero or greater amounts under debit.) aregister (areg) - Show the transactions and running balances in one account, with each + Show the transactions and running balances in one account, with each transaction on one line. Flags: @@ -7617,64 +7632,64 @@ Standard report commands one of the above formats selects that format. aregister shows the overall transactions affecting a particular account - (and any subaccounts). Each report line represents one transaction in - this account. Transactions before the report start date are included - in the running balance (--historical mode is the default). You can + (and any subaccounts). Each report line represents one transaction in + this account. Transactions before the report start date are included + in the running balance (--historical mode is the default). You can suppress this behaviour using the --cumulative option. - 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. - By default, aregister shows a heading above the data. However, when - reporting in a language different from English, it is easier to omit - this heading and prepend your own one. For this purpose, use the + By default, aregister shows a heading above the data. However, when + reporting in a language different from English, it is easier to omit + this heading and prepend your own one. For this purpose, use the --heading=no option. This command also supports the output destination and output format op- @@ -7682,13 +7697,13 @@ Standard report commands html, fods (Added in 1.41) 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. @@ -7728,14 +7743,14 @@ Standard report commands one of the above formats selects that format. The register command displays matched postings, across all accounts, in - date order, with their running total or running historical balance. - (See also the aregister command, which shows matched transactions in a + date order, with their running total or running historical balance. + (See also the aregister command, which shows matched transactions in a specific account.) register normally shows line per posting, but note that multi-commodity amounts will occupy multiple lines (one line per commodity). - It is typically used with a query selecting a particular account, to + It is typically used with a query selecting a particular account, to see that account's activity: $ hledger register checking @@ -7746,14 +7761,14 @@ Standard report commands With --date2, it shows and sorts by secondary date instead. - For performance reasons, column widths are chosen based on the first - 1000 lines; this means unusually wide values in later lines can cause - visual discontinuities as column widths are adjusted. If you want to - ensure perfect alignment, at the cost of more time and memory, use the + For performance reasons, column widths are chosen based on the first + 1000 lines; this means unusually wide values in later lines can cause + visual discontinuities as column widths are adjusted. If you want to + ensure perfect alignment, at the cost of more time and memory, use the --align-all flag. - The --historical/-H flag adds the balance from any undisplayed prior - postings to the running total. This is useful when you want to see + The --historical/-H flag adds the balance from any undisplayed prior + postings to the running total. This is useful when you want to see only recent activity, with a historically accurate running balance: $ hledger register checking -b 2008/6 --historical @@ -7763,25 +7778,25 @@ Standard report commands The --depth option limits the amount of sub-account detail displayed. - The --average/-A flag shows the running average posting amount instead + The --average/-A flag shows the running average posting amount instead of the running total (so, the final number displayed is the average for - the whole report period). This flag implies --empty (see below). It - is affected by --historical. It works best when showing just one ac- + the whole report period). This flag implies --empty (see below). It + is affected by --historical. It works best when showing just one ac- count and one commodity. - The --related/-r flag shows the other postings in the transactions of + The --related/-r flag shows the other postings in the transactions of the postings which would normally be shown. - The --invert flag negates all amounts. For example, it can be used on + The --invert flag negates all amounts. For example, it can be used on an income account where amounts are normally displayed as negative num- - bers. It's also useful to show postings on the checking account to- + bers. It's also useful to show postings on the checking account to- gether with the related account: - The --sort=FIELDS flag sorts by the fields given, which can be any of + The --sort=FIELDS flag sorts by the fields given, which can be any of account, amount, absamount, date, or desc/description, optionally sepa- - rated by commas. For example, --sort account,amount will group all + rated by commas. For example, --sort account,amount will group all transactions in each account, sorted by transaction amount. Each field - can be negated by a preceding -, so --sort -amount will show transac- + can be negated by a preceding -, so --sort -amount will show transac- tions ordered from smallest amount to largest amount. $ hledger register --related --invert assets:checking @@ -7793,7 +7808,7 @@ Standard report commands 2008/01 income:salary $-1 $-1 2008/06 income:gifts $-1 $-2 - Periods with no activity, and summary postings with a zero amount, are + Periods with no activity, and summary postings with a zero amount, are not shown by default; use the --empty/-E flag to see them: $ hledger register --monthly income -E @@ -7810,7 +7825,7 @@ Standard report commands 2008/11 0 $-2 2008/12 0 $-2 - Often, you'll want to see just one line per interval. The --depth op- + Often, you'll want to see just one line per interval. The --depth op- tion helps with this, causing subaccounts to be aggregated: $ hledger register --monthly assets --depth 1h @@ -7818,21 +7833,21 @@ Standard report commands 2008/06 assets $-1 0 2008/12 assets $-1 $-1 - Note when using report intervals, if you specify start/end dates these - will be adjusted outward if necessary to contain a whole number of in- - tervals. This ensures that the first and last intervals are full + Note when using report intervals, if you specify start/end dates these + will be adjusted outward if necessary to contain a whole number of in- + tervals. This ensures that the first and last intervals are full length and comparable to the others in the report. - With -m DESC/--match=DESC, register does a fuzzy search for one recent + With -m DESC/--match=DESC, register does a fuzzy search for one recent posting whose description is most similar to DESC. DESC should contain at least two characters. If there is no similar-enough match, no post- ing will be shown and the program exit code will be non-zero. Custom register output - register normally uses the full terminal width (or 80 columns if it + register normally uses the full terminal width (or 80 columns if it can't detect that). You can override this with the --width/-w option. - The description and account columns normally share the space equally + The description and account columns normally share the space equally (about half of (width - 40) each). You can adjust this by adding a de- scription width as part of --width's argument, comma-separated: --width W,D . Here's a diagram (won't display correctly in --help): @@ -7848,14 +7863,14 @@ Standard report commands $ hledger reg -w 100,40 # set overall width 100, description width 40 This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv (Added in 1.32), + tions The output formats supported are txt, csv, tsv (Added in 1.32), and json. balancesheet (bs) - Show the end balances in asset and liability accounts. Amounts are - shown with normal positive sign, as in conventional financial state- + Show the end balances in asset and liability accounts. Amounts are + shown with normal positive sign, as in conventional financial state- ments. Flags: @@ -7906,13 +7921,13 @@ Standard report commands -o --output-file=FILE write output to FILE. A file extension matching one of the above formats selects that format. - This command displays a balance sheet, showing historical ending bal- + This command displays a balance sheet, showing historical ending bal- ances of asset and liability accounts. (To see equity as well, use the balancesheetequity command.) Accounts declared with the Asset, Cash or Liability type are shown (see - account types). Or if no such accounts are declared, it shows - top-level accounts named asset or liability (case insensitive, plurals + account types). Or if no such accounts are declared, it shows + top-level accounts named asset or liability (case insensitive, plurals allowed) and their subaccounts. Example: @@ -7938,20 +7953,20 @@ Standard report commands Net: || 0 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. - It is similar to hledger balance -H assets liabilities, but with - smarter account detection, and liabilities displayed with their sign + ports many of that command's features, such as multi-period reports. + It is similar to hledger balance -H assets liabilities, but with + smarter account detection, and liabilities displayed with their sign flipped. This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv (Added in 1.32), + 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. Flags: @@ -8002,9 +8017,9 @@ Standard report commands -o --output-file=FILE write output to FILE. A file extension matching one of the above formats selects that format. - 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: @@ -8035,14 +8050,14 @@ Standard report commands Net: || 0 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. + 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 report is the easiest way to see if the accounting equation (A+L+E - = 0) is satisfied (after you have done a close --retain to merge rev- - enues and expenses with equity, and perhaps added --infer-equity to + = 0) is satisfied (after you have done a close --retain to merge rev- + enues and expenses with equity, and perhaps added --infer-equity to balance your commodity conversions). This command also supports the output destination and output format op- @@ -8051,9 +8066,9 @@ Standard report commands cashflow (cf) - This command displays a (simple) cashflow statement, showing the in- - flows and outflows affecting "cash" (ie, liquid, easily convertible) - assets. Amounts are shown with normal positive sign, as in conven- + This command displays a (simple) cashflow statement, showing the in- + flows and outflows affecting "cash" (ie, liquid, easily convertible) + assets. Amounts are shown with normal positive sign, as in conven- tional financial statements. Flags: @@ -8105,10 +8120,10 @@ Standard report commands -o --output-file=FILE write output to FILE. A file extension matching one of the above formats selects that format. - 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. @@ -8135,19 +8150,19 @@ Standard report 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 (Added in 1.32), + tions The output formats supported are txt, csv, tsv (Added in 1.32), html, and json. incomestatement (is) - Show revenue inflows and expense outflows during the report period. - Amounts are shown with normal positive sign, as in conventional finan- + Show revenue inflows and expense outflows during the report period. + Amounts are shown with normal positive sign, as in conventional finan- cial statements. Flags: @@ -8199,12 +8214,12 @@ Standard report commands -o --output-file=FILE write output to FILE. A file extension matching one of the above formats selects that format. - This command displays an income statement, showing revenues and ex- + This command displays an income statement, showing revenues and ex- penses during one or more periods. - It shows accounts declared with the Revenue or Expense type (see ac- - count types). Or if no such accounts are declared, it shows top-level - accounts named revenue or income or expense (case insensitive, plurals + It shows accounts declared with the Revenue or Expense type (see ac- + count types). Or if no such accounts are declared, it shows top-level + accounts named revenue or income or expense (case insensitive, plurals allowed) and their subaccounts. Example: @@ -8231,20 +8246,20 @@ Standard report commands Net: || 0 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. + ports many of that command's features, such as multi-period reports. It is similar to hledger balance '(revenues|income)' expenses, but with - smarter account detection, and revenues/income displayed with their + smarter account detection, and revenues/income displayed with their sign flipped. This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, tsv (Added in 1.32), + tions The output formats supported are txt, csv, tsv (Added in 1.32), html, and json. Advanced report commands balance (bal) - A flexible, general purpose "summing" report that shows accounts with + A flexible, general purpose "summing" report that shows accounts with some kind of numeric data. This can be balance changes per period, end balances, budget performance, unrealised capital gains, etc. @@ -8311,19 +8326,19 @@ Advanced report commands -o --output-file=FILE write output to FILE. A file extension matching one of the above formats selects that format. - 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 variants of the balance command with convenient de- - faults, which are simpler to use: balancesheet, balancesheetequity, - cashflow and incomestatement. When you need more control, then use + faults, which are simpler to use: balancesheet, balancesheetequity, + cashflow and incomestatement. When you need more control, 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 other balance-like commands as well (bs, cf, is..). balance can show.. @@ -8378,7 +8393,7 @@ Advanced report 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) @@ -8391,20 +8406,20 @@ Advanced report commands This command supports the output destination and output format options, with output formats txt, csv, tsv (Added in 1.32), json, and (multi-pe- - riod reports only:) html, fods (Added in 1.40). In txt output in a + riod reports only:) html, fods (Added in 1.40). In txt output in a colour-supporting terminal, negative amounts are shown in red. Simple balance report - With no arguments, balance shows a list of all accounts and their - change of balance - ie, the sum of posting amounts, both inflows and - outflows - during the entire period of the journal. ("Simple" here - means just one column of numbers, covering a single period. You can + With no arguments, balance shows a list of all accounts and their + change of balance - ie, the sum of posting amounts, both inflows and + outflows - during the entire period of the journal. ("Simple" here + means just one column of numbers, covering a single period. You can also have multi-period reports, described later.) - For real-world accounts, these numbers will normally be their end bal- + For real-world accounts, these numbers will normally be their end bal- ance at the end of the journal period; more on this below. - Accounts are sorted by declaration order if any, and then alphabeti- + Accounts are sorted by declaration order if any, and then alphabeti- cally by account name. For instance (using examples/sample.journal): $ hledger -f examples/sample.journal bal @@ -8419,7 +8434,7 @@ Advanced report commands 0 Accounts with a zero balance (and no non-zero subaccounts, in tree mode - - see below) are hidden by default. Use -E/--empty to show them (re- + - see below) are hidden by default. Use -E/--empty to show them (re- vealing assets:bank:checking here): $ hledger -f examples/sample.journal bal -E @@ -8434,12 +8449,12 @@ Advanced report commands -------------------- 0 - The total of the amounts displayed is shown as the last line, unless + The total of the amounts displayed is shown as the last line, unless -N/--no-total is used. Balance report line format For single-period balance reports displayed in the terminal (only), you - can use --format FMT to customise the format and content of each line. + can use --format FMT to customise the format and content of each line. Eg: $ hledger -f examples/sample.journal balance --format "%20(account) %12(total)" @@ -8456,7 +8471,7 @@ Advanced report commands --------------------------------- 0 - The FMT format string specifies the formatting applied to each ac- + The FMT format string specifies the formatting applied to each ac- count/balance pair. It may contain any suitable text, with data fields interpolated like so: @@ -8468,14 +8483,14 @@ Advanced report commands o FIELDNAME must be enclosed in parentheses, and can be one of: - o depth_spacer - a number of spaces equal to the account's depth, or + o depth_spacer - a number of spaces equal to the account's depth, or if MIN is specified, MIN * depth spaces. o account - the account's name o total - the account's balance/posted total, right justified - Also, FMT can begin with an optional prefix to control how multi-com- + Also, FMT can begin with an optional prefix to control how multi-com- modity amounts are rendered: o %_ - render on multiple lines, bottom-aligned (the default) @@ -8485,25 +8500,25 @@ Advanced report commands o %, - render on one line, comma-separated There are some quirks. Eg in one-line mode, %(depth_spacer) has no ef- - fect, instead %(account) has indentation built in. Experimentation + fect, instead %(account) has indentation built in. Experimentation may be needed to get pleasing results. Some example formats: o %(total) - the account's total - o %-20.20(account) - the account's name, left justified, padded to 20 + o %-20.20(account) - the account's name, left justified, padded to 20 characters and clipped at 20 characters - o %,%-50(account) %25(total) - account name padded to 50 characters, - total padded to 20 characters, with multiple commodities rendered on + o %,%-50(account) %25(total) - account name padded to 50 characters, + total padded to 20 characters, with multiple commodities rendered on one line - o %20(total) %2(depth_spacer)%-(account) - the default format for the + o %20(total) %2(depth_spacer)%-(account) - the default format for the single-column balance report Filtered balance report - You can show fewer accounts, a different time period, totals from + You can show fewer accounts, a different time period, totals from cleared transactions only, etc. by using query arguments or options to limit the postings being matched. Eg: @@ -8513,10 +8528,10 @@ Advanced report commands $-2 List or tree mode - By default, or with -l/--flat, accounts are shown as a flat list with + By default, or with -l/--flat, accounts are shown as a flat list with their full names visible, as in the examples above. - With -t/--tree, the account hierarchy is shown, with subaccounts' + With -t/--tree, the account hierarchy is shown, with subaccounts' "leaf" names indented below their parent: $ hledger -f examples/sample.journal balance @@ -8536,26 +8551,26 @@ Advanced report commands Notes: o "Boring" accounts are combined with their subaccount for more compact - output, unless --no-elide is used. Boring accounts have no balance - of their own and just one subaccount (eg assets:bank and liabilities + output, unless --no-elide is used. Boring accounts have no balance + of their own and just one subaccount (eg assets:bank and liabilities above). - o All balances shown are "inclusive", ie including the balances from - all subaccounts. Note this means some repetition in the output, + o All balances shown are "inclusive", ie including the balances from + all subaccounts. Note this means some repetition in the output, which requires explanation when sharing reports with non-plaintextac- - counting-users. A tree mode report's final total is the sum of the + counting-users. A tree mode report's final total is the sum of the top-level balances shown, not of all the balances shown. - o Each group of sibling accounts (ie, under a common parent) is sorted + o Each group of sibling accounts (ie, under a common parent) is sorted separately. Depth limiting - With a depth:NUM query, or --depth NUM option, or just -NUM (eg: -3) - balance reports will show accounts only to the specified depth, hiding - the deeper subaccounts. This can be useful for getting an overview + With a depth:NUM query, or --depth NUM option, or just -NUM (eg: -3) + balance reports will show accounts only to the specified depth, hiding + the deeper subaccounts. This can be useful for getting an overview without too much detail. - Account balances at the depth limit always include the balances from + Account balances at the depth limit always include the balances from any deeper subaccounts (even in list mode). Eg, limiting to depth 1: $ hledger -f examples/sample.journal balance -1 @@ -8567,7 +8582,7 @@ Advanced report commands 0 Dropping top-level accounts - You can also hide one or more top-level account name parts, using + You can also hide one or more top-level account name parts, using --drop NUM. This can be useful for hiding repetitive top-level account names: @@ -8578,54 +8593,54 @@ Advanced report commands $2 Showing declared accounts - With --declared, accounts which have been declared with an account di- - rective will be included in the balance report, even if they have no + With --declared, accounts which have been declared with an account di- + rective will be included in the balance report, even if they have no transactions. (Since they will have a zero balance, you will also need -E/--empty to see them.) - More precisely, leaf declared accounts (with no subaccounts) will be + More precisely, leaf declared accounts (with no subaccounts) will be included, since those are usually the more useful in reports. - The idea of this is to be able to see a useful "complete" balance re- + The idea of this is to be able to see a useful "complete" balance re- port, even when you don't have transactions in all of your declared ac- counts yet. Sorting by amount - With -S/--sort-amount, accounts with the largest (most positive) bal- - ances are shown first. Eg: hledger bal expenses -MAS shows your - biggest averaged monthly expenses first. When more than one commodity - is present, they will be sorted by the alphabetically earliest commod- - ity first, and then by subsequent commodities (if an amount is missing + With -S/--sort-amount, accounts with the largest (most positive) bal- + ances are shown first. Eg: hledger bal expenses -MAS shows your + biggest averaged monthly expenses first. When more than one commodity + is present, they will be sorted by the alphabetically earliest commod- + ity first, and then by subsequent commodities (if an amount is missing a commodity, it is treated as 0). - Revenues and liability balances are typically negative, however, so -S - shows these in reverse order. To work around this, you can add --in- - vert to flip the signs. Or you could use one of the higher-level bal- + Revenues and liability balances are typically negative, however, so -S + shows these in reverse order. To work around this, you can add --in- + vert to flip the signs. Or you could use one of the higher-level bal- ance reports (bs, is..), which flip the sign automatically (eg: hledger is -MAS). Percentages - With -%/--percent, balance reports show each account's value expressed + With -%/--percent, balance reports show each account's value expressed as a percentage of the (column) total. Note it is not useful to calculate percentages if the amounts in a col- - umn have mixed signs. In this case, make a separate report for each + umn have mixed signs. In this case, make a separate report for each sign, eg: $ hledger bal -% amt:`>0` $ hledger bal -% amt:`<0` - Similarly, if the amounts in a column have mixed commodities, convert - them to one commodity with -B, -V, -X or --value, or make a separate + Similarly, if the amounts in a column have mixed commodities, convert + them to one commodity with -B, -V, -X or --value, or make a separate report for each commodity: $ hledger bal -% cur:\\$ $ hledger bal -% cur: Multi-period balance report - With a report interval (set by the -D/--daily, -W/--weekly, - -M/--monthly, -Q/--quarterly, -Y/--yearly, or -p/--period flag), bal- - ance shows a tabular report, with columns representing successive time + With a report interval (set by the -D/--daily, -W/--weekly, + -M/--monthly, -Q/--quarterly, -Y/--yearly, or -p/--period flag), bal- + ance shows a tabular report, with columns representing successive time periods (and a title): $ hledger -f examples/sample.journal bal --quarterly income expenses -E @@ -8646,24 +8661,24 @@ Advanced report commands encompass the displayed subperiods (so that the first and last subpe- riods have the same duration as the others). - o Leading and trailing periods (columns) containing all zeroes are not + o Leading and trailing periods (columns) containing all zeroes are not shown, unless -E/--empty is used. - o Accounts (rows) containing all zeroes are not shown, unless + o Accounts (rows) containing all zeroes are not shown, unless -E/--empty is used. - o Amounts with many commodities are shown in abbreviated form, unless + o Amounts with many commodities are shown in abbreviated form, unless --no-elide is used. - o Average and/or total columns can be added with the -A/--average and + o Average and/or total columns can be added with the -A/--average and -T/--row-total flags. o The --transpose flag can be used to exchange rows and columns. - o The --pivot FIELD option causes a different transaction field to be + o The --pivot FIELD option causes a different transaction field to be used as "account name". See PIVOTING. - o The --summary-only flag (--summary also works) hides all but the To- + o The --summary-only flag (--summary also works) hides all but the To- tal and Average columns (those should be enabled with --row-total and -A/--average). @@ -8682,57 +8697,57 @@ Advanced report commands o Reduce the terminal's font size - o View with a pager like less, eg: hledger bal -D --color=yes | less + o View with a pager like less, eg: hledger bal -D --color=yes | less -RS - o Output as CSV and use a CSV viewer like visidata (hledger bal -D -O - csv | vd -f csv), Emacs' csv-mode (M-x csv-mode, C-c C-a), or a + o Output as CSV and use a CSV viewer like visidata (hledger bal -D -O + csv | vd -f csv), Emacs' csv-mode (M-x csv-mode, C-c C-a), or a spreadsheet (hledger bal -D -o a.csv && open a.csv) - o Output as HTML and view with a browser: hledger bal -D -o a.html && + o Output as HTML and view with a browser: hledger bal -D -o a.html && open a.html Balance change, end balance - It's important to be clear on the meaning of the numbers shown in bal- + It's important to be clear on the meaning of the numbers shown in bal- ance reports. Here is some terminology we use: - A balance change is the net amount added to, or removed from, an ac- + A balance change is the net amount added to, or removed from, an ac- count during some period. - An end balance is the amount accumulated in an account as of some date - (and some time, but hledger doesn't store that; assume end of day in + An end balance is the amount accumulated in an account as of some date + (and some time, but hledger doesn't store that; assume end of day in your timezone). It is the sum of previous balance changes. - We call it a historical end balance if it includes all balance changes + We call it a historical end balance if it includes all balance changes since the account was created. For a real world account, this means it - will match the "historical record", eg the balances reported in your + will match the "historical record", eg the balances reported in your bank statements or bank web UI. (If they are correct!) - In general, balance changes are what you want to see when reviewing + In general, balance changes are what you want to see when reviewing revenues and expenses, and historical end balances are what you want to see when reviewing or reconciling asset, liability and equity accounts. - balance shows balance changes by default. To see accurate historical + balance shows balance changes by default. To see accurate historical end balances: - 1. Initialise account starting balances with an "opening balances" - transaction (a transfer from equity to the account), unless the + 1. Initialise account starting balances with an "opening balances" + transaction (a transfer from equity to the account), unless the journal covers the account's full lifetime. 2. Include all of of the account's prior postings in the report, by not - specifying a report start date, or by using the -H/--historical + specifying a report start date, or by using the -H/--historical flag. (-H causes report start date to be ignored when summing post- ings.) Balance report modes - The balance command is quite flexible; here is the full detail on how - to control what it reports. If the following seems complicated, don't - worry - this is for advanced reporting, and it does take time and ex- + The balance command is quite flexible; here is the full detail on how + to control what it reports. If the following seems complicated, don't + worry - this is for advanced reporting, and it does take time and ex- perimentation to get familiar with all the report modes. There are three important option groups: - hledger balance [CALCULATIONMODE] [ACCUMULATIONMODE] [VALUATIONMODE] + hledger balance [CALCULATIONMODE] [ACCUMULATIONMODE] [VALUATIONMODE] ... Calculation mode @@ -8744,35 +8759,35 @@ Advanced report commands each account/period) o --valuechange : show the change in period-end historical balance val- - ues (caused by deposits, withdrawals, and/or market price fluctua- + ues (caused by deposits, withdrawals, and/or market price fluctua- tions) - o --gain : show the unrealised capital gain/loss, (the current valued + o --gain : show the unrealised capital gain/loss, (the current valued balance minus each amount's original cost) o --count : show the count of postings Accumulation mode - How amounts should accumulate across a report's subperiods/columns. - Another way to say it: which time period's postings should contribute + How amounts should accumulate across a report's subperiods/columns. + Another way to say it: which time period's postings should contribute to each cell's calculation. It is one of: - o --change : calculate with postings from column start to column end, - ie "just this column". Typically used to see revenues/expenses. + o --change : calculate with postings from column start to column end, + ie "just this column". Typically used to see revenues/expenses. (default for balance, cashflow, incomestatement) - o --cumulative : calculate with postings from report start to column - end, ie "previous columns plus this column". Typically used to show + o --cumulative : calculate with postings from report start to column + end, ie "previous columns plus this column". Typically used to show changes accumulated since the report's start date. Not often used. - o --historical/-H : calculate with postings from journal start to col- - umn end, ie "all postings from before report start date until this - column's end". Typically used to see historical end balances of as- - sets/liabilities/equity. (default for balancesheet, balancesheete- + o --historical/-H : calculate with postings from journal start to col- + umn end, ie "all postings from before report start date until this + column's end". Typically used to see historical end balances of as- + sets/liabilities/equity. (default for balancesheet, balancesheete- quity) Valuation mode - Which kind of value or cost conversion should be applied, if any, be- + Which kind of value or cost conversion should be applied, if any, be- fore displaying the report. See Cost reporting and Value reporting for more about conversions. @@ -8780,19 +8795,19 @@ Advanced report commands o no conversion : don't convert to cost or value (default) - o --value=cost[,COMM] : convert amounts to cost (then optionally to + o --value=cost[,COMM] : convert amounts to cost (then optionally to some other commodity) - o --value=then[,COMM] : convert amounts to market value on transaction + o --value=then[,COMM] : convert amounts to market value on transaction dates - o --value=end[,COMM] : convert amounts to market value on period end + o --value=end[,COMM] : convert amounts to market value on period end date(s) (default with --valuechange, --gain) o --value=now[,COMM] : convert amounts to market value on today's date - o --value=YYYY-MM-DD[,COMM] : convert amounts to market value on an- + o --value=YYYY-MM-DD[,COMM] : convert amounts to market value on an- other date or with the legacy -B/-V/-X options, which are equivalent and easier to @@ -8805,17 +8820,17 @@ Advanced report commands o -X COMM/--exchange COMM : like --value=end,COMM Note that --value can also convert to cost, as a convenience; but actu- - ally --cost and --value are independent options, and could be used to- + ally --cost and --value are independent options, and could be used to- gether. Combining balance report modes Most combinations of these modes should produce reasonable reports, but - if you find any that seem wrong or misleading, let us know. The fol- + if you find any that seem wrong or misleading, let us know. The fol- lowing restrictions are applied: o --valuechange implies --value=end - o --valuechange makes --change the default when used with the bal- + o --valuechange makes --change the default when used with the bal- ancesheet/balancesheetequity commands o --cumulative or --historical disables --row-total/-T @@ -8828,18 +8843,18 @@ Advanced report commands Accumu- /now lation:v ----------------------------------------------------------------------------------- - --change change in period sum of post- period-end DATE-value of - ing-date market value of change change in pe- + --change change in period sum of post- period-end DATE-value of + ing-date market value of change change in pe- values in period in period riod - --cumu- change from re- sum of post- period-end DATE-value of - lative port start to ing-date market value of change change from + --cumu- change from re- sum of post- period-end DATE-value of + lative port start to ing-date market value of change change from period end values from re- from report report start port start to pe- start to period to period end riod end end - --his- change from sum of post- period-end DATE-value of + --his- change from sum of post- period-end DATE-value of torical journal start to ing-date market value of change change from /-H period end (his- values from jour- from journal journal start - torical end bal- nal start to pe- start to period to period end + torical end bal- nal start to pe- start to period to period end ance) riod end end Budget report @@ -8850,11 +8865,11 @@ Advanced report commands o Accounts which don't have budget goals are hidden by default. - This is useful for comparing planned and actual income, expenses, time + This is useful for comparing planned and actual income, expenses, time usage, etc. - Periodic transaction rules are used to define budget goals. For exam- - ple, here's a periodic rule defining monthly goals for bus travel and + Periodic transaction rules are used to define budget goals. For exam- + ple, here's a periodic rule defining monthly goals for bus travel and food expenses: ;; Budget @@ -8896,66 +8911,66 @@ Advanced report commands || 0 [ 0% of $430] 0 [ 0% of $430] This is "goal-based budgeting"; you define goals for accounts and peri- - ods, often recurring, and hledger shows performance relative to the - goals. This contrasts with "envelope budgeting", which is more de- - tailed and strict - useful when cash is tight, but also quite a bit - more work. https://plaintextaccounting.org/Budgeting has more on this + ods, often recurring, and hledger shows performance relative to the + goals. This contrasts with "envelope budgeting", which is more de- + tailed and strict - useful when cash is tight, but also quite a bit + more work. https://plaintextaccounting.org/Budgeting has more on this topic. Using the budget report - Historically this report has been confusing and fragile. hledger's - version should be relatively robust and intuitive, but you may still - find surprises. Here are more notes to help with learning and trou- + Historically this report has been confusing and fragile. hledger's + version should be relatively robust and intuitive, but you may still + find surprises. Here are more notes to help with learning and trou- bleshooting. - o In the above example, expenses:bus and expenses:food are shown be- + o In the above example, expenses:bus and expenses:food are shown be- cause they have budget goals during the report period. - o Their parent expenses is also shown, with budget goals aggregated + o Their parent expenses is also shown, with budget goals aggregated from the children. - o The subaccounts expenses:food:groceries and expenses:food:dining are - not shown since they have no budget goal of their own, but they con- + o The subaccounts expenses:food:groceries and expenses:food:dining are + not shown since they have no budget goal of their own, but they con- tribute to expenses:food's actual amount. - o Unbudgeted accounts expenses:movies and expenses:gifts are also not + o Unbudgeted accounts expenses:movies and expenses:gifts are also not shown, but they contribute to expenses's actual amount. - o The other unbudgeted accounts income and assets:bank:checking are + o The other unbudgeted accounts income and assets:bank:checking are grouped as . - o --depth or depth: can be used to limit report depth in the usual way + o --depth or depth: can be used to limit report depth in the usual way (but will not reveal unbudgeted subaccounts). o Amounts are always inclusive of subaccounts (even in -l/--list mode). o Numbers displayed in a --budget report will not always agree with the - totals, because of hidden unbudgeted accounts; this is normal. + totals, because of hidden unbudgeted accounts; this is normal. -E/--empty can be used to reveal the hidden accounts. o In the periodic rules used for setting budget goals, unbalanced post- ings are convenient. - o You can filter budget reports with the usual queries, eg to focus on - particular accounts. It's common to restrict them to just expenses. - (The account is occasionally hard to exclude; this is + o You can filter budget reports with the usual queries, eg to focus on + particular accounts. It's common to restrict them to just expenses. + (The account is occasionally hard to exclude; this is because of date surprises, discussed below.) - o When you have multiple currencies, you may want to convert them to - one (-X COMM --infer-market-prices) and/or show just one at a time - (cur:COMM). If you do need to show multiple currencies at once, + o When you have multiple currencies, you may want to convert them to + one (-X COMM --infer-market-prices) and/or show just one at a time + (cur:COMM). If you do need to show multiple currencies at once, --layout bare can be helpful. - o You can "roll over" amounts (actual and budgeted) to the next period + o You can "roll over" amounts (actual and budgeted) to the next period with --cumulative. See also: https://hledger.org/budgeting.html. Budget date surprises - With small data, or when starting out, some of the generated budget - goal transaction dates might fall outside the report periods. Eg with - the following journal and report, the first period appears to have no - expenses:food budget. (Also the account should be ex- + With small data, or when starting out, some of the generated budget + goal transaction dates might fall outside the report periods. Eg with + the following journal and report, the first period appears to have no + expenses:food budget. (Also the account should be ex- cluded by the expenses query, but isn't.): ~ monthly in 2020 @@ -8975,64 +8990,64 @@ Advanced report commands ---------------++-------------------- || $400 [80% of $500] - In this case, the budget goal transactions are generated on first days - of of month (this can be seen with hledger print --forecast tag:gener- - ated expenses). Whereas the report period defaults to just the 15th - day of january (this can be seen from the report table's column head- + In this case, the budget goal transactions are generated on first days + of of month (this can be seen with hledger print --forecast tag:gener- + ated expenses). Whereas the report period defaults to just the 15th + day of january (this can be seen from the report table's column head- ings). - To fix this kind of thing, be more explicit about the report period - (and/or the periodic rules' dates). In this case, adding -b 2020 does + To fix this kind of thing, be more explicit about the report period + (and/or the periodic rules' dates). In this case, adding -b 2020 does the trick. Selecting budget goals - By default, the budget report uses all available periodic transaction - rules to generate goals. This includes rules with a different report - interval from your report. Eg if you have daily, weekly and monthly - periodic rules, all of these will contribute to the goals in a monthly + By default, the budget report uses all available periodic transaction + rules to generate goals. This includes rules with a different report + interval from your report. Eg if you have daily, weekly and monthly + periodic rules, all of these will contribute to the goals in a monthly budget report. - You can select a subset of periodic rules by providing an argument to - the --budget flag. --budget=DESCPAT will match all periodic rules + You can select a subset of periodic rules by providing an argument to + the --budget flag. --budget=DESCPAT will match all periodic rules whose description contains DESCPAT, a case-insensitive substring (not a - regular expression or query). This means you can give your periodic - rules descriptions (remember that two spaces are needed between period - expression and description), and then select from multiple budgets de- + regular expression or query). This means you can give your periodic + rules descriptions (remember that two spaces are needed between period + expression and description), and then select from multiple budgets de- fined in your journal. Budgeting vs forecasting - --forecast and --budget both use the periodic transaction rules in the - journal to generate temporary transactions for reporting purposes. - However they are separate features - though you can use both at the + --forecast and --budget both use the periodic transaction rules in the + journal to generate temporary transactions for reporting purposes. + However they are separate features - though you can use both at the same time if you want. Here are some differences between them: --forecast --budget -------------------------------------------------------------------------- - is a general option; it enables fore- is a balance command option; it - casting with all reports selects the balance report's + is a general option; it enables fore- is a balance command option; it + casting with all reports selects the balance report's budget mode - generates visible transactions which generates invisible transactions + generates visible transactions which generates invisible transactions appear in reports which produce goal amounts - generates forecast transactions from generates budget goal transac- - after the last regular transaction, to tions throughout the report pe- - the end of the report period; or with riod, optionally restricted by - an argument --forecast=PERIODEXPR gen- periods specified in the peri- - erates them throughout the specified odic transaction rules - period, both optionally restricted by - periods specified in the periodic + generates forecast transactions from generates budget goal transac- + after the last regular transaction, to tions throughout the report pe- + the end of the report period; or with riod, optionally restricted by + an argument --forecast=PERIODEXPR gen- periods specified in the peri- + erates them throughout the specified odic transaction rules + period, both optionally restricted by + periods specified in the periodic transaction rules uses all periodic rules uses all periodic rules; or with an argument --budget=DESCPAT - uses just the rules matched by + uses just the rules matched by DESCPAT Balance report layout The --layout option affects how balance and the other balance-like com- - mands show multi-commodity amounts and commodity symbols. It can im- + mands show multi-commodity amounts and commodity symbols. It can im- prove readability, for humans and/or machines (other software). It has four possible values: - o --layout=wide[,WIDTH]: commodities are shown on a single line, op- + o --layout=wide[,WIDTH]: commodities are shown on a single line, op- tionally elided to WIDTH o --layout=tall: each commodity is shown on a separate line @@ -9040,11 +9055,11 @@ Advanced report commands o --layout=bare: commodity symbols are in their own column, amounts are bare numbers - o --layout=tidy: data is normalised to easily-consumed "tidy" form, - with one row per data value. (This one is currently supported only + o --layout=tidy: data is normalised to easily-consumed "tidy" form, + with one row per data value. (This one is currently supported only by the balance command.) - Here are the --layout modes supported by each output format Only CSV + Here are the --layout modes supported by each output format Only CSV output supports all of them: - txt csv html json sql @@ -9080,7 +9095,7 @@ Advanced report commands || 10.00 ITOT, 337.18 USD, 2 more.. 70.00 GLD, 18.00 ITOT, 3 more.. -11.00 ITOT, 3 more.. 70.00 GLD, 17.00 ITOT, 3 more.. Tall layout - Each commodity gets a new line (may be different in each column), and + Each commodity gets a new line (may be different in each column), and account names are repeated: $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=tall @@ -9101,7 +9116,7 @@ Advanced report commands || 18.00 VHT 294.00 VHT Bare layout - Commodity symbols are kept in one column, each commodity has its own + Commodity symbols are kept in one column, each commodity has its own row, amounts are bare numbers, account names are repeated: $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=bare @@ -9137,15 +9152,15 @@ Advanced report commands "Total:","VEA","36.00" "Total:","VHT","294.00" - Bare layout will sometimes display an extra row for the no-symbol com- - modity, because of zero amounts (hledger treats zeroes as commod- + Bare layout will sometimes display an extra row for the no-symbol com- + modity, because of zero amounts (hledger treats zeroes as commod- ity-less, usually). This can break hledger-bar confusingly (workaround: add a cur: query to exclude the no-symbol row). Tidy layout This produces normalised "tidy data" (see https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html) - where every variable has its own column and each row represents a sin- + where every variable has its own column and each row represents a sin- gle data point. This is the easiest kind of data for other software to consume: @@ -9168,40 +9183,40 @@ Advanced report commands "Assets:US:ETrade","2014","2014-01-01","2014-12-31","VHT","170.00" Balance report output - As noted in Output format, if you choose HTML output (by using -O html + As noted in Output format, if you choose HTML output (by using -O html or -o somefile.html), you can create a hledger.css file in the same di- rectory to customise the report's appearance. The HTML and FODS output formats can generate hyperlinks to a - hledger-web register view for each account and period. E.g. if your + hledger-web register view for each account and period. E.g. if your hledger-web server is reachable at http://localhost:5000 then you might - run the balance command with the extra option --base-url=http://local- - host:5000. You can also produce relative links, like + run the balance command with the extra option --base-url=http://local- + host:5000. You can also produce relative links, like --base-url="some/path" or --base-url="".) Some useful balance reports Some frequently used balance options/reports are: o bal -M revenues expenses - Show revenues/expenses in each month. Also available as the incomes- + Show revenues/expenses in each month. Also available as the incomes- tatement command. o bal -M -H assets liabilities - Show historical asset/liability balances at each month end. Also + Show historical asset/liability balances at each month end. Also available as the balancesheet command. o bal -M -H assets liabilities equity - Show historical asset/liability/equity balances at each month end. + Show historical asset/liability/equity balances at each month end. Also available as the balancesheetequity command. o bal -M assets not:receivable - Show changes to liquid assets in each month. Also available as the + Show changes to liquid assets in each month. Also available as the cashflow command. Also: o bal -M expenses -2 -SA - Show monthly expenses summarised to depth 2 and sorted by average + Show monthly expenses summarised to depth 2 and sorted by average amount. o bal -M --budget expenses @@ -9215,7 +9230,7 @@ Advanced report commands Show top gainers [or losers] last week roi - Shows the time-weighted (TWR) and money-weighted (IRR) rate of return + Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on your investments. Flags: @@ -9225,38 +9240,38 @@ Advanced report commands --profit-loss=QUERY --pnl query to select profit-and-loss or appreciation/valuation transactions - At a minimum, you need to supply a query (which could be just an ac- - count name) to select your investment(s) with --inv, and another query + At a minimum, you need to supply a query (which could be just an ac- + count name) to select your investment(s) with --inv, and another query to identify your profit and loss transactions with --pnl. - If you do not record changes in the value of your investment manually, - or do not require computation of time-weighted return (TWR), --pnl + If you do not record changes in the value of your investment manually, + or do not require computation of time-weighted return (TWR), --pnl could be an empty query (--pnl "" or --pnl STR where STR does not match any of your accounts). - This command will compute and display the internalized rate of return - (IRR, also known as money-weighted rate of return) and time-weighted - rate of return (TWR) for your investments for the time period re- - quested. IRR is always annualized due to the way it is computed, but - TWR is reported both as a rate over the chosen reporting period and as + This command will compute and display the internalized rate of return + (IRR, also known as money-weighted rate of return) and time-weighted + rate of return (TWR) for your investments for the time period re- + quested. IRR is always annualized due to the way it is computed, but + TWR is reported both as a rate over the chosen reporting period and as an annual rate. - Price directives will be taken into account if you supply appropriate + Price directives will be taken into account if you supply appropriate --cost or --value flags (see VALUATION). Note, in some cases this report can fail, for these reasons: - o Error (NotBracketed): No solution for Internal Rate of Return (IRR). - Possible causes: IRR is huge (>1000000%), balance of investment be- + o Error (NotBracketed): No solution for Internal Rate of Return (IRR). + Possible causes: IRR is huge (>1000000%), balance of investment be- comes negative at some point in time. - o Error (SearchFailed): Failed to find solution for Internal Rate of + o Error (SearchFailed): Failed to find solution for Internal Rate of Return (IRR). Either search does not converge to a solution, or con- verges too slowly. Examples: - o Using roi to compute total return of investment in stocks: + o Using roi to compute total return of investment in stocks: https://github.com/simonmichael/hledger/blob/master/examples/invest- ing/roi-unrealised.ledger @@ -9266,28 +9281,28 @@ Advanced report commands Note that --inv and --pnl's argument is a query, and queries could have several space-separated terms (see QUERIES). - To indicate that all search terms form single command-line argument, + To indicate that all search terms form single command-line argument, you will need to put them in quotes (see Special characters): $ hledger roi --inv 'term1 term2 term3 ...' - If any query terms contain spaces themselves, you will need an extra + If any query terms contain spaces themselves, you will need an extra level of nested quoting, eg: $ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'" Semantics of --inv and --pnl - Query supplied to --inv has to match all transactions that are related + Query supplied to --inv has to match all transactions that are related to your investment. Transactions not matching --inv will be ignored. In these transactions, ROI will conside postings that match --inv to be - "investment postings" and other postings (not matching --inv) will be - sorted into two categories: "cash flow" and "profit and loss", as ROI - needs to know which part of the investment value is your contributions + "investment postings" and other postings (not matching --inv) will be + sorted into two categories: "cash flow" and "profit and loss", as ROI + needs to know which part of the investment value is your contributions and which is due to the return on investment. o "Cash flow" is depositing or withdrawing money, buying or selling as- - sets, or otherwise converting between your investment commodity and + sets, or otherwise converting between your investment commodity and any other commodity. Example: 2019-01-01 Investing in Snake Oil @@ -9304,12 +9319,12 @@ Advanced report commands investment:snake oil = $57 equity:unrealized profit or loss - All non-investment postings are assumed to be "cash flow", unless they - match --pnl query. Changes in value of your investment due to "profit - and loss" postings will be considered as part of your investment re- + All non-investment postings are assumed to be "cash flow", unless they + match --pnl query. Changes in value of your investment due to "profit + and loss" postings will be considered as part of your investment re- turn. - Example: if you use --inv snake --pnl equity:unrealized, then postings + Example: if you use --inv snake --pnl equity:unrealized, then postings in the example below would be classifed as: 2019-01-01 Snake Oil #1 @@ -9326,58 +9341,58 @@ Advanced report commands snake oil $50 ; investment posting IRR and TWR explained - "ROI" stands for "return on investment". Traditionally this was com- - puted as a difference between current value of investment and its ini- + "ROI" stands for "return on investment". Traditionally this was com- + puted as a difference between current value of investment and its ini- tial value, expressed in percentage of the initial value. However, this approach is only practical in simple cases, where invest- - ments receives no in-flows or out-flows of money, and where rate of + ments receives no in-flows or out-flows of money, and where rate of growth is fixed over time. For more complex scenarios you need differ- - ent ways to compute rate of return, and this command implements two of + ent ways to compute rate of return, and this command implements two of them: IRR and TWR. - Internal rate of return, or "IRR" (also called "money-weighted rate of - return") takes into account effects of in-flows and out-flows, and the - time between them. Investment at a particular fixed interest rate is - going to give you more interest than the same amount invested at the - same interest rate, but made later in time. If you are withdrawing - from your investment, your future gains would be smaller (in absolute - numbers), and will be a smaller percentage of your initial investment, + Internal rate of return, or "IRR" (also called "money-weighted rate of + return") takes into account effects of in-flows and out-flows, and the + time between them. Investment at a particular fixed interest rate is + going to give you more interest than the same amount invested at the + same interest rate, but made later in time. If you are withdrawing + from your investment, your future gains would be smaller (in absolute + numbers), and will be a smaller percentage of your initial investment, so your IRR will be smaller. And if you are adding to your investment, you will receive bigger absolute gains, which will be a bigger percent- age of your initial investment, so your IRR will be larger. - As mentioned before, in-flows and out-flows would be any cash that you + As mentioned before, in-flows and out-flows would be any cash that you personally put in or withdraw, and for the "roi" command, these are the - postings that match the query in the--inv argument and NOT match the + postings that match the query in the--inv argument and NOT match the query in the--pnl argument. - If you manually record changes in the value of your investment as - transactions that balance them against "profit and loss" (or "unreal- - ized gains") account or use price directives, then in order for IRR to - compute the precise effect of your in-flows and out-flows on the rate - of return, you will need to record the value of your investement on or + If you manually record changes in the value of your investment as + transactions that balance them against "profit and loss" (or "unreal- + ized gains") account or use price directives, then in order for IRR to + compute the precise effect of your in-flows and out-flows on the rate + of return, you will need to record the value of your investement on or close to the days when in- or out-flows occur. - In technical terms, IRR uses the same approach as computation of net + In technical terms, IRR uses the same approach as computation of net present value, and tries to find a discount rate that makes net present value of all the cash flows of your investment to add up to zero. This - could be hard to wrap your head around, especially if you haven't done + could be hard to wrap your head around, especially if you haven't done discounted cash flow analysis before. Implementation of IRR in hledger should produce results that match the =XIRR formula in Excel. - Second way to compute rate of return that roi command implements is - called "time-weighted rate of return" or "TWR". Like IRR, it will ac- - count for the effect of your in-flows and out-flows, but unlike IRR it - will try to compute the true rate of return of the underlying asset, - compensating for the effect that deposits and withdrawas have on the + Second way to compute rate of return that roi command implements is + called "time-weighted rate of return" or "TWR". Like IRR, it will ac- + count for the effect of your in-flows and out-flows, but unlike IRR it + will try to compute the true rate of return of the underlying asset, + compensating for the effect that deposits and withdrawas have on the apparent rate of growth of your investment. - TWR represents your investment as an imaginary "unit fund" where - in-flows/ out-flows lead to buying or selling "units" of your invest- - ment and changes in its value change the value of "investment unit". - Change in "unit price" over the reporting period gives you rate of re- - turn of your investment, and make TWR less sensitive than IRR to the + TWR represents your investment as an imaginary "unit fund" where + in-flows/ out-flows lead to buying or selling "units" of your invest- + ment and changes in its value change the value of "investment unit". + Change in "unit price" over the reporting period gives you rate of re- + turn of your investment, and make TWR less sensitive than IRR to the effects of cash in-flows and out-flows. References: @@ -9390,7 +9405,7 @@ Advanced report commands o IRR vs TWR - o Examples of computing IRR and TWR and discussion of the limitations + o Examples of computing IRR and TWR and discussion of the limitations of both metrics Chart commands @@ -9400,8 +9415,8 @@ Chart commands Flags: no command-specific flags - The activity command displays an ascii histogram showing transaction - counts by day, week, month or other reporting interval (by day is the + The activity command displays an ascii histogram showing transaction + counts by day, week, month or other reporting interval (by day is the default). With query arguments, it counts only matched transactions. Examples: @@ -9416,10 +9431,10 @@ Data generation commands close (equity) - close prints several kinds of "closing" and/or "opening" transactions, + close prints several kinds of "closing" and/or "opening" transactions, useful in various situations: migrating balances to a new journal file, - retaining earnings into equity, consolidating balances, viewing lot - costs.. Like print, it prints valid journal entries. You can copy + retaining earnings into equity, consolidating balances, viewing lot + costs.. Like print, it prints valid journal entries. You can copy these into your journal file(s) when you are happy with how they look. Flags: @@ -9450,13 +9465,13 @@ Data generation commands all - also round cost amounts to precision (can unbalance transactions) - close has six modes, selected by choosing one of the mode flags - (--close is the default). They all do much the same operation, but + close has six modes, selected by choosing one of the mode flags + (--close is the default). They all do much the same operation, but with different defaults, useful in different situations. close --clopen This is useful if migrating balances to a new journal file at the start - of a new year. It prints a "closing balances" transaction that zeroes + of a new year. It prints a "closing balances" transaction that zeroes out account balances (Asset and Liability accounts, by default), and an opposite "opening balances" transaction that restores them again. Typ- ically, you would run @@ -9467,45 +9482,45 @@ Data generation commands (and probably also update your LEDGER_FILE environment variable). Why might you do this ? If your reports are fast, you may not need it. - But at some point you will probably want to partition your data by - time, for performance or data integrity or regulatory reasons. A new - file or set of files per year is common. Then, having each file/file- - set "bookended" with opening and closing balance transactions will al- - low you to freely pick and choose which files to read - just the cur- + But at some point you will probably want to partition your data by + time, for performance or data integrity or regulatory reasons. A new + file or set of files per year is common. Then, having each file/file- + set "bookended" with opening and closing balance transactions will al- + low you to freely pick and choose which files to read - just the cur- rent year, any past year, any sequence of years, or all of them - while - showing correct account balances in each case. The earliest opening - balances transaction sets correct starting balances, and any later + showing correct account balances in each case. The earliest opening + balances transaction sets correct starting balances, and any later closing/opening pairs will harmlessly cancel each other out. - The balances will be transferred to and from equity:opening/closing - balances by default. You can override this by using --close-acct + The balances will be transferred to and from equity:opening/closing + balances by default. You can override this by using --close-acct and/or --open-acct. - You can select a different set of accounts to close/open by providing - an account query. Eg to add Equity accounts, provide arguments like - assets liabilities equity or type:ALE. When migrating to a new file, - you'll usually want to bring along the AL or ALE accounts, but not the + You can select a different set of accounts to close/open by providing + an account query. Eg to add Equity accounts, provide arguments like + assets liabilities equity or type:ALE. When migrating to a new file, + you'll usually want to bring along the AL or ALE accounts, but not the RX accounts (Revenue, Expense). - Assertions will be added indicating and checking the new balances of + Assertions will be added indicating and checking the new balances of the closed/opened accounts. - The generated transactions will have a clopen: tag. If the main jour- - nal's base file name contains a number (eg a year number), the tag's - value will be that base file name with the number incremented. Or you + The generated transactions will have a clopen: tag. If the main jour- + nal's base file name contains a number (eg a year number), the tag's + value will be that base file name with the number incremented. Or you can choose the tag value yourself, by using --clopen=TAGVAL. close --close - This prints just the closing balances transaction of --clopen. It is + This prints just the closing balances transaction of --clopen. It is the default if you don't specify a mode. - More customisation options are described below. Among other things, + More customisation options are described below. Among other things, you can use close --close to generate a transaction moving the balances from any set of accounts, to a different account. (If you need to move just a portion of the balance, see hledger-move.) close --open - This prints just the opening balances transaction of --clopen. (It is + This prints just the opening balances transaction of --clopen. (It is similar to Ledger's equity command.) close --assert @@ -9515,29 +9530,29 @@ Data generation commands close --assign This prints a transaction that assigns the account balances as they are - on the end date (and adds an "assign:" tag). Unlike balance asser- + on the end date (and adds an "assign:" tag). Unlike balance asser- tions, assignments will post changes to balances as needed to reach the specified amounts. - This is another way to set starting balances when migrating to a new - file, and it will set them correctly even in the presence of earlier - files which do not have a closing balances transaction. However, it - can hide errors, and disturb the accounting equation, so --clopen is + This is another way to set starting balances when migrating to a new + file, and it will set them correctly even in the presence of earlier + files which do not have a closing balances transaction. However, it + can hide errors, and disturb the accounting equation, so --clopen is usually recommended. close --retain - This is like --close, but it closes Revenue and Expense account bal- - ances by default. They will be transferred to equity:retained earn- + This is like --close, but it closes Revenue and Expense account bal- + ances by default. They will be transferred to equity:retained earn- ings, or another account specified with --close-acct. - Revenues and expenses correspond to changes in equity. They are cate- + Revenues and expenses correspond to changes in equity. They are cate- gorised separately for reporting purposes, but traditionally at the end - of each accounting period, businesses consolidate them into equity, + of each accounting period, businesses consolidate them into equity, This is called "retaining earnings", or "closing the books". - In personal accounting, there's not much reason to do this, and most - people don't. (One reason to do it is to help the balancesheetequity - report show a zero total, demonstrating that the accounting equation + In personal accounting, there's not much reason to do this, and most + people don't. (One reason to do it is to help the balancesheetequity + report show a zero total, demonstrating that the accounting equation (A-L=E) is satisfied.) close customisation @@ -9547,57 +9562,57 @@ Data generation commands o the balancing account, with --close-acct=ACCT and/or --open-acct=ACCT - o the transaction descriptions, with --close-desc=DESC and + o the transaction descriptions, with --close-desc=DESC and --open-desc=DESC o the transaction's tag value, with a --MODE=NEW option argument o the closing/opening dates, with -e OPENDATE - By default, the closing date is yesterday, or the journal's end date, - whichever is later; and the opening date is always one day after the - closing date. You can change these by specifying a report end date; + By default, the closing date is yesterday, or the journal's end date, + whichever is later; and the opening date is always one day after the + closing date. You can change these by specifying a report end date; the closing date will be the last day of the report period. Eg -e 2024 means "close on 2023-12-31, open on 2024-01-01". With --x/--explicit, the balancing amount will be shown explicitly, and - if it involves multiple commodities, a separate posting will be gener- + if it involves multiple commodities, a separate posting will be gener- ated for each of them (similar to print -x). - With --interleaved, each individual transfer is shown with source and - destination postings next to each other (perhaps useful for trou- + With --interleaved, each individual transfer is shown with source and + destination postings next to each other (perhaps useful for trou- bleshooting). With --show-costs, balances' costs are also shown, with different costs - kept separate. This may generate very large journal entries, if you - have many currency conversions or investment transactions. close - --show-costs is currently the best way to view investment lots with - hledger. (To move or dispose of lots, see the more capable + kept separate. This may generate very large journal entries, if you + have many currency conversions or investment transactions. close + --show-costs is currently the best way to view investment lots with + hledger. (To move or dispose of lots, see the more capable hledger-move script.) close and balance assertions close adds balance assertions verifying that the accounts have been re- set to zero in a closing transaction or restored to their previous bal- - ances in an opening transaction. These provide useful error checking, + ances in an opening transaction. These provide useful error checking, but you can ignore them temporarily with -I, or remove them if you pre- fer. - Single-commodity, subaccount-exclusive balance assertions (=) are gen- - erated by default. This can be changed with --assertion-type='==*' + Single-commodity, subaccount-exclusive balance assertions (=) are gen- + erated by default. This can be changed with --assertion-type='==*' (eg). - When running close you should probably avoid using -C, -R, status: - (filtering by status or realness) or --auto (generating postings), + When running close you should probably avoid using -C, -R, status: + (filtering by status or realness) or --auto (generating postings), since the generated balance assertions would then require these. - Transactions with multiple dates (eg posting dates) spanning the file + Transactions with multiple dates (eg posting dates) spanning the file boundary also can disrupt the balance assertions: 2023-12-30 a purchase made in december, cleared in january expenses:food 5 assets:bank:checking -5 ; date: 2023-01-02 - To solve this you can transfer the money to and from a temporary ac- + To solve this you can transfer the money to and from a temporary ac- count, splitting the multi-day transaction into two single-day transac- tions: @@ -9618,7 +9633,7 @@ Data generation commands $ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal - After this, to see 2022's revenues and expenses you must exclude the + After this, to see 2022's revenues and expenses you must exclude the retain earnings transaction: $ hledger -f 2022.journal is not:desc:'retain earnings' @@ -9630,12 +9645,12 @@ Data generation commands # copy/paste the closing transaction to the end of 2022.journal # copy/paste the opening transaction to the start of 2023.journal - After this, to see 2022's end-of-year balances you must exclude the + After this, to see 2022's end-of-year balances you must exclude the closing balances transaction: $ hledger -f 2022.journal bs not:desc:'closing balances' - For more flexibility, it helps to tag closing and opening transactions + For more flexibility, it helps to tag closing and opening transactions with eg clopen:NEWYEAR, then you can ensure correct balances by exclud- ing all opening/closing transactions except the first, like so: @@ -9651,7 +9666,7 @@ Data generation commands rewrite Print all transactions, rewriting the postings of matched transactions. - For now the only rewrite available is adding new postings, like print + For now the only rewrite available is adding new postings, like print --auto. Flags: @@ -9665,9 +9680,9 @@ Data generation commands patch tool This is a start at a generic rewriter of transaction entries. It reads - the default journal and prints the transactions, like print, but adds + the default journal and prints the transactions, like print, but adds one or more specified postings to any transactions matching QUERY. The - posting amounts can be fixed, or a multiplier of the existing transac- + posting amounts can be fixed, or a multiplier of the existing transac- tion's first posting amount. Examples: @@ -9683,7 +9698,7 @@ Data generation commands (reserve:grocery) *0.25 ; reserve 25% for grocery (reserve:) *0.25 ; reserve 25% for grocery - Note the single quotes to protect the dollar sign from bash, and the + Note the single quotes to protect the dollar sign from bash, and the two spaces between account and amount. More: @@ -9693,16 +9708,16 @@ Data generation commands $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"' $ hledger rewrite -- ^income --add-posting '(budget:foreign currency) *0.25 JPY; diversify' - Argument for --add-posting option is a usual posting of transaction - with an exception for amount specification. More precisely, you can + Argument for --add-posting option is a usual posting of transaction + with an exception for amount specification. More precisely, you can use '*' (star symbol) before the amount to indicate that that this is a - factor for an amount of original matched posting. If the amount in- + factor for an amount of original matched posting. If the amount in- cludes a commodity name, the new posting amount will be in the new com- - modity; otherwise, it will be in the matched posting amount's commod- + modity; otherwise, it will be in the matched posting amount's commod- ity. Re-write rules in a file - During the run this tool will execute so called "Automated Transac- + During the run this tool will execute so called "Automated Transac- tions" found in any journal it process. I.e instead of specifying this operations in command line you can put them in a journal file. @@ -9717,7 +9732,7 @@ Data generation commands budget:gifts *-1 assets:budget *1 - Note that '=' (equality symbol) that is used instead of date in trans- + Note that '=' (equality symbol) that is used instead of date in trans- actions you usually write. It indicates the query by which you want to match the posting to add new ones. @@ -9730,12 +9745,12 @@ Data generation commands --add-posting 'assets:budget *1' \ > rewritten-tidy-output.journal - It is important to understand that relative order of such entries in - journal is important. You can re-use result of previously added post- + It is important to understand that relative order of such entries in + journal is important. You can re-use result of previously added post- ings. Diff output format - To use this tool for batch modification of your journal files you may + To use this tool for batch modification of your journal files you may find useful output in form of unified diff. $ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax) *.33' @@ -9759,10 +9774,10 @@ Data generation commands If you'll pass this through patch tool you'll get transactions contain- ing the posting that matches your query be updated. Note that multiple - files might be update according to list of input files specified via + files might be update according to list of input files specified via --file options and include directives inside of these files. - Be careful. Whole transaction being re-formatted in a style of output + Be careful. Whole transaction being re-formatted in a style of output from hledger print. See also: @@ -9770,17 +9785,17 @@ Data generation commands https://github.com/simonmichael/hledger/issues/99 rewrite vs. print --auto - This command predates print --auto, and currently does much the same + This command predates print --auto, and currently does much the same thing, but with these differences: - o with multiple files, rewrite lets rules in any file affect all other - files. print --auto uses standard directive scoping; rules affect + o with multiple files, rewrite lets rules in any file affect all other + files. print --auto uses standard directive scoping; rules affect only child files. - o rewrite's query limits which transactions can be rewritten; all are + o rewrite's query limits which transactions can be rewritten; all are printed. print --auto's query limits which transactions are printed. - o rewrite applies rules specified on command line or in the journal. + o rewrite applies rules specified on command line or in the journal. print --auto applies rules specified in the journal. Maintenance commands @@ -9790,63 +9805,63 @@ Maintenance commands Flags: no command-specific flags - hledger provides a number of built-in correctness checks to help vali- - date your data and prevent errors. Some are run automatically, some - when you enable --strict mode; or you can run any of them on demand by - providing them as arguments to the check command. check produces no + hledger provides a number of built-in correctness checks to help vali- + date your data and prevent errors. Some are run automatically, some + when you enable --strict mode; or you can run any of them on demand by + providing them as arguments to the check command. check produces no output and a zero exit code if all is well. Eg: hledger check # run basic checks hledger check -s # run basic and strict checks hledger check ordereddates payees # run basic checks and two others - If you are an Emacs user, you can also configure flycheck-hledger to + If you are an Emacs user, you can also configure flycheck-hledger to run these checks, providing instant feedback as you edit the journal. Here are the checks currently available. Generally, they are performed - in the order they are shown here (and only the first failure is re- + in the order they are shown here (and only the first failure is re- ported). Basic checks - These important checks are performed by default, by almost all hledger + These important checks are performed by default, by almost all hledger commands: - o parseable - data files are in a supported format, with no syntax er- - rors and no invalid include directives. This ensures that all files + o parseable - data files are in a supported format, with no syntax er- + rors and no invalid include directives. This ensures that all files exist and are readable. o autobalanced - all transactions are balanced, after automatically in- - ferring missing amounts and conversion rates and then converting - amounts to cost. This ensures that each transaction's entry is well + ferring missing amounts and conversion rates and then converting + amounts to cost. This ensures that each transaction's entry is well formed. o assertions - all balance assertions in the journal are passing. Bal- - ance assertions are a strong defense against errors; they help catch - many problems. If this check gets in your way, you can disable it + ance assertions are a strong defense against errors; they help catch + many problems. If this check gets in your way, you can disable it with -I/--ignore-assertions. Or you can add that to your config file - to disable it by default (and then use -s/--strict or hledger check + to disable it by default (and then use -s/--strict or hledger check assertions to enable it). Strict checks These additional checks are performed by all commands when the - -s/--strict flag is used (strict mode). They provide extra er- - ror-catching power to keep your data clean and correct. Strict mode + -s/--strict flag is used (strict mode). They provide extra er- + ror-catching power to keep your data clean and correct. Strict mode also always enables the assertions check. o balanced - like autobalanced, but all conversions between commodities - must use explicit cost notation or equity postings. This prevents + must use explicit cost notation or equity postings. This prevents wrong conversions caused by typos. - o commodities - all commodity symbols used must be declared. This - guards against mistyping or omitting commodity symbols. Declaring - commodities also sets their precision for display and transaction + o commodities - all commodity symbols used must be declared. This + guards against mistyping or omitting commodity symbols. Declaring + commodities also sets their precision for display and transaction balancing. - o accounts - all account names used must be declared. This prevents + o accounts - all account names used must be declared. This prevents the use of mis-spelled or outdated account names. Other checks - These are not wanted by everyone, but can be run using the check com- + These are not wanted by everyone, but can be run using the check com- mand: o tags - all tags used must be declared. This prevents mis-spelled tag @@ -9856,39 +9871,39 @@ Maintenance commands force you to declare any new payee name before using it. Most people will probably find this a bit too strict. - o ordereddates - within each file, transactions must be ordered by - date. This is a simple and effective error catcher. It's not in- + o ordereddates - within each file, transactions must be ordered by + date. This is a simple and effective error catcher. It's not in- cluded in strict mode, but you can add it by running hledger check -s ordereddates. If enabled, this check is performed before balance as- sertions. o recentassertions - all accounts with balance assertions must have one - that's within the 7 days before their latest posting. This will en- + that's within the 7 days before their latest posting. This will en- courage adding balance assertions for your active asset/liability ac- - counts, which in turn should encourage you to reconcile regularly - with those real world balances - another strong defense against er- - rors. hledger close --assert can help generate assertion entries. + counts, which in turn should encourage you to reconcile regularly + with those real world balances - another strong defense against er- + rors. hledger close --assert can help generate assertion entries. Over time the older assertions become somewhat redundant, and you can remove them if you like (they don't affect performance much, but they add some noise to the journal). o uniqueleafnames - no two accounts may have the same last account name - part (eg the checking in assets:bank:checking). This ensures each + part (eg the checking in assets:bank:checking). This ensures each account can be matched by a unique short name, easier to remember and to type. Custom checks - You can build your own custom checks with add-on command scripts. See + You can build your own custom checks with add-on command scripts. See also Cookbook > Scripting. Here are some examples from hledger/bin/: - o hledger-check-tagfiles - all tag values containing / (a forward + o hledger-check-tagfiles - all tag values containing / (a forward slash) exist as file paths - o hledger-check-fancyassertions - more complex balance assertions are + o hledger-check-fancyassertions - more complex balance assertions are passing diff - Compares a particular account's transactions in two input files. It + Compares a particular account's transactions in two input files. It shows any transactions to this account which are in one file but not in the other. @@ -9896,16 +9911,16 @@ Maintenance commands no command-specific flags More precisely: for each posting affecting this account in either file, - this command looks for a corresponding posting in the other file which - posts the same amount to the same account (ignoring date, description, + this command looks for a corresponding posting in the other file which + posts the same amount to the same account (ignoring date, description, etc). Since it compares postings, not transactions, this also works when mul- tiple bank transactions have been combined into a single journal entry. - This command is useful eg if you have downloaded an account's transac- - tions from your bank (eg as CSV data): when hledger and your bank dis- - agree about the account balance, you can compare the bank data with + This command is useful eg if you have downloaded an account's transac- + tions from your bank (eg as CSV data): when hledger and your bank dis- + agree about the account balance, you can compare the bank data with your journal to find out the cause. Examples: @@ -9926,18 +9941,18 @@ Maintenance commands Flags: no command-specific flags - setup tests your hledger installation and prints a list of results, - sometimes with helpful hints. This is a good first command to run af- - ter installing hledger. Also after upgrading, or when something's not + setup tests your hledger installation and prints a list of results, + sometimes with helpful hints. This is a good first command to run af- + ter installing hledger. Also after upgrading, or when something's not working, or just when you want a reminder of where things are. - It makes one network request to detect the latest hledger release ver- - sion. It's ok if this fails or times out. It will use ANSI color by - default, unless disabled by NO_COLOR or --color=n. It does not use a + It makes one network request to detect the latest hledger release ver- + sion. It's ok if this fails or times out. It will use ANSI color by + default, unless disabled by NO_COLOR or --color=n. It does not use a pager or a config file. - It expects that the hledger version you are running is installed in - your PATH. If not, it will stop until you have done that (to keep + It expects that the hledger version you are running is installed in + your PATH. If not, it will stop until you have done that (to keep things simple). Example: @@ -9987,17 +10002,17 @@ Maintenance commands Flags: no command-specific flags - This command runs the unit tests built in to hledger and hledger-lib, - printing the results on stdout. If any test fails, the exit code will + This command runs the unit tests built in to hledger and hledger-lib, + printing the results on stdout. If any test fails, the exit code will be non-zero. - This is mainly used by hledger developers, but you can also use it to - sanity-check the installed hledger executable on your platform. All - tests are expected to pass - if you ever see a failure, please report + This is mainly used by hledger developers, but you can also use it to + sanity-check the installed hledger executable on your platform. All + tests are expected to pass - if you ever see a failure, please report as a bug! - Any arguments before a -- argument will be passed to the tasty test - runner as test-selecting -p patterns, and any arguments after -- will + Any arguments before a -- argument will be passed to the tasty test + runner as test-selecting -p patterns, and any arguments after -- will be passed to tasty unchanged. Examples: @@ -10007,7 +10022,7 @@ Maintenance commands $ hledger test -- -h # show tasty's options 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 @@ -10017,37 +10032,37 @@ Getting help $ hledger --help # show common options $ hledger CMD --help # show CMD's options, common options and CMD's documentation - You can also view your hledger version's manual in several formats by + You can also view your hledger version's manual in several formats by using the help command. Eg: $ hledger help # show the hledger manual with info, man or $PAGER (best available) $ hledger help journal # show the journal topic in the hledger manual $ hledger help --help # find out more about the help command - To view manuals and introductory docs on the web, visit - https://hledger.org. Chat and mail list support and discussion + To view manuals and introductory docs on the web, visit + https://hledger.org. Chat and mail list support and discussion archives can be found at https://hledger.org/support. Constructing command lines - hledger has a flexible command line interface. We strive to keep it - simple and ergonomic, but if you run into one of the sharp edges de- + hledger has a flexible command line interface. We strive to keep it + simple and ergonomic, but if you run into one of the sharp edges de- scribed in OPTIONS, here are some tips that might help: - o command-specific options must go after the command (it's fine to put + o command-specific options must go after the command (it's fine to put common options there too: hledger CMD OPTS ARGS) - o running add-on executables directly simplifies command line parsing + o running add-on executables directly simplifies command line parsing (hledger-ui OPTS ARGS) o enclose "problematic" args in single quotes - o if needed, also add a backslash to hide regular expression metachar- + o if needed, also add a backslash to hide regular expression metachar- acters from the shell o to see how a misbehaving command line is being parsed, add --debug=2. Starting a journal file - hledger looks for your accounting data in a journal file, + hledger looks for your accounting data in a journal file, $HOME/.hledger.journal by default: $ hledger stats @@ -10055,9 +10070,9 @@ Starting a journal file Please create it first, eg with "hledger add" or a text editor. Or, specify an existing journal file with -f or LEDGER_FILE. - You can override this by setting the LEDGER_FILE environment variable - (see below). It's a good practice to keep this important file under - version control, and to start a new file each year. So you could do + You can override this by setting the LEDGER_FILE environment variable + (see below). It's a good practice to keep this important file under + version control, and to start a new file each year. So you could do something like this: $ mkdir ~/finance @@ -10083,52 +10098,52 @@ Starting a journal file Setting LEDGER_FILE How to set LEDGER_FILE permanently depends on your setup: - On unix and mac, running these commands in the terminal will work for + On unix and mac, running these commands in the terminal will work for many people; adapt as needed: $ echo 'export LEDGER_FILE=~/finance/2023.journal' >> ~/.profile $ source ~/.profile - When correctly configured, in a new terminal window env | grep + When correctly configured, in a new terminal window env | grep LEDGER_FILE will show your file, and so will hledger files. - On mac, this additional step might be helpful for GUI applications - (like Emacs started from the dock): add an entry to ~/.MacOSX/environ- + On mac, this additional step might be helpful for GUI applications + (like Emacs started from the dock): add an entry to ~/.MacOSX/environ- ment.plist like { "LEDGER_FILE" : "~/finance/2023.journal" } - and then run killall Dock in a terminal window (or restart the ma- + and then run killall Dock in a terminal window (or restart the ma- chine). On Windows, see https://www.java.com/en/download/help/path.html, or try - running these commands in a powershell window (let us know if it per- + running these commands in a powershell window (let us know if it per- sists across a reboot, and if you need to be an Administrator): > CD > MKDIR finance > SETX LEDGER_FILE "C:\Users\USERNAME\finance\2023.journal" - When correctly configured, in a new terminal window $env:LEDGER_FILE + When correctly configured, in a new terminal window $env:LEDGER_FILE will show the file path, and so will hledger files. 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 @@ -10138,19 +10153,19 @@ Setting opening balances liabilities:creditcard $-50 = $-50 equity:opening/closing balances - These are start-of-day balances, ie whatever was in the account at + These are start-of-day balances, ie whatever was in the account at the end of the previous day. - The * after the date is an optional status flag. Here it means + The * after the date is an optional status flag. Here it means "cleared & confirmed". - The currency symbols are optional, but usually a good idea as you'll + The currency symbols are optional, but usually a good idea as you'll be dealing with multiple currencies sooner or later. - The = amounts are optional balance assertions, providing extra error + The = amounts are optional balance assertions, providing extra error checking. - o The second way: run hledger add and follow the prompts to record a + o The second way: run hledger add and follow the prompts to record a similar transaction: $ hledger add @@ -10187,18 +10202,18 @@ Setting opening balances Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2023-01-01]: . - If you're using version control, this could be a good time to commit + If you're using version control, this could be a good time to commit the journal. Eg: $ git commit -m 'initial balances' 2023.journal Recording transactions - As you spend or receive money, you can record these transactions using - one of the methods above (text editor, hledger add) or by using the - hledger-iadd or hledger-web add-ons, or by using the import command to + As you spend or receive money, you can record these transactions using + one of the methods above (text editor, hledger add) or by using the + hledger-iadd or hledger-web add-ons, or by using the import command to convert CSV data downloaded from your bank. - Here are some simple transactions, see the hledger_journal(5) manual + Here are some simple transactions, see the hledger_journal(5) manual and hledger.org for more ideas: 2023/1/10 * gift received @@ -10214,22 +10229,22 @@ Recording transactions assets:bank:checking $1000 Reconciling - Periodically you should reconcile - compare your hledger-reported bal- - ances against external sources of truth, like bank statements or your - bank's website - to be sure that your ledger accurately represents the - real-world balances (and, that the real-world institutions have not - made a mistake!). This gets easy and fast with (1) practice and (2) - frequency. If you do it daily, it can take 2-10 minutes. If you let - it pile up, expect it to take longer as you hunt down errors and dis- + Periodically you should reconcile - compare your hledger-reported bal- + ances against external sources of truth, like bank statements or your + bank's website - to be sure that your ledger accurately represents the + real-world balances (and, that the real-world institutions have not + made a mistake!). This gets easy and fast with (1) practice and (2) + frequency. If you do it daily, it can take 2-10 minutes. If you let + it pile up, expect it to take longer as you hunt down errors and dis- crepancies. A typical workflow: - 1. Reconcile cash. Count what's in your wallet. Compare with what - hledger reports (hledger bal cash). If they are different, try to - remember the missing transaction, or look for the error in the al- - ready-recorded transactions. A register report can be helpful - (hledger reg cash). If you can't find the error, add an adjustment + 1. Reconcile cash. Count what's in your wallet. Compare with what + hledger reports (hledger bal cash). If they are different, try to + remember the missing transaction, or look for the error in the al- + ready-recorded transactions. A register report can be helpful + (hledger reg cash). If you can't find the error, add an adjustment transaction. Eg if you have $105 after the above, and can't explain the missing $2, it could be: @@ -10239,26 +10254,26 @@ Reconciling 2. Reconcile checking. Log in to your bank's website. Compare today's (cleared) balance with hledger's cleared balance (hledger bal check- - ing -C). If they are different, track down the error or record the - missing transaction(s) or add an adjustment transaction, similar to + ing -C). If they are different, track down the error or record the + missing transaction(s) or add an adjustment transaction, similar to the above. Unlike the cash case, you can usually compare the trans- - action history and running balance from your bank with the one re- - ported by hledger reg checking -C. This will be easier if you gen- - erally record transaction dates quite similar to your bank's clear- + action history and running balance from your bank with the one re- + ported by hledger reg checking -C. This will be easier if you gen- + erally record transaction dates quite similar to your bank's clear- ing dates. 3. Repeat for other asset/liability accounts. - Tip: instead of the register command, use hledger-ui to see a live-up- + Tip: instead of the register command, use hledger-ui to see a live-up- dating register while you edit the journal: hledger-ui --watch --regis- ter checking -C - After reconciling, it could be a good time to mark the reconciled - transactions' status as "cleared and confirmed", if you want to track - that, by adding the * marker. Eg in the paycheck transaction above, + After reconciling, it could be a good time to mark the reconciled + transactions' status as "cleared and confirmed", if you want to track + that, by adding the * marker. Eg in the paycheck transaction above, insert * between 2023-01-15 and paycheck - If you're using version control, this can be another good time to com- + If you're using version control, this can be another good time to com- mit: $ git commit -m 'txns' 2023.journal @@ -10330,7 +10345,7 @@ Reporting -------------------- 0 - Show only asset and liability balances, as a flat list, limited to + Show only asset and liability balances, as a flat list, limited to depth 2: $ hledger bal assets liabilities -2 @@ -10340,7 +10355,7 @@ Reporting -------------------- $4055 - Show the same thing without negative numbers, formatted as a simple + Show the same thing without negative numbers, formatted as a simple balance sheet: $ hledger bs -2 @@ -10407,64 +10422,64 @@ Reporting 2023-01-13 **** Migrating to a new file - At the end of the year, you may want to continue your journal in a new + At the end of the year, you may want to continue your journal in a new file, so that old transactions don't slow down or clutter your reports, - and to help ensure the integrity of your accounting history. See the + and to help ensure the integrity of your accounting history. See the close command. If using version control, don't forget to git add the new file. BUGS - We welcome bug reports in the hledger issue tracker + We welcome bug reports in the hledger issue tracker (https://bugs.hledger.org), or on the hledger chat or 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 system locale with a suitable text encoding must be configured to + A system locale with a suitable text encoding must be configured to work with non-ascii data. (See Text encoding, 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). On Windows, $env:LEDGER_FILE should show it. - 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. Text decoding issues: I get errors like "Illegal byte sequence" or "In- - valid or incomplete multibyte or wide character" or "commitAndRelease- + valid or incomplete multibyte or wide character" or "commitAndRelease- Buffer: invalid argument (invalid character)" - hledger usually needs its input to be decodable with the system lo- + hledger usually needs its input to be decodable with the system lo- cale's text encoding. See Text encoding and Install: Text encoding. 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.