From 368297102d25d735919493f6107d2c0f64270a9b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 22 Jun 2020 12:20:14 -0700 Subject: [PATCH] ;regen manuals --- hledger-lib/hledger_csv.5 | 72 +- hledger-lib/hledger_csv.info | 200 ++++-- hledger-lib/hledger_csv.txt | 199 ++++-- hledger/Hledger/Cli/Commands/Print.txt | 2 +- hledger/hledger.1 | 19 +- hledger/hledger.info | 314 ++++---- hledger/hledger.txt | 950 +++++++++++++------------ 7 files changed, 995 insertions(+), 761 deletions(-) diff --git a/hledger-lib/hledger_csv.5 b/hledger-lib/hledger_csv.5 index d1d6f00e7..cd362728f 100644 --- a/hledger-lib/hledger_csv.5 +++ b/hledger-lib/hledger_csv.5 @@ -610,7 +610,7 @@ separator TAB .fi .PP See also: File Extension. -.SS \f[C]if\f[R] +.SS \f[C]if\f[R] block .IP .nf \f[C] @@ -702,6 +702,76 @@ banking thru software comment XXX deductible ? check it \f[R] .fi +.SS \f[C]if\f[R] table +.IP +.nf +\f[C] +if,CSVFIELDNAME1,CSVFIELDNAME2,...,CSVFIELDNAMEn +MATCHER1,VALUE11,VALUE12,...,VALUE1n +MATCHER2,VALUE21,VALUE22,...,VALUE2n +MATCHER3,VALUE31,VALUE32,...,VALUE3n + +\f[R] +.fi +.PP +Conditional tables (\[dq]if tables\[dq]) are a different syntax to +specify field assignments that will be applied only to CSV records which +match certain patterns. +.PP +MATCHER could be either field or record matcher, as described above. +When MATCHER matches, values from that row would be assigned to the CSV +fields named on the \f[C]if\f[R] line, in the same order. +.PP +Therefore \f[C]if\f[R] table is exactly equivalent to a sequence of of +\f[C]if\f[R] blocks: +.IP +.nf +\f[C] +if MATCHER1 + CSVFIELDNAME1 VALUE11 + CSVFIELDNAME2 VALUE12 + ... + CSVFIELDNAMEn VALUE1n + +if MATCHER2 + CSVFIELDNAME1 VALUE21 + CSVFIELDNAME2 VALUE22 + ... + CSVFIELDNAMEn VALUE2n + +if MATCHER3 + CSVFIELDNAME1 VALUE31 + CSVFIELDNAME2 VALUE32 + ... + CSVFIELDNAMEn VALUE3n +\f[R] +.fi +.PP +Each line starting with MATCHER should contain enough (possibly empty) +values for all the listed fields. +.PP +Rules would be checked and applied in the order they are listed in the +table and, like with \f[C]if\f[R] blocks, later rules (in the same or +another table) or \f[C]if\f[R] blocks could override the effect of any +rule. +.PP +Instead of \[aq],\[aq] you can use a variety of other non-alphanumeric +characters as a separator. +First character after \f[C]if\f[R] is taken to be the separator for the +rest of the table. +It is the responsibility of the user to ensure that separator does not +occur inside MATCHERs and values - there is no way to escape separator. +.PP +Example: +.IP +.nf +\f[C] +if,account2,comment +atm transaction fee,expenses:business:banking,deductible? check it +%description groceries,expenses:groceries, +2020/01/12.*Plumbing LLC,expenses:house:upkeep,emergency plumbing call-out +\f[R] +.fi .SS \f[C]end\f[R] .PP This rule can be used inside if blocks (only), to make hledger stop diff --git a/hledger-lib/hledger_csv.info b/hledger-lib/hledger_csv.info index 8efccb90f..86b8a0890 100644 --- a/hledger-lib/hledger_csv.info +++ b/hledger-lib/hledger_csv.info @@ -374,7 +374,8 @@ Blank lines and lines beginning with '#' or ';' are ignored. * fields:: * field assignment:: * separator:: -* if:: +* if block:: +* if table:: * end:: * date-format:: * newest-first:: @@ -567,7 +568,7 @@ becomes '1' when interpolated) (#1051). See TIPS below for more about referencing other fields.  -File: hledger_csv.info, Node: separator, Next: if, Prev: field assignment, Up: CSV RULES +File: hledger_csv.info, Node: separator, Next: if block, Prev: field assignment, Up: CSV RULES 2.4 'separator' =============== @@ -587,10 +588,10 @@ separator TAB See also: File Extension.  -File: hledger_csv.info, Node: if, Next: end, Prev: separator, Up: CSV RULES +File: hledger_csv.info, Node: if block, Next: if table, Prev: separator, Up: CSV RULES -2.5 'if' -======== +2.5 'if' block +============== if MATCHER RULE @@ -659,9 +660,70 @@ banking thru software comment XXX deductible ? check it  -File: hledger_csv.info, Node: end, Next: date-format, Prev: if, Up: CSV RULES +File: hledger_csv.info, Node: if table, Next: end, Prev: if block, Up: CSV RULES -2.6 'end' +2.6 'if' table +============== + +if,CSVFIELDNAME1,CSVFIELDNAME2,...,CSVFIELDNAMEn +MATCHER1,VALUE11,VALUE12,...,VALUE1n +MATCHER2,VALUE21,VALUE22,...,VALUE2n +MATCHER3,VALUE31,VALUE32,...,VALUE3n + + + Conditional tables ("if tables") are a different syntax to specify +field assignments that will be applied only to CSV records which match +certain patterns. + + MATCHER could be either field or record matcher, as described above. +When MATCHER matches, values from that row would be assigned to the CSV +fields named on the 'if' line, in the same order. + + Therefore 'if' table is exactly equivalent to a sequence of of 'if' +blocks: + +if MATCHER1 + CSVFIELDNAME1 VALUE11 + CSVFIELDNAME2 VALUE12 + ... + CSVFIELDNAMEn VALUE1n + +if MATCHER2 + CSVFIELDNAME1 VALUE21 + CSVFIELDNAME2 VALUE22 + ... + CSVFIELDNAMEn VALUE2n + +if MATCHER3 + CSVFIELDNAME1 VALUE31 + CSVFIELDNAME2 VALUE32 + ... + CSVFIELDNAMEn VALUE3n + + Each line starting with MATCHER should contain enough (possibly +empty) values for all the listed fields. + + Rules would be checked and applied in the order they are listed in +the table and, like with 'if' blocks, later rules (in the same or +another table) or 'if' blocks could override the effect of any rule. + + Instead of ',' you can use a variety of other non-alphanumeric +characters as a separator. First character after 'if' is taken to be +the separator for the rest of the table. It is the responsibility of +the user to ensure that separator does not occur inside MATCHERs and +values - there is no way to escape separator. + + Example: + +if,account2,comment +atm transaction fee,expenses:business:banking,deductible? check it +%description groceries,expenses:groceries, +2020/01/12.*Plumbing LLC,expenses:house:upkeep,emergency plumbing call-out + + +File: hledger_csv.info, Node: end, Next: date-format, Prev: if table, Up: CSV RULES + +2.7 'end' ========= This rule can be used inside if blocks (only), to make hledger stop @@ -675,7 +737,7 @@ if ,,,,  File: hledger_csv.info, Node: date-format, Next: newest-first, Prev: end, Up: CSV RULES -2.7 'date-format' +2.8 'date-format' ================= date-format DATEFMT @@ -706,7 +768,7 @@ https://hackage.haskell.org/package/time/docs/Data-Time-Format.html#v:formatTime  File: hledger_csv.info, Node: newest-first, Next: include, Prev: date-format, Up: CSV RULES -2.8 'newest-first' +2.9 'newest-first' ================== hledger always sorts the generated transactions by date. Transactions @@ -728,8 +790,8 @@ newest-first  File: hledger_csv.info, Node: include, Next: balance-type, Prev: newest-first, Up: CSV RULES -2.9 'include' -============= +2.10 'include' +============== include RULESFILE @@ -751,7 +813,7 @@ include categorisation.rules  File: hledger_csv.info, Node: balance-type, Prev: include, Up: CSV RULES -2.10 'balance-type' +2.11 'balance-type' =================== Balance assertions generated by assigning to balanceN are of the simple @@ -1048,62 +1110,64 @@ Node: Paypal6570 Ref: #paypal6664 Node: CSV RULES14308 Ref: #csv-rules14417 -Node: skip14693 -Ref: #skip14786 -Node: fields15161 -Ref: #fields15283 -Node: Transaction field names16448 -Ref: #transaction-field-names16608 -Node: Posting field names16719 -Ref: #posting-field-names16871 -Node: account16941 -Ref: #account17057 -Node: amount17594 -Ref: #amount17725 -Node: currency18832 -Ref: #currency18967 -Node: balance19173 -Ref: #balance19307 -Node: comment19624 -Ref: #comment19741 -Node: field assignment19904 -Ref: #field-assignment20047 -Node: separator20865 -Ref: #separator20994 -Node: if21405 -Ref: #if21507 -Node: end23663 -Ref: #end23769 -Node: date-format23993 -Ref: #date-format24125 -Node: newest-first24874 -Ref: #newest-first25012 -Node: include25695 -Ref: #include25824 -Node: balance-type26268 -Ref: #balance-type26388 -Node: TIPS27088 -Ref: #tips27170 -Node: Rapid feedback27426 -Ref: #rapid-feedback27543 -Node: Valid CSV28003 -Ref: #valid-csv28133 -Node: File Extension28325 -Ref: #file-extension28477 -Node: Reading multiple CSV files28887 -Ref: #reading-multiple-csv-files29072 -Node: Valid transactions29313 -Ref: #valid-transactions29491 -Node: Deduplicating importing30119 -Ref: #deduplicating-importing30298 -Node: Setting amounts31331 -Ref: #setting-amounts31500 -Node: Setting currency/commodity32487 -Ref: #setting-currencycommodity32679 -Node: Referencing other fields33482 -Ref: #referencing-other-fields33682 -Node: How CSV rules are evaluated34579 -Ref: #how-csv-rules-are-evaluated34752 +Node: skip14712 +Ref: #skip14805 +Node: fields15180 +Ref: #fields15302 +Node: Transaction field names16467 +Ref: #transaction-field-names16627 +Node: Posting field names16738 +Ref: #posting-field-names16890 +Node: account16960 +Ref: #account17076 +Node: amount17613 +Ref: #amount17744 +Node: currency18851 +Ref: #currency18986 +Node: balance19192 +Ref: #balance19326 +Node: comment19643 +Ref: #comment19760 +Node: field assignment19923 +Ref: #field-assignment20066 +Node: separator20884 +Ref: #separator21019 +Node: if block21430 +Ref: #if-block21555 +Node: if table23711 +Ref: #if-table23830 +Node: end25568 +Ref: #end25680 +Node: date-format25904 +Ref: #date-format26036 +Node: newest-first26785 +Ref: #newest-first26923 +Node: include27606 +Ref: #include27737 +Node: balance-type28181 +Ref: #balance-type28301 +Node: TIPS29001 +Ref: #tips29083 +Node: Rapid feedback29339 +Ref: #rapid-feedback29456 +Node: Valid CSV29916 +Ref: #valid-csv30046 +Node: File Extension30238 +Ref: #file-extension30390 +Node: Reading multiple CSV files30800 +Ref: #reading-multiple-csv-files30985 +Node: Valid transactions31226 +Ref: #valid-transactions31404 +Node: Deduplicating importing32032 +Ref: #deduplicating-importing32211 +Node: Setting amounts33244 +Ref: #setting-amounts33413 +Node: Setting currency/commodity34400 +Ref: #setting-currencycommodity34592 +Node: Referencing other fields35395 +Ref: #referencing-other-fields35595 +Node: How CSV rules are evaluated36492 +Ref: #how-csv-rules-are-evaluated36665  End Tag Table diff --git a/hledger-lib/hledger_csv.txt b/hledger-lib/hledger_csv.txt index 54ea3c77c..eef39106c 100644 --- a/hledger-lib/hledger_csv.txt +++ b/hledger-lib/hledger_csv.txt @@ -467,7 +467,7 @@ CSV RULES See also: File Extension. - if + if block if MATCHER RULE @@ -535,8 +535,63 @@ CSV RULES account2 expenses:business:banking comment XXX deductible ? check it + if table + if,CSVFIELDNAME1,CSVFIELDNAME2,...,CSVFIELDNAMEn + MATCHER1,VALUE11,VALUE12,...,VALUE1n + MATCHER2,VALUE21,VALUE22,...,VALUE2n + MATCHER3,VALUE31,VALUE32,...,VALUE3n + + + Conditional tables ("if tables") are a different syntax to specify + field assignments that will be applied only to CSV records which match + certain patterns. + + MATCHER could be either field or record matcher, as described above. + When MATCHER matches, values from that row would be assigned to the CSV + fields named on the if line, in the same order. + + Therefore if table is exactly equivalent to a sequence of of if blocks: + + if MATCHER1 + CSVFIELDNAME1 VALUE11 + CSVFIELDNAME2 VALUE12 + ... + CSVFIELDNAMEn VALUE1n + + if MATCHER2 + CSVFIELDNAME1 VALUE21 + CSVFIELDNAME2 VALUE22 + ... + CSVFIELDNAMEn VALUE2n + + if MATCHER3 + CSVFIELDNAME1 VALUE31 + CSVFIELDNAME2 VALUE32 + ... + CSVFIELDNAMEn VALUE3n + + Each line starting with MATCHER should contain enough (possibly empty) + values for all the listed fields. + + Rules would be checked and applied in the order they are listed in the + table and, like with if blocks, later rules (in the same or another ta- + ble) or if blocks could override the effect of any rule. + + Instead of ',' you can use a variety of other non-alphanumeric charac- + ters as a separator. First character after if is taken to be the sepa- + rator for the rest of the table. It is the responsibility of the user + to ensure that separator does not occur inside MATCHERs and values - + there is no way to escape separator. + + Example: + + if,account2,comment + atm transaction fee,expenses:business:banking,deductible? check it + %description groceries,expenses:groceries, + 2020/01/12.*Plumbing LLC,expenses:house:upkeep,emergency plumbing call-out + end - This rule can be used inside if blocks (only), to make hledger stop + This rule can be used inside if blocks (only), to make hledger stop reading this CSV file and move on to the next input file, or to command execution. Eg: @@ -547,10 +602,10 @@ CSV RULES date-format date-format DATEFMT - This is a helper for the date (and date2) fields. If your CSV dates - are not formatted like YYYY-MM-DD, YYYY/MM/DD or YYYY.MM.DD, you'll - need to add a date-format rule describing them with a strptime date - parsing pattern, which must parse the CSV date value completely. Some + This is a helper for the date (and date2) fields. If your CSV dates + are not formatted like YYYY-MM-DD, YYYY/MM/DD or YYYY.MM.DD, you'll + need to add a date-format rule describing them with a strptime date + parsing pattern, which must parse the CSV date value completely. Some examples: # MM/DD/YY @@ -572,15 +627,15 @@ CSV RULES mat.html#v:formatTime newest-first - hledger always sorts the generated transactions by date. Transactions - on the same date should appear in the same order as their CSV records, - as hledger can usually auto-detect whether the CSV's normal order is + hledger always sorts the generated transactions by date. Transactions + on the same date should appear in the same order as their CSV records, + as hledger can usually auto-detect whether the CSV's normal order is oldest first or newest first. But if all of the following are true: - o the CSV might sometimes contain just one day of data (all records + o the CSV might sometimes contain just one day of data (all records having the same date) - o the CSV records are normally in reverse chronological order (newest + o the CSV records are normally in reverse chronological order (newest at the top) o and you care about preserving the order of same-day transactions @@ -593,9 +648,9 @@ CSV RULES include include RULESFILE - This includes the contents of another CSV rules file at this point. - RULESFILE is an absolute file path or a path relative to the current - file's directory. This can be useful for sharing common rules between + This includes the contents of another CSV rules file at this point. + RULESFILE is an absolute file path or a path relative to the current + file's directory. This can be useful for sharing common rules between several rules files, eg: # someaccount.csv.rules @@ -610,10 +665,10 @@ CSV RULES balance-type Balance assertions generated by assigning to balanceN are of the simple - = type by default, which is a single-commodity, subaccount-excluding + = type by default, which is a single-commodity, subaccount-excluding assertion. You may find the subaccount-including variants more useful, - eg if you have created some virtual subaccounts of checking to help - with budgeting. You can select a different type of assertion with the + eg if you have created some virtual subaccounts of checking to help + with budgeting. You can select a different type of assertion with the balance-type rule: # balance assertions will consider all commodities and all subaccounts @@ -628,19 +683,19 @@ CSV RULES TIPS Rapid feedback - It's a good idea to get rapid feedback while creating/troubleshooting + It's a good idea to get rapid feedback while creating/troubleshooting CSV rules. Here's a good way, using entr from http://eradman.com/entr- project : $ ls foo.csv* | entr bash -c 'echo ----; hledger -f foo.csv print desc:SOMEDESC' - A desc: query (eg) is used to select just one, or a few, transactions - of interest. "bash -c" is used to run multiple commands, so we can - echo a separator each time the command re-runs, making it easier to + A desc: query (eg) is used to select just one, or a few, transactions + of interest. "bash -c" is used to run multiple commands, so we can + echo a separator each time the command re-runs, making it easier to read the output. Valid CSV - hledger accepts CSV conforming to RFC 4180. When CSV values are en- + hledger accepts CSV conforming to RFC 4180. When CSV values are en- closed in quotes, note: o they must be double quotes (not single quotes) @@ -648,9 +703,9 @@ TIPS o spaces outside the quotes are not allowed File Extension - CSV ("Character Separated Values") files should be named with one of - these filename extensions: .csv, .ssv, .tsv. Or, the file path should - be prefixed with one of csv:, ssv:, tsv:. This helps hledger identify + CSV ("Character Separated Values") files should be named with one of + these filename extensions: .csv, .ssv, .tsv. Or, the file path should + be prefixed with one of csv:, ssv:, tsv:. This helps hledger identify the format and show the right error messages. For example: $ hledger -f foo.ssv print @@ -662,44 +717,44 @@ TIPS More about this: Input files in the hledger manual. Reading multiple CSV files - If you use multiple -f options to read multiple CSV files at once, - hledger will look for a correspondingly-named rules file for each CSV - file. But if you use the --rules-file option, that rules file will be + If you use multiple -f options to read multiple CSV files at once, + hledger will look for a correspondingly-named rules file for each CSV + file. But if you use the --rules-file option, that rules file will be used for all the CSV files. Valid transactions After reading a CSV file, hledger post-processes and validates the gen- erated journal entries as it would for a journal file - balancing them, - applying balance assignments, and canonicalising amount styles. Any - errors at this stage will be reported in the usual way, displaying the + applying balance assignments, and canonicalising amount styles. Any + errors at this stage will be reported in the usual way, displaying the problem entry. There is one exception: balance assertions, if you have generated them, - will not be checked, since normally these will work only when the CSV - data is part of the main journal. If you do need to check balance as- + will not be checked, since normally these will work only when the CSV + data is part of the main journal. If you do need to check balance as- sertions generated from CSV right away, pipe into another hledger: $ hledger -f file.csv print | hledger -f- print Deduplicating, importing - When you download a CSV file periodically, eg to get your latest bank - transactions, the new file may overlap with the old one, containing + When you download a CSV file periodically, eg to get your latest bank + transactions, the new file may overlap with the old one, containing some of the same records. The import command will (a) detect the new transactions, and (b) append just those transactions to your main journal. It is idempotent, so you - don't have to remember how many times you ran it or with which version - of the CSV. (It keeps state in a hidden .latest.FILE.csv file.) This + don't have to remember how many times you ran it or with which version + of the CSV. (It keeps state in a hidden .latest.FILE.csv file.) This is the easiest way to import CSV data. Eg: # download the latest CSV files, then run this command. # Note, no -f flags needed here. $ hledger import *.csv [--dry] - This method works for most CSV files. (Where records have a stable + This method works for most CSV files. (Where records have a stable chronological order, and new records appear only at the new end.) - A number of other tools and workflows, hledger-specific and otherwise, + A number of other tools and workflows, hledger-specific and otherwise, exist for converting, deduplicating, classifying and managing CSV data. See: @@ -710,43 +765,43 @@ TIPS Setting amounts A posting amount can be set in one of these ways: - o by assigning (with a fields list or field assignment) to amountN + o by assigning (with a fields list or field assignment) to amountN (posting N's amount) or amount (posting 1'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 + 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. - o by assigning to balanceN (or balance) instead of the above, setting - the amount indirectly via a balance assignment. If you do this the + 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. There is some special handling for an amount's sign: - o If an amount value is parenthesised, it will be de-parenthesised and + o If an amount value is parenthesised, it will be de-parenthesised and sign-flipped. - o If an amount value begins with a double minus sign, those cancel out + o If an amount value begins with a double minus sign, those cancel out and are removed. o If an amount value begins with a plus sign, that will be removed Setting currency/commodity - If the currency/commodity symbol is included in the CSV's amount + If the currency/commodity symbol is included in the CSV's amount field(s), you don't have to do anything special. If the currency is provided as a separate CSV field, you can either: - o assign that to currency, which adds it to all posting amounts. The - symbol will prepended to the amount quantity (on the left side). If - you write a trailing space after the symbol, there will be a space - between symbol and amount (an exception to the usual whitespace + o assign that to currency, which adds it to all posting amounts. The + symbol will prepended to the amount quantity (on the left side). If + you write a trailing space after the symbol, there will be a space + between symbol and amount (an exception to the usual whitespace stripping). o or assign it to currencyN which adds it to posting N's amount only. - o or for more control, construct the amount from symbol and quantity + o or for more control, construct the amount from symbol and quantity using field assignment, eg: fields date,description,currency,quantity @@ -754,9 +809,9 @@ TIPS amount %quantity %currency 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 - field named amount1, but %amount1 always means the CSV field, not the + 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 + field named amount1, but %amount1 always means the CSV field, not the hledger field: # Name the third CSV field "amount1" @@ -768,7 +823,7 @@ TIPS # Set comment to the CSV amount1 (not the amount1 assigned above) comment %amount1 - Here, since there's no CSV amount1 field, %amount1 will produce a lit- + Here, since there's no CSV amount1 field, %amount1 will produce a lit- eral "amount1": fields date,description,csvamount @@ -776,7 +831,7 @@ TIPS # Can't interpolate amount1 here comment %amount1 - When there are multiple field assignments to the same hledger field, + When there are multiple field assignments to the same hledger field, only the last one takes effect. Here, comment's value will be be B, or C if "something" is matched, but never A: @@ -786,14 +841,14 @@ TIPS comment C How CSV rules are evaluated - Here's how to think of CSV rules being evaluated (if you really need + Here's how to think of CSV rules being evaluated (if you really need to). First, - o include - all includes are inlined, from top to bottom, depth first. - (At each include point the file is inlined and scanned for further + o include - all includes are inlined, from top to bottom, depth first. + (At each include point the file is inlined and scanned for further includes, recursively, before proceeding.) - Then "global" rules are evaluated, top to bottom. If a rule is re- + Then "global" rules are evaluated, top to bottom. If a rule is re- peated, the last one wins: o skip (at top level) @@ -807,30 +862,30 @@ TIPS Then for each CSV record in turn: - o test all if blocks. If any of them contain a end rule, skip all re- - maining CSV records. Otherwise if any of them contain a skip rule, - skip that many CSV records. If there are multiple matched skip + o test all if blocks. If any of them contain a end rule, skip all re- + maining CSV records. Otherwise if any of them contain a skip rule, + skip that many CSV records. If there are multiple matched skip rules, the first one wins. - o collect all field assignments at top level and in matched if blocks. - When there are multiple assignments for a field, keep only the last + o collect all field assignments at top level and in matched if blocks. + When there are multiple assignments for a field, keep only the last one. - o compute a value for each hledger field - either the one that was as- + o compute a value for each hledger field - either the one that was as- signed to it (and interpolate the %CSVFIELDNAME references), or a de- fault o generate a synthetic hledger transaction from these values. - This is all part of the CSV reader, one of several readers hledger can - use to parse input files. When all files have been read successfully, - the transactions are passed as input to whichever hledger command the + This is all part of the CSV reader, one of several readers hledger can + use to parse input files. When all files have been read successfully, + the transactions are passed as input to whichever hledger command the user specified. REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel + Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel or hledger mail list) @@ -844,7 +899,7 @@ COPYRIGHT SEE ALSO - hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1), + hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1), hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time- dot(5), ledger(1) diff --git a/hledger/Hledger/Cli/Commands/Print.txt b/hledger/Hledger/Cli/Commands/Print.txt index ec521a26e..9ad7e46b8 100644 --- a/hledger/Hledger/Cli/Commands/Print.txt +++ b/hledger/Hledger/Cli/Commands/Print.txt @@ -72,7 +72,7 @@ reordered. See also the import command. This command also supports the output destination and output format options The output formats supported are txt, csv, and (experimental) -json. +json and sql. Here's an example of print's CSV output: diff --git a/hledger/hledger.1 b/hledger/hledger.1 index 5b82219a2..248a646ea 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -1070,7 +1070,8 @@ $ hledger print -o - # write to stdout (the default) Some commands (print, register, the balance commands) offer a choice of output format. In addition to the usual plain text format (\f[C]txt\f[R]), there are -CSV (\f[C]csv\f[R]), HTML (\f[C]html\f[R]) and JSON (\f[C]json\f[R]). +CSV (\f[C]csv\f[R]), HTML (\f[C]html\f[R]), JSON (\f[C]json\f[R]) and +SQL (\f[C]sql\f[R]). This is controlled by the \f[C]-O/--output-format\f[R] option: .IP .nf @@ -1119,6 +1120,20 @@ your control. We hope this approach will not cause problems in practice; if you find otherwise, please let us know. (Cf #1195) +.PP +Notes about SQL output: +.IP \[bu] 2 +SQL output is also marked experimental, and much like JSON could use +real-world feedback. +.IP \[bu] 2 +SQL output is expected to work with sqlite, MySQL and PostgreSQL +.IP \[bu] 2 +SQL output is structured with the expectations that statements will be +executed in the empty database. +If you already have tables created via SQL output of hledger, you would +probably want to either clear tables of existing data (via +\f[C]delete\f[R] or \f[C]truncate\f[R] SQL statements) or drop tables +completely as otherwise your postings will be duped. .SS Regular expressions .PP hledger uses regular expressions in a number of places: @@ -3763,7 +3778,7 @@ See also the import command. .PP This command also supports the output destination and output format options The output formats supported are \f[C]txt\f[R], \f[C]csv\f[R], -and (experimental) \f[C]json\f[R]. +and (experimental) \f[C]json\f[R] and \f[C]sql\f[R]. .PP Here\[aq]s an example of print\[aq]s CSV output: .IP diff --git a/hledger/hledger.info b/hledger/hledger.info index 188adfc93..bcd3c5303 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -1007,8 +1007,8 @@ File: hledger.info, Node: Output format, Next: Regular expressions, Prev: Out 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') and JSON ('json'). This is -controlled by the '-O/--output-format' option: +there are CSV ('csv'), HTML ('html'), JSON ('json') and SQL ('sql'). +This is controlled by the '-O/--output-format' option: $ hledger print -O csv @@ -1039,6 +1039,20 @@ $ hledger balancesheet -o foo.txt -O html # write HTML to foo.txt 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: + + * SQL output is also marked experimental, and much like JSON could + use real-world feedback. + + * SQL output is expected to work with sqlite, MySQL and PostgreSQL + + * SQL output is structured with the expectations that statements will + be executed in the empty database. If you already have tables + created 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. +  File: hledger.info, Node: Regular expressions, Next: Smart dates, Prev: Output format, Up: OPTIONS @@ -3192,7 +3206,7 @@ reordered. See also the import command. This command also supports the output destination and output format options The output formats supported are 'txt', 'csv', and -(experimental) 'json'. +(experimental) 'json' and 'sql'. Here's an example of print's CSV output: @@ -3902,153 +3916,153 @@ Node: Output destination32183 Ref: #output-destination32335 Node: Output format32760 Ref: #output-format32910 -Node: Regular expressions34492 -Ref: #regular-expressions34649 -Node: Smart dates36385 -Ref: #smart-dates36536 -Node: Report start & end date37897 -Ref: #report-start-end-date38069 -Node: Report intervals39566 -Ref: #report-intervals39731 -Node: Period expressions40121 -Ref: #period-expressions40281 -Node: Depth limiting44417 -Ref: #depth-limiting44561 -Node: Pivoting44893 -Ref: #pivoting45016 -Node: Valuation46692 -Ref: #valuation46794 -Node: -B Cost47483 -Ref: #b-cost47587 -Node: -V Value47720 -Ref: #v-value47866 -Node: -X Value in specified commodity48061 -Ref: #x-value-in-specified-commodity48260 -Node: Valuation date48409 -Ref: #valuation-date48577 -Node: Market prices48987 -Ref: #market-prices49167 -Node: --infer-value market prices from transactions49944 -Ref: #infer-value-market-prices-from-transactions50193 -Node: Valuation commodity51475 -Ref: #valuation-commodity51684 -Node: Simple valuation examples52910 -Ref: #simple-valuation-examples53112 -Node: --value Flexible valuation53771 -Ref: #value-flexible-valuation53979 -Node: More valuation examples55926 -Ref: #more-valuation-examples56135 -Node: Effect of valuation on reports58140 -Ref: #effect-of-valuation-on-reports58328 -Node: COMMANDS63849 -Ref: #commands63957 -Node: accounts65041 -Ref: #accounts65139 -Node: activity65838 -Ref: #activity65948 -Node: add66331 -Ref: #add66430 -Node: balance69169 -Ref: #balance69280 -Node: Classic balance report70738 -Ref: #classic-balance-report70911 -Node: Customising the classic balance report72280 -Ref: #customising-the-classic-balance-report72508 -Node: Colour support74584 -Ref: #colour-support74751 -Node: Flat mode74924 -Ref: #flat-mode75072 -Node: Depth limited balance reports75485 -Ref: #depth-limited-balance-reports75670 -Node: Percentages76126 -Ref: #percentages76292 -Node: Multicolumn balance report77429 -Ref: #multicolumn-balance-report77609 -Node: Budget report82871 -Ref: #budget-report83014 -Node: Nested budgets88280 -Ref: #nested-budgets88392 -Ref: #output-format-191873 -Node: balancesheet92070 -Ref: #balancesheet92206 -Node: balancesheetequity93672 -Ref: #balancesheetequity93821 -Node: cashflow94544 -Ref: #cashflow94672 -Node: check-dates95851 -Ref: #check-dates95978 -Node: check-dupes96257 -Ref: #check-dupes96381 -Node: close96674 -Ref: #close96788 -Node: close usage98310 -Ref: #close-usage98403 -Node: commodities101216 -Ref: #commodities101343 -Node: descriptions101425 -Ref: #descriptions101553 -Node: diff101734 -Ref: #diff101840 -Node: files102887 -Ref: #files102987 -Node: help103134 -Ref: #help103234 -Node: import104315 -Ref: #import104429 -Node: Importing balance assignments105322 -Ref: #importing-balance-assignments105470 -Node: incomestatement106119 -Ref: #incomestatement106252 -Node: notes107739 -Ref: #notes107852 -Node: payees107978 -Ref: #payees108084 -Node: prices108242 -Ref: #prices108348 -Node: print108689 -Ref: #print108799 -Node: print-unique113585 -Ref: #print-unique113711 -Node: register113996 -Ref: #register114123 -Node: Custom register output118295 -Ref: #custom-register-output118424 -Node: register-match119761 -Ref: #register-match119895 -Node: rewrite120246 -Ref: #rewrite120361 -Node: Re-write rules in a file122216 -Ref: #re-write-rules-in-a-file122350 -Node: Diff output format123560 -Ref: #diff-output-format123729 -Node: rewrite vs print --auto124821 -Ref: #rewrite-vs.-print---auto125000 -Node: roi125556 -Ref: #roi125654 -Node: stats126666 -Ref: #stats126765 -Node: tags127553 -Ref: #tags127651 -Node: test127945 -Ref: #test128053 -Node: Add-on commands128800 -Ref: #add-on-commands128917 -Node: ui130260 -Ref: #ui130348 -Node: web130402 -Ref: #web130505 -Node: iadd130621 -Ref: #iadd130732 -Node: interest130814 -Ref: #interest130921 -Node: ENVIRONMENT131161 -Ref: #environment131273 -Node: FILES132102 -Ref: #files-1132205 -Node: LIMITATIONS132418 -Ref: #limitations132537 -Node: TROUBLESHOOTING133279 -Ref: #troubleshooting133392 +Node: Regular expressions35077 +Ref: #regular-expressions35234 +Node: Smart dates36970 +Ref: #smart-dates37121 +Node: Report start & end date38482 +Ref: #report-start-end-date38654 +Node: Report intervals40151 +Ref: #report-intervals40316 +Node: Period expressions40706 +Ref: #period-expressions40866 +Node: Depth limiting45002 +Ref: #depth-limiting45146 +Node: Pivoting45478 +Ref: #pivoting45601 +Node: Valuation47277 +Ref: #valuation47379 +Node: -B Cost48068 +Ref: #b-cost48172 +Node: -V Value48305 +Ref: #v-value48451 +Node: -X Value in specified commodity48646 +Ref: #x-value-in-specified-commodity48845 +Node: Valuation date48994 +Ref: #valuation-date49162 +Node: Market prices49572 +Ref: #market-prices49752 +Node: --infer-value market prices from transactions50529 +Ref: #infer-value-market-prices-from-transactions50778 +Node: Valuation commodity52060 +Ref: #valuation-commodity52269 +Node: Simple valuation examples53495 +Ref: #simple-valuation-examples53697 +Node: --value Flexible valuation54356 +Ref: #value-flexible-valuation54564 +Node: More valuation examples56511 +Ref: #more-valuation-examples56720 +Node: Effect of valuation on reports58725 +Ref: #effect-of-valuation-on-reports58913 +Node: COMMANDS64434 +Ref: #commands64542 +Node: accounts65626 +Ref: #accounts65724 +Node: activity66423 +Ref: #activity66533 +Node: add66916 +Ref: #add67015 +Node: balance69754 +Ref: #balance69865 +Node: Classic balance report71323 +Ref: #classic-balance-report71496 +Node: Customising the classic balance report72865 +Ref: #customising-the-classic-balance-report73093 +Node: Colour support75169 +Ref: #colour-support75336 +Node: Flat mode75509 +Ref: #flat-mode75657 +Node: Depth limited balance reports76070 +Ref: #depth-limited-balance-reports76255 +Node: Percentages76711 +Ref: #percentages76877 +Node: Multicolumn balance report78014 +Ref: #multicolumn-balance-report78194 +Node: Budget report83456 +Ref: #budget-report83599 +Node: Nested budgets88865 +Ref: #nested-budgets88977 +Ref: #output-format-192458 +Node: balancesheet92655 +Ref: #balancesheet92791 +Node: balancesheetequity94257 +Ref: #balancesheetequity94406 +Node: cashflow95129 +Ref: #cashflow95257 +Node: check-dates96436 +Ref: #check-dates96563 +Node: check-dupes96842 +Ref: #check-dupes96966 +Node: close97259 +Ref: #close97373 +Node: close usage98895 +Ref: #close-usage98988 +Node: commodities101801 +Ref: #commodities101928 +Node: descriptions102010 +Ref: #descriptions102138 +Node: diff102319 +Ref: #diff102425 +Node: files103472 +Ref: #files103572 +Node: help103719 +Ref: #help103819 +Node: import104900 +Ref: #import105014 +Node: Importing balance assignments105907 +Ref: #importing-balance-assignments106055 +Node: incomestatement106704 +Ref: #incomestatement106837 +Node: notes108324 +Ref: #notes108437 +Node: payees108563 +Ref: #payees108669 +Node: prices108827 +Ref: #prices108933 +Node: print109274 +Ref: #print109384 +Node: print-unique114180 +Ref: #print-unique114306 +Node: register114591 +Ref: #register114718 +Node: Custom register output118890 +Ref: #custom-register-output119019 +Node: register-match120356 +Ref: #register-match120490 +Node: rewrite120841 +Ref: #rewrite120956 +Node: Re-write rules in a file122811 +Ref: #re-write-rules-in-a-file122945 +Node: Diff output format124155 +Ref: #diff-output-format124324 +Node: rewrite vs print --auto125416 +Ref: #rewrite-vs.-print---auto125595 +Node: roi126151 +Ref: #roi126249 +Node: stats127261 +Ref: #stats127360 +Node: tags128148 +Ref: #tags128246 +Node: test128540 +Ref: #test128648 +Node: Add-on commands129395 +Ref: #add-on-commands129512 +Node: ui130855 +Ref: #ui130943 +Node: web130997 +Ref: #web131100 +Node: iadd131216 +Ref: #iadd131327 +Node: interest131409 +Ref: #interest131516 +Node: ENVIRONMENT131756 +Ref: #environment131868 +Node: FILES132697 +Ref: #files-1132800 +Node: LIMITATIONS133013 +Ref: #limitations133132 +Node: TROUBLESHOOTING133874 +Ref: #troubleshooting133987  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index eaf70da4d..f48551390 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -853,8 +853,8 @@ OPTIONS 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) and JSON (json). This is controlled by the - -O/--output-format option: + are CSV (csv), HTML (html), JSON (json) and SQL (sql). This is con- + trolled by the -O/--output-format option: $ hledger print -O csv @@ -886,61 +886,74 @@ OPTIONS 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 + 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 + clear tables of existing data (via delete or truncate SQL statements) + or drop tables completely as otherwise your postings will be duped. + Regular expressions hledger uses regular expressions in a number of places: - o query terms, on the command line and in the hledger-web search form: + o query terms, on the command line and in the hledger-web search form: REGEX, desc:REGEX, cur:REGEX, tag:...=REGEX o CSV rules conditional blocks: if REGEX ... - o account alias directives and options: alias /REGEX/ = REPLACEMENT, + o account alias directives and options: alias /REGEX/ = REPLACEMENT, --alias /REGEX/=REPLACEMENT - hledger's regular expressions come from the regex-tdfa library. If - they're not doing what you expect, it's important to know exactly what + hledger's regular expressions come from the regex-tdfa library. If + they're not doing what you expect, it's important to know exactly what they support: 1. they are case insensitive - 2. they are infix matching (they do not need to match the entire thing + 2. they are infix matching (they do not need to match the entire thing being matched) 3. they are POSIX ERE (extended regular expressions) 4. they also support GNU word boundaries (\b, \B, \<, \>) - 5. they do not support backreferences; if you write \1, it will match - the digit 1. Except when doing text replacement, eg in account - aliases, where backreferences can be used in the replacement string + 5. they do not support backreferences; if you write \1, it will match + the digit 1. Except when doing text replacement, eg in account + aliases, where backreferences can be used in the replacement string to reference capturing groups in the search regexp. - 6. they do not support mode modifiers ((?s)), character classes (\w, + 6. they do not support mode modifiers ((?s)), character classes (\w, \d), or anything else not mentioned above. Some things to note: - o In the alias directive and --alias option, regular expressions must - be enclosed in forward slashes (/REGEX/). Elsewhere in hledger, + o In the alias directive and --alias option, regular expressions must + be enclosed in forward slashes (/REGEX/). Elsewhere in hledger, these are not required. - o In queries, to match a regular expression metacharacter like $ as a - literal character, prepend a backslash. Eg to search for amounts + o In queries, to match a regular expression metacharacter like $ as a + literal character, prepend a backslash. Eg to search for amounts with the dollar sign in hledger-web, write cur:\$. - o On the command line, some metacharacters like $ have a special mean- + o On the command line, some metacharacters like $ have a special mean- ing to the shell and so must be escaped at least once more. See Spe- cial characters. Smart dates hledger's user interfaces accept a flexible "smart date" syntax (unlike - dates in the journal file). Smart dates allow some english words, can - be relative to today's date, and can have less-significant date parts + dates in the journal file). Smart dates allow some english words, can + be relative to today's date, and can have less-significant date parts omitted (defaulting to 1). Examples: - 2004/10/1, 2004-01-01, exact date, several separators allowed. Year + 2004/10/1, 2004-01-01, exact date, several separators allowed. Year 2004.9.1 is 4+ digits, month is 1-12, day is 1-31 2004 start of year 2004/10 start of month @@ -955,48 +968,49 @@ OPTIONS 20181201 8 digit YYYYMMDD with valid year month and day 201812 6 digit YYYYMM with valid year and month - Counterexamples - malformed digit sequences might give surprising re- + Counterexamples - malformed digit sequences might give surprising re- sults: - 201813 6 digits with an invalid month is parsed as start of + 201813 6 digits with an invalid month is parsed as start of 6-digit year - 20181301 8 digits with an invalid month is parsed as start of + 20181301 8 digits with an invalid month is parsed as start of 8-digit year 20181232 8 digits with an invalid day gives an error 201801012 9+ digits beginning with a valid YYYYMMDD gives an error Report start & end date - Most hledger reports show the full span of time represented by the + Most hledger reports show the full span of time represented by the journal data, by default. So, the effective report start and end dates - will be the earliest and latest transaction or posting dates found in + will be the earliest and latest transaction or posting dates found in the journal. - Often you will want to see a shorter time span, such as the current - month. You can specify a start and/or end date using -b/--begin, + Often you will want to see a shorter time span, such as the current + month. You can specify a start and/or end date using -b/--begin, -e/--end, -p/--period or a date: query (described below). All of these accept the smart date syntax. Some notes: - o As in Ledger, end dates are exclusive, so you need to write the date + o As in Ledger, end dates are exclusive, so you need to write the date after the last day you want to include. - o As noted in reporting options: among start/end dates specified with + o As noted in reporting options: among start/end dates specified with options, the last (i.e. right-most) option takes precedence. - o The effective report start and end dates are the intersection of the - start/end dates from options and that from date: queries. That is, - date:2019-01 date:2019 -p'2000 to 2030' yields January 2019, the + o The effective report start and end dates are the intersection of the + start/end dates from options and that from date: queries. That is, + date:2019-01 date:2019 -p'2000 to 2030' yields January 2019, the smallest common time span. Examples: -b 2016/3/17 begin on St. Patrick's day 2016 - -e 12/1 end at the start of december 1st of the current year + -e 12/1 end at the start of december 1st of the current year (11/30 will be the last date included) + -b thismonth all transactions on or after the 1st of the current month -p thismonth all transactions in the current month - date:2016/3/17.. the above written as queries instead (.. can also be re- + date:2016/3/17.. the above written as queries instead (.. can also be re- placed with -) date:..12/1 date:thismonth.. @@ -1004,31 +1018,31 @@ OPTIONS Report intervals A report interval can be specified so that commands like register, bal- - ance and activity will divide their reports into multiple subperiods. - The basic intervals can be selected with one of -D/--daily, - -W/--weekly, -M/--monthly, -Q/--quarterly, or -Y/--yearly. More com- - plex intervals may be specified with a period expression. Report in- + ance and activity will divide their reports into multiple subperiods. + The basic intervals can be selected with one of -D/--daily, + -W/--weekly, -M/--monthly, -Q/--quarterly, or -Y/--yearly. More com- + plex intervals may be specified with a period expression. Report in- tervals can not be specified with a query. Period expressions - The -p/--period option accepts period expressions, a shorthand way of + The -p/--period option accepts period expressions, a shorthand way of expressing a start date, end date, and/or report interval all at once. - Here's a basic period expression specifying the first quarter of 2009. - Note, hledger always treats start dates as inclusive and end dates as + Here's a basic period expression specifying the first quarter of 2009. + Note, hledger always treats start dates as inclusive and end dates as exclusive: -p "from 2009/1/1 to 2009/4/1" - Keywords like "from" and "to" are optional, and so are the spaces, as - long as you don't run two dates together. "to" can also be written as + Keywords like "from" and "to" are optional, and so are the spaces, as + long as you don't run two dates together. "to" can also be written as ".." or "-". These are equivalent to the above: -p "2009/1/1 2009/4/1" -p2009/1/1to2009/4/1 -p2009/1/1..2009/4/1 - Dates are smart dates, so if the current year is 2009, the above can + Dates are smart dates, so if the current year is 2009, the above can also be written as: -p "1/1 4/1" @@ -1042,64 +1056,62 @@ OPTIONS 1, 2009 -p "from 2009/1" the same -p "from 2009" the same - -p "to 2009" everything before january + -p "to 2009" everything before january 1, 2009 - A single date with no "from" or "to" defines both the start and end + A single date with no "from" or "to" defines both the start and end date like so: - -p "2009" the year 2009; equivalent + -p "2009" the year 2009; equivalent to "2009/1/1 to 2010/1/1" - -p "2009/1" the month of jan; equiva- + -p "2009/1" the month of jan; equiva- lent to "2009/1/1 to 2009/2/1" - -p "2009/1/1" just that day; equivalent + -p "2009/1/1" just that day; equivalent to "2009/1/1 to 2009/1/2" - The argument of -p can also begin with, or be, a report interval ex- + The argument of -p can also begin with, or be, a report interval ex- pression. The basic report intervals are daily, weekly, monthly, quar- - terly, or yearly, which have the same effect as the -D,-W,-M,-Q, or -Y - flags. Between report interval and start/end dates (if any), the word + terly, or yearly, which have the same effect as the -D,-W,-M,-Q, or -Y + flags. Between report interval and start/end dates (if any), the word in is optional. Examples: -p "weekly from 2009/1/1 to 2009/4/1" -p "monthly in 2008" -p "quarterly" - Note that weekly, monthly, quarterly and yearly intervals will always + Note that weekly, monthly, quarterly and yearly intervals will always start on the first day on week, month, quarter or year accordingly, and - will end on the last day of same period, even if associated period ex- + will end on the last day of same period, even if associated period ex- pression specifies different explicit start and end date. For example: - -p "weekly from 2009/1/1 starts on 2008/12/29, closest preceding Mon- + -p "weekly from 2009/1/1 starts on 2008/12/29, closest preceding Mon- to 2009/4/1" day - - - -p "monthly in starts on 2018/11/01 + -p "monthly in starts on 2018/11/01 2008/11/25" - -p "quarterly from starts on 2009/04/01, ends on 2009/06/30, + -p "quarterly from starts on 2009/04/01, ends on 2009/06/30, 2009-05-05 to 2009-06-01" which are first and last days of Q2 2009 -p "yearly from starts on 2009/01/01, first day of 2009 2009-12-29" - The following more complex report intervals are also supported: bi- + The following more complex report intervals are also supported: bi- weekly, bimonthly, every day|week|month|quarter|year, every N days|weeks|months|quarters|years. - All of these will start on the first day of the requested period and + All of these will start on the first day of the requested period and end on the last one, as described above. Examples: - -p "bimonthly from 2008" periods will have boundaries on 2008/01/01, + -p "bimonthly from 2008" periods will have boundaries on 2008/01/01, 2008/03/01, ... -p "every 2 weeks" starts on closest preceding Monday - -p "every 5 month from periods will have boundaries on 2009/03/01, + -p "every 5 month from periods will have boundaries on 2009/03/01, 2009/03" 2009/08/01, ... - If you want intervals that start on arbitrary day of your choosing and + If you want intervals that start on arbitrary day of your choosing and span a week, month or year, you need to use any of the following: every Nth day of week, every , every Nth day [of month], every @@ -1111,42 +1123,42 @@ OPTIONS -p "every 2nd day of periods will go from Tue to Tue week" -p "every Tue" same - -p "every 15th day" period boundaries will be on 15th of each + -p "every 15th day" period boundaries will be on 15th of each month - -p "every 2nd Monday" period boundaries will be on second Monday of + -p "every 2nd Monday" period boundaries will be on second Monday of each month -p "every 11/05" yearly periods with boundaries on 5th of Nov -p "every 5th Nov" same -p "every Nov 5th" same - Show historical balances at end of 15th each month (N is exclusive end + Show historical balances at end of 15th each month (N is exclusive end date): hledger balance -H -p "every 16th day" - Group postings from start of wednesday to end of next tuesday (N is + Group postings from start of wednesday to end of next tuesday (N is start date and exclusive end date): hledger register checking -p "every 3rd day of week" Depth limiting With the --depth N option (short form: -N), commands like account, bal- - ance and register will show only the uppermost accounts in the account - tree, down to level N. Use this when you want a summary with less de- + ance and register will show only the uppermost accounts in the account + tree, down to level N. Use this when you want a summary with less de- tail. This flag has the same effect as a depth: query argument (so -2, --depth=2 or depth:2 are equivalent). 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. @@ -1172,7 +1184,7 @@ OPTIONS -------------------- 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=. @@ -1180,7 +1192,7 @@ OPTIONS -------------------- -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:. @@ -1189,56 +1201,56 @@ OPTIONS -2 EUR Valuation - Instead of reporting amounts in their original commodity, hledger can + Instead of reporting amounts in their original commodity, hledger can convert them to cost/sale amount (using the conversion rate recorded in the transaction), or to market value (using some market price on a cer- tain date). This is controlled by the --value=TYPE[,COMMODITY] option, - but we also provide the simpler -B/-V/-X flags, and usually one of + but we also provide the simpler -B/-V/-X flags, and usually one of those is all you need. -B: Cost - The -B/--cost flag converts amounts to their cost or sale amount at + The -B/--cost flag converts amounts to their cost or sale amount at transaction time, if they have a transaction price specified. -V: Value - The -V/--market flag converts amounts to market value in their default + The -V/--market flag converts amounts to market value in their default valuation commodity, using the market prices in effect on the valuation date(s), if any. More on these in a minute. -X: Value in specified commodity The -X/--exchange=COMM option is like -V, except you tell it which cur- - rency you want to convert to, and it tries to convert everything to + rency you want to convert to, and it tries to convert everything to that. Valuation date - Since market prices can change from day to day, market value reports + Since market prices can change from day to day, market value reports have a valuation date (or more than one), which determines which market prices will be used. For single period reports, if an explicit report end date is specified, - that will be used as the valuation date; otherwise the valuation date + that will be used as the valuation date; otherwise the valuation date is "today". - For multiperiod reports, each column/period is valued on the last day + For multiperiod reports, each column/period is valued on the last day of the period. Market prices (experimental) - To convert a commodity A to its market value in another commodity B, - hledger looks for a suitable market price (exchange rate) as follows, + To convert a commodity A to its market value in another commodity B, + hledger looks for a suitable market price (exchange rate) as follows, in this order of preference : - 1. A declared market price or inferred market price: A's latest market + 1. A declared market price or inferred market price: A's latest market price in B on or before the valuation date as declared by a P direc- - tive, or (if the --infer-value flag is used) inferred from transac- + tive, or (if the --infer-value flag is used) inferred from transac- tion prices. 2. A reverse market price: the inverse of a declared or inferred market price from B to A. - 3. A chained market price: a synthetic price formed by combining the - shortest chain of market prices (any of the above types) leading + 3. A chained market price: a synthetic price formed by combining the + shortest chain of market prices (any of the above types) leading from A to B. Amounts for which no applicable market price can be found, are not con- @@ -1249,17 +1261,17 @@ OPTIONS 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. @@ -1267,45 +1279,45 @@ OPTIONS 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 (experimental) 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 @@ -1332,7 +1344,7 @@ OPTIONS $ 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 @@ -1353,36 +1365,36 @@ OPTIONS 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- + 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. --value=end - Convert amounts to their value in the default valuation commod- - ity, using market prices on the last day of the report period - (or if unspecified, the journal's end date); or in multiperiod + Convert amounts to their value in the default valuation commod- + ity, using market prices on the last day of the report period + (or if unspecified, the journal's end date); or in multiperiod reports, market prices on the last day of each subperiod. --value=now - Convert amounts to their value in the default valuation commod- - ity using current market prices (as of when report is gener- + Convert amounts to their value in the default valuation commod- + ity using current market prices (as of when report is gener- ated). --value=YYYY-MM-DD - Convert amounts to their value in the default valuation commod- + Convert amounts to their value in the default valuation commod- ity using market prices on this date. To select a different valuation commodity, add the optional ,COMM part: - a comma, then the target commodity's symbol. Eg: --value=now,EUR. + a comma, then the target commodity's symbol. Eg: --value=now,EUR. hledger will do its best to convert amounts to this commodity, deducing market prices as described above. More valuation examples - Here are some examples showing the effect of --value, as seen with + Here are some examples showing the effect of --value, as seen with print: P 2000-01-01 A 1 B @@ -1420,7 +1432,7 @@ OPTIONS 2000-02-01 (a) 2 B - With no report period specified, that shows the value as of the last + With no report period specified, that shows the value as of the last day of the journal (2000-03-01): $ hledger -f- print --value=end @@ -1457,7 +1469,7 @@ OPTIONS 2000-03-01 (a) 1 B - You may need to explicitly set a commodity's display style, when re- + You may need to explicitly set a commodity's display style, when re- verse prices are used. Eg this output might be surprising: P 2000-01-01 A 2B @@ -1471,10 +1483,10 @@ OPTIONS a 0 b 0 - Explanation: because there's no amount or commodity directive specify- - ing a display style for A, 0.5A gets the default style, which shows no + Explanation: because there's no amount or commodity directive specify- + ing a display style for A, 0.5A gets the default style, which shows no decimal digits. Because the displayed amount looks like zero, the com- - modity symbol and minus sign are not displayed either. Adding a com- + modity symbol and minus sign are not displayed either. Adding a com- modity directive sets a more useful display style for A: P 2000-01-01 A 2B @@ -1490,9 +1502,9 @@ OPTIONS b -0.50A Effect of valuation on reports - Here is a reference for how valuation is supposed to affect each part - of hledger's reports (and a glossary). (It's wide, you'll have to - scroll sideways.) It may be useful when troubleshooting. If you find + Here is a reference for how valuation is supposed to affect each part + of hledger's reports (and a glossary). (It's wide, you'll have to + scroll sideways.) It may be useful when troubleshooting. If you find problems, please report them, ideally with a reproducible example. Re- lated: #329, #1083. @@ -1501,7 +1513,7 @@ OPTIONS ------------------------------------------------------------------------------------------ print posting cost value at re- value at value at re- value at - amounts port end or posting date port or DATE/today + amounts port end or posting date port or DATE/today today journal end balance as- unchanged unchanged unchanged unchanged unchanged sertions / @@ -1514,10 +1526,10 @@ OPTIONS journal journal start start posting cost value at re- value at value at re- value at - amounts (no port end or posting date port or DATE/today + amounts (no port end or posting date port or DATE/today report in- today journal end terval) - summary summarised value at pe- sum of post- value at pe- value at + 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 inter- @@ -1530,7 +1542,7 @@ OPTIONS bse, cf, is..) balances (no sums of value at re- not supported value at re- value at - report in- costs port end or port or DATE/today of + report in- costs port end or port or DATE/today of terval) today of journal end sums of post- sums of of sums of ings postings postings @@ -1546,15 +1558,19 @@ OPTIONS budget like bal- like bal- not supported like bal- like balances amounts with ances ances ances --budget - grand total sum of dis- sum of dis- not supported sum of dis- sum of dis- + grand total sum of dis- sum of dis- not supported sum of dis- sum of dis- (no report played val- played val- played val- played values interval) ues ues ues + + + + row to- sums/aver- sums/aver- not supported sums/aver- sums/averages tals/aver- ages of dis- ages of dis- ages of dis- of displayed ages (with played val- played val- played val- values report in- ues ues ues terval) - column to- sums of dis- sums of dis- not supported sums of dis- sums of dis- + column to- sums of dis- sums of dis- not supported sums of dis- sums of dis- tals played val- played val- played val- played values ues ues ues grand to- sum/average sum/average not supported sum/average sum/average @@ -1566,60 +1582,60 @@ OPTIONS 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). COMMANDS - hledger provides a number of subcommands; hledger with no arguments + hledger provides a number of subcommands; hledger with no arguments shows a list. If you install additional hledger-* packages, or if you put programs or - scripts named hledger-NAME in your PATH, these will also be listed as + scripts named hledger-NAME in your PATH, these will also be listed as subcommands. - Run a subcommand by writing its name as first argument (eg hledger in- - comestatement). You can also write one of the standard short aliases - displayed in parentheses in the command list (hledger b), or any any + Run a subcommand by writing its name as first argument (eg hledger in- + comestatement). You can also write one of the standard short aliases + displayed in parentheses in the command list (hledger b), or any any unambiguous prefix of a command name (hledger inc). - Here are all the builtin commands in alphabetical order. See also - hledger for a more organised command list, and hledger CMD -h for de- + Here are all the builtin commands in alphabetical order. See also + hledger for a more organised command list, and hledger CMD -h for de- tailed command help. accounts accounts, a 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: @@ -1638,8 +1654,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: @@ -1654,22 +1670,22 @@ COMMANDS add Prompt for transactions and add them to the journal. - 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. @@ -1677,10 +1693,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. @@ -1689,7 +1705,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): @@ -1719,8 +1735,8 @@ 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 - file path ends with a period, as it can cause data loss on that plat- + On Microsoft Windows, the add command makes sure that no part of the + file path ends with a period, as it can cause data loss on that plat- form (cf #1056). balance @@ -1728,29 +1744,29 @@ 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). The balance command can produce several styles of report: Classic balance report - This is the original balance report, as found in Ledger. It usually + This is the original balance report, as found in Ledger. It usually looks like this: $ hledger balance @@ -1768,22 +1784,22 @@ COMMANDS 0 By default, accounts are displayed hierarchically, with subaccounts in- - dented below their parent. At each level of the tree, accounts are - sorted by account code if any, then by account name. Or with + dented below their parent. At each level of the tree, accounts are + sorted by account code if any, then by account name. Or with -S/--sort-amount, by their balance amount. "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 + 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 are "inclusive" - they include the balances of any + Account balances are "inclusive" - they include the balances of any subaccounts. - Accounts which have zero balance (and no non-zero subaccounts) are + 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 + A final total is displayed by default; use -N/--no-total to suppress it, eg: $ hledger balance -p 2008/6 expenses --no-total @@ -1792,7 +1808,7 @@ COMMANDS $1 supplies Customising the classic balance report - You can customise the layout of classic balance reports with --format + You can customise the layout of classic balance reports with --format FMT: $ hledger balance --format "%20(account) %12(total)" @@ -1810,7 +1826,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) @@ -1821,14 +1837,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) @@ -1845,14 +1861,14 @@ 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 @@ -1863,9 +1879,9 @@ COMMANDS o the output is not being redirected or piped anywhere 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 + 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. @@ -1874,8 +1890,8 @@ COMMANDS $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 + 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. $ hledger balance -N -1 @@ -1888,9 +1904,9 @@ COMMANDS inclusive balances at the depth limit. 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 + 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: $ hledger balance expenses -% @@ -1900,32 +1916,32 @@ COMMANDS -------------------- 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- + 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 + 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- + 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. 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- + 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. - There are three types of multicolumn balance report, showing different + 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 + the account's change of balance in that period. This is useful eg for a monthly income statement: $ hledger balance --quarterly income expenses -E @@ -1941,7 +1957,7 @@ COMMANDS || $-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 + riod, accumulating the changes across periods, starting from 0 at the report start date: $ hledger balance --quarterly income expenses -E --cumulative @@ -1957,8 +1973,8 @@ 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 + 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: @@ -1977,26 +1993,26 @@ 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; + 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 + 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- ods will be "full" and comparable to the others. - The -E/--empty flag does two things in multicolumn balance reports: + The -E/--empty flag does two things in multicolumn balance reports: first, the report will show all columns within the specified report pe- - riod (without -E, leading and trailing columns with all zeroes are not - shown). Second, all accounts which existed at the report start date - will be considered, not just the ones with activity during the report - period (use -E to include low-activity accounts which would otherwise + riod (without -E, leading and trailing columns with all zeroes are not + shown). Second, all accounts which existed at the report start date + will be considered, not just the ones with activity during the report + period (use -E to include low-activity accounts which would otherwise would be omitted). The -T/--row-total flag adds an additional column showing the total for each row. - The -A/--average flag adds a column showing the average value in each + The -A/--average flag adds a column showing the average value in each row. Here's an example of all three: @@ -2017,21 +2033,21 @@ COMMANDS (Average is rounded to the dollar here since all journal amounts are) - A limitation of multicolumn balance reports: eliding of boring parent - accounts in tree mode, as in the classic balance report, is not yet + A limitation of multicolumn balance reports: eliding of boring parent + accounts in tree mode, as in the classic balance report, is not yet supported. - The --transpose flag can be used to exchange the rows and columns of a + The --transpose flag can be used to exchange the rows and columns of a multicolumn report. Budget report - With --budget, extra columns are displayed showing budget goals for - each account and period, if any. Budget goals are defined by periodic + With --budget, extra columns are displayed showing budget goals for + each account and period, if any. Budget goals are defined by periodic transactions. This is very useful for comparing planned and actual in- - come, expenses, time usage, etc. --budget is most often combined with + come, expenses, time usage, etc. --budget is most often combined with a report interval. - For example, you can take average monthly expenses in the common ex- + For example, you can take average monthly expenses in the common ex- pense categories to construct a minimal monthly budget: ;; Budget @@ -2078,26 +2094,26 @@ COMMANDS This is different from a normal balance report in several ways: - o Only accounts with budget goals during the report period are shown, + o Only accounts with budget goals during the report period are shown, by default. - o In each column, in square brackets after the actual amount, budget - goal amounts are shown, and the actual/goal percentage. (Note: bud- + o In each column, in square brackets after the actual amount, budget + goal amounts are shown, and the actual/goal percentage. (Note: bud- get goals should be in the same commodity as the actual amount.) - o All parent accounts are always shown, even in flat mode. Eg assets, + o All parent accounts are always shown, even in flat mode. Eg assets, assets:bank, and expenses above. - o Amounts always include all subaccounts, budgeted or unbudgeted, even + o Amounts always include all subaccounts, budgeted or unbudgeted, even in flat mode. This means that the numbers displayed will not always add up! Eg above, - the expenses actual amount includes the gifts and supplies transac- - tions, but the expenses:gifts and expenses:supplies accounts are not + the expenses actual amount includes the gifts and supplies transac- + tions, but the expenses:gifts and expenses:supplies accounts are not shown, as they have no budget amounts declared. - This can be confusing. When you need to make things clearer, use the - -E/--empty flag, which will reveal all accounts including unbudgeted + This can be confusing. When you need to make things clearer, use the + -E/--empty flag, which will reveal all accounts including unbudgeted ones, giving the full picture. Eg: $ hledger balance -M --budget --empty @@ -2139,12 +2155,12 @@ COMMANDS For more examples, see Budgeting and Forecasting. Nested budgets - You can add budgets to any account in your account hierarchy. If you + You can add budgets to any account in your account hierarchy. If you have budgets on both parent account and some of its children, then bud- - get(s) of the child account(s) would be added to the budget of their + get(s) of the child account(s) would be added to the budget of their parent, much like account balances behave. - In the most simple case this means that once you add a budget to any + In the most simple case this means that once you add a budget to any account, all its parents would have budget as well. To illustrate this, consider the following budget: @@ -2154,13 +2170,13 @@ COMMANDS expenses:personal:electronics $100.00 liabilities - With this, monthly budget for electronics is defined to be $100 and - budget for personal expenses is an additional $1000, which implicitly + With this, monthly budget for electronics is defined to be $100 and + budget for personal expenses is an additional $1000, which implicitly means that budget for both expenses:personal and expenses is $1100. - Transactions in expenses:personal:electronics will be counted both to- + Transactions in expenses:personal:electronics will be counted both to- wards its $100 budget and $1100 of expenses:personal , and transactions - in any other subaccount of expenses:personal would be counted towards + in any other subaccount of expenses:personal would be counted towards only towards the budget of expenses:personal. For example, let's consider these transactions: @@ -2186,9 +2202,9 @@ COMMANDS expenses:personal $30.00 liabilities - As you can see, we have transactions in expenses:personal:electron- - ics:upgrades and expenses:personal:train tickets, and since both of - these accounts are without explicitly defined budget, these transac- + As you can see, we have transactions in expenses:personal:electron- + ics:upgrades and expenses:personal:train tickets, and since both of + these accounts are without explicitly defined budget, these transac- tions would be counted towards budgets of expenses:personal:electronics and expenses:personal accordingly: @@ -2204,7 +2220,7 @@ COMMANDS -------------------------------++------------------------------- || 0 [ 0] - And with --empty, we can get a better picture of budget allocation and + And with --empty, we can get a better picture of budget allocation and consumption: $ hledger balance --budget -M --empty @@ -2223,17 +2239,17 @@ COMMANDS Output format This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, (multicolumn non-bud- + tions The output formats supported are txt, csv, (multicolumn non-bud- get reports only) html, and (experimental) json. balancesheet balancesheet, bs This command displays a simple balance sheet, showing historical ending - balances of asset and liability accounts (ignoring any report begin - date). It assumes that these accounts are under a top-level asset or + balances of asset and liability accounts (ignoring any report begin + date). It assumes that these accounts are under a top-level asset or liability account (case insensitive, plural forms also allowed). - Note this report shows all account balances with normal positive sign + Note this report shows all account balances with normal positive sign (like conventional financial statements, unlike balance/print/register) (experimental). @@ -2259,21 +2275,21 @@ COMMANDS 0 With a reporting interval, multiple columns will be shown, one for each - report period. As with multicolumn balance reports, you can alter the - report mode with --change/--cumulative/--historical. Normally bal- - ancesheet shows historical ending balances, which is what you need for - a balance sheet; note this means it ignores report begin dates (and - -T/--row-total, since summing end balances generally does not make - sense). Instead of absolute values percentages can be displayed with + report period. As with multicolumn balance reports, you can alter the + report mode with --change/--cumulative/--historical. Normally bal- + ancesheet shows historical ending balances, which is what you need for + a balance sheet; note this means it ignores report begin dates (and + -T/--row-total, since summing end balances generally does not make + sense). Instead of absolute 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. balancesheetequity balancesheetequity, bse - Just like balancesheet, but also reports Equity (which it assumes is + Just like balancesheet, but also reports Equity (which it assumes is under a top-level equity account). Example: @@ -2303,15 +2319,15 @@ COMMANDS 0 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. cashflow cashflow, cf - This command displays a simple cashflow statement, showing changes in - "cash" accounts. It assumes that these accounts are under a top-level - asset account (case insensitive, plural forms also allowed) and do not - contain receivable or A/R in their name. Note this report shows all + This command displays a simple cashflow statement, showing changes in + "cash" accounts. It assumes that these accounts are under a top-level + asset account (case insensitive, plural forms also allowed) and do not + contain receivable or A/R in their name. Note this report shows all account balances with normal positive sign (like conventional financial statements, unlike balance/print/register) (experimental). @@ -2332,90 +2348,90 @@ COMMANDS $-1 With a reporting interval, multiple columns will be shown, one for each - report period. Normally cashflow shows changes in assets per period, - though as with multicolumn balance reports you can alter the report + report period. Normally cashflow shows changes in assets per period, + though as with multicolumn balance reports you can alter the report mode with --change/--cumulative/--historical. Instead of absolute val- ues 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. check-dates check-dates - Check that transactions are sorted by increasing date. With --date2, - checks secondary dates instead. With --strict, dates must also be - unique. With a query, only matched transactions' dates are checked. + Check that transactions are sorted by increasing date. With --date2, + checks secondary dates instead. With --strict, dates must also be + unique. With a query, only matched transactions' dates are checked. Reads the default journal file, or another specified with -f. check-dupes check-dupes - Reports account names having the same leaf but different prefixes. In - other words, two or more leaves that are categorized differently. + Reports account names having the same leaf but different prefixes. In + other words, two or more leaves that are categorized differently. Reads the default journal file, or another specified as an argument. An example: http://stefanorodighiero.net/software/hledger-dupes.html 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: @@ -2470,18 +2486,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. @@ -2499,20 +2515,20 @@ 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 any of the hledger manuals. - The help command displays any of the main hledger manuals, in one of - several ways. Run it with no argument to list the manuals, or provide + The help command displays any of the main hledger manuals, in one of + several ways. Run it with no argument to list the manuals, or provide a full or partial manual name to select one. - hledger manuals are available in several formats. hledger help will - use the first of these display methods that it finds: info, man, - $PAGER, less, stdout (or when non-interactive, just stdout). You can + hledger manuals are available in several formats. hledger help will + use the first of these display methods that it finds: info, man, + $PAGER, less, stdout (or when non-interactive, just stdout). You can force a particular viewer with the --info, --man, --pager, --cat flags. Examples: @@ -2539,9 +2555,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 @@ -2552,36 +2568,36 @@ 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.) incomestatement incomestatement, is - This command displays a simple income statement, showing revenues and - expenses during a period. It assumes that these accounts are under a - top-level revenue or income or expense account (case insensitive, plu- - ral forms also allowed). Note this report shows all account balances - with normal positive sign (like conventional financial statements, un- + This command displays a simple income statement, showing revenues and + expenses during a period. It assumes that these accounts are under a + top-level revenue or income or expense account (case insensitive, plu- + ral forms also allowed). Note this report shows all account balances + with normal positive sign (like conventional financial statements, un- like balance/print/register) (experimental). - This command displays a simple income statement. It currently assumes - that you have top-level accounts named income (or revenue) and expense + This command displays a simple income statement. It currently assumes + that you have top-level accounts named income (or revenue) and expense (plural forms also allowed.) $ hledger incomestatement @@ -2606,13 +2622,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 @@ -2640,10 +2656,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 @@ -2651,11 +2667,11 @@ COMMANDS Show transaction journal entries, sorted by date. The print command displays full journal entries (transactions) from the - journal file in date order, tidily formatted. With --date2, transac- + journal file in date order, tidily formatted. With --date2, transac- tions are sorted by secondary date instead. print's output is always a valid hledger journal. - It preserves all transaction information, but it does not preserve di- + It preserves all transaction information, but it does not preserve di- rectives or inter-transaction comments $ hledger print @@ -2682,44 +2698,44 @@ COMMANDS Normally, the journal entry's explicit or implicit amount style is pre- served. For example, when an amount is omitted in the journal, it will - not appear in the output. Similarly, when a 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) - json. + tions The output formats supported are txt, csv, and (experimental) + json and sql. Here's an example of print's CSV output: @@ -2737,20 +2753,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 @@ -2774,7 +2790,7 @@ COMMANDS Show postings and their running total. The register command displays postings in date order, one per line, and - their running total. This is typically used with a query selecting a + their running total. This is typically used with a query selecting a particular account, to see that account's activity: $ hledger register checking @@ -2785,8 +2801,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 @@ -2796,18 +2812,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 @@ -2819,7 +2835,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 @@ -2836,7 +2852,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 @@ -2844,17 +2860,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): @@ -2873,27 +2889,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: @@ -2909,7 +2925,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: @@ -2919,16 +2935,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. @@ -2943,7 +2959,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. @@ -2956,12 +2972,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' @@ -2985,10 +3001,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: @@ -2996,48 +3012,48 @@ 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. - It 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, + It 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. stats 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: @@ -3055,14 +3071,14 @@ 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 all the tag names used in the journal. With a TAGREGEX argument, - only tag names matching the regular expression (case insensitive) are - shown. With QUERY arguments, only transactions matching the query are + List all the tag names used in the journal. With a TAGREGEX argument, + only tag names matching the regular expression (case insensitive) are + shown. With QUERY arguments, only transactions matching the query are considered. With --values flag, the tags' unique values are listed in- stead. @@ -3070,13 +3086,13 @@ COMMANDS 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 -- @@ -3085,35 +3101,35 @@ 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). Add-on commands - hledger also searches for external add-on commands, and will include + hledger also searches for external add-on commands, and will include these in the commands list. These are programs or scripts in your PATH - whose name starts with hledger- and ends with a recognised file exten- + whose name starts with hledger- and ends with a recognised file exten- sion (currently: no extension, bat,com,exe, hs,lhs,pl,py,rb,rkt,sh). - Add-ons can be invoked like any hledger command, but there are a few + Add-ons can be invoked like any hledger command, but there are a few things to be aware of. Eg if the hledger-web add-on is installed, - o hledger -h web shows hledger's help, while hledger web -h shows + o hledger -h web shows hledger's help, while hledger web -h shows hledger-web's help. - o Flags specific to the add-on must have a preceding -- to hide them - from hledger. So hledger web --serve --port 9000 will be rejected; + o Flags specific to the add-on must have a preceding -- to hide them + from hledger. So hledger web --serve --port 9000 will be rejected; you must use hledger web -- --serve --port 9000. o You can always run add-ons directly if preferred: hledger-web --serve --port 9000. - 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 (and - haskell) library functions that built-in commands do, for command-line + 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 (and + haskell) library functions that built-in commands do, for command-line options, journal parsing, reporting, etc. - Two important add-ons are the hledger-ui and hledger-web user inter- + Two important add-ons are the hledger-ui and hledger-web user inter- faces. These are maintained and released along with hledger: ui @@ -3132,23 +3148,23 @@ COMMANDS hledger-interest generates interest transactions for an account accord- ing to various schemes. - A few more experimental or old add-ons can be found in hledger's bin/ + A few more experimental or old add-ons can be found in hledger's bin/ directory. These are typically prototypes and not guaranteed to work. ENVIRONMENT - COLUMNS The screen width used by the register command. Default: the + COLUMNS The screen width used by the register command. Default: the full terminal width. LEDGER_FILE The journal file path when not specified with -f. Default: - ~/.hledger.journal (on windows, perhaps C:/Users/USER/.hledger.jour- + ~/.hledger.journal (on windows, perhaps C:/Users/USER/.hledger.jour- nal). - A typical value is ~/DIR/YYYY.journal, where DIR is a version-con- - trolled finance directory and YYYY is the current year. Or ~/DIR/cur- + A typical value is ~/DIR/YYYY.journal, where DIR is a version-con- + trolled finance directory and YYYY is the current year. Or ~/DIR/cur- rent.journal, where current.journal is a symbolic link to YYYY.journal. On Mac computers, you can set this and other environment variables in a - more thorough way that also affects applications started from the GUI + more thorough way that also affects applications started from the GUI (say, an Emacs dock icon). Eg on MacOS Catalina I have a ~/.MacOSX/en- vironment.plist file containing @@ -3159,13 +3175,13 @@ ENVIRONMENT To see the effect you may need to killall Dock, or reboot. FILES - Reads data from one or more files in hledger journal, timeclock, time- - dot, or CSV format specified with -f, or $LEDGER_FILE, or - $HOME/.hledger.journal (on windows, perhaps + Reads data from one or more files in hledger journal, timeclock, time- + dot, or CSV format specified with -f, or $LEDGER_FILE, or + $HOME/.hledger.journal (on windows, perhaps C:/Users/USER/.hledger.journal). LIMITATIONS - The need to precede addon command options with -- when invoked from + The need to precede addon command options with -- when invoked from hledger is awkward. When input data contains non-ascii characters, a suitable system locale @@ -3181,36 +3197,36 @@ LIMITATIONS In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger add. - Not all of Ledger's journal file syntax is supported. See file format + Not all of Ledger's journal file syntax is supported. See file format differences. - On large data files, hledger is slower and uses more memory than + On large data files, hledger is slower and uses more memory than Ledger. TROUBLESHOOTING - Here are some issues you might encounter when you run hledger (and re- - member you can also seek help from the IRC channel, mail list or bug + Here are some issues you might encounter when you run hledger (and re- + member you can also seek help from the IRC channel, mail list or bug tracker): Successfully installed, but "No command 'hledger' found" stack and cabal install binaries into a special directory, which should - be added to your PATH environment variable. Eg on unix-like systems, + be added to your PATH environment variable. Eg on unix-like systems, that is ~/.local/bin and ~/.cabal/bin respectively. I set a custom LEDGER_FILE, but hledger is still using the default file - LEDGER_FILE should be a real environment variable, not just a shell - variable. The command env | grep LEDGER_FILE should show it. You may + LEDGER_FILE should be a real environment variable, not just a shell + variable. The command env | grep LEDGER_FILE should show it. You may need to use export. Here's an explanation. - Getting errors like "Illegal byte sequence" or "Invalid or incomplete - multibyte or wide character" or "commitAndReleaseBuffer: invalid argu- + Getting errors like "Illegal byte sequence" or "Invalid or incomplete + multibyte or wide character" or "commitAndReleaseBuffer: invalid argu- ment (invalid character)" Programs compiled with GHC (hledger, haskell build tools, etc.) need to have a UTF-8-aware locale configured in the environment, otherwise they - will fail with these kinds of errors when they encounter non-ascii + will fail with these kinds of errors when they encounter non-ascii characters. - To fix it, set the LANG environment variable to some locale which sup- + To fix it, set the LANG environment variable to some locale which sup- ports UTF-8. The locale you choose must be installed on your system. Here's an example of setting LANG temporarily, on Ubuntu GNU/Linux: @@ -3225,8 +3241,8 @@ TROUBLESHOOTING POSIX $ LANG=en_US.utf8 hledger -f my.journal print # ensure it is used for this command - If available, C.UTF-8 will also work. If your preferred locale isn't - listed by locale -a, you might need to install it. Eg on Ubuntu/De- + If available, C.UTF-8 will also work. If your preferred locale isn't + listed by locale -a, you might need to install it. Eg on Ubuntu/De- bian: $ apt-get install language-pack-fr @@ -3246,8 +3262,8 @@ TROUBLESHOOTING $ echo "export LANG=en_US.utf8" >>~/.bash_profile $ bash --login - Exact spelling and capitalisation may be important. Note the differ- - ence on MacOS (UTF-8, not utf8). Some platforms (eg ubuntu) allow + Exact spelling and capitalisation may be important. Note the differ- + ence on MacOS (UTF-8, not utf8). Some platforms (eg ubuntu) allow variant spellings, but others (eg macos) require it to be exact: $ locale -a | grep -iE en_us.*utf @@ -3257,7 +3273,7 @@ TROUBLESHOOTING REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel + Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel or hledger mail list) @@ -3271,7 +3287,7 @@ COPYRIGHT SEE ALSO - hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1), + hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1), hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time- dot(5), ledger(1)