From 50a7914b3b34065e1798ad38c6cbc2738b558ed8 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 10 Jan 2021 15:37:32 -0800 Subject: [PATCH] ;update manuals --- hledger/hledger.1 | 459 ++++++++---- hledger/hledger.info | 1456 ++++++++++++++++++++------------------ hledger/hledger.txt | 1611 ++++++++++++++++++++++-------------------- 3 files changed, 1953 insertions(+), 1573 deletions(-) diff --git a/hledger/hledger.1 b/hledger/hledger.1 index 0d3000ad4..f4bde1b20 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -604,11 +604,18 @@ messages. .PP You can also force a specific reader/format by prefixing the file path with the format and a colon. -Eg to read a .dat file as csv: +Eg, to read a .dat file as csv format: .IP .nf \f[C] $ hledger -f csv:/some/csv-file.dat stats +\f[R] +.fi +.PP +Or to read stdin (\f[C]-\f[R]) as timeclock format: +.IP +.nf +\f[C] $ echo \[aq]i 2009/13/1 08:00:00\[aq] | hledger print -ftimeclock:- \f[R] .fi @@ -1277,7 +1284,13 @@ A \f[I]any chain of market prices\f[R]: a chain of any market prices, including both forward and reverse prices (1 and 2 above), leading from A to B. .PP -Amounts for which no applicable market price can be found, are not +There is a limit to the length of these price chains; if hledger reaches +that length without finding a complete chain or exhausting all +possibilities, it will give up (with a \[dq]gave up\[dq] message visible +in \f[C]--debug=2\f[R] output). +That limit is currently 1000. +.PP +Amounts for which no suitable market price can be found, are not converted. .SS --infer-value: market prices from transactions .PP @@ -1421,7 +1434,6 @@ Convert amounts to cost, using the prices recorded in transactions. \f[B]\f[CB]--value=then\f[B]\f[R] Convert amounts to their value in the default valuation commodity, using market prices on each posting\[aq]s date. -This is currently supported only by the print and register commands. .TP \f[B]\f[CB]--value=end\f[B]\f[R] Convert amounts to their value in the default valuation commodity, using @@ -1604,7 +1616,7 @@ Related: #329, #1083. .PP .TS tab(@); -lw(10.6n) lw(13.2n) lw(13.4n) lw(11.0n) lw(13.4n) lw(8.2n). +lw(9.5n) lw(11.8n) lw(12.0n) lw(17.2n) lw(12.0n) lw(7.4n). T{ Report type T}@T{ @@ -1675,7 +1687,7 @@ cost T}@T{ value at day before report or journal start T}@T{ -not supported +valued at day each historical posting was made T}@T{ value at day before report or journal start T}@T{ @@ -1742,7 +1754,7 @@ sums of costs T}@T{ value at report end or today of sums of postings T}@T{ -not supported +value at posting date T}@T{ value at report or journal end of sums of postings T}@T{ @@ -1755,7 +1767,7 @@ like balance changes T}@T{ like balance changes T}@T{ -not supported +like balance changes T}@T{ like balances T}@T{ @@ -1768,7 +1780,7 @@ sum of displayed values T}@T{ sum of displayed values T}@T{ -not supported +sum of displayed valued T}@T{ sum of displayed values T}@T{ @@ -1796,7 +1808,8 @@ sums of costs of postings before report start T}@T{ value at report start of sums of all postings before report start T}@T{ -not supported +sums of values of postings before report start at respective posting +dates T}@T{ value at report start of sums of all postings before report start T}@T{ @@ -1809,7 +1822,7 @@ sums of costs of postings in period T}@T{ same as --value=end T}@T{ -not supported +sums of values of postings in period at respective posting dates T}@T{ balance change in each period, valued at period ends T}@T{ @@ -1822,7 +1835,8 @@ sums of costs of postings from before report start to period end T}@T{ same as --value=end T}@T{ -not supported +sums of values of postings from before period start to period end at +respective posting dates T}@T{ period end balances, valued at period ends T}@T{ @@ -1835,7 +1849,7 @@ like balance changes/end balances T}@T{ like balance changes/end balances T}@T{ -not supported +like balance changes/end balances T}@T{ like balances T}@T{ @@ -1848,7 +1862,7 @@ sums, averages of displayed values T}@T{ sums, averages of displayed values T}@T{ -not supported +sums, averages of displayed values T}@T{ sums, averages of displayed values T}@T{ @@ -1861,7 +1875,7 @@ sums of displayed values T}@T{ sums of displayed values T}@T{ -not supported +sums of displayed values T}@T{ sums of displayed values T}@T{ @@ -1874,7 +1888,7 @@ sum, average of column totals T}@T{ sum, average of column totals T}@T{ -not supported +sum, average of column totals T}@T{ sum, average of column totals T}@T{ @@ -2449,10 +2463,39 @@ options The output formats supported are (in most modes): \f[C]txt\f[R], \f[C]csv\f[R], \f[C]html\f[R], and \f[C]json\f[R]. .PP The balance command can produce several styles of report: -.SS Classic balance report .PP -This is the original balance report, as found in Ledger. -It usually looks like this: +.SS Single-period flat balance report +.PP +This is the default for hledger\[aq]s balance command: a flat list of +all (or with a query, matched) accounts, showing full account names. +Accounts are sorted by declaration order if any, and then by account +name. +Accounts which have zero balance are not shown unless +\f[C]-E/--empty\f[R] is used. +The reported balances\[aq] total is shown as the last line, unless +disabled by \f[C]-N\f[R]/\f[C]--no-total\f[R]. +.IP +.nf +\f[C] +$ hledger bal + $1 assets:bank:saving + $-2 assets:cash + $1 expenses:food + $1 expenses:supplies + $-1 income:gifts + $-1 income:salary + $1 liabilities:debts +-------------------- + 0 +\f[R] +.fi +.PP +.SS Single-period tree-mode balance report +.PP +With the \f[C]-t/--tree\f[R] flag, accounts are displayed +hierarchically, showing subaccounts as short names indented below their +parent. +(This is the default style in Ledger and in older hledger versions.) .IP .nf \f[C] @@ -2472,38 +2515,30 @@ $ hledger balance \f[R] .fi .PP -By default, accounts are displayed hierarchically, with subaccounts -indented below their parent, with accounts at each level of the tree -sorted by declaration order if declared, then by account name. +For more compact output, \[dq]boring\[dq] accounts containing a single +interesting subaccount and no balance of their own +(\f[C]assets:bank\f[R] and \f[C]liabilities\f[R] here) are elided into +the following line, unless \f[C]--no-elide\f[R] is used. +And accounts which have zero balance and no non-zero subaccounts are +omitted, unless \f[C]-E/--empty\f[R] is used. .PP -\[dq]Boring\[dq] accounts, which contain a single interesting subaccount -and no balance of their own, are elided into the following line for more -compact output. -(Eg above, the \[dq]liabilities\[dq] account.) Use \f[C]--no-elide\f[R] -to prevent this. +Account balances in tree mode are \[dq]inclusive\[dq] - they include the +balances of any subaccounts. +Eg, the \f[C]assets\f[R] \f[C]$-1\f[R] balance here includes the +\f[C]$1\f[R] from \f[C]assets:bank:saving\f[R] and the \f[C]$-2\f[R] +from \f[C]assets:cash\f[R]. +(And it would include balance posted to the \f[C]assets\f[R] account +itself, if there was any). +Note this causes some repetition, and the final total (\f[C]0\f[R]) is +the sum of the top-level balances, not of all the balances shown. .PP -Account balances are \[dq]inclusive\[dq] - they include the balances of -any subaccounts. +Each group of sibling accounts is sorted separately, by declaration +order and then by account name. +.SS Customising single-period balance reports .PP -Accounts which have zero balance (and no non-zero subaccounts) are -omitted. -Use \f[C]-E/--empty\f[R] to show them. -.PP -A final total is displayed by default; use \f[C]-N/--no-total\f[R] to -suppress it, eg: -.IP -.nf -\f[C] -$ hledger balance -p 2008/6 expenses --no-total - $2 expenses - $1 food - $1 supplies -\f[R] -.fi -.SS Customising the classic balance report -.PP -You can customise the layout of classic balance reports with -\f[C]--format FMT\f[R]: +You can customise the layout of single-period balance reports with +\f[C]--format FMT\f[R], which sets the format of each line. +Eg: .IP .nf \f[C] @@ -2572,32 +2607,13 @@ rendered on one line .IP \[bu] 2 \f[C]%20(total) %2(depth_spacer)%-(account)\f[R] - the default format for the single-column balance report -.SS Colour support +.SS Depth limiting .PP -In terminal output, when colour is enabled, the balance command shows -negative amounts in red. -.SS Flat mode -.PP -To see a flat list instead of the default hierarchical display, use -\f[C]--flat\f[R]. -In this mode, accounts (unless depth-clipped) show their full names and -\[dq]exclusive\[dq] balance, excluding any subaccount balances. -In this mode, you can also use \f[C]--drop N\f[R] to omit the first few -account name components. -.IP -.nf -\f[C] -$ hledger balance -p 2008/6 expenses -N --flat --drop 1 - $1 food - $1 supplies -\f[R] -.fi -.SS Depth limited balance reports -.PP -With \f[C]--depth N\f[R] or \f[C]depth:N\f[R] or just \f[C]-N\f[R], -balance reports show accounts only to the specified numeric depth. -This is very useful to summarise a complex set of accounts and get an -overview. +With a \f[C]depth:N\f[R] query, or \f[C]--depth N\f[R] option, or just +\f[C]-N\f[R], balance reports will show accounts only to the specified +depth. +This is very useful to hide low-level accounts and get an overview. +Eg, limiting to depth 1 shows the top-level accounts: .IP .nf \f[C] @@ -2609,8 +2625,30 @@ $ hledger balance -N -1 \f[R] .fi .PP -Flat-mode balance reports, which normally show exclusive balances, show -inclusive balances at the depth limit. +Accounts at the depth limit will include the balances of any hidden +subaccounts (even in flat mode, which normally shows exclusive +balances). +.PP +You can also drop account name components from the start of account +names, using \f[C]--drop N\f[R]. +This can be useful to hide unwanted top-level detail. +.SS Colour support +.PP +In terminal output, when colour is enabled, the balance command shows +negative amounts in red. +.SS Sorting by amount +.PP +With \f[C]-S\f[R]/\f[C]--sort-amount\f[R], accounts with the largest +(most positive) balances are shown first. +For example, \f[C]hledger bal expenses -MAS\f[R] shows your biggest +averaged monthly expenses first. +.PP +Revenues and liability balances are typically negative, however, so +\f[C]-S\f[R] shows these in reverse order. +To work around this, you can add \f[C]--invert\f[R] to flip the signs. +Or, use one of the sign-flipping reports like \f[C]balancesheet\f[R] or +\f[C]incomestatement\f[R], which also support \f[C]-S\f[R]. +Eg: \f[C]hledger is -MAS\f[R]. .SS Percentages .PP With \f[C]-%\f[R] or \f[C]--percent\f[R], balance reports show each @@ -2646,34 +2684,25 @@ accounts. If there are mixed commodity accounts in the report be sure to use \f[C]-V\f[R] or \f[C]-B\f[R] to coerce the report into using a single commodity. -.SS Sorting by amount .PP -With \f[C]-S\f[R]/\f[C]--sort-amount\f[R], accounts with the largest -(most positive) balances are shown first. -For example, \f[C]hledger bal expenses -MAS\f[R] shows your biggest -averaged monthly expenses first. +.SS Multi-period balance report .PP -Revenues and liability balances are typically negative, however, so -\f[C]-S\f[R] shows these in reverse order. -To work around this, you can add \f[C]--invert\f[R] to flip the signs. -Or, use one of the sign-flipping reports like \f[C]balancesheet\f[R] or -\f[C]incomestatement\f[R], which also support \f[C]-S\f[R]. -Eg: \f[C]hledger is -MAS\f[R]. -.SS Multicolumn balance report +Multi-period balance reports are a very useful hledger feature, +activated if you provide one of the reporting interval flags, such as +\f[C]-M\f[R]/\f[C]--monthly\f[R]. +They are similar to single-period balance reports, but they show the +report as a table, with columns representing one or more successive time +periods. +This is the usually the preferred style of balance report in hledger +(even for a single period). .PP -Multicolumn or tabular balance reports are a very useful hledger -feature, and usually the preferred style. -They share many of the above features, but they show the report as a -table, with columns representing time periods. -This mode is activated by providing a reporting interval. -.PP -There are three types of multicolumn balance report, showing different +Multi-period balance reports come in several types, showing different information: .IP "1." 3 -By default: each column shows the sum of postings in that period, ie the -account\[aq]s change of balance in that period. +A balance change report: by default, each column shows the sum of +postings in that period, ie the account\[aq]s change of balance in that +period. This is useful eg for a monthly income statement: -.RS 4 .IP .nf \f[C] @@ -2690,11 +2719,10 @@ Balance changes in 2008: || $-1 $1 0 0 \f[R] .fi -.RE .IP "2." 3 -With \f[C]--cumulative\f[R]: each column shows the ending balance for -that period, accumulating the changes across periods, starting from 0 at -the report start date: +A cumulative end balance report: with \f[C]--cumulative\f[R], each +column shows the end balance for that period, accumulating the changes +across periods, starting from 0 at the report start date: .RS 4 .IP .nf @@ -2714,11 +2742,12 @@ Ending balances (cumulative) in 2008: .fi .RE .IP "3." 3 -With \f[C]--historical/-H\f[R]: each column shows the actual historical -ending balance for that period, accumulating the changes across periods, -starting from the actual balance at the report start date. -This is useful eg for a multi-period balance sheet, and when you are -showing only the data after a certain start date: +A historical end balance report: with \f[C]--historical/-H\f[R], each +column shows the actual historical end balance for that period, +accumulating the changes across periods, and including the balance from +any postings before the report start date. +This is useful eg for a multi-period balance sheet, and when you want to +see balances only after a certain date: .RS 4 .IP .nf @@ -2742,9 +2771,6 @@ Note that \f[C]--cumulative\f[R] or \f[C]--historical/-H\f[R] disable \f[C]--row-total/-T\f[R], since summing end balances generally does not make sense. .PP -Multicolumn balance reports display accounts in flat mode by default; to -see the hierarchy, use \f[C]--tree\f[R]. -.PP With a reporting interval (like \f[C]--quarterly\f[R] above), the report start/end dates will be adjusted if necessary so that they encompass the displayed report periods. @@ -3263,27 +3289,29 @@ check .P .PD Check for various kinds of errors in your data. -\f[I]experimental\f[R] .PP hledger provides a number of built-in error checks to help prevent problems in your data. Some of these are run automatically; or, you can use this \f[C]check\f[R] command to run them on demand, with no output and a zero exit code if all is well. +Specify their names (or a prefix) as argument(s). +.PP Some examples: .IP .nf \f[C] hledger check # basic checks hledger check -s # basic + strict checks -hledger check ordereddates uniqueleafnames # basic + specified checks +hledger check ordereddates payees # basic + two other checks \f[R] .fi .PP Here are the checks currently available: .SS Basic checks .PP -These are always run by this command and other commands: +These checks are always run automatically, by (almost) all hledger +commands, including \f[C]check\f[R]: .IP \[bu] 2 \f[B]parseable\f[R] - data files are well-formed and can be successfully parsed @@ -3298,8 +3326,10 @@ passing. \f[C]-I\f[R]/\f[C]--ignore-assertions\f[R].) .SS Strict checks .PP -These are always run by this and other commands when -\f[C]-s\f[R]/\f[C]--strict\f[R] is used (strict mode): +These additional checks are run when the \f[C]-s\f[R]/\f[C]--strict\f[R] +(strict mode) flag is used. +Or, they can be run by giving their names as arguments to +\f[C]check\f[R]: .IP \[bu] 2 \f[B]accounts\f[R] - all account names used by transactions have been declared @@ -3307,18 +3337,21 @@ declared \f[B]commodities\f[R] - all commodity symbols used have been declared .SS Other checks .PP -These checks can be run by specifying their names as arguments to the -check command: +These checks can be run only by giving their names as arguments to +\f[C]check\f[R]. +They are more specialised and not desirable for everyone, therefore +optional: .IP \[bu] 2 \f[B]ordereddates\f[R] - transactions are ordered by date (similar to the old \f[C]check-dates\f[R] command) .IP \[bu] 2 +\f[B]payees\f[R] - all payees used by transactions have been declared +.IP \[bu] 2 \f[B]uniqueleafnames\f[R] - all account leaf names are unique (similar -to the old \f[C]check-dupes\f[R] command) -.SS Add-on checks +to the old \f[C]check-dupes\f[R] command). +.SS Custom checks .PP -Some checks are not yet integrated with this command, but are available -as add-on commands in +A few more checks are are available as separate add-on commands, in https://github.com/simonmichael/hledger/tree/master/bin: .IP \[bu] 2 \f[B]hledger-check-tagfiles\f[R] - all tag values containing / (a @@ -3327,8 +3360,8 @@ forward slash) exist as file paths \f[B]hledger-check-fancyassertions\f[R] - more complex balance assertions are passing .PP -You could make your own similar scripts to perform custom checks; -Cookbook -> Scripting may be helpful. +You could make similar scripts to perform your own custom checks. +See: Cookbook -> Scripting. .SS close .PP close, equity @@ -5198,7 +5231,7 @@ Account names typically have several parts separated by a full colon, from which hledger derives a hierarchical chart of accounts. They can be anything you like, but in finance there are traditionally five top-level accounts: \f[C]assets\f[R], \f[C]liabilities\f[R], -\f[C]income\f[R], \f[C]expenses\f[R], and \f[C]equity\f[R]. +\f[C]revenue\f[R], \f[C]expenses\f[R], and \f[C]equity\f[R]. .PP Account names may contain single spaces, eg: \f[C]assets:accounts receivable\f[R]. @@ -5808,6 +5841,15 @@ T}@T{ what the included directives affect T} T{ +[\f[C]payee\f[R]] +T}@T{ +T}@T{ +T}@T{ +declare a payee name +T}@T{ +following entries until end of current file +T} +T{ \f[C]P\f[R] T}@T{ T}@T{ @@ -5952,6 +5994,19 @@ Y2010 ; change default year to 2010 assets \f[R] .fi +.SS Declaring payees +.PP +The \f[C]payee\f[R] directive can be used to declare a limited set of +payees which may appear in transaction descriptions. +The \[dq]payees\[dq] check will report an error if any transaction +refers to a payee that has not been declared. +Eg: +.IP +.nf +\f[C] +payee Whole Foods +\f[R] +.fi .SS Declaring commodities .PP The \f[C]commodity\f[R] directive has several functions: @@ -7961,32 +8016,148 @@ https://hledger.org -> sidebar -> real world setups https://plaintextaccounting.org -> data import/conversion .SS Setting amounts .PP -A posting amount can be set in one of these ways: -.IP \[bu] 2 -by assigning (with a fields list or field assignment) to -\f[C]amountN\f[R] (posting N\[aq]s amount) or \f[C]amount\f[R] (posting -1\[aq]s amount) -.IP \[bu] 2 -by assigning to \f[C]amountN-in\f[R] and \f[C]amountN-out\f[R] (or -\f[C]amount-in\f[R] and \f[C]amount-out\f[R]). -For each CSV record, whichever of these has a non-zero value will be -used, with appropriate sign. -If both contain a non-zero value, this may not work. -.IP \[bu] 2 -by assigning to \f[C]balanceN\f[R] (or \f[C]balance\f[R]) instead of the -above, setting the amount indirectly via a balance assignment. -If you do this the default account name may be wrong, so you should set -that explicitly. +Some tips on using the amount-setting rules discussed above. .PP -There is some special handling for an amount\[aq]s sign: +Here are the ways to set a posting\[aq]s amount: +.IP "1." 3 +\f[B]If the CSV has a single amount field:\f[R] +.PD 0 +.P +.PD +Assign (via a fields list or a field assignment) to \f[C]amountN\f[R]. +This sets the Nth posting\[aq]s amount. +N is usually 1 or 2 but can go up to 99. +.IP "2." 3 +\f[B]If the CSV has separate Debit and Credit amount fields:\f[R] +.PD 0 +.P +.PD +Assign to \f[C]amountN-in\f[R] and \f[C]amountN-out\f[R]. +This sets posting N\[aq]s amount to whichever of these has a non-zero +value, guessing an appropriate sign. +.RS 4 .IP \[bu] 2 -If an amount value is parenthesised, it will be de-parenthesised and -sign-flipped. +\f[B]If hledger guesses the wrong sign:\f[R] +.PD 0 +.P +.PD +Prepend a minus sign to flip it. +Eg: +.RS 2 +.IP +.nf +\f[C] +fields date, description, amount-in, amount-out +amount-out -%amount-out +\f[R] +.fi +.RE .IP \[bu] 2 -If an amount value begins with a double minus sign, those cancel out and -are removed. +\f[B]If both fields contain a non-zero value:\f[R] +.PD 0 +.P +.PD +The \f[C]amountN-in\f[R]/\f[C]amountN-out\f[R] rules require that each +CSV record has a non-zero value in exactly one of the two fields, so +that hledger knows which to choose. +So these would all be rejected: +.RS 2 +.IP +.nf +\f[C] +\[dq]\[dq], \[dq]\[dq] +\[dq]0\[dq], \[dq]0\[dq] +\[dq]1\[dq], \[dq]none\[dq] +\f[R] +.fi +.PP +If your CSV has amount values like this, use conditional rules instead. +For example, to make hledger to choose the value containing non-zero +digits: +.IP +.nf +\f[C] +fields date, description, in, out +if %in [1-9] + amount1 %in +if %out [1-9] + amount1 %out +\f[R] +.fi +.RE +.RE +.IP "3." 3 +\f[B]Using the old numberless syntax:\f[R] +.PD 0 +.P +.PD +Assign to \f[C]amount\f[R] (or to \f[C]amount-in\f[R] and +\f[C]amount-out\f[R]). +This sets posting 1\[aq]s and posting 2\[aq]s amounts (and converts +posting 2\[aq]s amount to cost). +This is supported for backwards compatibility (and occasional +convenience). +.IP "4." 3 +\f[B]If the CSV has the balance instead of the transaction amount:\f[R] +.PD 0 +.P +.PD +Assign to \f[C]balanceN\f[R], which sets posting N\[aq]s amount +indirectly via a balance assignment. +(Old syntax: \f[C]balance\f[R], equivalent to \f[C]balance1\f[R].) +.RS 4 .IP \[bu] 2 -If an amount value begins with a plus sign, that will be removed +\f[B]If hledger guesses the wrong default account name:\f[R] +.PD 0 +.P +.PD +When setting the amount via balance assertion, hledger may guess the +wrong default account name. +So, set the account name explicitly, eg: +.RS 2 +.IP +.nf +\f[C] +fields date, description, balance1 +account1 assets:checking +\f[R] +.fi +.RE +.RE +.SS Amount signs +.PP +There is some special handling for amount signs, to simplify parsing and +sign-flipping: +.IP \[bu] 2 +\f[B]If an amount value begins with a plus sign:\f[R] +.PD 0 +.P +.PD +that will be removed: \f[C]+AMT\f[R] becomes \f[C]AMT\f[R] +.IP \[bu] 2 +\f[B]If an amount value is parenthesised:\f[R] +.PD 0 +.P +.PD +it will be de-parenthesised and sign-flipped: \f[C](AMT)\f[R] becomes +\f[C]-AMT\f[R] +.IP \[bu] 2 +\f[B]If an amount value has two minus signs (or two sets of parentheses, +or a minus sign and parentheses):\f[R] +.PD 0 +.P +.PD +they cancel out and will be removed: \f[C]--AMT\f[R] or \f[C]-(AMT)\f[R] +becomes \f[C]AMT\f[R] +.IP \[bu] 2 +\f[B]If an amount value contains just a sign (or just a set of +parentheses):\f[R] +.PD 0 +.P +.PD +that is removed, making it an empty value. +\f[C]\[dq]+\[dq]\f[R] or \f[C]\[dq]-\[dq]\f[R] or \f[C]\[dq]()\[dq]\f[R] +becomes \f[C]\[dq]\[dq]\f[R]. .SS Setting currency/commodity .PP If the currency/commodity symbol is included in the CSV\[aq]s amount diff --git a/hledger/hledger.info b/hledger/hledger.info index 3ad3415e0..cfe91b08a 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -563,9 +563,13 @@ recognised file extension, so as to either read successfully or to show relevant error messages. You can also force a specific reader/format by prefixing the file -path with the format and a colon. Eg to read a .dat file as csv: +path with the format and a colon. Eg, to read a .dat file as csv +format: $ hledger -f csv:/some/csv-file.dat stats + + Or to read stdin ('-') as timeclock format: + $ echo 'i 2009/13/1 08:00:00' | hledger print -ftimeclock:-  @@ -1068,7 +1072,12 @@ this order of preference : including both forward and reverse prices (1 and 2 above), leading from A to B. - Amounts for which no applicable market price can be found, are not + There is a limit to the length of these price chains; if hledger +reaches that length without finding a complete chain or exhausting all +possibilities, it will give up (with a "gave up" message visible in +'--debug=2' output). That limit is currently 1000. + + Amounts for which no suitable market price can be found, are not converted.  @@ -1203,8 +1212,7 @@ option: '--value=then' Convert amounts to their value in the default valuation commodity, - using market prices on each posting's date. This is currently - supported only by the print and register commands. + using market prices on each posting's date. '--value=end' Convert amounts to their value in the default valuation commodity, @@ -1351,93 +1359,101 @@ sideways.) It may be useful when troubleshooting. If you find problems, please report them, ideally with a reproducible example. Related: #329, #1083. -Report '-B', '-V', '-X' '--value=then''--value=end' '--value=DATE', -type '--value=cost' '--value=now' --------------------------------------------------------------------------------- +Report '-B', '-V', '-X' '--value=then' '--value=end''--value=DATE', +type '--value=cost' '--value=now' +------------------------------------------------------------------------------ *print* -posting cost value at value at value at value -amounts report end posting report or at - or today date journal end DATE/today -balance unchanged unchanged unchanged unchanged unchanged +posting cost value at value at posting value at value +amounts report end date report or at + or today journal DATE/today + end +balance unchanged unchanged unchanged unchanged unchanged assertions/assignments *register* -starting cost value at day not value at day value -balance before supported before at -(-H) report or report or DATE/today - journal journal - start start -posting cost value at value at value at value -amounts report end posting report or at - or today date journal end DATE/today -summary summarised value at sum of value at value -posting cost period ends postings period ends at -amounts in DATE/today -with interval, -report valued at -interval interval - start -running sum/average sum/average sum/average sum/average sum/average -total/averageof displayed of displayed of of displayed of - values values displayed values displayed - values values +starting cost value at valued at day value at value +balance day before each historical day before at +(-H) report or posting was made report or DATE/today + journal journal + start start +posting cost value at value at posting value at value +amounts report end date report or at + or today journal DATE/today + end +summary summarised value at sum of postings value at value +posting cost period in interval, period at +amounts ends valued at ends DATE/today +with interval start +report +interval +running sum/average sum/average sum/average of sum/average sum/average +total/averageof of displayed values of of + displayed displayed displayed displayed + values values values values *balance -(bs, bse, -cf, is)* -balance sums of value at not value at value -changes costs report end supported report or at - or today of journal end DATE/today - sums of of sums of of sums - postings postings of - postings -budget like balance like balance not like like -amounts changes changes supported balances balance -(-budget) changes -grand sum of sum of not sum of sum of -total displayed displayed supported displayed displayed - values values values values +(bs, +bse, cf, +is)* +balance sums of value at value at posting value at value +changes costs report end date report or at + or today journal DATE/today + of sums of end of of + postings sums of sums + postings of + postings +budget like like like balance like like +amounts balance balance changes balances balance +(-budget) changes changes changes +grand sum of sum of sum of displayed sum of sum of +total displayed displayed valued displayed displayed + values values values values *balance -(bs, bse, -cf, is) -with +(bs, +bse, cf, +is) with report interval* -starting sums of value at not value at sums of -balances costs of report start supported report start postings -(-H) postings of sums of of sums of before - before all postings all postings report - report start before before start - report start report start -balance sums of same as not balance value -changes costs of -value=end supported change in at -(bal, is, postings in each period, DATE/today -bs period valued at of sums --change, period ends of -cf postings --change) -end sums of same as not period end value -balances costs of -value=end supported balances, at -(bal -H, postings valued at DATE/today -is -H, from before period ends of sums -bs, cf) report start of - to period postings - end -budget like balance like balance not like like -amounts changes/end changes/end supported balances balance -(-budget) balances balances changes/end - balances -row sums, sums, not sums, sums, -totals, averages of averages of supported averages of averages -row displayed displayed displayed of -averages values values values displayed -(-T, -A) values -column sums of sums of not sums of sums of -totals displayed displayed supported displayed displayed - values values values values -grand sum, average sum, average not sum, average sum, -total, of column of column supported of column average -grand totals totals totals of -average column - totals +starting sums of value at sums of values value at sums +balances costs of report of postings report of +(-H) postings start of before report start of postings + before sums of start at sums of before + report all respective all report + start postings posting dates postings start + before before + report report + start start +balance sums of same as sums of values balance value +changes costs of -value=end of postings in change in at +(bal, postings period at each DATE/today +is, bs in period respective period, of +-change, posting dates valued at sums +cf period of +-change) ends postings +end sums of same as sums of values period end value +balances costs of -value=end of postings from balances, at +(bal -H, postings before period valued at DATE/today +is -H, from start to period period of +bs, cf) before end at ends sums + report respective of + start to posting dates postings + period end +budget like like like balance like like +amounts balance balance changes/end balances balance +(-budget) changes/end changes/end balances changes/end + balances balances balances +row sums, sums, sums, averages sums, sums, +totals, averages averages of displayed averages averages +row of of values of of +averages displayed displayed displayed displayed +(-T, -A) values values values values +column sums of sums of sums of sums of sums +totals displayed displayed displayed values displayed of + values values values displayed + values +grand sum, sum, sum, average of sum, sum, +total, average of average of column totals average of average +grand column column column of +average totals totals totals column + totals '--cumulative' is omitted to save space, it works like '-H' but with a zero starting balance. @@ -1961,24 +1977,49 @@ options The output formats supported are (in most modes): 'txt', 'csv', * Menu: -* Classic balance report:: -* Customising the classic balance report:: +* Single-period flat balance report:: +* Single-period tree-mode balance report:: +* Customising single-period balance reports:: +* Depth limiting:: * Colour support:: -* Flat mode:: -* Depth limited balance reports:: -* Percentages:: * Sorting by amount:: -* Multicolumn balance report:: +* Percentages:: +* Multi-period balance report:: * Budget report::  -File: hledger.info, Node: Classic balance report, Next: Customising the classic balance report, Up: balance +File: hledger.info, Node: Single-period flat balance report, Next: Single-period tree-mode balance report, Up: balance -10.5.1 Classic balance report ------------------------------ +10.5.1 Single-period flat balance report +---------------------------------------- -This is the original balance report, as found in Ledger. It usually -looks like this: +This is the default for hledger's balance command: a flat list of all +(or with a query, matched) accounts, showing full account names. +Accounts are sorted by declaration order if any, and then by account +name. Accounts which have zero balance are not shown unless +'-E/--empty' is used. The reported balances' total is shown as the last +line, unless disabled by '-N'/'--no-total'. + +$ hledger bal + $1 assets:bank:saving + $-2 assets:cash + $1 expenses:food + $1 expenses:supplies + $-1 income:gifts + $-1 income:salary + $1 liabilities:debts +-------------------- + 0 + + +File: hledger.info, Node: Single-period tree-mode balance report, Next: Customising single-period balance reports, Prev: Single-period flat balance report, Up: balance + +10.5.2 Single-period tree-mode balance report +--------------------------------------------- + +With the '-t/--tree' flag, accounts are displayed hierarchically, +showing subaccounts as short names indented below their parent. (This +is the default style in Ledger and in older hledger versions.) $ hledger balance $-1 assets @@ -1994,37 +2035,31 @@ $ hledger balance -------------------- 0 - By default, accounts are displayed hierarchically, with subaccounts -indented below their parent, with accounts at each level of the tree -sorted by declaration order if declared, then by account name. + For more compact output, "boring" accounts containing a single +interesting subaccount and no balance of their own ('assets:bank' and +'liabilities' here) are elided into the following line, unless +'--no-elide' is used. And accounts which have zero balance and no +non-zero subaccounts are omitted, unless '-E/--empty' is used. - "Boring" accounts, which contain a single interesting subaccount and -no balance of their own, are elided into the following line for more -compact output. (Eg above, the "liabilities" account.) Use -'--no-elide' to prevent this. + Account balances in tree mode are "inclusive" - they include the +balances of any subaccounts. Eg, the 'assets' '$-1' balance here +includes the '$1' from 'assets:bank:saving' and the '$-2' from +'assets:cash'. (And it would include balance posted to the 'assets' +account itself, if there was any). Note this causes some repetition, +and the final total ('0') is the sum of the top-level balances, not of +all the balances shown. - Account balances are "inclusive" - they include the balances of any -subaccounts. - - Accounts which have zero balance (and no non-zero subaccounts) are -omitted. Use '-E/--empty' to show them. - - A final total is displayed by default; use '-N/--no-total' to -suppress it, eg: - -$ hledger balance -p 2008/6 expenses --no-total - $2 expenses - $1 food - $1 supplies + Each group of sibling accounts is sorted separately, by declaration +order and then by account name.  -File: hledger.info, Node: Customising the classic balance report, Next: Colour support, Prev: Classic balance report, Up: balance +File: hledger.info, Node: Customising single-period balance reports, Next: Depth limiting, Prev: Single-period tree-mode balance report, Up: balance -10.5.2 Customising the classic balance report ---------------------------------------------- +10.5.3 Customising single-period balance reports +------------------------------------------------ -You can customise the layout of classic balance reports with '--format -FMT': +You can customise the layout of single-period balance reports with +'--format FMT', which sets the format of each line. Eg: $ hledger balance --format "%20(account) %12(total)" assets $-1 @@ -2080,39 +2115,15 @@ may be needed to get pleasing results. the single-column balance report  -File: hledger.info, Node: Colour support, Next: Flat mode, Prev: Customising the classic balance report, Up: balance +File: hledger.info, Node: Depth limiting, Next: Colour support, Prev: Customising single-period balance reports, Up: balance -10.5.3 Colour support +10.5.4 Depth limiting --------------------- -In terminal output, when colour is enabled, the balance command shows -negative amounts in red. - - -File: hledger.info, Node: Flat mode, Next: Depth limited balance reports, Prev: Colour support, Up: balance - -10.5.4 Flat mode ----------------- - -To see a flat list instead of the default hierarchical display, use -'--flat'. In this mode, accounts (unless depth-clipped) show their full -names and "exclusive" balance, excluding any subaccount balances. In -this mode, you can also use '--drop N' to omit the first few account -name components. - -$ hledger balance -p 2008/6 expenses -N --flat --drop 1 - $1 food - $1 supplies - - -File: hledger.info, Node: Depth limited balance reports, Next: Percentages, Prev: Flat mode, Up: balance - -10.5.5 Depth limited balance reports ------------------------------------- - -With '--depth N' or 'depth:N' or just '-N', balance reports show -accounts only to the specified numeric depth. This is very useful to -summarise a complex set of accounts and get an overview. +With a 'depth:N' query, or '--depth N' option, or just '-N', balance +reports will show accounts only to the specified depth. This is very +useful to hide low-level accounts and get an overview. Eg, limiting to +depth 1 shows the top-level accounts: $ hledger balance -N -1 $-1 assets @@ -2120,13 +2131,43 @@ $ hledger balance -N -1 $-2 income $1 liabilities - Flat-mode balance reports, which normally show exclusive balances, -show inclusive balances at the depth limit. + Accounts at the depth limit will include the balances of any hidden +subaccounts (even in flat mode, which normally shows exclusive +balances). + + You can also drop account name components from the start of account +names, using '--drop N'. This can be useful to hide unwanted top-level +detail.  -File: hledger.info, Node: Percentages, Next: Sorting by amount, Prev: Depth limited balance reports, Up: balance +File: hledger.info, Node: Colour support, Next: Sorting by amount, Prev: Depth limiting, Up: balance -10.5.6 Percentages +10.5.5 Colour support +--------------------- + +In terminal output, when colour is enabled, the balance command shows +negative amounts in red. + + +File: hledger.info, Node: Sorting by amount, Next: Percentages, Prev: Colour support, Up: balance + +10.5.6 Sorting by amount +------------------------ + +With '-S'/'--sort-amount', accounts with the largest (most positive) +balances are shown first. For example, 'hledger bal expenses -MAS' +shows your biggest averaged monthly expenses first. + + Revenues and liability balances are typically negative, however, so +'-S' shows these in reverse order. To work around this, you can add +'--invert' to flip the signs. Or, use one of the sign-flipping reports +like 'balancesheet' or 'incomestatement', which also support '-S'. Eg: +'hledger is -MAS'. + + +File: hledger.info, Node: Percentages, Next: Multi-period balance report, Prev: Sorting by amount, Up: balance + +10.5.7 Percentages ------------------ With '-%' or '--percent', balance reports show each account's value @@ -2156,54 +2197,40 @@ accounts. If there are mixed commodity accounts in the report be sure to use '-V' or '-B' to coerce the report into using a single commodity.  -File: hledger.info, Node: Sorting by amount, Next: Multicolumn balance report, Prev: Percentages, Up: balance +File: hledger.info, Node: Multi-period balance report, Next: Budget report, Prev: Percentages, Up: balance -10.5.7 Sorting by amount ------------------------- +10.5.8 Multi-period balance report +---------------------------------- -With '-S'/'--sort-amount', accounts with the largest (most positive) -balances are shown first. For example, 'hledger bal expenses -MAS' -shows your biggest averaged monthly expenses first. +Multi-period balance reports are a very useful hledger feature, +activated if you provide one of the reporting interval flags, such as +'-M'/'--monthly'. They are similar to single-period balance reports, +but they show the report as a table, with columns representing one or +more successive time periods. This is the usually the preferred style +of balance report in hledger (even for a single period). - Revenues and liability balances are typically negative, however, so -'-S' shows these in reverse order. To work around this, you can add -'--invert' to flip the signs. Or, use one of the sign-flipping reports -like 'balancesheet' or 'incomestatement', which also support '-S'. Eg: -'hledger is -MAS'. + Multi-period balance reports come in several types, showing different +information: - -File: hledger.info, Node: Multicolumn balance report, Next: Budget report, Prev: Sorting by amount, Up: balance + 1. A balance change report: by default, each column shows the sum of + postings in that period, ie the account's change of balance in that + period. This is useful eg for a monthly income statement: -10.5.8 Multicolumn balance report ---------------------------------- +$ hledger balance --quarterly income expenses -E +Balance changes in 2008: -Multicolumn or tabular balance reports are a very useful hledger -feature, and usually the preferred style. They share many of the above -features, but they show the report as a table, with columns representing -time periods. This mode is activated by providing a reporting interval. + || 2008q1 2008q2 2008q3 2008q4 +===================++================================= + expenses:food || 0 $1 0 0 + expenses:supplies || 0 $1 0 0 + income:gifts || 0 $-1 0 0 + income:salary || $-1 0 0 0 +-------------------++--------------------------------- + || $-1 $1 0 0 - There are three types of multicolumn balance report, showing -different information: - - 1. By default: each column shows the sum of postings in that period, - ie the account's change of balance in that period. This is useful - eg for a monthly income statement: - - $ hledger balance --quarterly income expenses -E - Balance changes in 2008: - - || 2008q1 2008q2 2008q3 2008q4 - ===================++================================= - expenses:food || 0 $1 0 0 - expenses:supplies || 0 $1 0 0 - income:gifts || 0 $-1 0 0 - income:salary || $-1 0 0 0 - -------------------++--------------------------------- - || $-1 $1 0 0 - - 2. With '--cumulative': each column shows the ending balance for that - period, accumulating the changes across periods, starting from 0 at - the report start date: + 2. A cumulative end balance report: with '--cumulative', each column + shows the end balance for that period, accumulating the changes + across periods, starting from 0 at the report start date: $ hledger balance --quarterly income expenses -E --cumulative Ending balances (cumulative) in 2008: @@ -2217,11 +2244,12 @@ different information: -------------------++------------------------------------------------- || $-1 0 0 0 - 3. With '--historical/-H': each column shows the actual historical - ending balance for that period, accumulating the changes across - periods, starting from the actual balance at the report start date. - This is useful eg for a multi-period balance sheet, and when you - are showing only the data after a certain start date: + 3. A historical end balance report: with '--historical/-H', each + column shows the actual historical end balance for that period, + accumulating the changes across periods, and including the balance + from any postings before the report start date. This is useful eg + for a multi-period balance sheet, and when you want to see balances + only after a certain date: $ hledger balance ^assets ^liabilities --quarterly --historical --begin 2008/4/1 Ending balances (historical) in 2008/04/01-2008/12/31: @@ -2239,9 +2267,6 @@ different information: '--row-total/-T', since summing end balances generally does not make sense. - Multicolumn balance reports display accounts in flat mode by default; -to see the hierarchy, use '--tree'. - With a reporting interval (like '--quarterly' above), the report start/end dates will be adjusted if necessary so that they encompass the displayed report periods. This is so that the first and last periods @@ -2293,7 +2318,7 @@ into 'less -RS' (-R for colour, -S to chop long lines). Eg: 'hledger bal -D --color=yes | less -RS'.  -File: hledger.info, Node: Budget report, Prev: Multicolumn balance report, Up: balance +File: hledger.info, Node: Budget report, Prev: Multi-period balance report, Up: balance 10.5.9 Budget report -------------------- @@ -2703,16 +2728,19 @@ File: hledger.info, Node: check, Next: close, Prev: cashflow, Up: COMMANDS ========== check -Check for various kinds of errors in your data. _experimental_ +Check for various kinds of errors in your data. hledger provides a number of built-in error checks to help prevent problems in your data. Some of these are run automatically; or, you can use this 'check' command to run them on demand, with no output and a -zero exit code if all is well. Some examples: +zero exit code if all is well. Specify their names (or a prefix) as +argument(s). + + Some examples: hledger check # basic checks hledger check -s # basic + strict checks -hledger check ordereddates uniqueleafnames # basic + specified checks +hledger check ordereddates payees # basic + two other checks Here are the checks currently available: @@ -2721,7 +2749,7 @@ hledger check ordereddates uniqueleafnames # basic + specified checks * Basic checks:: * Strict checks:: * Other checks:: -* Add-on checks:: +* Custom checks::  File: hledger.info, Node: Basic checks, Next: Strict checks, Up: check @@ -2729,7 +2757,8 @@ File: hledger.info, Node: Basic checks, Next: Strict checks, Up: check 10.9.1 Basic checks ------------------- -These are always run by this command and other commands: +These checks are always run automatically, by (almost) all hledger +commands, including 'check': * *parseable* - data files are well-formed and can be successfully parsed @@ -2747,8 +2776,9 @@ File: hledger.info, Node: Strict checks, Next: Other checks, Prev: Basic chec 10.9.2 Strict checks -------------------- -These are always run by this and other commands when '-s'/'--strict' is -used (strict mode): +These additional checks are run when the '-s'/'--strict' (strict mode) +flag is used. Or, they can be run by giving their names as arguments to +'check': * *accounts* - all account names used by transactions have been declared @@ -2756,28 +2786,30 @@ used (strict mode): * *commodities* - all commodity symbols used have been declared  -File: hledger.info, Node: Other checks, Next: Add-on checks, Prev: Strict checks, Up: check +File: hledger.info, Node: Other checks, Next: Custom checks, Prev: Strict checks, Up: check 10.9.3 Other checks ------------------- -These checks can be run by specifying their names as arguments to the -check command: +These checks can be run only by giving their names as arguments to +'check'. They are more specialised and not desirable for everyone, +therefore optional: * *ordereddates* - transactions are ordered by date (similar to the old 'check-dates' command) + * *payees* - all payees used by transactions have been declared + * *uniqueleafnames* - all account leaf names are unique (similar to - the old 'check-dupes' command) + the old 'check-dupes' command).  -File: hledger.info, Node: Add-on checks, Prev: Other checks, Up: check +File: hledger.info, Node: Custom checks, Prev: Other checks, Up: check -10.9.4 Add-on checks +10.9.4 Custom checks -------------------- -Some checks are not yet integrated with this command, but are available -as add-on commands in +A few more checks are are available as separate add-on commands, in https://github.com/simonmichael/hledger/tree/master/bin: * *hledger-check-tagfiles* - all tag values containing / (a forward @@ -2786,8 +2818,8 @@ https://github.com/simonmichael/hledger/tree/master/bin: * *hledger-check-fancyassertions* - more complex balance assertions are passing - You could make your own similar scripts to perform custom checks; -Cookbook -> Scripting may be helpful. + You could make similar scripts to perform your own custom checks. +See: Cookbook -> Scripting.  File: hledger.info, Node: close, Next: codes, Prev: check, Up: COMMANDS @@ -4079,6 +4111,7 @@ that looks unnecessary right now. * Comment blocks:: * Including other files:: * Default year:: +* Declaring payees:: * Declaring commodities:: * Default commodity:: * Declaring market prices:: @@ -4453,7 +4486,7 @@ File: hledger.info, Node: Account names, Next: Amounts, Prev: Postings, Up: Account names typically have several parts separated by a full colon, from which hledger derives a hierarchical chart of accounts. They can be anything you like, but in finance there are traditionally five -top-level accounts: 'assets', 'liabilities', 'income', 'expenses', and +top-level accounts: 'assets', 'liabilities', 'revenue', 'expenses', and 'equity'. Account names may contain single spaces, eg: 'assets:accounts @@ -4990,6 +5023,9 @@ account' apply account names until end of reports 'include' include entries/directives what the included from another file directives affect +['payee'] declare a payee name following entries + until end of + current file 'P' declare a market price for amounts of that a commodity commodity in reports, when -V @@ -5081,7 +5117,7 @@ overriding the file extension (as described in hledger.1 -> Input files): 'include timedot:~/notes/2020*.md'.  -File: hledger.info, Node: Default year, Next: Declaring commodities, Prev: Including other files, Up: JOURNAL FORMAT +File: hledger.info, Node: Default year, Next: Declaring payees, Prev: Including other files, Up: JOURNAL FORMAT 11.18 Default year ================== @@ -5107,9 +5143,22 @@ Y2010 ; change default year to 2010 assets  -File: hledger.info, Node: Declaring commodities, Next: Default commodity, Prev: Default year, Up: JOURNAL FORMAT +File: hledger.info, Node: Declaring payees, Next: Declaring commodities, Prev: Default year, Up: JOURNAL FORMAT -11.19 Declaring commodities +11.19 Declaring payees +====================== + +The 'payee' directive can be used to declare a limited set of payees +which may appear in transaction descriptions. The "payees" check will +report an error if any transaction refers to a payee that has not been +declared. Eg: + +payee Whole Foods + + +File: hledger.info, Node: Declaring commodities, Next: Default commodity, Prev: Declaring payees, Up: JOURNAL FORMAT + +11.20 Declaring commodities =========================== The 'commodity' directive has several functions: @@ -5166,7 +5215,7 @@ zero decimal digits is "0". (More at Commodity display style.)  File: hledger.info, Node: Commodity error checking, Up: Declaring commodities -11.19.1 Commodity error checking +11.20.1 Commodity error checking -------------------------------- In strict mode, enabled with the '-s'/'--strict' flag, hledger will @@ -5177,7 +5226,7 @@ checking, see the notes there for more details.  File: hledger.info, Node: Default commodity, Next: Declaring market prices, Prev: Declaring commodities, Up: JOURNAL FORMAT -11.20 Default commodity +11.21 Default commodity ======================= The 'D' directive sets a default commodity, to be used for amounts @@ -5204,7 +5253,7 @@ D $1,000.00  File: hledger.info, Node: Declaring market prices, Next: Declaring accounts, Prev: Default commodity, Up: JOURNAL FORMAT -11.21 Declaring market prices +11.22 Declaring market prices ============================= The 'P' directive declares a market price, which is an exchange rate @@ -5234,7 +5283,7 @@ amount values in another commodity. See Valuation.  File: hledger.info, Node: Declaring accounts, Next: Rewriting accounts, Prev: Declaring market prices, Up: JOURNAL FORMAT -11.22 Declaring accounts +11.23 Declaring accounts ======================== 'account' directives can be used to declare accounts (ie, the places @@ -5272,7 +5321,7 @@ account assets:bank:checking  File: hledger.info, Node: Account error checking, Next: Account comments, Up: Declaring accounts -11.22.1 Account error checking +11.23.1 Account error checking ------------------------------ By default, accounts come into existence when a transaction references @@ -5300,7 +5349,7 @@ been declared by an account directive. Some notes:  File: hledger.info, Node: Account comments, Next: Account subdirectives, Prev: Account error checking, Up: Declaring accounts -11.22.2 Account comments +11.23.2 Account comments ------------------------ Comments, beginning with a semicolon, can be added: @@ -5320,7 +5369,7 @@ account assets:bank:checking ; same-line comment, note 2+ spaces before ;  File: hledger.info, Node: Account subdirectives, Next: Account types, Prev: Account comments, Up: Declaring accounts -11.22.3 Account subdirectives +11.23.3 Account subdirectives ----------------------------- We also allow (and ignore) Ledger-style indented subdirectives, just for @@ -5338,7 +5387,7 @@ account ACCTNAME [ACCTTYPE] [;COMMENT]  File: hledger.info, Node: Account types, Next: Account display order, Prev: Account subdirectives, Up: Declaring accounts -11.22.4 Account types +11.23.4 Account types --------------------- hledger recognises five main types of account, corresponding to the @@ -5365,7 +5414,7 @@ or receivables.)  File: hledger.info, Node: Declaring account types, Next: Auto-detected account types, Up: Account types -11.22.4.1 Declaring account types +11.23.4.1 Declaring account types ................................. Generally, to make these reports work you should declare your top-level @@ -5387,7 +5436,7 @@ account expenses ; type: Expense  File: hledger.info, Node: Auto-detected account types, Next: Interference from auto-detected account types, Prev: Declaring account types, Up: Account types -11.22.4.2 Auto-detected account types +11.23.4.2 Auto-detected account types ..................................... If you happen to use common english top-level account names, you may not @@ -5414,7 +5463,7 @@ predictability.  File: hledger.info, Node: Interference from auto-detected account types, Next: Old account type syntax, Prev: Auto-detected account types, Up: Account types -11.22.4.3 Interference from auto-detected account types +11.23.4.3 Interference from auto-detected account types ....................................................... If you assign any account type, it's a good idea to assign all of them, @@ -5434,7 +5483,7 @@ account liabilities ; type:Equity  File: hledger.info, Node: Old account type syntax, Prev: Interference from auto-detected account types, Up: Account types -11.22.4.4 Old account type syntax +11.23.4.4 Old account type syntax ................................. In some hledger journals you might instead see this old syntax (the @@ -5450,7 +5499,7 @@ account expenses X  File: hledger.info, Node: Account display order, Prev: Account types, Up: Declaring accounts -11.22.5 Account display order +11.23.5 Account display order ----------------------------- Account directives also set the order in which accounts are displayed, @@ -5496,7 +5545,7 @@ means:  File: hledger.info, Node: Rewriting accounts, Next: Default parent account, Prev: Declaring accounts, Up: JOURNAL FORMAT -11.23 Rewriting accounts +11.24 Rewriting accounts ======================== You can define account alias rules which rewrite your account names, or @@ -5526,7 +5575,7 @@ hledger-web.  File: hledger.info, Node: Basic aliases, Next: Regex aliases, Up: Rewriting accounts -11.23.1 Basic aliases +11.24.1 Basic aliases --------------------- To set an account alias, use the 'alias' directive in your journal file. @@ -5549,7 +5598,7 @@ alias checking = assets:bank:wells fargo:checking  File: hledger.info, Node: Regex aliases, Next: Combining aliases, Prev: Basic aliases, Up: Rewriting accounts -11.23.2 Regex aliases +11.24.2 Regex aliases --------------------- There is also a more powerful variant that uses a regular expression, @@ -5574,7 +5623,7 @@ whitespace.  File: hledger.info, Node: Combining aliases, Next: Aliases and multiple files, Prev: Regex aliases, Up: Rewriting accounts -11.23.3 Combining aliases +11.24.3 Combining aliases ------------------------- You can define as many aliases as you like, using journal directives @@ -5611,7 +5660,7 @@ which aliases are being applied when.  File: hledger.info, Node: Aliases and multiple files, Next: end aliases, Prev: Combining aliases, Up: Rewriting accounts -11.23.4 Aliases and multiple files +11.24.4 Aliases and multiple files ---------------------------------- As explained at Directives and multiple files, 'alias' directives do not @@ -5643,7 +5692,7 @@ include c.journal ; also affected  File: hledger.info, Node: end aliases, Prev: Aliases and multiple files, Up: Rewriting accounts -11.23.5 'end aliases' +11.24.5 'end aliases' --------------------- You can clear (forget) all currently defined aliases with the 'end @@ -5654,7 +5703,7 @@ end aliases  File: hledger.info, Node: Default parent account, Next: Periodic transactions, Prev: Rewriting accounts, Up: JOURNAL FORMAT -11.24 Default parent account +11.25 Default parent account ============================ You can specify a parent account which will be prepended to all accounts @@ -5695,7 +5744,7 @@ parent account.  File: hledger.info, Node: Periodic transactions, Next: Auto postings, Prev: Default parent account, Up: JOURNAL FORMAT -11.25 Periodic transactions +11.26 Periodic transactions =========================== Periodic transaction rules describe transactions that recur. They allow @@ -5742,7 +5791,7 @@ to define budget goals, shown in budget reports.  File: hledger.info, Node: Periodic rule syntax, Next: Two spaces between period expression and description!, Up: Periodic transactions -11.25.1 Periodic rule syntax +11.26.1 Periodic rule syntax ---------------------------- A periodic transaction rule looks like a normal journal entry, with the @@ -5765,7 +5814,7 @@ will be relative to Y/1/1.  File: hledger.info, Node: Two spaces between period expression and description!, Next: Forecasting with periodic transactions, Prev: Periodic rule syntax, Up: Periodic transactions -11.25.2 Two spaces between period expression and description! +11.26.2 Two spaces between period expression and description! ------------------------------------------------------------- If the period expression is followed by a transaction description, these @@ -5790,7 +5839,7 @@ accidentally alter their meaning, as in this example:  File: hledger.info, Node: Forecasting with periodic transactions, Next: Budgeting with periodic transactions, Prev: Two spaces between period expression and description!, Up: Periodic transactions -11.25.3 Forecasting with periodic transactions +11.26.3 Forecasting with periodic transactions ---------------------------------------------- The '--forecast' flag activates any periodic transaction rules in the @@ -5836,7 +5885,7 @@ examples: '--forecast=202001-202004', '--forecast=jan-',  File: hledger.info, Node: Budgeting with periodic transactions, Prev: Forecasting with periodic transactions, Up: Periodic transactions -11.25.4 Budgeting with periodic transactions +11.26.4 Budgeting with periodic transactions -------------------------------------------- With the '--budget' flag, currently supported by the balance command, @@ -5851,7 +5900,7 @@ compared in budget reports.  File: hledger.info, Node: Auto postings, Prev: Periodic transactions, Up: JOURNAL FORMAT -11.26 Auto postings +11.27 Auto postings =================== "Automated postings" or "auto postings" are extra postings which get @@ -5929,7 +5978,7 @@ $ hledger print --auto  File: hledger.info, Node: Auto postings and multiple files, Next: Auto postings and dates, Up: Auto postings -11.26.1 Auto postings and multiple files +11.27.1 Auto postings and multiple files ---------------------------------------- An auto posting rule can affect any transaction in the current file, or @@ -5939,7 +5988,7 @@ sibling files (when multiple '-f'/'--file' are used - see #1212).  File: hledger.info, Node: Auto postings and dates, Next: Auto postings and transaction balancing / inferred amounts / balance assertions, Prev: Auto postings and multiple files, Up: Auto postings -11.26.2 Auto postings and dates +11.27.2 Auto postings and dates ------------------------------- A posting date (or secondary date) in the matched posting, or (taking @@ -5949,7 +5998,7 @@ used in the generated posting.  File: hledger.info, Node: Auto postings and transaction balancing / inferred amounts / balance assertions, Next: Auto posting tags, Prev: Auto postings and dates, Up: Auto postings -11.26.3 Auto postings and transaction balancing / inferred amounts / +11.27.3 Auto postings and transaction balancing / inferred amounts / -------------------------------------------------------------------- balance assertions Currently, auto postings are added: @@ -5965,7 +6014,7 @@ for background.  File: hledger.info, Node: Auto posting tags, Prev: Auto postings and transaction balancing / inferred amounts / balance assertions, Up: Auto postings -11.26.4 Auto posting tags +11.27.4 Auto posting tags ------------------------- Automated postings will have some extra tags: @@ -6861,6 +6910,7 @@ File: hledger.info, Node: Tips, Prev: CSV rules, Up: CSV FORMAT * Valid transactions:: * Deduplicating importing:: * Setting amounts:: +* Amount signs:: * Setting currency/commodity:: * Referencing other fields:: * How CSV rules are evaluated:: @@ -6975,38 +7025,100 @@ CSV data. See: * https://plaintextaccounting.org -> data import/conversion  -File: hledger.info, Node: Setting amounts, Next: Setting currency/commodity, Prev: Deduplicating importing, Up: Tips +File: hledger.info, Node: Setting amounts, Next: Amount signs, Prev: Deduplicating importing, Up: Tips 12.3.7 Setting amounts ---------------------- -A posting amount can be set in one of these ways: +Some tips on using the amount-setting rules discussed above. - * by assigning (with a fields list or field assignment) to 'amountN' - (posting N's amount) or 'amount' (posting 1's amount) + Here are the ways to set a posting's amount: - * by assigning to 'amountN-in' and 'amountN-out' (or 'amount-in' and - 'amount-out'). For each CSV record, whichever of these has a - non-zero value will be used, with appropriate sign. If both - contain a non-zero value, this may not work. + 1. *If the CSV has a single amount field:* + Assign (via a fields list or a field assignment) to 'amountN'. + This sets the Nth posting's amount. N is usually 1 or 2 but can go + up to 99. - * by assigning to 'balanceN' (or 'balance') instead of the above, - setting the amount indirectly via a balance assignment. If you do - this the default account name may be wrong, so you should set that - explicitly. + 2. *If the CSV has separate Debit and Credit amount fields:* + Assign to 'amountN-in' and 'amountN-out'. This sets posting N's + amount to whichever of these has a non-zero value, guessing an + appropriate sign. - There is some special handling for an amount's sign: + * *If hledger guesses the wrong sign:* + Prepend a minus sign to flip it. Eg: - * If an amount value is parenthesised, it will be de-parenthesised - and sign-flipped. - * If an amount value begins with a double minus sign, those cancel - out and are removed. - * If an amount value begins with a plus sign, that will be removed + fields date, description, amount-in, amount-out + amount-out -%amount-out + + * *If both fields contain a non-zero value:* + The 'amountN-in'/'amountN-out' rules require that each CSV + record has a non-zero value in exactly one of the two fields, + so that hledger knows which to choose. So these would all be + rejected: + + "", "" + "0", "0" + "1", "none" + + If your CSV has amount values like this, use conditional rules + instead. For example, to make hledger to choose the value + containing non-zero digits: + + fields date, description, in, out + if %in [1-9] + amount1 %in + if %out [1-9] + amount1 %out + + 3. *Using the old numberless syntax:* + Assign to 'amount' (or to 'amount-in' and 'amount-out'). This sets + posting 1's and posting 2's amounts (and converts posting 2's + amount to cost). This is supported for backwards compatibility + (and occasional convenience). + + 4. *If the CSV has the balance instead of the transaction amount:* + Assign to 'balanceN', which sets posting N's amount indirectly via + a balance assignment. (Old syntax: 'balance', equivalent to + 'balance1'.) + + * *If hledger guesses the wrong default account name:* + When setting the amount via balance assertion, hledger may + guess the wrong default account name. So, set the account + name explicitly, eg: + + fields date, description, balance1 + account1 assets:checking  -File: hledger.info, Node: Setting currency/commodity, Next: Referencing other fields, Prev: Setting amounts, Up: Tips +File: hledger.info, Node: Amount signs, Next: Setting currency/commodity, Prev: Setting amounts, Up: Tips -12.3.8 Setting currency/commodity +12.3.8 Amount signs +------------------- + +There is some special handling for amount signs, to simplify parsing and +sign-flipping: + + * *If an amount value begins with a plus sign:* + that will be removed: '+AMT' becomes 'AMT' + + * *If an amount value is parenthesised:* + it will be de-parenthesised and sign-flipped: '(AMT)' becomes + '-AMT' + + * *If an amount value has two minus signs (or two sets of + parentheses, or a minus sign and parentheses):* + they cancel out and will be removed: '--AMT' or '-(AMT)' becomes + 'AMT' + + * *If an amount value contains just a sign (or just a set of + parentheses):* + that is removed, making it an empty value. '"+"' or '"-"' or + '"()"' becomes '""'. + + +File: hledger.info, Node: Setting currency/commodity, Next: Referencing other fields, Prev: Amount signs, Up: Tips + +12.3.9 Setting currency/commodity --------------------------------- If the currency/commodity symbol is included in the CSV's amount @@ -7054,8 +7166,8 @@ that would trigger the prepending effect, which we don't want here.  File: hledger.info, Node: Referencing other fields, Next: How CSV rules are evaluated, Prev: Setting currency/commodity, Up: Tips -12.3.9 Referencing other fields -------------------------------- +12.3.10 Referencing other fields +-------------------------------- In field assignments, you can interpolate only CSV fields, not hledger fields. In the example below, there's both a CSV field and a hledger @@ -7091,7 +7203,7 @@ if something  File: hledger.info, Node: How CSV rules are evaluated, Prev: Referencing other fields, Up: Tips -12.3.10 How CSV rules are evaluated +12.3.11 How CSV rules are evaluated ----------------------------------- Here's how to think of CSV rules being evaluated (if you really need @@ -7875,397 +7987,401 @@ Node: DATA FILES15724 Ref: #data-files15843 Node: Data formats16382 Ref: #data-formats16500 -Node: Multiple files17837 -Ref: #multiple-files17979 -Node: Strict mode18448 -Ref: #strict-mode18563 -Node: TIME PERIODS19211 -Ref: #time-periods19328 -Node: Smart dates19426 -Ref: #smart-dates19552 -Node: Report start & end date20878 -Ref: #report-start-end-date21053 -Node: Report intervals22586 -Ref: #report-intervals22754 -Node: Period expressions23144 -Ref: #period-expressions23284 -Node: DEPTH27727 -Ref: #depth27827 -Node: QUERIES28159 -Ref: #queries28260 -Node: VALUATION32222 -Ref: #valuation32330 -Node: -B Cost33019 -Ref: #b-cost33117 -Node: -V Value33250 -Ref: #v-value33390 -Node: -X Value in specified commodity33585 -Ref: #x-value-in-specified-commodity33778 -Node: Valuation date33927 -Ref: #valuation-date34089 -Node: Market prices34526 -Ref: #market-prices34700 -Node: --infer-value market prices from transactions35621 -Ref: #infer-value-market-prices-from-transactions35864 -Node: Valuation commodity37125 -Ref: #valuation-commodity37328 -Node: Simple valuation examples38533 -Ref: #simple-valuation-examples38729 -Node: --value Flexible valuation39388 -Ref: #value-flexible-valuation39590 -Node: More valuation examples41537 -Ref: #more-valuation-examples41740 -Node: Effect of valuation on reports43745 -Ref: #effect-of-valuation-on-reports43927 -Node: PIVOTING50946 -Ref: #pivoting51051 -Node: OUTPUT52727 -Ref: #output52827 -Node: Output destination52878 -Ref: #output-destination53009 -Node: Output format53434 -Ref: #output-format53555 -Node: COMMANDS55722 -Ref: #commands55834 -Node: accounts59199 -Ref: #accounts59299 -Node: activity59995 -Ref: #activity60107 -Node: add60490 -Ref: #add60593 -Node: aregister63386 -Ref: #aregister63500 -Node: aregister and custom posting dates64994 -Ref: #aregister-and-custom-posting-dates65160 -Node: balance65981 -Ref: #balance66100 -Node: Classic balance report67723 -Ref: #classic-balance-report67898 -Node: Customising the classic balance report69222 -Ref: #customising-the-classic-balance-report69452 -Node: Colour support71528 -Ref: #colour-support71697 -Node: Flat mode71793 -Ref: #flat-mode71943 -Node: Depth limited balance reports72356 -Ref: #depth-limited-balance-reports72543 -Node: Percentages72999 -Ref: #percentages73158 -Node: Sorting by amount74295 -Ref: #sorting-by-amount74463 -Node: Multicolumn balance report74957 -Ref: #multicolumn-balance-report75145 -Node: Budget report80742 -Ref: #budget-report80878 -Node: Budget report start date86167 -Ref: #budget-report-start-date86334 -Node: Nested budgets87666 -Ref: #nested-budgets87813 -Node: balancesheet91253 -Ref: #balancesheet91391 -Node: balancesheetequity93028 -Ref: #balancesheetequity93179 -Node: cashflow94398 -Ref: #cashflow94522 -Node: check95856 -Ref: #check95961 -Node: Basic checks96566 -Ref: #basic-checks96684 -Node: Strict checks97177 -Ref: #strict-checks97318 -Node: Other checks97561 -Ref: #other-checks97701 -Node: Add-on checks97999 -Ref: #add-on-checks98119 -Node: close98572 -Ref: #close98676 -Node: close usage100198 -Ref: #close-usage100293 -Node: codes103106 -Ref: #codes103216 -Node: commodities103928 -Ref: #commodities104057 -Node: descriptions104139 -Ref: #descriptions104269 -Node: diff104573 -Ref: #diff104681 -Node: files105728 -Ref: #files105830 -Node: help105977 -Ref: #help106079 -Node: import106806 -Ref: #import106922 -Node: Importing balance assignments107844 -Ref: #importing-balance-assignments108027 -Node: Commodity display styles108676 -Ref: #commodity-display-styles108849 -Node: incomestatement108978 -Ref: #incomestatement109113 -Node: notes110575 -Ref: #notes110690 -Node: payees111058 -Ref: #payees111166 -Node: prices111586 -Ref: #prices111694 -Node: print112035 -Ref: #print112147 -Node: print-unique117632 -Ref: #print-unique117760 -Node: register118045 -Ref: #register118174 -Node: Custom register output122620 -Ref: #custom-register-output122751 -Node: register-match124088 -Ref: #register-match124224 -Node: rewrite124575 -Ref: #rewrite124692 -Node: Re-write rules in a file126598 -Ref: #re-write-rules-in-a-file126761 -Node: Diff output format127910 -Ref: #diff-output-format128093 -Node: rewrite vs print --auto129185 -Ref: #rewrite-vs.-print---auto129345 -Node: roi129901 -Ref: #roi130001 -Node: stats142211 -Ref: #stats142312 -Node: tags143100 -Ref: #tags143200 -Node: test143719 -Ref: #test143835 -Node: About add-on commands144582 -Ref: #about-add-on-commands144719 -Node: JOURNAL FORMAT145850 -Ref: #journal-format145978 -Node: Transactions148144 -Ref: #transactions148259 -Node: Dates149273 -Ref: #dates149389 -Node: Simple dates149454 -Ref: #simple-dates149574 -Node: Secondary dates150083 -Ref: #secondary-dates150231 -Node: Posting dates151567 -Ref: #posting-dates151690 -Node: Status153062 -Ref: #status153179 -Node: Description154887 -Ref: #description155017 -Node: Payee and note155337 -Ref: #payee-and-note155445 -Node: Comments155780 -Ref: #comments155902 -Node: Tags157096 -Ref: #tags-1157207 -Node: Postings158600 -Ref: #postings158724 -Node: Virtual postings159750 -Ref: #virtual-postings159861 -Node: Account names161166 -Ref: #account-names161303 -Node: Amounts161790 -Ref: #amounts161925 -Node: Digit group marks163049 -Ref: #digit-group-marks163194 -Node: Commodity display style164132 -Ref: #commodity-display-style164306 -Node: Rounding166019 -Ref: #rounding166137 -Node: Transaction prices166549 -Ref: #transaction-prices166715 -Node: Lot prices lot dates169146 -Ref: #lot-prices-lot-dates169329 -Node: Balance assertions169817 -Ref: #balance-assertions169995 -Node: Assertions and ordering171028 -Ref: #assertions-and-ordering171210 -Node: Assertions and included files171910 -Ref: #assertions-and-included-files172147 -Node: Assertions and multiple -f options172480 -Ref: #assertions-and-multiple--f-options172730 -Node: Assertions and commodities172862 -Ref: #assertions-and-commodities173088 -Node: Assertions and prices174245 -Ref: #assertions-and-prices174453 -Node: Assertions and subaccounts174893 -Ref: #assertions-and-subaccounts175116 -Node: Assertions and virtual postings175440 -Ref: #assertions-and-virtual-postings175676 -Node: Assertions and precision175818 -Ref: #assertions-and-precision176005 -Node: Balance assignments176272 -Ref: #balance-assignments176442 -Node: Balance assignments and prices177606 -Ref: #balance-assignments-and-prices177772 -Node: Directives177996 -Ref: #directives178159 -Node: Directives and multiple files183402 -Ref: #directives-and-multiple-files183598 -Node: Comment blocks184262 -Ref: #comment-blocks184439 -Node: Including other files184615 -Ref: #including-other-files184789 -Node: Default year185713 -Ref: #default-year185876 -Node: Declaring commodities186283 -Ref: #declaring-commodities186460 -Node: Commodity error checking188304 -Ref: #commodity-error-checking188454 -Node: Default commodity188711 -Ref: #default-commodity188891 -Node: Declaring market prices189780 -Ref: #declaring-market-prices189969 -Node: Declaring accounts190826 -Ref: #declaring-accounts191006 -Node: Account error checking192208 -Ref: #account-error-checking192374 -Node: Account comments193553 -Ref: #account-comments193737 -Node: Account subdirectives194161 -Ref: #account-subdirectives194346 -Node: Account types194659 -Ref: #account-types194833 -Node: Declaring account types195569 -Ref: #declaring-account-types195748 -Node: Auto-detected account types196398 -Ref: #auto-detected-account-types196639 -Node: Interference from auto-detected account types197536 -Ref: #interference-from-auto-detected-account-types197813 -Node: Old account type syntax198296 -Ref: #old-account-type-syntax198493 -Node: Account display order198793 -Ref: #account-display-order198953 -Node: Rewriting accounts200104 -Ref: #rewriting-accounts200283 -Node: Basic aliases201040 -Ref: #basic-aliases201176 -Node: Regex aliases201880 -Ref: #regex-aliases202042 -Node: Combining aliases202761 -Ref: #combining-aliases202944 -Node: Aliases and multiple files204220 -Ref: #aliases-and-multiple-files204419 -Node: end aliases204998 -Ref: #end-aliases205145 -Node: Default parent account205246 -Ref: #default-parent-account205436 -Node: Periodic transactions206320 -Ref: #periodic-transactions206503 -Node: Periodic rule syntax208420 -Ref: #periodic-rule-syntax208620 -Node: Two spaces between period expression and description!209324 -Ref: #two-spaces-between-period-expression-and-description209637 -Node: Forecasting with periodic transactions210321 -Ref: #forecasting-with-periodic-transactions210620 -Node: Budgeting with periodic transactions212675 -Ref: #budgeting-with-periodic-transactions212908 -Node: Auto postings213317 -Ref: #auto-postings213453 -Node: Auto postings and multiple files215632 -Ref: #auto-postings-and-multiple-files215830 -Node: Auto postings and dates216039 -Ref: #auto-postings-and-dates216307 -Node: Auto postings and transaction balancing / inferred amounts / balance assertions216482 -Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions216827 -Node: Auto posting tags217169 -Ref: #auto-posting-tags217378 -Node: CSV FORMAT218014 -Ref: #csv-format218142 -Node: Examples220728 -Ref: #examples220831 -Node: Basic221039 -Ref: #basic221141 -Node: Bank of Ireland221683 -Ref: #bank-of-ireland221820 -Node: Amazon223282 -Ref: #amazon223402 -Node: Paypal225121 -Ref: #paypal225217 -Node: CSV rules232861 -Ref: #csv-rules232979 -Node: skip233291 -Ref: #skip233386 -Node: fields233761 -Ref: #fields233885 -Node: Transaction field names235050 -Ref: #transaction-field-names235212 -Node: Posting field names235323 -Ref: #posting-field-names235477 -Node: field assignment237847 -Ref: #field-assignment237992 -Node: separator238810 -Ref: #separator238947 -Node: if block239487 -Ref: #if-block239614 -Node: Matching the whole record240015 -Ref: #matching-the-whole-record240192 -Node: Matching individual fields240996 -Ref: #matching-individual-fields241202 -Node: Combining matchers241426 -Ref: #combining-matchers241624 -Node: Rules applied on successful match241937 -Ref: #rules-applied-on-successful-match242130 -Node: if table242784 -Ref: #if-table242905 -Node: end244643 -Ref: #end244757 -Node: date-format244981 -Ref: #date-format245115 -Node: decimal-mark245864 -Ref: #decimal-mark246009 -Node: newest-first246348 -Ref: #newest-first246491 -Node: include247174 -Ref: #include247307 -Node: balance-type247751 -Ref: #balance-type247873 -Node: Tips248573 -Ref: #tips248664 -Node: Rapid feedback248920 -Ref: #rapid-feedback249039 -Node: Valid CSV249499 -Ref: #valid-csv249631 -Node: File Extension249823 -Ref: #file-extension249977 -Node: Reading multiple CSV files250406 -Ref: #reading-multiple-csv-files250593 -Node: Valid transactions250834 -Ref: #valid-transactions251014 -Node: Deduplicating importing251642 -Ref: #deduplicating-importing251823 -Node: Setting amounts252856 -Ref: #setting-amounts253027 -Node: Setting currency/commodity254014 -Ref: #setting-currencycommodity254208 -Node: Referencing other fields255382 -Ref: #referencing-other-fields255584 -Node: How CSV rules are evaluated256481 -Ref: #how-csv-rules-are-evaluated256656 -Node: TIMECLOCK FORMAT258107 -Ref: #timeclock-format258247 -Node: TIMEDOT FORMAT260308 -Ref: #timedot-format260446 -Node: COMMON TASKS264722 -Ref: #common-tasks264851 -Node: Getting help265258 -Ref: #getting-help265392 -Node: Constructing command lines265945 -Ref: #constructing-command-lines266139 -Node: Starting a journal file266836 -Ref: #starting-a-journal-file267036 -Node: Setting opening balances268224 -Ref: #setting-opening-balances268422 -Node: Recording transactions271563 -Ref: #recording-transactions271745 -Node: Reconciling272301 -Ref: #reconciling272446 -Node: Reporting274703 -Ref: #reporting274845 -Node: Migrating to a new file278844 -Ref: #migrating-to-a-new-file278994 -Node: LIMITATIONS279293 -Ref: #limitations279421 -Node: TROUBLESHOOTING280164 -Ref: #troubleshooting280279 +Node: Multiple files17894 +Ref: #multiple-files18036 +Node: Strict mode18505 +Ref: #strict-mode18620 +Node: TIME PERIODS19268 +Ref: #time-periods19385 +Node: Smart dates19483 +Ref: #smart-dates19609 +Node: Report start & end date20935 +Ref: #report-start-end-date21110 +Node: Report intervals22643 +Ref: #report-intervals22811 +Node: Period expressions23201 +Ref: #period-expressions23341 +Node: DEPTH27784 +Ref: #depth27884 +Node: QUERIES28216 +Ref: #queries28317 +Node: VALUATION32279 +Ref: #valuation32387 +Node: -B Cost33076 +Ref: #b-cost33174 +Node: -V Value33307 +Ref: #v-value33447 +Node: -X Value in specified commodity33642 +Ref: #x-value-in-specified-commodity33835 +Node: Valuation date33984 +Ref: #valuation-date34146 +Node: Market prices34583 +Ref: #market-prices34757 +Node: --infer-value market prices from transactions35936 +Ref: #infer-value-market-prices-from-transactions36179 +Node: Valuation commodity37440 +Ref: #valuation-commodity37643 +Node: Simple valuation examples38848 +Ref: #simple-valuation-examples39044 +Node: --value Flexible valuation39703 +Ref: #value-flexible-valuation39905 +Node: More valuation examples41777 +Ref: #more-valuation-examples41980 +Node: Effect of valuation on reports43985 +Ref: #effect-of-valuation-on-reports44167 +Node: PIVOTING51568 +Ref: #pivoting51673 +Node: OUTPUT53349 +Ref: #output53449 +Node: Output destination53500 +Ref: #output-destination53631 +Node: Output format54056 +Ref: #output-format54177 +Node: COMMANDS56344 +Ref: #commands56456 +Node: accounts59821 +Ref: #accounts59921 +Node: activity60617 +Ref: #activity60729 +Node: add61112 +Ref: #add61215 +Node: aregister64008 +Ref: #aregister64122 +Node: aregister and custom posting dates65616 +Ref: #aregister-and-custom-posting-dates65782 +Node: balance66603 +Ref: #balance66722 +Node: Single-period flat balance report68374 +Ref: #single-period-flat-balance-report68582 +Node: Single-period tree-mode balance report69286 +Ref: #single-period-tree-mode-balance-report69554 +Node: Customising single-period balance reports70999 +Ref: #customising-single-period-balance-reports71254 +Node: Depth limiting73377 +Ref: #depth-limiting73554 +Node: Colour support74250 +Ref: #colour-support74403 +Node: Sorting by amount74499 +Ref: #sorting-by-amount74655 +Node: Percentages75149 +Ref: #percentages75306 +Node: Multi-period balance report76443 +Ref: #multi-period-balance-report76628 +Node: Budget report82278 +Ref: #budget-report82415 +Node: Budget report start date87704 +Ref: #budget-report-start-date87871 +Node: Nested budgets89203 +Ref: #nested-budgets89350 +Node: balancesheet92790 +Ref: #balancesheet92928 +Node: balancesheetequity94565 +Ref: #balancesheetequity94716 +Node: cashflow95935 +Ref: #cashflow96059 +Node: check97393 +Ref: #check97498 +Node: Basic checks98132 +Ref: #basic-checks98250 +Node: Strict checks98782 +Ref: #strict-checks98923 +Node: Other checks99227 +Ref: #other-checks99367 +Node: Custom checks99804 +Ref: #custom-checks99924 +Node: close100341 +Ref: #close100445 +Node: close usage101967 +Ref: #close-usage102062 +Node: codes104875 +Ref: #codes104985 +Node: commodities105697 +Ref: #commodities105826 +Node: descriptions105908 +Ref: #descriptions106038 +Node: diff106342 +Ref: #diff106450 +Node: files107497 +Ref: #files107599 +Node: help107746 +Ref: #help107848 +Node: import108575 +Ref: #import108691 +Node: Importing balance assignments109613 +Ref: #importing-balance-assignments109796 +Node: Commodity display styles110445 +Ref: #commodity-display-styles110618 +Node: incomestatement110747 +Ref: #incomestatement110882 +Node: notes112344 +Ref: #notes112459 +Node: payees112827 +Ref: #payees112935 +Node: prices113355 +Ref: #prices113463 +Node: print113804 +Ref: #print113916 +Node: print-unique119401 +Ref: #print-unique119529 +Node: register119814 +Ref: #register119943 +Node: Custom register output124389 +Ref: #custom-register-output124520 +Node: register-match125857 +Ref: #register-match125993 +Node: rewrite126344 +Ref: #rewrite126461 +Node: Re-write rules in a file128367 +Ref: #re-write-rules-in-a-file128530 +Node: Diff output format129679 +Ref: #diff-output-format129862 +Node: rewrite vs print --auto130954 +Ref: #rewrite-vs.-print---auto131114 +Node: roi131670 +Ref: #roi131770 +Node: stats143980 +Ref: #stats144081 +Node: tags144869 +Ref: #tags144969 +Node: test145488 +Ref: #test145604 +Node: About add-on commands146351 +Ref: #about-add-on-commands146488 +Node: JOURNAL FORMAT147619 +Ref: #journal-format147747 +Node: Transactions149934 +Ref: #transactions150049 +Node: Dates151063 +Ref: #dates151179 +Node: Simple dates151244 +Ref: #simple-dates151364 +Node: Secondary dates151873 +Ref: #secondary-dates152021 +Node: Posting dates153357 +Ref: #posting-dates153480 +Node: Status154852 +Ref: #status154969 +Node: Description156677 +Ref: #description156807 +Node: Payee and note157127 +Ref: #payee-and-note157235 +Node: Comments157570 +Ref: #comments157692 +Node: Tags158886 +Ref: #tags-1158997 +Node: Postings160390 +Ref: #postings160514 +Node: Virtual postings161540 +Ref: #virtual-postings161651 +Node: Account names162956 +Ref: #account-names163093 +Node: Amounts163581 +Ref: #amounts163716 +Node: Digit group marks164840 +Ref: #digit-group-marks164985 +Node: Commodity display style165923 +Ref: #commodity-display-style166097 +Node: Rounding167810 +Ref: #rounding167928 +Node: Transaction prices168340 +Ref: #transaction-prices168506 +Node: Lot prices lot dates170937 +Ref: #lot-prices-lot-dates171120 +Node: Balance assertions171608 +Ref: #balance-assertions171786 +Node: Assertions and ordering172819 +Ref: #assertions-and-ordering173001 +Node: Assertions and included files173701 +Ref: #assertions-and-included-files173938 +Node: Assertions and multiple -f options174271 +Ref: #assertions-and-multiple--f-options174521 +Node: Assertions and commodities174653 +Ref: #assertions-and-commodities174879 +Node: Assertions and prices176036 +Ref: #assertions-and-prices176244 +Node: Assertions and subaccounts176684 +Ref: #assertions-and-subaccounts176907 +Node: Assertions and virtual postings177231 +Ref: #assertions-and-virtual-postings177467 +Node: Assertions and precision177609 +Ref: #assertions-and-precision177796 +Node: Balance assignments178063 +Ref: #balance-assignments178233 +Node: Balance assignments and prices179397 +Ref: #balance-assignments-and-prices179563 +Node: Directives179787 +Ref: #directives179950 +Node: Directives and multiple files185408 +Ref: #directives-and-multiple-files185604 +Node: Comment blocks186268 +Ref: #comment-blocks186445 +Node: Including other files186621 +Ref: #including-other-files186795 +Node: Default year187719 +Ref: #default-year187877 +Node: Declaring payees188284 +Ref: #declaring-payees188450 +Node: Declaring commodities188696 +Ref: #declaring-commodities188877 +Node: Commodity error checking190721 +Ref: #commodity-error-checking190871 +Node: Default commodity191128 +Ref: #default-commodity191308 +Node: Declaring market prices192197 +Ref: #declaring-market-prices192386 +Node: Declaring accounts193243 +Ref: #declaring-accounts193423 +Node: Account error checking194625 +Ref: #account-error-checking194791 +Node: Account comments195970 +Ref: #account-comments196154 +Node: Account subdirectives196578 +Ref: #account-subdirectives196763 +Node: Account types197076 +Ref: #account-types197250 +Node: Declaring account types197986 +Ref: #declaring-account-types198165 +Node: Auto-detected account types198815 +Ref: #auto-detected-account-types199056 +Node: Interference from auto-detected account types199953 +Ref: #interference-from-auto-detected-account-types200230 +Node: Old account type syntax200713 +Ref: #old-account-type-syntax200910 +Node: Account display order201210 +Ref: #account-display-order201370 +Node: Rewriting accounts202521 +Ref: #rewriting-accounts202700 +Node: Basic aliases203457 +Ref: #basic-aliases203593 +Node: Regex aliases204297 +Ref: #regex-aliases204459 +Node: Combining aliases205178 +Ref: #combining-aliases205361 +Node: Aliases and multiple files206637 +Ref: #aliases-and-multiple-files206836 +Node: end aliases207415 +Ref: #end-aliases207562 +Node: Default parent account207663 +Ref: #default-parent-account207853 +Node: Periodic transactions208737 +Ref: #periodic-transactions208920 +Node: Periodic rule syntax210837 +Ref: #periodic-rule-syntax211037 +Node: Two spaces between period expression and description!211741 +Ref: #two-spaces-between-period-expression-and-description212054 +Node: Forecasting with periodic transactions212738 +Ref: #forecasting-with-periodic-transactions213037 +Node: Budgeting with periodic transactions215092 +Ref: #budgeting-with-periodic-transactions215325 +Node: Auto postings215734 +Ref: #auto-postings215870 +Node: Auto postings and multiple files218049 +Ref: #auto-postings-and-multiple-files218247 +Node: Auto postings and dates218456 +Ref: #auto-postings-and-dates218724 +Node: Auto postings and transaction balancing / inferred amounts / balance assertions218899 +Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions219244 +Node: Auto posting tags219586 +Ref: #auto-posting-tags219795 +Node: CSV FORMAT220431 +Ref: #csv-format220559 +Node: Examples223145 +Ref: #examples223248 +Node: Basic223456 +Ref: #basic223558 +Node: Bank of Ireland224100 +Ref: #bank-of-ireland224237 +Node: Amazon225699 +Ref: #amazon225819 +Node: Paypal227538 +Ref: #paypal227634 +Node: CSV rules235278 +Ref: #csv-rules235396 +Node: skip235708 +Ref: #skip235803 +Node: fields236178 +Ref: #fields236302 +Node: Transaction field names237467 +Ref: #transaction-field-names237629 +Node: Posting field names237740 +Ref: #posting-field-names237894 +Node: field assignment240264 +Ref: #field-assignment240409 +Node: separator241227 +Ref: #separator241364 +Node: if block241904 +Ref: #if-block242031 +Node: Matching the whole record242432 +Ref: #matching-the-whole-record242609 +Node: Matching individual fields243413 +Ref: #matching-individual-fields243619 +Node: Combining matchers243843 +Ref: #combining-matchers244041 +Node: Rules applied on successful match244354 +Ref: #rules-applied-on-successful-match244547 +Node: if table245201 +Ref: #if-table245322 +Node: end247060 +Ref: #end247174 +Node: date-format247398 +Ref: #date-format247532 +Node: decimal-mark248281 +Ref: #decimal-mark248426 +Node: newest-first248765 +Ref: #newest-first248908 +Node: include249591 +Ref: #include249724 +Node: balance-type250168 +Ref: #balance-type250290 +Node: Tips250990 +Ref: #tips251081 +Node: Rapid feedback251354 +Ref: #rapid-feedback251473 +Node: Valid CSV251933 +Ref: #valid-csv252065 +Node: File Extension252257 +Ref: #file-extension252411 +Node: Reading multiple CSV files252840 +Ref: #reading-multiple-csv-files253027 +Node: Valid transactions253268 +Ref: #valid-transactions253448 +Node: Deduplicating importing254076 +Ref: #deduplicating-importing254257 +Node: Setting amounts255290 +Ref: #setting-amounts255447 +Node: Amount signs257666 +Ref: #amount-signs257820 +Node: Setting currency/commodity258507 +Ref: #setting-currencycommodity258698 +Node: Referencing other fields259872 +Ref: #referencing-other-fields260076 +Node: How CSV rules are evaluated260973 +Ref: #how-csv-rules-are-evaluated261148 +Node: TIMECLOCK FORMAT262599 +Ref: #timeclock-format262739 +Node: TIMEDOT FORMAT264800 +Ref: #timedot-format264938 +Node: COMMON TASKS269214 +Ref: #common-tasks269343 +Node: Getting help269750 +Ref: #getting-help269884 +Node: Constructing command lines270437 +Ref: #constructing-command-lines270631 +Node: Starting a journal file271328 +Ref: #starting-a-journal-file271528 +Node: Setting opening balances272716 +Ref: #setting-opening-balances272914 +Node: Recording transactions276055 +Ref: #recording-transactions276237 +Node: Reconciling276793 +Ref: #reconciling276938 +Node: Reporting279195 +Ref: #reporting279337 +Node: Migrating to a new file283336 +Ref: #migrating-to-a-new-file283486 +Node: LIMITATIONS283785 +Ref: #limitations283913 +Node: TROUBLESHOOTING284656 +Ref: #troubleshooting284771  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index e76fcb3b6..a7766828f 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -453,9 +453,12 @@ DATA FILES relevant error messages. You can also force a specific reader/format by prefixing the file path - with the format and a colon. Eg to read a .dat file as csv: + with the format and a colon. Eg, to read a .dat file as csv format: $ hledger -f csv:/some/csv-file.dat stats + + Or to read stdin (-) as timeclock format: + $ echo 'i 2009/13/1 08:00:00' | hledger print -ftimeclock:- Multiple files @@ -557,7 +560,6 @@ TIME PERIODS Examples: -b 2016/3/17 begin on St. Patrick's day 2016 - -e 12/1 end at the start of december 1st of the current year (11/30 will be the last date included) -b thismonth all transactions on or after the 1st of the current month @@ -627,8 +629,6 @@ TIME PERIODS -p "2009Q1" first quarter of 2009, equivalent to "2009/1/1 to 2009/4/1" - - -p "q4" fourth quarter of the cur- rent year @@ -873,23 +873,28 @@ VALUATION ing both forward and reverse prices (1 and 2 above), leading from A to B. - Amounts for which no applicable market price can be found, are not con- + There is a limit to the length of these price chains; if hledger + reaches that length without finding a complete chain or exhausting all + possibilities, it will give up (with a "gave up" message visible in + --debug=2 output). That limit is currently 1000. + + Amounts for which no suitable market price can be found, are not con- verted. --infer-value: market prices from transactions Normally, market value in hledger is fully controlled by, and requires, P directives in your journal. Since adding and updating those can be a - chore, and since transactions usually take place at close to market + chore, and since transactions usually take place at close to market value, why not use the recorded transaction prices as additional market prices (as Ledger does) ? We could produce value reports without need- ing P directives at all. - Adding the --infer-value flag to -V, -X or --value enables this. So - for example, hledger bs -V --infer-value will get market prices both + Adding the --infer-value flag to -V, -X or --value enables this. So + for example, hledger bs -V --infer-value will get market prices both from P directives and from transactions. There is a downside: value reports can sometimes be affected in confus- - ing/undesired ways by your journal entries. If this happens to you, + ing/undesired ways by your journal entries. If this happens to you, read all of this Valuation section carefully, and try adding --debug or --debug=2 to troubleshoot. @@ -897,43 +902,43 @@ VALUATION o multicommodity transactions with explicit prices (@/@@) - o multicommodity transactions with implicit prices (no @, two commodi- - ties, unbalanced). (With these, the order of postings matters. + o multicommodity transactions with implicit prices (no @, two commodi- + ties, unbalanced). (With these, the order of postings matters. hledger print -x can be useful for troubleshooting.) - o but not, currently, from "more correct" multicommodity transactions + o but not, currently, from "more correct" multicommodity transactions (no @, multiple commodities, balanced). Valuation commodity When you specify a valuation commodity (-X COMM or --value TYPE,COMM): - hledger will convert all amounts to COMM, wherever it can find a suit- + hledger will convert all amounts to COMM, wherever it can find a suit- able market price (including by reversing or chaining prices). - When you leave the valuation commodity unspecified (-V or --value + When you leave the valuation commodity unspecified (-V or --value TYPE): - For each commodity A, hledger picks a default valuation commodity as + For each commodity A, hledger picks a default valuation commodity as follows, in this order of preference: 1. The price commodity from the latest P-declared market price for A on or before valuation date. 2. The price commodity from the latest P-declared market price for A on - any date. (Allows conversion to proceed when there are inferred + any date. (Allows conversion to proceed when there are inferred prices before the valuation date.) - 3. If there are no P directives at all (any commodity or date) and the - --infer-value flag is used: the price commodity from the latest + 3. If there are no P directives at all (any commodity or date) and the + --infer-value flag is used: the price commodity from the latest transaction-inferred price for A on or before valuation date. This means: - o If you have P directives, they determine which commodities -V will + o If you have P directives, they determine which commodities -V will convert, and to what. o If you have no P directives, and use the --infer-value flag, transac- tion prices determine it. - Amounts for which no valuation commodity can be found are not con- + Amounts for which no valuation commodity can be found are not con- verted. Simple valuation examples @@ -960,7 +965,7 @@ VALUATION $ hledger -f t.j bal -N euros -V -e 2016/11/4 $110.00 assets:euros - What are they worth after 2016/12/21 ? (no report end date specified, + What are they worth after 2016/12/21 ? (no report end date specified, defaults to today) $ hledger -f t.j bal -N euros -V @@ -981,13 +986,12 @@ VALUATION The TYPE part selects cost or value and valuation date: --value=cost - Convert amounts to cost, using the prices recorded in transac- + Convert amounts to cost, using the prices recorded in transac- tions. --value=then - Convert amounts to their value in the default valuation commod- - ity, using market prices on each posting's date. This is cur- - rently supported only by the print and register commands. + Convert amounts to their value in the default valuation commod- + ity, using market prices on each posting's date. --value=end Convert amounts to their value in the default valuation commod- @@ -1124,88 +1128,105 @@ VALUATION problems, please report them, ideally with a reproducible example. Re- lated: #329, #1083. - Report type -B, -V, -X --value=then --value=end --value=DATE, - --value=cost --value=now + Report -B, -V, -X --value=then --value=end --value=DATE, + type --value=cost --value=now -------------------------------------------------------------------------------------------- print - posting cost value at re- value at value at re- value at - amounts port end or posting date port or jour- DATE/today - today nal end - - balance as- unchanged unchanged unchanged unchanged unchanged - ser- + posting cost value at re- value at posting value at re- value at + amounts port end or date port or DATE/today + today journal end + balance unchanged unchanged unchanged unchanged unchanged + asser- tions/as- signments register - starting cost value at day not sup- value at day value at - balance before report ported before report DATE/today - (-H) or journal or journal - start start - posting cost value at re- value at value at re- value at - amounts port end or posting date port or jour- DATE/today - today nal end - summary summarised value at pe- sum of post- value at pe- value at - posting cost riod ends ings in in- riod ends DATE/today - amounts terval, val- - with report ued at in- - interval terval start - running to- sum/average sum/average sum/average sum/average sum/average - tal/average of displayed of displayed of displayed of displayed of displayed - values values values values values + + + + + + starting cost value at day valued at day value at day value at + balance before re- each historical before re- DATE/today + (-H) port or posting was made port or + journal journal + start start + posting cost value at re- value at posting value at re- value at + amounts port end or date port or DATE/today + today journal end + summary summarised value at pe- sum of postings value at pe- value at + posting cost riod ends in interval, val- riod ends DATE/today + amounts ued at interval + with re- start + port in- + terval + running sum/average sum/average sum/average of sum/average sum/average + total/av- of displayed of displayed displayed values of displayed of displayed + erage values values values values balance - (bs, bse, + (bs, bse, cf, is) - balance sums of costs value at re- not sup- value at re- value at - changes port end or ported port or jour- DATE/today of - today of sums nal end of sums of post- - of postings sums of post- ings - ings - budget like balance like balance not sup- like balances like balance - amounts changes changes ported changes - (--budget) - grand total sum of dis- sum of dis- not sup- sum of dis- sum of dis- - played values played values ported played values played values + balance sums of value at re- value at posting value at re- value at + changes costs port end or date port or DATE/today of + today of journal end sums of post- + sums of of sums of ings + postings postings + budget like balance like balance like balance like bal- like balance + amounts changes changes changes ances changes + (--bud- + get) + grand to- sum of dis- sum of dis- sum of displayed sum of dis- sum of dis- + tal played val- played val- valued played val- played values + ues ues ues balance - (bs, bse, - cf, is) - with report - interval - starting sums of costs value at re- not sup- value at re- sums of post- - balances of postings port start of ported port start of ings before - (-H) before report sums of all sums of all report start - start postings be- postings be- - fore report fore report - start start - balance sums of costs same as not sup- balance value at - changes of postings --value=end ported change in DATE/today of - (bal, is, in period each period, sums of post- - bs valued at pe- ings - --change, riod ends + (bs, bse, + cf, is) + with re- + port in- + terval + starting sums of value at re- sums of values of value at re- sums of post- + balances costs of port start postings before port start ings before + (-H) postings be- of sums of report start at of sums of report start + fore report all postings respective post- all postings + start before re- ing dates before re- + port start port start + balance sums of same as sums of values of balance value at + changes costs of --value=end postings in pe- change in DATE/today of + (bal, is, postings in riod at respec- each period, sums of post- + bs period tive posting valued at ings + --change, dates period ends cf --change) - end bal- sums of costs same as not sup- period end value at - ances (bal of postings --value=end ported balances, DATE/today of - -H, is --H, from before valued at pe- sums of post- - bs, cf) report start riod ends ings - to period end - budget like balance like balance not sup- like balances like balance - amounts changes/end changes/end ported changes/end - (--budget) balances balances balances - row totals, sums, aver- sums, aver- not sup- sums, aver- sums, aver- - row aver- ages of dis- ages of dis- ported ages of dis- ages of dis- - ages (-T, played values played values played values played values - -A) - column to- sums of dis- sums of dis- not sup- sums of dis- sums of dis- - tals played values played values ported played values played values - grand to- sum, average sum, average not sup- sum, average sum, average - tal, grand of column to- of column to- ported of column to- of column to- - average tals tals tals tals + end bal- sums of same as sums of values of period end value at + ances costs of --value=end postings from be- balances, DATE/today of + (bal -H, postings fore period start valued at sums of post- + is --H, from before to period end at period ends ings + bs, cf) report start respective post- + to period ing dates + end + budget like balance like balance like balance like bal- like balance + amounts changes/end changes/end changes/end bal- ances changes/end + (--bud- balances balances ances balances + get) + row to- sums, aver- sums, aver- sums, averages of sums, aver- sums, aver- + tals, row ages of dis- ages of dis- displayed values ages of dis- ages of dis- + averages played val- played val- played val- played values + (-T, -A) ues ues ues + column sums of dis- sums of dis- sums of displayed sums of dis- sums of dis- + totals played val- played val- values played val- played values + ues ues ues + + grand to- sum, average sum, average sum, average of sum, average sum, average + tal, of column of column column totals of column of column to- + grand av- totals totals totals tals + erage + + --cumulative is omitted to save space, it works like -H but with a zero starting balance. @@ -1213,43 +1234,43 @@ VALUATION cost calculated using price(s) recorded in the transaction(s). - value market value using available market price declarations, or the + value market value using available market price declarations, or the unchanged amount if no conversion rate can be found. report start - the first day of the report period specified with -b or -p or + the first day of the report period specified with -b or -p or date:, otherwise today. report or journal start - the first day of the report period specified with -b or -p or - date:, otherwise the earliest transaction date in the journal, + the first day of the report period specified with -b or -p or + date:, otherwise the earliest transaction date in the journal, otherwise today. report end - the last day of the report period specified with -e or -p or + the last day of the report period specified with -e or -p or date:, otherwise today. report or journal end - the last day of the report period specified with -e or -p or - date:, otherwise the latest transaction date in the journal, + the last day of the report period specified with -e or -p or + date:, otherwise the latest transaction date in the journal, otherwise today. report interval - a flag (-D/-W/-M/-Q/-Y) or period expression that activates the + a flag (-D/-W/-M/-Q/-Y) or period expression that activates the report's multi-period mode (whether showing one or many subperi- ods). PIVOTING Normally hledger sums amounts, and organizes them in a hierarchy, based - on account name. The --pivot FIELD option causes it to sum and orga- - nize hierarchy based on the value of some other field instead. FIELD + on account name. The --pivot FIELD option causes it to sum and orga- + nize hierarchy based on the value of some other field instead. FIELD can be: code, description, payee, note, or the full name (case insensi- tive) of any tag. As with account names, values containing colon:sepa- rated:parts will be displayed hierarchically in reports. - --pivot is a general option affecting all reports; you can think of + --pivot is a general option affecting all reports; you can think of hledger transforming the journal before any other processing, replacing - every posting's account name with the value of the specified field on + every posting's account name with the value of the specified field on that posting, inheriting it from the transaction or using a blank value if it's not present. @@ -1275,7 +1296,7 @@ PIVOTING -------------------- 0 - One way to show only amounts with a member: value (using a query, de- + One way to show only amounts with a member: value (using a query, de- scribed below): $ hledger balance --pivot member tag:member=. @@ -1283,7 +1304,7 @@ PIVOTING -------------------- -2 EUR - Another way (the acct: query matches against the pivoted "account + Another way (the acct: query matches against the pivoted "account name"): $ hledger balance --pivot member acct:. @@ -1298,8 +1319,8 @@ OUTPUT $ hledger print > foo.txt - Some commands (print, register, stats, the balance commands) also pro- - vide the -o/--output-file option, which does the same thing without + Some commands (print, register, stats, the balance commands) also pro- + vide the -o/--output-file option, which does the same thing without needing the shell. Eg: $ hledger print -o foo.txt @@ -1308,7 +1329,7 @@ OUTPUT Output format Some commands (print, register, the balance commands) offer a choice of output format. In addition to the usual plain text format (txt), there - are CSV (csv), HTML (html), JSON (json) and SQL (sql). This is con- + are CSV (csv), HTML (html), JSON (json) and SQL (sql). This is con- trolled by the -O/--output-format option: $ hledger print -O csv @@ -1323,42 +1344,42 @@ OUTPUT Some notes about JSON output: - o This feature is marked experimental, and not yet much used; you + o This feature is marked experimental, and not yet much used; you should expect our JSON to evolve. Real-world feedback is welcome. - o Our JSON is rather large and verbose, as it is quite a faithful rep- - resentation of hledger's internal data types. To understand the + o Our JSON is rather large and verbose, as it is quite a faithful rep- + resentation of hledger's internal data types. To understand the JSON, read the Haskell type definitions, which are mostly in https://github.com/simonmichael/hledger/blob/master/hledger- lib/Hledger/Data/Types.hs. - o hledger represents quantities as Decimal values storing up to 255 - significant digits, eg for repeating decimals. Such numbers can + o hledger represents quantities as Decimal values storing up to 255 + significant digits, eg for repeating decimals. Such numbers can arise in practice (from automatically-calculated transaction prices), - and would break most JSON consumers. So in JSON, we show quantities + and would break most JSON consumers. So in JSON, we show quantities as simple Numbers with at most 10 decimal places. We don't limit the - number of integer digits, but that part is under your control. We - hope this approach will not cause problems in practice; if you find + number of integer digits, but that part is under your control. We + hope this approach will not cause problems in practice; if you find otherwise, please let us know. (Cf #1195) Notes about SQL output: - o SQL output is also marked experimental, and much like JSON could use + o SQL output is also marked experimental, and much like JSON could use real-world feedback. o SQL output is expected to work with sqlite, MySQL and PostgreSQL - o SQL output is structured with the expectations that statements will - be executed in the empty database. If you already have tables cre- - ated via SQL output of hledger, you would probably want to either + o SQL output is structured with the expectations that statements will + be executed in the empty database. If you already have tables cre- + ated via SQL output of hledger, you would probably want to either clear tables of existing data (via delete or truncate SQL statements) or drop tables completely as otherwise your postings will be duped. COMMANDS - hledger provides a number of commands for producing reports and manag- - ing your data. Run hledger with no arguments to list the commands - available, and hledger CMD to run a command. CMD can be the full com- - mand name, or its standard abbreviation shown in the commands list, or + hledger provides a number of commands for producing reports and manag- + ing your data. Run hledger with no arguments to list the commands + available, and hledger CMD to run a command. CMD can be the full com- + mand name, or its standard abbreviation shown in the commands list, or any unambiguous prefix of the name. Eg: hledger bal. Here are the built-in commands, with the most often-used in bold: @@ -1402,7 +1423,7 @@ COMMANDS o activity - show postings-per-interval bar charts - o balance (bal) - show balance changes/end balances/budgets in any ac- + o balance (bal) - show balance changes/end balances/budgets in any ac- counts o codes - show transaction codes @@ -1425,10 +1446,10 @@ COMMANDS o print-unique - show only transactions with unique descriptions - 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 register-match - show a recent posting that best matches a descrip- + o register-match - show a recent posting that best matches a descrip- tion o stats - show journal statistics @@ -1439,8 +1460,8 @@ COMMANDS Add-on commands: - Programs or scripts named hledger-SOMETHING in your PATH are add-on - commands; these appear in the commands list with a + mark. Two of + Programs or scripts named hledger-SOMETHING in your PATH are add-on + commands; these appear in the commands list with a + mark. Two of these are maintained and released with hledger: o ui - an efficient terminal interface (TUI) for hledger @@ -1451,10 +1472,10 @@ COMMANDS o iadd - a more interactive alternative for the add command - o interest - generates interest transactions according to various + o interest - generates interest transactions according to various schemes - o stockquotes - downloads market prices for your commodities from Al- + o stockquotes - downloads market prices for your commodities from Al- phaVantage (experimental) Next, the detailed command docs, in alphabetical order. @@ -1463,13 +1484,13 @@ COMMANDS accounts Show account names. - This command lists account names, either declared with account direc- - tives (--declared), posted to (--used), or both (the default). With - query arguments, only matched account names and account names refer- - enced by matched postings are shown. 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 com- - ponents. Account names can be depth-clipped with depth:N or --depth N + This command lists account names, either declared with account direc- + tives (--declared), posted to (--used), or both (the default). With + query arguments, only matched account names and account names refer- + enced by matched postings are shown. 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 com- + ponents. Account names can be depth-clipped with depth:N or --depth N or -N. Examples: @@ -1488,8 +1509,8 @@ COMMANDS activity Show an ascii barchart of posting counts per interval. - The activity command displays an ascii histogram showing transaction - counts by day, week, month or other reporting interval (by day is the + The activity command displays an ascii histogram showing transaction + counts by day, week, month or other reporting interval (by day is the default). With query arguments, it counts only matched transactions. Examples: @@ -1502,25 +1523,25 @@ COMMANDS add add - Prompt for transactions and add them to the journal. Any arguments + Prompt for transactions and add them to the journal. Any arguments will be used as default inputs for the first N prompts. - Many hledger users edit their journals directly with a text editor, or - generate them from CSV. For more interactive data entry, there is the - add command, which prompts interactively on the console for new trans- + 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 journal file (if there are multiple -f - FILE options, the first file is used.) Existing transactions are not - changed. This is the only hledger command that writes to the journal + FILE options, the first file is used.) Existing transactions are not + changed. This is the only hledger command that writes to the journal file. 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. @@ -1528,10 +1549,10 @@ COMMANDS o Readline-style edit keys can be used during data entry. o The tab key will auto-complete whenever possible - accounts, descrip- - tions, dates (yesterday, today, tomorrow). If the input area is + tions, dates (yesterday, today, tomorrow). If the input area is empty, it will insert the default value. - o If the journal defines a default commodity, it will be added to any + o If the journal defines a default commodity, it will be added to any bare numbers entered. o A parenthesised transaction code may be entered following a date. @@ -1540,7 +1561,7 @@ COMMANDS o If you make a mistake, enter < at any prompt to go one step backward. - o Input prompts are displayed in a different colour when the terminal + o Input prompts are displayed in a different colour when the terminal supports it. Example (see the tutorial for a detailed explanation): @@ -1570,16 +1591,16 @@ COMMANDS Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2015/05/22]: $ - On Microsoft Windows, the add command makes sure that no part of the + On Microsoft Windows, the add command makes sure that no part of the file path ends with a period, as that would cause problems (#1056). aregister aregister, areg - Show transactions affecting a particular account, and the account's + Show transactions affecting a particular account, and the account's running balance. - aregister shows the transactions affecting a particular account (and - its subaccounts), from the point of view of that account. Each line + aregister shows the transactions affecting a particular account (and + its subaccounts), from the point of view of that account. Each line shows: o the transaction's (or posting's, see below) date @@ -1588,48 +1609,48 @@ COMMANDS o the net change to this account's balance - o the account's historical running balance (including balance from + o the account's historical running balance (including balance from transactions before the report start date). - With aregister, each line represents a whole transaction - as in - hledger-ui, hledger-web, and your bank statement. By contrast, the - register command shows individual postings, across all accounts. You - might prefer aregister for reconciling with real-world asset/liability + With aregister, each line represents a whole transaction - as in + hledger-ui, hledger-web, and your bank statement. By contrast, the + register command shows individual postings, across all accounts. You + might prefer aregister for reconciling with real-world asset/liability accounts, and register for reviewing detailed revenues/expenses. An account must be specified as the first argument, which should be the - full account name or an account pattern (regular expression). aregis- - ter will show transactions in this account (the first one matched) and + full account name or an account pattern (regular expression). aregis- + ter will show transactions in this account (the first one matched) and any of its subaccounts. - Any additional arguments form a query which will filter the transac- + Any additional arguments form a query which will filter the transac- tions shown. - 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. This command also supports the output destination and output format op- tions The output formats supported are txt, csv, and json. aregister and custom posting dates - Transactions whose date is outside the report period can still be - shown, if they have a posting to this account dated inside the report - period. (And in this case it's the posting date that is shown.) This + Transactions whose date is outside the report period can still be + shown, if they have a posting to this account dated inside the report + period. (And in this case it's the posting date that is shown.) This ensures that aregister can show an accurate historical running balance, matching the one shown by register -H with the same arguments. - To filter strictly by transaction date instead, add the --txn-dates - flag. If you use this flag and some of your postings have custom + To filter strictly by transaction date instead, add the --txn-dates + flag. If you use this flag and some of your postings have custom dates, it's probably best to assume the running balance is wrong. Examples: - Show all transactions and historical running balance in the first ac- + Show all transactions and historical running balance in the first ac- count whose name contains "checking": $ hledger areg checking - Show transactions and historical running balance in all asset accounts + Show transactions and historical running balance in all asset accounts during july: $ hledger areg assets date:jul @@ -1639,22 +1660,22 @@ COMMANDS Show accounts and their balances. The balance command is hledger's most versatile command. Note, despite - the name, it is not always used for showing real-world account bal- - ances; the more accounting-aware balancesheet and incomestatement may + the name, it is not always used for showing real-world account bal- + ances; the more accounting-aware balancesheet and incomestatement may be more convenient for that. By default, it displays all accounts, and each account's change in bal- ance during the entire period of the journal. Balance changes are cal- - culated by adding up the postings in each account. You can limit the - postings matched, by a query, to see fewer accounts, changes over a + culated by adding up the postings in each account. You can limit the + postings matched, by a query, to see fewer accounts, changes over a different time period, changes from only cleared transactions, etc. If you include an account's complete history of postings in the report, - the balance change is equivalent to the account's current ending bal- - ance. For a real-world account, typically you won't have all transac- + the balance change is equivalent to the account's current ending bal- + ance. For a real-world account, typically you won't have all transac- tions in the journal; instead you'll have all transactions after a cer- - tain date, and an "opening balances" transaction setting the correct - starting balance on that date. Then the balance command will show + tain date, and an "opening balances" transaction setting the correct + starting balance on that date. Then the balance command will show real-world account balances. In some cases the -H/--historical flag is used to ensure this (more below). @@ -1664,9 +1685,29 @@ COMMANDS The balance command can produce several styles of report: - Classic balance report - This is the original balance report, as found in Ledger. It usually - looks like this: + Single-period flat balance report + This is the default for hledger's balance command: a flat list of all + (or with a query, matched) accounts, showing full account names. Ac- + counts are sorted by declaration order if any, and then by account + name. Accounts which have zero balance are not shown unless -E/--empty + is used. The reported balances' total is shown as the last line, un- + less disabled by -N/--no-total. + + $ hledger bal + $1 assets:bank:saving + $-2 assets:cash + $1 expenses:food + $1 expenses:supplies + $-1 income:gifts + $-1 income:salary + $1 liabilities:debts + -------------------- + 0 + + Single-period tree-mode balance report + With the -t/--tree flag, accounts are displayed hierarchically, showing + subaccounts as short names indented below their parent. (This is the + default style in Ledger and in older hledger versions.) $ hledger balance $-1 assets @@ -1682,32 +1723,25 @@ COMMANDS -------------------- 0 - By default, accounts are displayed hierarchically, with subaccounts in- - dented below their parent, with accounts at each level of the tree - sorted by declaration order if declared, then by account name. + For more compact output, "boring" accounts containing a single inter- + esting subaccount and no balance of their own (assets:bank and liabili- + ties here) are elided into the following line, unless --no-elide is + used. And accounts which have zero balance and no non-zero subaccounts + are omitted, unless -E/--empty is used. - "Boring" accounts, which contain a single interesting subaccount and no - balance of their own, are elided into the following line for more com- - pact output. (Eg above, the "liabilities" account.) Use --no-elide to - prevent this. + Account balances in tree mode are "inclusive" - they include the bal- + ances of any subaccounts. Eg, the assets $-1 balance here includes the + $1 from assets:bank:saving and the $-2 from assets:cash. (And it would + include balance posted to the assets account itself, if there was any). + Note this causes some repetition, and the final total (0) is the sum of + the top-level balances, not of all the balances shown. - Account balances are "inclusive" - they include the balances of any - subaccounts. + Each group of sibling accounts is sorted separately, by declaration or- + der and then by account name. - Accounts which have zero balance (and no non-zero subaccounts) are - omitted. Use -E/--empty to show them. - - A final total is displayed by default; use -N/--no-total to suppress - it, eg: - - $ hledger balance -p 2008/6 expenses --no-total - $2 expenses - $1 food - $1 supplies - - Customising the classic balance report - You can customise the layout of classic balance reports with --format - FMT: + Customising single-period balance reports + You can customise the layout of single-period balance reports with + --format FMT, which sets the format of each line. Eg: $ hledger balance --format "%20(account) %12(total)" assets $-1 @@ -1724,7 +1758,7 @@ COMMANDS 0 The FMT format string (plus a newline) specifies the formatting applied - to each account/balance pair. It may contain any suitable text, with + to each account/balance pair. It may contain any suitable text, with data fields interpolated like so: %[MIN][.MAX](FIELDNAME) @@ -1735,14 +1769,14 @@ 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) @@ -1759,35 +1793,21 @@ COMMANDS 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 - Colour support - In terminal output, when colour is enabled, the balance command shows - negative amounts in red. - - Flat mode - To see a flat list instead of the default hierarchical display, use - --flat. In this mode, accounts (unless depth-clipped) show their full - names and "exclusive" balance, excluding any subaccount balances. In - this mode, you can also use --drop N to omit the first few account name - components. - - $ hledger balance -p 2008/6 expenses -N --flat --drop 1 - $1 food - $1 supplies - - Depth limited balance reports - With --depth N or depth:N or just -N, balance reports show accounts - only to the specified numeric depth. This is very useful to summarise - a complex set of accounts and get an overview. + Depth limiting + With a depth:N query, or --depth N option, or just -N, balance reports + will show accounts only to the specified depth. This is very useful to + hide low-level accounts and get an overview. Eg, limiting to depth 1 + shows the top-level accounts: $ hledger balance -N -1 $-1 assets @@ -1795,35 +1815,17 @@ COMMANDS $-2 income $1 liabilities - Flat-mode balance reports, which normally show exclusive balances, show - inclusive balances at the depth limit. + Accounts at the depth limit will include the balances of any hidden + subaccounts (even in flat mode, which normally shows exclusive bal- + ances). - Percentages - With -% or --percent, balance reports show each account's value ex- - pressed as a percentage of the column's total. This is useful to get - an overview of the relative sizes of account balances. For example to - obtain an overview of expenses: + You can also drop account name components from the start of account + names, using --drop N. This can be useful to hide unwanted top-level + detail. - $ hledger balance expenses -% - 100.0 % expenses - 50.0 % food - 50.0 % supplies - -------------------- - 100.0 % - - Note that --tree does not have an effect on -%. The percentages are - always relative to the total sum of each column, they are never rela- - tive to the parent account. - - Since the percentages are relative to the columns sum, it is usually - not useful to calculate percentages if the signs of the amounts are - mixed. Although the results are technically correct, they are most - likely useless. Especially in a balance report that sums up to zero - (eg hledger balance -B) all percentage values will be zero. - - This flag does not work if the report contains any mixed commodity ac- - counts. If there are mixed commodity accounts in the report be sure to - use -V or -B to coerce the report into using a single commodity. + Colour support + In terminal output, when colour is enabled, the balance command shows + negative amounts in red. Sorting by amount With -S/--sort-amount, accounts with the largest (most positive) bal- @@ -1836,35 +1838,63 @@ COMMANDS balancesheet or incomestatement, which also support -S. Eg: hledger is -MAS. - Multicolumn balance report - Multicolumn or tabular balance reports are a very useful hledger fea- - ture, and usually the preferred style. They share many of the above - features, but they show the report as a table, with columns represent- - ing time periods. This mode is activated by providing a reporting in- - terval. + Percentages + With -% or --percent, balance reports show each account's value ex- + pressed as a percentage of the column's total. This is useful to get + an overview of the relative sizes of account balances. For example to + obtain an overview of expenses: - There are three types of multicolumn balance report, showing different + $ hledger balance expenses -% + 100.0 % expenses + 50.0 % food + 50.0 % supplies + -------------------- + 100.0 % + + Note that --tree does not have an effect on -%. The percentages are + always relative to the total sum of each column, they are never rela- + tive to the parent account. + + Since the percentages are relative to the columns sum, it is usually + not useful to calculate percentages if the signs of the amounts are + mixed. Although the results are technically correct, they are most + likely useless. Especially in a balance report that sums up to zero + (eg hledger balance -B) all percentage values will be zero. + + This flag does not work if the report contains any mixed commodity ac- + counts. If there are mixed commodity accounts in the report be sure to + use -V or -B to coerce the report into using a single commodity. + + Multi-period balance report + Multi-period balance reports are a very useful hledger feature, acti- + vated if you provide one of the reporting interval flags, such as + -M/--monthly. They are similar to single-period balance reports, but + they show the report as a table, with columns representing one or more + successive time periods. This is the usually the preferred style of + balance report in hledger (even for a single period). + + Multi-period balance reports come in several types, showing different information: - 1. By default: each column shows the sum of postings in that period, ie - the account's change of balance in that period. This is useful eg - for a monthly income statement: + 1. A balance change report: by default, each column shows the sum of + postings in that period, ie the account's change of balance in that + period. This is useful eg for a monthly income statement: - $ hledger balance --quarterly income expenses -E - Balance changes in 2008: + $ hledger balance --quarterly income expenses -E + Balance changes in 2008: - || 2008q1 2008q2 2008q3 2008q4 - ===================++================================= - expenses:food || 0 $1 0 0 - expenses:supplies || 0 $1 0 0 - income:gifts || 0 $-1 0 0 - income:salary || $-1 0 0 0 - -------------------++--------------------------------- - || $-1 $1 0 0 + || 2008q1 2008q2 2008q3 2008q4 + ===================++================================= + expenses:food || 0 $1 0 0 + expenses:supplies || 0 $1 0 0 + income:gifts || 0 $-1 0 0 + income:salary || $-1 0 0 0 + -------------------++--------------------------------- + || $-1 $1 0 0 - 2. With --cumulative: each column shows the ending balance for that pe- - riod, accumulating the changes across periods, starting from 0 at - the report start date: + 2. A cumulative end balance report: with --cumulative, each column + shows the end balance for that period, accumulating the changes + across periods, starting from 0 at the report start date: $ hledger balance --quarterly income expenses -E --cumulative Ending balances (cumulative) in 2008: @@ -1878,11 +1908,12 @@ COMMANDS -------------------++------------------------------------------------- || $-1 0 0 0 - 3. With --historical/-H: each column shows the actual historical ending - balance for that period, accumulating the changes across periods, - starting from the actual balance at the report start date. This is - useful eg for a multi-period balance sheet, and when you are showing - only the data after a certain start date: + 3. A historical end balance report: with --historical/-H, each column + shows the actual historical end balance for that period, accumulat- + ing the changes across periods, and including the balance from any + postings before the report start date. This is useful eg for a + multi-period balance sheet, and when you want to see balances only + after a certain date: $ hledger balance ^assets ^liabilities --quarterly --historical --begin 2008/4/1 Ending balances (historical) in 2008/04/01-2008/12/31: @@ -1899,9 +1930,6 @@ COMMANDS Note that --cumulative or --historical/-H disable --row-total/-T, since summing end balances generally does not make sense. - Multicolumn balance reports display accounts in flat mode by default; - to see the hierarchy, use --tree. - With a reporting interval (like --quarterly above), the report start/end dates will be adjusted if necessary so that they encompass the displayed report periods. This is so that the first and last peri- @@ -2323,21 +2351,25 @@ COMMANDS check check - Check for various kinds of errors in your data. experimental + Check for various kinds of errors in your data. hledger provides a number of built-in error checks to help prevent problems in your data. Some of these are run automatically; or, you can use this check command to run them on demand, with no output and a - zero exit code if all is well. Some examples: + zero exit code if all is well. Specify their names (or a prefix) as + argument(s). + + Some examples: hledger check # basic checks hledger check -s # basic + strict checks - hledger check ordereddates uniqueleafnames # basic + specified checks + hledger check ordereddates payees # basic + two other checks Here are the checks currently available: Basic checks - These are always run by this command and other commands: + These checks are always run automatically, by (almost) all hledger com- + mands, including check: o parseable - data files are well-formed and can be successfully parsed @@ -2349,97 +2381,100 @@ COMMANDS (This check can be disabled with -I/--ignore-assertions.) Strict checks - These are always run by this and other commands when -s/--strict is - used (strict mode): + These additional checks are run when the -s/--strict (strict mode) flag + is used. Or, they can be run by giving their names as arguments to + check: o accounts - all account names used by transactions have been declared o commodities - all commodity symbols used have been declared Other checks - These checks can be run by specifying their names as arguments to the - check command: + These checks can be run only by giving their names as arguments to + check. They are more specialised and not desirable for everyone, + therefore optional: o ordereddates - transactions are ordered by date (similar to the old check-dates command) + o payees - all payees used by transactions have been declared + o uniqueleafnames - all account leaf names are unique (similar to the - old check-dupes command) + old check-dupes command). - Add-on checks - Some checks are not yet integrated with this command, but are available - as add-on commands in https://github.com/simonmichael/hledger/tree/mas- - ter/bin: + Custom checks + A few more checks are are available as separate add-on commands, in + https://github.com/simonmichael/hledger/tree/master/bin: - o hledger-check-tagfiles - all tag values containing / (a forward + o hledger-check-tagfiles - all tag values containing / (a forward slash) exist as file paths - o hledger-check-fancyassertions - more complex balance assertions are + o hledger-check-fancyassertions - more complex balance assertions are passing - You could make your own similar scripts to perform custom checks; Cook- - book -> Scripting may be helpful. + You could make similar scripts to perform your own custom checks. See: + Cookbook -> Scripting. close close, equity - Prints a "closing balances" transaction and an "opening balances" + Prints a "closing balances" transaction and an "opening balances" transaction that bring account balances to and from zero, respectively. These can be added to your journal file(s), eg to bring asset/liability - balances forward into a new journal file, or to close out revenues/ex- + balances forward into a new journal file, or to close out revenues/ex- penses to retained earnings at the end of a period. - You can print just one of these transactions by using the --close or - --open flag. You can customise their descriptions with the --close- + You can print just one of these transactions by using the --close or + --open flag. You can customise their descriptions with the --close- desc and --open-desc options. One amountless posting to "equity:opening/closing balances" is added to - balance the transactions, by default. You can customise this account - name with --close-acct and --open-acct; if you specify only one of + balance the transactions, by default. You can customise this account + name with --close-acct and --open-acct; if you specify only one of these, it will be used for both. With --x/--explicit, the equity posting's amount will be shown. And if - it involves multiple commodities, a posting for each commodity will be + it involves multiple commodities, a posting for each commodity will be shown, as with the print command. - With --interleaved, the equity postings are shown next to the postings + With --interleaved, the equity postings are shown next to the postings they balance, which makes troubleshooting easier. By default, transaction prices in the journal are ignored when generat- ing the closing/opening transactions. With --show-costs, this cost in- - formation is preserved (balance -B reports will be unchanged after the - transition). Separate postings are generated for each cost in each - commodity. Note this can generate very large journal entries, if you + formation is preserved (balance -B reports will be unchanged after the + transition). Separate postings are generated for each cost in each + commodity. Note this can generate very large journal entries, if you have many foreign currency or investment transactions. close usage If you split your journal files by time (eg yearly), you will typically - run this command at the end of the year, and save the closing transac- - tion as last entry of the old file, and the opening transaction as the - first entry of the new file. This makes the files self contained, so - that correct balances are reported no matter which of them are loaded. - Ie, if you load just one file, the balances are initialised correctly; - or if you load several files, the redundant closing/opening transac- - tions cancel each other out. (They will show up in print or register - reports; you can exclude them with a query like not:desc:'(open- + run this command at the end of the year, and save the closing transac- + tion as last entry of the old file, and the opening transaction as the + first entry of the new file. This makes the files self contained, so + that correct balances are reported no matter which of them are loaded. + Ie, if you load just one file, the balances are initialised correctly; + or if you load several files, the redundant closing/opening transac- + tions cancel each other out. (They will show up in print or register + reports; you can exclude them with a query like not:desc:'(open- ing|closing) balances'.) If you're running a business, you might also use this command to "close - the books" at the end of an accounting period, transferring income - statement account balances to retained earnings. (You may want to + the books" at the end of an accounting period, transferring income + statement account balances to retained earnings. (You may want to change the equity account name to something like "equity:retained earn- ings".) - By default, the closing transaction is dated yesterday, the balances - are calculated as of end of yesterday, and the opening transaction is - dated today. To close on some other date, use: hledger close -e OPEN- - INGDATE. Eg, to close/open on the 2018/2019 boundary, use -e 2019. + By default, the closing transaction is dated yesterday, the balances + are calculated as of end of yesterday, and the opening transaction is + dated today. To close on some other date, use: hledger close -e OPEN- + INGDATE. Eg, to close/open on the 2018/2019 boundary, use -e 2019. You can also use -p or date:PERIOD (any starting date is ignored). - Both transactions will include balance assertions for the closed/re- + Both transactions will include balance assertions for the closed/re- opened accounts. You probably shouldn't use status or realness filters - (like -C or -R or status:) with this command, or the generated balance - assertions will depend on these flags. Likewise, if you run this com- - mand with --auto, the balance assertions will probably always require + (like -C or -R or status:) with this command, or the generated balance + assertions will depend on these flags. Likewise, if you run this com- + mand with --auto, the balance assertions will probably always require --auto. Examples: @@ -2480,13 +2515,13 @@ COMMANDS codes List the codes seen in transactions, in the order parsed. - This command prints the value of each transaction's code field, in the - order transactions were parsed. The transaction code is an optional - value written in parentheses between the date and description, often + This command prints the value of each transaction's code field, in the + order transactions were parsed. The transaction code is an optional + value written in parentheses between the date and description, often used to store a cheque number, order number or similar. Transactions aren't required to have a code, and missing or empty codes - will not be shown by default. With the -E/--empty flag, they will be + will not be shown by default. With the -E/--empty flag, they will be printed as blank lines. You can add a query to select a subset of transactions. @@ -2526,7 +2561,7 @@ COMMANDS List the unique descriptions that appear in transactions. This command lists the unique descriptions that appear in transactions, - in alphabetic order. You can add a query to select a subset of trans- + in alphabetic order. You can add a query to select a subset of trans- actions. Example: @@ -2538,18 +2573,18 @@ COMMANDS diff diff - Compares a particular account's transactions in two input files. It + Compares a particular account's transactions in two input files. It shows any transactions to this account which are in one file but not in the other. More precisely, for each posting affecting this account in either file, - it looks for a corresponding posting in the other file which posts the - same amount to the same account (ignoring date, description, etc.) + it looks for a corresponding posting in the other file which posts the + same amount to the same account (ignoring date, description, etc.) Since postings not transactions are compared, this also works when mul- tiple bank transactions have been combined into a single journal entry. This is useful eg if you have downloaded an account's transactions from - your bank (eg as CSV data). When hledger and your bank disagree about + your bank (eg as CSV data). When hledger and your bank disagree about the account balance, you can compare the bank data with your journal to find out the cause. @@ -2567,18 +2602,18 @@ COMMANDS files 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. help help - Show the hledger user manual in one of several formats, optionally po- - sitioned at a given TOPIC (if possible). TOPIC is any heading, or - heading prefix, in the manual. Some examples: commands, print, 'auto + Show the hledger user manual in one of several formats, optionally po- + sitioned at a given TOPIC (if possible). TOPIC is any heading, or + heading prefix, in the manual. Some examples: commands, print, 'auto postings', periodic. - This command shows the user manual built in to this hledger version. - It can be useful if the correct version of the hledger manual, or the + This command shows the user manual built in to this hledger version. + It can be useful if the correct version of the hledger manual, or the usual viewing tools, are not installed on your system. By default it uses the best viewer it can find in $PATH, in this order: @@ -2588,9 +2623,9 @@ COMMANDS import import - Read new transactions added to each FILE since last run, and add them - to the main journal file. Or with --dry-run, just print the transac- - tions that would be added. Or with --catchup, just mark all of the + Read new transactions added to each FILE since last run, and add them + to the main journal file. Or with --dry-run, just print the transac- + tions that would be added. Or with --catchup, just mark all of the FILEs' transactions as imported, without actually importing any. The input files are specified as arguments - no need to write -f before @@ -2601,23 +2636,23 @@ COMMANDS ing transactions are always added to the input files in increasing date order, and by saving .latest.FILE state files. - The --dry-run output is in journal format, so you can filter it, eg to + The --dry-run output is in journal format, so you can filter it, eg to see only uncategorised transactions: $ hledger import --dry ... | hledger -f- print unknown --ignore-assertions Importing balance assignments - Entries added by import will have their posting amounts made explicit - (like hledger print -x). This means that any balance assignments in - imported files must be evaluated; but, imported files don't get to see - the main file's account balances. As a result, importing entries with + Entries added by import will have their posting amounts made explicit + (like hledger print -x). This means that any balance assignments in + imported files must be evaluated; but, imported files don't get to see + the main file's account balances. As a result, importing entries with balance assignments (eg from an institution that provides only balances - and not posting amounts) will probably generate incorrect posting + and not posting amounts) will probably generate incorrect posting amounts. To avoid this problem, use print instead of import: $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE - (If you think import should leave amounts implicit like print does, + (If you think import should leave amounts implicit like print does, please test it and send a pull request.) Commodity display styles @@ -2626,16 +2661,16 @@ COMMANDS incomestatement incomestatement, is - 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. Amounts are shown with normal posi- tive sign, as in conventional financial statements. The revenue and expense accounts shown are those accounts declared with - the Revenue or Expense type, or otherwise all accounts under a top- - level revenue or income or expense account (case insensitive, plurals + the Revenue or Expense type, or otherwise all accounts under a top- + level revenue or income or expense account (case insensitive, plurals allowed). - (This report is essentially similar to "hledger balance --change rev- + (This report is essentially similar to "hledger balance --change rev- enues expenses", with revenues sign-flipped.) Example: @@ -2662,13 +2697,13 @@ COMMANDS 0 With a reporting interval, multiple columns will be shown, one for each - report period. Normally incomestatement shows revenues/expenses per - period, though as with multicolumn balance reports you can alter the - report mode with --change/--cumulative/--historical. Instead of abso- + report period. Normally incomestatement shows revenues/expenses per + period, though as with multicolumn balance reports you can alter the + report mode with --change/--cumulative/--historical. Instead of abso- lute values percentages can be displayed with -%. This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, html, and (experimen- + tions The output formats supported are txt, csv, html, and (experimen- tal) json. notes @@ -2676,8 +2711,8 @@ COMMANDS List the unique notes that appear in transactions. This command lists the unique notes that appear in transactions, in al- - phabetic order. You can add a query to select a subset of transac- - tions. The note is the part of the transaction description after a | + phabetic order. You can add a query to select a subset of transac- + tions. The note is the part of the transaction description after a | character (or if there is no |, the whole description). Example: @@ -2691,8 +2726,8 @@ COMMANDS List the unique payee/payer names that appear in transactions. This command lists the unique payee/payer names that appear in transac- - tions, in alphabetic order. You can add a query to select a subset of - transactions. The payee/payer is the part of the transaction descrip- + tions, in alphabetic order. You can add a query to select a subset of + transactions. The payee/payer is the part of the transaction descrip- tion before a | character (or if there is no |, the whole description). Example: @@ -2704,10 +2739,10 @@ COMMANDS prices prices - Print market price directives from the journal. With --costs, also - print synthetic market prices based on transaction prices. With --in- - verted-costs, also print inverse prices based on transaction prices. - Prices (and postings providing prices) can be filtered by a query. + Print market price directives from the journal. With --costs, also + print synthetic market prices based on transaction prices. With --in- + verted-costs, also print inverse prices based on transaction prices. + Prices (and postings providing prices) can be filtered by a query. Price amounts are always displayed with their full precision. print @@ -2715,9 +2750,9 @@ COMMANDS Show transaction journal entries, sorted by date. The print command displays full journal entries (transactions) from the - journal file, sorted by date (or with --date2, by secondary date). + journal file, sorted by date (or with --date2, by secondary date). Amounts are shown right-aligned within each transaction (but not across - all transactions). Directives and inter-transaction comments are not + all transactions). Directives and inter-transaction comments are not shown. Eg: $ hledger print @@ -2742,7 +2777,7 @@ COMMANDS liabilities:debts $1 assets:bank:checking $-1 - print's output is usually a valid hledger journal, and you can process + print's output is usually a valid hledger journal, and you can process it again with a second hledger command. This can be useful for certain kinds of search, eg: @@ -2752,53 +2787,53 @@ COMMANDS There are some situations where print's output can become unparseable: - o Rounding amounts according to commodity display styles can cause + o Rounding amounts according to commodity display styles can cause transactions to appear unbalanced. - o Valuation affects posting amounts but not balance assertion or bal- + o Valuation affects posting amounts but not balance assertion or bal- ance assignment amounts, potentially causing those to fail. o Auto postings can generate postings with too many missing amounts. Normally, the journal entry's explicit or implicit amount style is pre- served. For example, when an amount is omitted in the journal, it will - not appear in the output. Similarly, when a transaction price is im- - plied but not written, it will not appear in the output. You can use - the -x/--explicit flag to make all amounts and transaction prices ex- - plicit, which can be useful for troubleshooting or for making your + not appear in the output. Similarly, when a transaction price is im- + plied but not written, it will not appear in the output. You can use + the -x/--explicit flag to make all amounts and transaction prices ex- + plicit, which can be useful for troubleshooting or for making your journal more readable and robust against data entry errors. -x is also implied by using any of -B,-V,-X,--value. - Note, -x/--explicit will cause postings with a multi-commodity amount - (these can arise when a multi-commodity transaction has an implicit - amount) to be split into multiple single-commodity postings, keeping + Note, -x/--explicit will cause postings with a multi-commodity amount + (these can arise when a multi-commodity transaction has an implicit + amount) to be split into multiple single-commodity postings, keeping the output parseable. - With -B/--cost, amounts with transaction prices are converted to cost + With -B/--cost, amounts with transaction prices are converted to cost using that price. This can be used for troubleshooting. - With -m/--match and a STR argument, print will show at most one trans- - action: the one one whose description is most similar to STR, and is - most recent. STR should contain at least two characters. If there is + With -m/--match and a STR argument, print will show at most one trans- + action: the one one whose description is most similar to STR, and is + most recent. STR should contain at least two characters. If there is no similar-enough match, no transaction will be shown. With --new, for each FILE being read, hledger reads (and writes) a spe- - cial state file (.latest.FILE in the same directory), containing the - latest transaction date(s) that were seen last time FILE was read. - When this file is found, only transactions with newer dates (and new - transactions on the latest date) are printed. This is useful for ig- - noring already-seen entries in import data, such as downloaded CSV + cial state file (.latest.FILE in the same directory), containing the + latest transaction date(s) that were seen last time FILE was read. + When this file is found, only transactions with newer dates (and new + transactions on the latest date) are printed. This is useful for ig- + noring already-seen entries in import data, such as downloaded CSV files. Eg: $ hledger -f bank1.csv print --new (shows transactions added since last print --new on this file) - This assumes that transactions added to FILE always have same or in- - creasing dates, and that transactions on the same day do not get re- + This assumes that transactions added to FILE always have same or in- + creasing dates, and that transactions on the same day do not get re- ordered. See also the import command. This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, and (experimental) + tions The output formats supported are txt, csv, and (experimental) json and sql. Here's an example of print's CSV output: @@ -2817,20 +2852,20 @@ 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.) print-unique @@ -2854,14 +2889,14 @@ COMMANDS Show postings and their running total. The register command displays matched postings, across all accounts, in - date order, with their running total or running historical balance. - (See also the aregister command, which shows matched transactions in a + date order, with their running total or running historical balance. + (See also the aregister command, which shows matched transactions in a specific account.) register normally shows line per posting, but note that multi-commodity amounts will occupy multiple lines (one line per commodity). - It is typically used with a query selecting a particular account, to + It is typically used with a query selecting a particular account, to see that account's activity: $ hledger register checking @@ -2872,8 +2907,8 @@ COMMANDS With --date2, it shows and sorts by secondary date instead. - 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 @@ -2883,18 +2918,18 @@ 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: $ hledger register --related --invert assets:checking @@ -2906,7 +2941,7 @@ 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 @@ -2923,7 +2958,7 @@ 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 @@ -2931,17 +2966,17 @@ 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. Custom register output - register uses the full terminal width by default, except on windows. - You can override this by setting the COLUMNS environment variable (not + register uses the full terminal width by default, except on windows. + You can override this by setting the COLUMNS environment variable (not a bash shell variable) or by using the --width/-w option. - The description and account columns normally share the space equally + 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): @@ -2960,27 +2995,27 @@ COMMANDS $ hledger reg -w $COLUMNS,40 # use terminal width, & description width 40 This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, and (experimental) + tions The output formats supported are txt, csv, and (experimental) json. register-match register-match Print the one posting whose transaction description is closest to DESC, - in the style of the register command. If there are multiple equally - good matches, it shows the most recent. Query options (options, not - arguments) can be used to restrict the search space. Helps ledger-au- + in the style of the register command. If there are multiple equally + good matches, it shows the most recent. Query options (options, not + arguments) can be used to restrict the search space. Helps ledger-au- tosync detect already-seen transactions when importing. rewrite rewrite Print all transactions, rewriting the postings of matched transactions. - For now the only rewrite available is adding new postings, like print + For now the only rewrite available is adding new postings, like print --auto. This is a start at a generic rewriter of transaction entries. It reads - the default journal and prints the transactions, like print, but adds + the default journal and prints the transactions, like print, but adds one or more specified postings to any transactions matching QUERY. The - posting amounts can be fixed, or a multiplier of the existing transac- + posting amounts can be fixed, or a multiplier of the existing transac- tion's first posting amount. Examples: @@ -2996,7 +3031,7 @@ 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: @@ -3006,16 +3041,16 @@ 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. @@ -3030,7 +3065,7 @@ 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. @@ -3043,12 +3078,12 @@ 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' @@ -3072,10 +3107,10 @@ 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: @@ -3083,49 +3118,49 @@ COMMANDS https://github.com/simonmichael/hledger/issues/99 rewrite vs. print --auto - This command predates print --auto, and currently does much the same + This command predates print --auto, and currently does much the same thing, but with these differences: - o with multiple files, rewrite lets rules in any file affect all other - files. print --auto uses standard directive scoping; rules affect + o with multiple files, rewrite lets rules in any file affect all other + files. print --auto uses standard directive scoping; rules affect only child files. - o rewrite's query limits which transactions can be rewritten; all are + o rewrite's query limits which transactions can be rewritten; all are printed. print --auto's query limits which transactions are printed. - o rewrite applies rules specified on command line or in the journal. + o rewrite applies rules specified on command line or in the journal. print --auto applies rules specified in the journal. roi 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. - This command assumes that you have account(s) that hold nothing but + This command assumes that you have account(s) that hold nothing but your investments and whenever you record current appraisal/valuation of these investments you offset unrealized profit and loss into account(s) that, again, hold nothing but unrealized profit and loss. - Any transactions affecting balance of investment account(s) and not - originating from unrealized profit and loss account(s) are assumed to + Any transactions affecting balance of investment account(s) and not + originating from unrealized profit and loss account(s) are assumed to be your investments or withdrawals. - At a minimum, you need to supply a query (which could be just an ac- + At a minimum, you need to supply a query (which could be just an ac- count name) to select your investments with --inv, and another query to identify your profit and loss transactions with --pnl. - This command will compute and display the internalized rate of return - (IRR) and time-weighted rate of return (TWR) for your investments for - the time period requested. Both rates of return are annualized before + This command will compute and display the internalized rate of return + (IRR) and time-weighted rate of return (TWR) for your investments for + the time period requested. Both rates of return are annualized before display, regardless of the length of reporting interval. 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. @@ -3136,67 +3171,67 @@ COMMANDS More background: - "ROI" stands for "return on investment". Traditionally this was com- - puted as a difference between current value of investment and its ini- + "ROI" stands for "return on investment". Traditionally this was com- + puted as a difference between current value of investment and its ini- tial value, expressed in percentage of the initial value. However, this approach is only practical in simple cases, where invest- - ments receives no in-flows or out-flows of money, and where rate of + ments receives no in-flows or out-flows of money, and where rate of growth is fixed over time. For more complex scenarios you need differ- - ent ways to compute rate of return, and this command implements two of + ent ways to compute rate of return, and this command implements two of them: IRR and TWR. - Internal rate of return, or "IRR" (also called "money-weighted rate of - return") takes into account effects of in-flows and out-flows. + Internal rate of return, or "IRR" (also called "money-weighted rate of + return") takes into account effects of in-flows and out-flows. Naively, if you are withdrawing from your investment, your future gains - would be smaller (in absolute numbers), and will be a smaller percent- - age of your initial investment, and if you are adding to your invest- - ment, you will receive bigger absolute gains (but probably at the same - rate of return). IRR is a way to compute rate of return for each pe- - riod between in-flow or out-flow of money, and then combine them in a + would be smaller (in absolute numbers), and will be a smaller percent- + age of your initial investment, and if you are adding to your invest- + ment, you will receive bigger absolute gains (but probably at the same + rate of return). IRR is a way to compute rate of return for each pe- + riod between in-flow or out-flow of money, and then combine them in a way that gives you an annual rate of return that investment is expected to generate. - 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 - transactions that involve account(s) matching --inv argument and NOT + 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 + transactions that involve account(s) matching --inv argument and NOT involve account(s) matching --pnl argument. - Presumably, you will also record changes in the value of your invest- - ment, and balance them against "profit and loss" (or "unrealized + Presumably, you will also record changes in the value of your invest- + ment, and balance them against "profit and loss" (or "unrealized gains") account. Note that in order for IRR to compute the precise ef- - fect 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 + fect 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. - Implementation of IRR in hledger should match the XIRR formula in Ex- + Implementation of IRR in hledger should match the XIRR formula in Ex- cel. - Second way to compute rate of return that roi command implements is + Second way to compute rate of return that roi command implements is called "time-weighted rate of return" or "TWR". Like IRR, it will also - break the history of your investment into periods between in-flows and + break the history of your investment into periods between in-flows and out-flows to compute rate of return per each period and then a compound rate of return. However, internal workings of TWR are quite different. - 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. - TWR represents your investment as an imaginary "unit fund" where in- - flows/ out-flows lead to buying or selling "units" of your investment + TWR represents your investment as an imaginary "unit fund" where in- + flows/ out-flows lead to buying or selling "units" of your investment and changes in its value change the value of "investment unit". Change - in "unit price" over the reporting period gives you rate of return of + in "unit price" over the reporting period gives you rate of return of your investment. - References: * Explanation of rate of return * Explanation of IRR * Ex- - planation of TWR * Examples of computing IRR and TWR and discussion of + References: * Explanation of rate of return * Explanation of IRR * Ex- + planation of TWR * Examples of computing IRR and TWR and discussion of the limitations of both metrics More examples: - Lets say that we found an investment in Snake Oil that is proising to + Lets say that we found an investment in Snake Oil that is proising to give us 10% annually: 2019-01-01 Investing in Snake Oil @@ -3207,7 +3242,7 @@ COMMANDS investment:snake oil = $110 equity:unrealized gains - For now, basic computation of the rate of return, as well as IRR and + For now, basic computation of the rate of return, as well as IRR and TWR, gives us the expected 10%: $ hledger roi -Y --inv investment --pnl "unrealized" @@ -3217,10 +3252,10 @@ COMMANDS | 1 || 2019-01-01 | 2019-12-31 || 0 | 100 | 110 | 10 || 10.00% | 10.00% | +---++------------+------------++---------------+----------+-------------+-----++--------+--------+ - However, lets say that shorty after investing in the Snake Oil we - started to have second thoughs, so we prompty withdrew $90, leaving - only $10 in. Before Christmas, though, we started to get the "fear of - mission out", so we put the $90 back in. So for most of the year, our + However, lets say that shorty after investing in the Snake Oil we + started to have second thoughs, so we prompty withdrew $90, leaving + only $10 in. Before Christmas, though, we started to get the "fear of + mission out", so we put the $90 back in. So for most of the year, our investment was just $10 dollars, and it gave us just $1 in growth: 2019-01-01 Investing in Snake Oil @@ -3251,10 +3286,10 @@ COMMANDS Here, IRR tells us that we made close to 10% on the $10 dollars that we had in the account most of the time. And TWR is ... just 1%? Why? - Based on the transactions in our journal, TWR "think" that we are buy- - ing back $90 worst of Snake Oil at the same price that it had at the + Based on the transactions in our journal, TWR "think" that we are buy- + ing back $90 worst of Snake Oil at the same price that it had at the beginning of they year, and then after that our $100 investment gets $1 - increase in value, or 1% of $100. Let's take a closer look at what is + increase in value, or 1% of $100. Let's take a closer look at what is happening here by asking for quarterly reports instead of annual: $ hledger roi -Q --inv investment --pnl "unrealized" @@ -3267,10 +3302,10 @@ COMMANDS | 4 || 2019-10-01 | 2019-12-31 || 10 | 90 | 101 | 1 || 37.80% | 4.03% | +---++------------+------------++---------------+----------+-------------+-----++--------+-------+ - Now both IRR and TWR are thrown off by the fact that all of the growth - for our investment happens in Q4 2019. This happes because IRR compu- + Now both IRR and TWR are thrown off by the fact that all of the growth + for our investment happens in Q4 2019. This happes because IRR compu- tation is still yielding 9.32% and TWR is still 1%, but this time these - are rates for three month period instead of twelve, so in order to get + are rates for three month period instead of twelve, so in order to get an annual rate they should be multiplied by four! Let's try to keep a better record of how Snake Oil grew in value: @@ -3315,10 +3350,10 @@ COMMANDS | 4 || 2019-10-01 | 2019-12-31 || 10.75 | 90 | 101.00 | 0.25 || 8.05% | 1.00% | +---++------------+------------++---------------+----------+-------------+------++--------+--------+ - Something is still wrong with TWR computation for Q4, and if you have - been paying attention you know what it is already: big $90 buy-back is - recorded prior to the only transaction that captures the change of - value of Snake Oil that happened in this time period. Lets combine + Something is still wrong with TWR computation for Q4, and if you have + been paying attention you know what it is already: big $90 buy-back is + recorded prior to the only transaction that captures the change of + value of Snake Oil that happened in this time period. Lets combine transactions from 30th and 31st of Dec into one: 2019-12-30 Fear of missing out and growth of Snake Oil @@ -3339,7 +3374,7 @@ COMMANDS | 4 || 2019-10-01 | 2019-12-31 || 10.75 | 90 | 101.00 | 0.25 || 8.05% | 9.57% | +---++------------+------------++---------------+----------+-------------+------++--------+--------+ - And for annual report, TWR now reports the exact profitability of our + And for annual report, TWR now reports the exact profitability of our investment: $ hledger roi -Y --inv investment --pnl "unrealized" @@ -3353,8 +3388,8 @@ COMMANDS stats Show some journal statistics. - The stats command displays summary information for the whole journal, - or a matched part of it. With a reporting interval, it shows a report + The stats command displays summary information for the whole journal, + or a matched part of it. With a reporting interval, it shows a report for each report period. Example: @@ -3372,35 +3407,35 @@ COMMANDS Commodities : 1 ($) Market prices : 12 ($) - This command also supports output destination and output format selec- + This command also supports output destination and output format selec- tion. tags tags - List the unique tag names used in the journal. With a TAGREGEX argu- + List the unique tag names used in the journal. With a TAGREGEX argu- ment, only tag names matching the regular expression (case insensitive) - are shown. With QUERY arguments, only transactions matching the query + are shown. With QUERY arguments, only transactions matching the query are considered. With the --values flag, the tags' unique values are listed instead. - With --parsed flag, all tags or values are shown in the order they are + With --parsed flag, all tags or values are shown in the order they are parsed from the input data, including duplicates. - With -E/--empty, any blank/empty values will also be shown, otherwise + With -E/--empty, any blank/empty values will also be shown, otherwise they are omitted. test test Run built-in unit tests. - This command runs the unit tests built in to hledger and hledger-lib, - printing the results on stdout. If any test fails, the exit code will + This command runs the unit tests built in to hledger and hledger-lib, + printing the results on stdout. If any test fails, the exit code will be non-zero. - This is mainly used by hledger developers, but you can also use it to - sanity-check the installed hledger executable on your platform. All - tests are expected to pass - if you ever see a failure, please report + This is mainly used by hledger developers, but you can also use it to + sanity-check the installed hledger executable on your platform. All + tests are expected to pass - if you ever see a failure, please report as a bug! This command also accepts tasty test runner options, written after a -- @@ -3409,7 +3444,7 @@ COMMANDS $ hledger test -- -pData.Amount --color=never - For help on these, see https://github.com/feuerbach/tasty#options (-- + For help on these, see https://github.com/feuerbach/tasty#options (-- --help currently doesn't show them). About add-on commands @@ -3417,16 +3452,16 @@ COMMANDS o whose name starts with hledger- - o whose name ends with a recognised file extension: .bat,.com,.exe, + o whose name ends with a recognised file extension: .bat,.com,.exe, .hs,.lhs,.pl,.py,.rb,.rkt,.sh or none o and (on unix, mac) which are executable by the current user. - Add-ons are a relatively easy way to add local features or experiment - with new ideas. They can be written in any language, but haskell - scripts have a big advantage: they can use the same hledger library - functions that built-in commands use for command-line options, parsing - and reporting. Some experimental/example add-on scripts can be found + Add-ons are a relatively easy way to add local features or experiment + with new ideas. They can be written in any language, but haskell + scripts have a big advantage: they can use the same hledger library + functions that built-in commands use for command-line options, parsing + and reporting. Some experimental/example add-on scripts can be found in the hledger repo's bin/ directory. Note in a hledger command line, add-on command flags must have a double @@ -3451,16 +3486,16 @@ JOURNAL FORMAT hledger's default file format, representing a General Journal. hledger's usual data source is a plain text file containing journal en- - tries in hledger journal format. This file represents a standard ac- - counting general journal. I use file names ending in .journal, but + tries in hledger journal format. This file represents a standard ac- + counting general journal. I use file names ending in .journal, but that's not required. The journal file contains a number of transaction entries, each describing a transfer of money (or any commodity) between two or more named accounts, in a simple format readable by both hledger and humans. - hledger's journal format is a compatible subset, mostly, of ledger's - journal format, so hledger can work with compatible ledger journal - files as well. It's safe, and encouraged, to run both hledger and + hledger's journal format is a compatible subset, mostly, of ledger's + journal format, so hledger can work with compatible ledger journal + files as well. It's safe, and encouraged, to run both hledger and ledger on the same journal file, eg to validate the results you're get- ting. @@ -3468,24 +3503,24 @@ JOURNAL FORMAT the add or web or import commands to create and update it. Many users, though, edit the journal file with a text editor, and track - changes with a version control system such as git. Editor addons such - as ledger-mode or hledger-mode for Emacs, vim-ledger for Vim, and + changes with a version control system such as git. Editor addons such + as ledger-mode or hledger-mode for Emacs, vim-ledger for Vim, and hledger-vscode for Visual Studio Code, make this easier, adding colour, formatting, tab completion, and useful commands. See Editor configura- tion at hledger.org for the full list. - Here's a description of each part of the file format (and hledger's - data model). These are mostly in the order you'll use them, but in - some cases related concepts have been grouped together for easy refer- - ence, or linked before they are introduced, so feel free to skip over + Here's a description of each part of the file format (and hledger's + data model). These are mostly in the order you'll use them, but in + some cases related concepts have been grouped together for easy refer- + ence, or linked before they are introduced, so feel free to skip over anything that looks unnecessary right now. Transactions - Transactions are the main unit of information in a journal file. They - represent events, typically a movement of some quantity of commodities + Transactions are the main unit of information in a journal file. They + represent events, typically a movement of some quantity of commodities between two or more named accounts. - Each transaction is recorded as a journal entry, beginning with a sim- + Each transaction is recorded as a journal entry, beginning with a sim- ple date in column 0. This can be followed by any of the following op- tional fields, separated by spaces: @@ -3495,11 +3530,11 @@ JOURNAL FORMAT o a description (any remaining text until end of line or a semicolon) - o a comment (any remaining text following a semicolon until end of + o a comment (any remaining text following a semicolon until end of line, and any following indented lines beginning with a semicolon) o 0 or more indented posting lines, describing what was transferred and - the accounts involved (indented comment lines are also allowed, but + the accounts involved (indented comment lines are also allowed, but not blank lines or non-indented lines). Here's a simple journal file containing one transaction: @@ -3510,35 +3545,35 @@ JOURNAL FORMAT Dates Simple dates - Dates in the journal file use simple dates format: YYYY-MM-DD or + Dates in the journal file use simple dates format: YYYY-MM-DD or YYYY/MM/DD or YYYY.MM.DD, with leading zeros optional. The year may be - omitted, in which case it will be inferred from the context: the cur- - rent transaction, the default year set with a default year directive, - or the current date when the command is run. Some examples: + omitted, in which case it will be inferred from the context: the cur- + rent transaction, the default year set with a default year directive, + or the current date when the command is run. Some examples: 2010-01-31, 2010/01/31, 2010.1.31, 1/31. - (The UI also accepts simple dates, as well as the more flexible smart + (The UI also accepts simple dates, as well as the more flexible smart dates documented in the hledger manual.) Secondary dates - Real-life transactions sometimes involve more than one date - eg the + Real-life transactions sometimes involve more than one date - eg the date you write a cheque, and the date it clears in your bank. When you - want to model this, for more accurate daily balances, you can specify + want to model this, for more accurate daily balances, you can specify individual posting dates. - Or, you can use the older secondary date feature (Ledger calls it aux- - iliary date or effective date). Note: we support this for compatibil- - ity, but I usually recommend avoiding this feature; posting dates are + Or, you can use the older secondary date feature (Ledger calls it aux- + iliary date or effective date). Note: we support this for compatibil- + ity, but I usually recommend avoiding this feature; posting dates are almost always clearer and simpler. A secondary date is written after the primary date, following an equals - sign. If the year is omitted, the primary date's year is assumed. - When running reports, the primary (left) date is used by default, but - with the --date2 flag (or --aux-date or --effective), the secondary + sign. If the year is omitted, the primary date's year is assumed. + When running reports, the primary (left) date is used by default, but + with the --date2 flag (or --aux-date or --effective), the secondary (right) date will be used instead. - The meaning of secondary dates is up to you, but it's best to follow a - consistent rule. Eg "primary = the bank's clearing date, secondary = + The meaning of secondary dates is up to you, but it's best to follow a + consistent rule. Eg "primary = the bank's clearing date, secondary = date the transaction was initiated, if different", as shown here: 2010/2/23=2/19 movie ticket @@ -3552,11 +3587,11 @@ JOURNAL FORMAT 2010-02-19 movie ticket assets:checking $-10 $-10 Posting dates - You can give individual postings a different date from their parent - transaction, by adding a posting comment containing a tag (see below) + You can give individual postings a different date from their parent + transaction, by adding a posting comment containing a tag (see below) like date:DATE. This is probably the best way to control posting dates - precisely. Eg in this example the expense should appear in May re- - ports, and the deduction from checking should be reported on 6/1 for + precisely. Eg in this example the expense should appear in May re- + ports, and the deduction from checking should be reported on 6/1 for easy bank reconciliation: 2015/5/30 @@ -3569,22 +3604,22 @@ JOURNAL FORMAT $ hledger -f t.j register checking 2015-06-01 assets:checking $-10 $-10 - DATE should be a simple date; if the year is not specified it will use - the year of the transaction's date. You can set the secondary date - similarly, with date2:DATE2. The date: or date2: tags must have a - valid simple date value if they are present, eg a date: tag with no + DATE should be a simple date; if the year is not specified it will use + the year of the transaction's date. You can set the secondary date + similarly, with date2:DATE2. The date: or date2: tags must have a + valid simple date value if they are present, eg a date: tag with no value is not allowed. Ledger's earlier, more compact bracketed date syntax is also supported: - [DATE], [DATE=DATE2] or [=DATE2]. hledger will attempt to parse any + [DATE], [DATE=DATE2] or [=DATE2]. hledger will attempt to parse any square-bracketed sequence of the 0123456789/-.= characters in this way. - With this syntax, DATE infers its year from the transaction and DATE2 + With this syntax, DATE infers its year from the transaction and DATE2 infers its year from DATE. Status - Transactions, or individual postings within a transaction, can have a - status mark, which is a single character before the transaction de- - scription or posting account name, separated from it by a space, indi- + Transactions, or individual postings within a transaction, can have a + status mark, which is a single character before the transaction de- + scription or posting account name, separated from it by a space, indi- cating one of three statuses: mark status @@ -3593,23 +3628,23 @@ JOURNAL FORMAT ! pending * cleared - When reporting, you can filter by status with the -U/--unmarked, - -P/--pending, and -C/--cleared flags; or the status:, status:!, and + When reporting, you can filter by status with the -U/--unmarked, + -P/--pending, and -C/--cleared flags; or the status:, status:!, and status:* queries; or the U, P, C keys in hledger-ui. - Note, in Ledger and in older versions of hledger, the "unmarked" state - is called "uncleared". As of hledger 1.3 we have renamed it to un- + Note, in Ledger and in older versions of hledger, the "unmarked" state + is called "uncleared". As of hledger 1.3 we have renamed it to un- marked for clarity. - To replicate Ledger and old hledger's behaviour of also matching pend- + To replicate Ledger and old hledger's behaviour of also matching pend- ing, combine -U and -P. - Status marks are optional, but can be helpful eg for reconciling with + Status marks are optional, but can be helpful eg for reconciling with real-world accounts. Some editor modes provide highlighting and short- - cuts for working with status. Eg in Emacs ledger-mode, you can toggle + cuts for working with status. Eg in Emacs ledger-mode, you can toggle transaction status with C-c C-e, or posting status with C-c C-c. - What "uncleared", "pending", and "cleared" actually mean is up to you. + What "uncleared", "pending", and "cleared" actually mean is up to you. Here's one suggestion: status meaning @@ -3620,34 +3655,34 @@ JOURNAL FORMAT cleared complete, reconciled as far as possible, and considered cor- rect - With this scheme, you would use -PC to see the current balance at your + With this scheme, you would use -PC to see the current balance at your bank, -U to see things which will probably hit your bank soon (like un- - cashed checks), and no flags to see the most up-to-date state of your + cashed checks), and no flags to see the most up-to-date state of your finances. Description - A transaction's description is the rest of the line following the date - and status mark (or until a comment begins). Sometimes called the + A transaction's description is the rest of the line following the date + and status mark (or until a comment begins). Sometimes called the "narration" in traditional bookkeeping, it can be used for whatever you - wish, or left blank. Transaction descriptions can be queried, unlike + wish, or left blank. Transaction descriptions can be queried, unlike comments. Payee and note You can optionally include a | (pipe) character in descriptions to sub- divide the description into separate fields for payee/payer name on the left (up to the first |) and an additional note field on the right (af- - ter the first |). This may be worthwhile if you need to do more pre- + ter the first |). This may be worthwhile if you need to do more pre- cise querying and pivoting by payee or by note. Comments Lines in the journal beginning with a semicolon (;) or hash (#) or star - (*) are comments, and will be ignored. (Star comments cause org-mode - nodes to be ignored, allowing emacs users to fold and navigate their + (*) are comments, and will be ignored. (Star comments cause org-mode + nodes to be ignored, allowing emacs users to fold and navigate their journals with org-mode or orgstruct-mode.) - You can attach comments to a transaction by writing them after the de- + You can attach comments to a transaction by writing them after the de- scription and/or indented on the following lines (before the postings). - Similarly, you can attach comments to an individual posting by writing + Similarly, you can attach comments to an individual posting by writing them after the amount and/or indented on the following lines. Transac- tion and posting comments must begin with a semicolon (;). @@ -3671,24 +3706,24 @@ JOURNAL FORMAT ; another comment line for posting 2 ; a file comment (because not indented) - You can also comment larger regions of a file using comment and end + You can also comment larger regions of a file using comment and end comment directives. Tags - Tags are a way to add extra labels or labelled data to postings and + Tags are a way to add extra labels or labelled data to postings and transactions, which you can then search or pivot on. - A simple tag is a word (which may contain hyphens) followed by a full + A simple tag is a word (which may contain hyphens) followed by a full colon, written inside a transaction or posting comment line: 2017/1/16 bought groceries ; sometag: - Tags can have a value, which is the text after the colon, up to the + Tags can have a value, which is the text after the colon, up to the next comma or end of line, with leading/trailing whitespace removed: expenses:food $10 ; a-posting-tag: the tag value - Note this means hledger's tag values can not contain commas or new- + Note this means hledger's tag values can not contain commas or new- lines. Ending at commas means you can write multiple short tags on one line, comma separated: @@ -3702,57 +3737,57 @@ JOURNAL FORMAT o "tag2" is another tag, whose value is "some value ..." - Tags in a transaction comment affect the transaction and all of its - postings, while tags in a posting comment affect only that posting. - For example, the following transaction has three tags (A, TAG2, third- + Tags in a transaction comment affect the transaction and all of its + postings, while tags in a posting comment affect only that posting. + For example, the following transaction has three tags (A, TAG2, third- tag) and the posting has four (those plus posting-tag): 1/1 a transaction ; A:, TAG2: ; third-tag: a third transaction tag, <- with a value (a) $1 ; posting-tag: - Tags are like Ledger's metadata feature, except hledger's tag values + Tags are like Ledger's metadata feature, except hledger's tag values are simple strings. Postings - A posting is an addition of some amount to, or removal of some amount - from, an account. Each posting line begins with at least one space or + A posting is an addition of some amount to, or removal of some amount + from, an account. Each posting line begins with at least one space or tab (2 or 4 spaces is common), followed by: o (optional) a status character (empty, !, or *), followed by a space - o (required) an account name (any text, optionally containing single + o (required) an account name (any text, optionally containing single spaces, until end of line or a double space) o (optional) two or more spaces or tabs followed by an amount. - Positive amounts are being added to the account, negative amounts are + Positive amounts are being added to the account, negative amounts are being removed. The amounts within a transaction must always sum up to zero. As a con- - venience, one amount may be left blank; it will be inferred so as to + venience, one amount may be left blank; it will be inferred so as to balance the transaction. - Be sure to note the unusual two-space delimiter between account name - and amount. This makes it easy to write account names containing spa- - ces. But if you accidentally leave only one space (or tab) before the + Be sure to note the unusual two-space delimiter between account name + and amount. This makes it easy to write account names containing spa- + ces. But if you accidentally leave only one space (or tab) before the amount, the amount will be considered part of the account name. Virtual postings A posting with a parenthesised account name is called a virtual posting - or unbalanced posting, which means it is exempt from the usual rule + or unbalanced posting, which means it is exempt from the usual rule that a transaction's postings must balance add up to zero. - This is not part of double entry accounting, so you might choose to - avoid this feature. Or you can use it sparingly for certain special - cases where it can be convenient. Eg, you could set opening balances + This is not part of double entry accounting, so you might choose to + avoid this feature. Or you can use it sparingly for certain special + cases where it can be convenient. Eg, you could set opening balances without using a balancing equity account: 1/1 opening balances (assets:checking) $1000 (assets:savings) $2000 - A posting with a bracketed account name is called a balanced virtual + A posting with a bracketed account name is called a balanced virtual posting. The balanced virtual postings in a transaction must add up to zero (separately from other postings). Eg: @@ -3764,34 +3799,34 @@ JOURNAL FORMAT [assets:checking:available] $10 ; <- (something:else) $5 ; <- not required to balance - Ordinary non-parenthesised, non-bracketed postings are called real - postings. You can exclude virtual postings from reports with the + Ordinary non-parenthesised, non-bracketed postings are called real + postings. You can exclude virtual postings from reports with the -R/--real flag or real:1 query. Account names - Account names typically have several parts separated by a full colon, - from which hledger derives a hierarchical chart of accounts. They can - be anything you like, but in finance there are traditionally five top- - level accounts: assets, liabilities, income, expenses, and equity. + Account names typically have several parts separated by a full colon, + from which hledger derives a hierarchical chart of accounts. They can + be anything you like, but in finance there are traditionally five top- + level accounts: assets, liabilities, revenue, expenses, and equity. - Account names may contain single spaces, eg: assets:accounts receiv- - able. Because of this, they must always be followed by two or more + Account names may contain single spaces, eg: assets:accounts receiv- + able. Because of this, they must always be followed by two or more spaces (or newline). Account names can be aliased. Amounts - After the account name, there is usually an amount. (Important: be- + After the account name, there is usually an amount. (Important: be- tween account name and amount, there must be two or more spaces.) - hledger's amount format is flexible, supporting several international - formats. Here are some examples. Amounts have a number (the "quan- + hledger's amount format is flexible, supporting several international + formats. Here are some examples. Amounts have a number (the "quan- tity"): 1 - ..and usually a currency or commodity name (the "commodity"). This is - a symbol, word, or phrase, to the left or right of the quantity, with + ..and usually a currency or commodity name (the "commodity"). This is + a symbol, word, or phrase, to the left or right of the quantity, with or without a separating space: $1 @@ -3803,13 +3838,13 @@ JOURNAL FORMAT 3 "no. 42 green apples" Amounts can be preceded by a minus sign (or a plus sign, though plus is - the default), The sign can be written before or after a left-side com- + the default), The sign can be written before or after a left-side com- modity symbol: -$1 $-1 - One or more spaces between the sign and the number are acceptable when + One or more spaces between the sign and the number are acceptable when parsing (but they won't be displayed in output): + $1 @@ -3826,8 +3861,8 @@ JOURNAL FORMAT 1,23456780000009 Digit group marks - In the integer part of the quantity (left of the decimal mark), groups - of digits can optionally be separated by a "digit group mark" - a + In the integer part of the quantity (left of the decimal mark), groups + of digits can optionally be separated by a "digit group mark" - a space, comma, or period (different from the decimal mark): $1,000,000.00 @@ -3835,7 +3870,7 @@ JOURNAL FORMAT INR 9,99,99,999.00 1 000 000.9455 - Note, a number containing a single group mark and no decimal mark is + Note, a number containing a single group mark and no decimal mark is ambiguous. Are these group marks or decimal marks ? 1,000 @@ -3843,9 +3878,9 @@ JOURNAL FORMAT hledger will treat them both as decimal marks by default (cf #793). If you use digit group marks, to prevent confusion and undetected typos we - recommend you write commodity directives at the top of the file to ex- - plicitly declare the decimal mark (and optionally a digit group mark). - Note, these formats ("amount styles") are specific to each commodity, + recommend you write commodity directives at the top of the file to ex- + plicitly declare the decimal mark (and optionally a digit group mark). + Note, these formats ("amount styles") are specific to each commodity, so if your data uses multiple formats, hledger can handle it: commodity $1,000.00 @@ -3855,43 +3890,43 @@ JOURNAL FORMAT Commodity display style For the amounts in each commodity, hledger chooses a consistent display - style. (Excluding price amounts, which are always displayed as writ- + style. (Excluding price amounts, which are always displayed as writ- ten). The display style is chosen as follows: - o If there is a commodity directive (or default commodity directive) + o If there is a commodity directive (or default commodity directive) for the commodity, its style is used (see examples above). - o Otherwise the style is inferred from the amounts in that commodity + o Otherwise the style is inferred from the amounts in that commodity seen in the journal. - o Or if there are no such amounts in the journal, a default style is + o Or if there are no such amounts in the journal, a default style is used (like $1000.00). A style is inferred from the journal amounts in a commodity as follows: - o Use the general style (decimal mark, symbol placement) of the first + o Use the general style (decimal mark, symbol placement) of the first amount - o Use the first-seen digit group style (digit group mark, digit group + o Use the first-seen digit group style (digit group mark, digit group sizes), if any o Use the maximum number of decimal places of all. - Transaction price amounts don't affect the commodity display style di- + Transaction price amounts don't affect the commodity display style di- rectly, but occasionally they can do so indirectly (eg when a posting's - amount is inferred using a transaction price). If you find this caus- + amount is inferred using a transaction price). If you find this caus- ing problems, use a commodity directive to fix the display style. In summary, each commodity's amounts will be normalised to o the style declared by a commodity directive - o or, the style of the first posting amount in the journal, with the - first-seen digit group style and the maximum-seen number of decimal + o or, the style of the first posting amount in the journal, with the + first-seen digit group style and the maximum-seen number of decimal places. So if your reports are showing amounts in a way you don't like, eg with - too many decimal places, use a commodity directive to set the commod- + too many decimal places, use a commodity directive to set the commod- ity's display style. For example: # declare euro, dollar and bitcoin commodities and set their display styles: @@ -3901,17 +3936,17 @@ JOURNAL FORMAT Rounding Amounts are stored internally as decimal numbers with up to 255 decimal - places, and displayed with the number of decimal places specified by - the commodity display style. Note, hledger uses banker's rounding: it - rounds to the nearest even number, eg 0.5 displayed with zero decimal - places is "0"). (Guaranteed since hledger 1.17.1; in older versions + places, and displayed with the number of decimal places specified by + the commodity display style. Note, hledger uses banker's rounding: it + rounds to the nearest even number, eg 0.5 displayed with zero decimal + places is "0"). (Guaranteed since hledger 1.17.1; in older versions this could vary if hledger was built with Decimal < 0.5.1.) Transaction prices Within a transaction, you can note an amount's price in another commod- - ity. This can be used to document the cost (in a purchase) or selling - price (in a sale). For example, transaction prices are useful to - record purchases of a foreign currency. Note transaction prices are + ity. This can be used to document the cost (in a purchase) or selling + price (in a sale). For example, transaction prices are useful to + record purchases of a foreign currency. Note transaction prices are fixed at the time of the transaction, and do not change over time. See also market prices, which represent prevailing exchange rates on a cer- tain date. @@ -3937,14 +3972,14 @@ JOURNAL FORMAT assets:euros EUR100 ; one hundred euros purchased assets:dollars $-135 ; for $135 - 4. Like 1, but the @ is parenthesised, i.e. (@); this is for compati- - bility with Ledger journals (Virtual posting costs), and is equiva- + 4. Like 1, but the @ is parenthesised, i.e. (@); this is for compati- + bility with Ledger journals (Virtual posting costs), and is equiva- lent to 1 in hledger. 5. Like 2, but as in 4 the @@ is parenthesised, i.e. (@@); in hledger, this is equivalent to 2. - Use the -B/--cost flag to convert amounts to their transaction price's + Use the -B/--cost flag to convert amounts to their transaction price's commodity, if any. (mnemonic: "B" is from "cost Basis", as in Ledger). Eg here is how -B affects the balance report for the example above: @@ -3955,8 +3990,8 @@ JOURNAL FORMAT $-135 assets:dollars $135 assets:euros # <- the euros' cost - Note -B is sensitive to the order of postings when a transaction price - is inferred: the inferred price will be in the commodity of the last + Note -B is sensitive to the order of postings when a transaction price + is inferred: the inferred price will be in the commodity of the last amount. So if example 3's postings are reversed, while the transaction is equivalent, -B shows something different: @@ -3969,18 +4004,18 @@ JOURNAL FORMAT EUR100 assets:euros Lot prices, lot dates - Ledger allows another kind of price, lot price (four variants: {UNIT- + Ledger allows another kind of price, lot price (four variants: {UNIT- PRICE}, {{TOTALPRICE}}, {=FIXEDUNITPRICE}, {{=FIXEDTOTALPRICE}}), and/or a lot date ([DATE]) to be specified. These are normally used to - select a lot when selling investments. hledger will parse these, for - compatibility with Ledger journals, but currently ignores them. A - transaction price, lot price and/or lot date may appear in any order, + select a lot when selling investments. hledger will parse these, for + compatibility with Ledger journals, but currently ignores them. A + transaction price, lot price and/or lot date may appear in any order, after the posting amount and before the balance assertion if any. Balance assertions - hledger supports Ledger-style balance assertions in journal files. - These look like, for example, = EXPECTEDBALANCE following a posting's - amount. Eg here we assert the expected dollar balance in accounts a + hledger supports Ledger-style balance assertions in journal files. + These look like, for example, = EXPECTEDBALANCE following a posting's + amount. Eg here we assert the expected dollar balance in accounts a and b after each posting: 2013/1/1 @@ -3992,32 +4027,32 @@ JOURNAL FORMAT b $-1 =$-2 After reading a journal file, hledger will check all balance assertions - and report an error if any of them fail. Balance assertions can pro- - tect you from, eg, inadvertently disrupting reconciled balances while - cleaning up old entries. You can disable them temporarily with the + and report an error if any of them fail. Balance assertions can pro- + tect you from, eg, inadvertently disrupting reconciled balances while + cleaning up old entries. You can disable them temporarily with the -I/--ignore-assertions flag, which can be useful for troubleshooting or - for reading Ledger files. (Note: this flag currently does not disable + for reading Ledger files. (Note: this flag currently does not disable balance assignments, below). Assertions and ordering - hledger sorts an account's postings and assertions first by date and - then (for postings on the same day) by parse order. Note this is dif- + hledger sorts an account's postings and assertions first by date and + then (for postings on the same day) by parse order. Note this is dif- ferent from Ledger, which sorts assertions only by parse order. (Also, - Ledger assertions do not see the accumulated effect of repeated post- + Ledger assertions do not see the accumulated effect of repeated post- ings to the same account within a transaction.) So, hledger balance assertions keep working if you reorder differently- - dated transactions within the journal. But if you reorder same-dated - transactions or postings, assertions might break and require updating. + dated transactions within the journal. But if you reorder same-dated + transactions or postings, assertions might break and require updating. This order dependence does bring an advantage: precise control over the order of postings and assertions within a day, so you can assert intra- day balances. Assertions and included files - With included files, things are a little more complicated. Including - preserves the ordering of postings and assertions. If you have multi- - ple postings to an account on the same day, split across different - files, and you also want to assert the account's balance on the same + With included files, things are a little more complicated. Including + preserves the ordering of postings and assertions. If you have multi- + ple postings to an account on the same day, split across different + files, and you also want to assert the account's balance on the same day, you'll have to put the assertion in the right file. Assertions and multiple -f options @@ -4025,15 +4060,15 @@ JOURNAL FORMAT -f options. Use include or concatenate the files instead. Assertions and commodities - The asserted balance must be a simple single-commodity amount, and in - fact the assertion checks only this commodity's balance within the - (possibly multi-commodity) account balance. This is how assertions + The asserted balance must be a simple single-commodity amount, and in + fact the assertion checks only this commodity's balance within the + (possibly multi-commodity) account balance. This is how assertions work in Ledger also. We could call this a "partial" balance assertion. To assert the balance of more than one commodity in an account, you can write multiple postings, each asserting one commodity's balance. - You can make a stronger "total" balance assertion by writing a double + You can make a stronger "total" balance assertion by writing a double equals sign (== EXPECTEDBALANCE). This asserts that there are no other unasserted commodities in the account (or, that their balance is 0). @@ -4053,7 +4088,7 @@ JOURNAL FORMAT a 0 == $1 It's not yet possible to make a complete assertion about a balance that - has multiple commodities. One workaround is to isolate each commodity + has multiple commodities. One workaround is to isolate each commodity into its own subaccount: 2013/1/1 @@ -4067,21 +4102,21 @@ JOURNAL FORMAT a:euro 0 == 1EUR Assertions and prices - Balance assertions ignore transaction prices, and should normally be + Balance assertions ignore transaction prices, and should normally be written without one: 2019/1/1 (a) $1 @ EUR1 = $1 - We do allow prices to be written there, however, and print shows them, - even though they don't affect whether the assertion passes or fails. - This is for backward compatibility (hledger's close command used to - generate balance assertions with prices), and because balance assign- + We do allow prices to be written there, however, and print shows them, + even though they don't affect whether the assertion passes or fails. + This is for backward compatibility (hledger's close command used to + generate balance assertions with prices), and because balance assign- ments do use them (see below). Assertions and subaccounts - The balance assertions above (= and ==) do not count the balance from - subaccounts; they check the account's exclusive balance only. You can + The balance assertions above (= and ==) do not count the balance from + subaccounts; they check the account's exclusive balance only. You can assert the balance including subaccounts by writing =* or ==*, eg: 2019/1/1 @@ -4095,16 +4130,16 @@ JOURNAL FORMAT tual. They are not affected by the --real/-R flag or real: query. Assertions and precision - Balance assertions compare the exactly calculated amounts, which are - not always what is shown by reports. Eg a commodity directive may - limit the display precision, but this will not affect balance asser- + Balance assertions compare the exactly calculated amounts, which are + not always what is shown by reports. Eg a commodity directive may + limit the display precision, but this will not affect balance asser- tions. Balance assertion failure messages show exact amounts. Balance assignments - Ledger-style balance assignments are also supported. These are like - balance assertions, but with no posting amount on the left side of the - equals sign; instead it is calculated automatically so as to satisfy - the assertion. This can be a convenience during data entry, eg when + Ledger-style balance assignments are also supported. These are like + balance assertions, but with no posting amount on the left side of the + equals sign; instead it is calculated automatically so as to satisfy + the assertion. This can be a convenience during data entry, eg when setting opening balances: ; starting a new journal, set asset account balances @@ -4122,14 +4157,14 @@ JOURNAL FORMAT expenses:misc The calculated amount depends on the account's balance in the commodity - at that point (which depends on the previously-dated postings of the - commodity to that account since the last balance assertion or assign- + at that point (which depends on the previously-dated postings of the + commodity to that account since the last balance assertion or assign- ment). Note that using balance assignments makes your journal a little less explicit; to know the exact amount posted, you have to run hledger or do the calculations yourself, instead of just reading it. Balance assignments and prices - A transaction price in a balance assignment will cause the calculated + A transaction price in a balance assignment will cause the calculated amount to have that price attached: 2019/1/1 @@ -4140,83 +4175,85 @@ JOURNAL FORMAT (a) $1 @ EUR2 = $1 @ EUR2 Directives - A directive is a line in the journal beginning with a special keyword, + A directive is a line in the journal beginning with a special keyword, that influences how the journal is processed. hledger's directives are based on a subset of Ledger's, but there are many differences (and also some differences between hledger versions). Directives' behaviour and interactions can get a little bit complex, so - here is a table summarising the directives and their effects, with - links to more detailed docs. Note part of this table is hidden when + here is a table summarising the directives and their effects, with + links to more detailed docs. Note part of this table is hidden when viewed in a web browser - scroll it sideways to see more. - direc- end di- subdi- purpose can affect (as of + direc- end di- subdi- purpose can affect (as of tive rective rec- 2018/06) tives ------------------------------------------------------------------------------------ - account any document account names, de- all entries in all - text clare account types & dis- files, before or + account any document account names, de- all entries in all + text clare account types & dis- files, before or play order after alias end rewrite account names following entries - aliases until end of cur- + aliases until end of cur- rent file or end directive - apply end apply prepend a common parent to following entries - account account account names until end of cur- + apply end apply prepend a common parent to following entries + account account account names until end of cur- rent file or end directive comment end com- ignore part of journal following entries - ment until end of cur- + ment until end of cur- rent file or end directive - commod- format declare a commodity and its number notation: + commod- format declare a commodity and its number notation: ity number notation & display following entries style in that commodity in all files ; dis- play style: amounts of that commodity in reports - D declare a commodity to be default commodity: + D declare a commodity to be default commodity: used for commodityless following commod- - amounts, and its number no- ityless entries un- - tation & display style til end of current - file; number nota- + amounts, and its number no- ityless entries un- + tation & display style til end of current + file; number nota- tion: following en- - tries in that com- + tries in that com- modity until end of - current file; dis- + current file; dis- play style: amounts of that commodity in reports include include entries/directives what the included from another file directives affect - P declare a market price for a amounts of that - commodity commodity in re- - ports, when -V is - used - Y declare a year for yearless following entries - dates until end of cur- + [payee] declare a payee name following entries + until end of cur- rent file - = declare an auto posting all entries in par- - rule, adding postings to ent/current/child + + P declare a market price for a amounts of that + commodity commodity in re- + ports, when -V is + used + Y declare a year for yearless following entries + dates until end of cur- + rent file + = declare an auto posting all entries in par- + rule, adding postings to ent/current/child other transactions files (but not sib- ling files, see #1212) And some definitions: - subdi- optional indented directive line immediately following a parent + subdi- optional indented directive line immediately following a parent rec- directive tive number how to interpret numbers when parsing journal entries (the iden- - nota- tity of the decimal separator character). (Currently each com- + nota- tity of the decimal separator character). (Currently each com- tion modity can have its own notation, even in the same file.) - dis- how to display amounts of a commodity in reports (symbol side + dis- how to display amounts of a commodity in reports (symbol side play and spacing, digit groups, decimal separator, decimal places) style - - - direc- which entries and (when there are multiple files) which files + direc- which entries and (when there are multiple files) which files tive are affected by a directive scope @@ -4225,35 +4262,35 @@ JOURNAL FORMAT ports). Some directives have multiple effects. Directives and multiple files - If you use multiple -f/--file options, or the include directive, - hledger will process multiple input files. But note that directives + If you use multiple -f/--file options, or the include directive, + hledger will process multiple input files. But note that directives which affect input (see above) typically last only until the end of the file in which they occur. This may seem inconvenient, but it's intentional; it makes reports sta- - ble and deterministic, independent of the order of input. Otherwise - you could see different numbers if you happened to write -f options in - a different order, or if you moved includes around while cleaning up + ble and deterministic, independent of the order of input. Otherwise + you could see different numbers if you happened to write -f options in + a different order, or if you moved includes around while cleaning up your files. - It can be surprising though; for example, it means that alias direc- + It can be surprising though; for example, it means that alias direc- tives do not affect parent or sibling files (see below). Comment blocks - A line containing just comment starts a commented region of the file, + A line containing just comment starts a commented region of the file, and a line containing just end comment (or the end of the current file) ends it. See also comments. Including other files - You can pull in the content of additional files by writing an include + You can pull in the content of additional files by writing an include directive, like this: include FILEPATH - Only journal files can include, and only journal, timeclock or timedot + Only journal files can include, and only journal, timeclock or timedot files can be included (not CSV files, currently). - If the file path does not begin with a slash, it is relative to the + If the file path does not begin with a slash, it is relative to the current file's folder. A tilde means home directory, eg: include ~/main.journal. @@ -4262,17 +4299,17 @@ JOURNAL FORMAT *.journal. There is limited support for recursive wildcards: **/ (the slash is re- - quired) matches 0 or more subdirectories. It's not super convenient - since you have to avoid include cycles and including directories, but + quired) matches 0 or more subdirectories. It's not super convenient + since you have to avoid include cycles and including directories, but this can be done, eg: include */**/*.journal. The path may also be prefixed to force a specific file format, overrid- - ing the file extension (as described in hledger.1 -> Input files): in- + ing the file extension (as described in hledger.1 -> Input files): in- clude timedot:~/notes/2020*.md. Default year - You can set a default year to be used for subsequent dates which don't - specify a year. This is a line beginning with Y followed by the year. + You can set a default year to be used for subsequent dates which don't + specify a year. This is a line beginning with Y followed by the year. Eg: Y2009 ; set default year to 2009 @@ -4291,6 +4328,14 @@ JOURNAL FORMAT expenses 1 assets + Declaring payees + The payee directive can be used to declare a limited set of payees + which may appear in transaction descriptions. The "payees" check will + report an error if any transaction refers to a payee that has not been + declared. Eg: + + payee Whole Foods + Declaring commodities The commodity directive has several functions: @@ -5035,8 +5080,6 @@ CSV FORMAT by patterns, alternate syntax end skip the remaining CSV records date-format how to parse dates in CSV records - - decimal-mark the decimal mark used in CSV amounts, if ambiguous newest-first disambiguate record order when there's @@ -5790,29 +5833,79 @@ CSV FORMAT o https://plaintextaccounting.org -> data import/conversion Setting amounts - A posting amount can be set in one of these ways: + Some tips on using the amount-setting rules discussed above. - o by assigning (with a fields list or field assignment) to amountN - (posting N's amount) or amount (posting 1's amount) + Here are the ways to set a posting's amount: - o by assigning to amountN-in and amountN-out (or amount-in and amount- - out). For each CSV record, whichever of these has a non-zero value - will be used, with appropriate sign. If both contain a non-zero - value, this may not work. + 1. If the CSV has a single amount field: + Assign (via a fields list or a field assignment) to amountN. This sets + the Nth posting's amount. N is usually 1 or 2 but can go up to 99. - o by assigning to balanceN (or balance) instead of the above, setting - the amount indirectly via a balance assignment. If you do this the - default account name may be wrong, so you should set that explicitly. + 2. If the CSV has separate Debit and Credit amount fields: + Assign to amountN-in and amountN-out. This sets posting N's amount to + whichever of these has a non-zero value, guessing an appropriate sign. - There is some special handling for an amount's sign: + o If hledger guesses the wrong sign: + Prepend a minus sign to flip it. Eg: - o If an amount value is parenthesised, it will be de-parenthesised and - sign-flipped. + fields date, description, amount-in, amount-out + amount-out -%amount-out - o If an amount value begins with a double minus sign, those cancel out - and are removed. + o If both fields contain a non-zero value: + The amountN-in/amountN-out rules require that each CSV record has a + non-zero value in exactly one of the two fields, so that hledger + knows which to choose. So these would all be rejected: - o If an amount value begins with a plus sign, that will be removed + "", "" + "0", "0" + "1", "none" + + If your CSV has amount values like this, use conditional rules + instead. For example, to make hledger to choose the value con- + taining non-zero digits: + + fields date, description, in, out + if %in [1-9] + amount1 %in + if %out [1-9] + amount1 %out + + 3. Using the old numberless syntax: + Assign to amount (or to amount-in and amount-out). This sets posting + 1's and posting 2's amounts (and converts posting 2's amount to cost). + This is supported for backwards compatibility (and occasional conve- + nience). + + 4. If the CSV has the balance instead of the transaction amount: + Assign to balanceN, which sets posting N's amount indirectly via a bal- + ance assignment. (Old syntax: balance, equivalent to balance1.) + + o If hledger guesses the wrong default account name: + When setting the amount via balance assertion, hledger may guess + the wrong default account name. So, set the account name explic- + itly, eg: + + fields date, description, balance1 + account1 assets:checking + + Amount signs + There is some special handling for amount signs, to simplify parsing + and sign-flipping: + + o If an amount value begins with a plus sign: + that will be removed: +AMT becomes AMT + + o If an amount value is parenthesised: + it will be de-parenthesised and sign-flipped: (AMT) becomes -AMT + + o If an amount value has two minus signs (or two sets of parentheses, + or a minus sign and parentheses): + they cancel out and will be removed: --AMT or -(AMT) becomes AMT + + o If an amount value contains just a sign (or just a set of parenthe- + ses): + that is removed, making it an empty value. "+" or "-" or "()" becomes + "". Setting currency/commodity If the currency/commodity symbol is included in the CSV's amount