diff --git a/hledger-lib/defs.m4 b/hledger-lib/defs.m4 index d83314ca0..bdd331d09 100644 --- a/hledger-lib/defs.m4 +++ b/hledger-lib/defs.m4 @@ -4,4 +4,4 @@ m4_dnl Program version. Updated by make setversion. m4_define({{_version_}}, {{1.17.99}})m4_dnl m4_dnl m4_dnl Date to show in man pages. Updated by make setdate. -m4_define({{_monthyear_}}, {{March 2020}})m4_dnl +m4_define({{_monthyear_}}, {{May 2020}})m4_dnl diff --git a/hledger-lib/hledger_csv.5 b/hledger-lib/hledger_csv.5 index 6234be684..5066de42c 100644 --- a/hledger-lib/hledger_csv.5 +++ b/hledger-lib/hledger_csv.5 @@ -1,6 +1,6 @@ .\"t -.TH "hledger_csv" "5" "March 2020" "hledger 1.17.99" "hledger User Manuals" +.TH "hledger_csv" "5" "May 2020" "hledger 1.17.99" "hledger User Manuals" @@ -19,7 +19,7 @@ file\f[R]. By default this is named like the CSV file with a \f[C].rules\f[R] extension added. Eg when reading \f[C]FILE.csv\f[R], hledger also looks for -\f[C]FILE.csv.rules\f[R] in the same directory. +\f[C]FILE.csv.rules\f[R] in the same directory as \f[C]FILE.csv\f[R]. You can specify a different rules file with the \f[C]--rules-file\f[R] option. If a rules file is not found, hledger will create a sample rules file, @@ -489,8 +489,8 @@ transaction\[aq]s first line. .SS Posting field names .SS account .PP -\f[C]accountN\f[R], where N is 1 to 9, causes a posting to be generated, -with that account name. +\f[C]accountN\f[R], where N is 1 to 99, causes a posting to be +generated, with that account name. .PP Most often there are two postings, so you\[aq]ll want to set \f[C]account1\f[R] and \f[C]account2\f[R]. @@ -504,14 +504,30 @@ below), a default account name will be chosen (like .SS amount .PP \f[C]amountN\f[R] sets posting N\[aq]s amount. -If the CSV uses separate fields for debit and credit amounts, you can -use \f[C]amountN-in\f[R] and \f[C]amountN-out\f[R] instead. +If the CSV uses separate fields for inflows and outflows, you can use +\f[C]amountN-in\f[R] and \f[C]amountN-out\f[R] instead. +By assigning to \f[C]amount1\f[R], \f[C]amount2\f[R], ... +etc. +you can generate anywhere from 0 to 99 postings. .PP -Also, for compatibility with hledger <1.17: \f[C]amount\f[R] or -\f[C]amount-in\f[R]/\f[C]amount-out\f[R] with no number sets the amount -for postings 1 and 2. -For posting 2 the amount is negated, and converted to cost if -there\[aq]s a transaction price. +There is also an older, unnumbered form of these names, suitable for +2-posting transactions, which sets both posting 1\[aq]s and (negated) +posting 2\[aq]s amount: \f[C]amount\f[R], or \f[C]amount-in\f[R] and +\f[C]amount-out\f[R]. +This is still supported because it keeps pre-hledger-1.17 csv rules +files working, and because it can be more succinct, and because it +converts posting 2\[aq]s amount to cost if there\[aq]s a transaction +price, which can be useful. +.PP +If you have an existing rules file using the unnumbered form, you might +want to use the numbered form in certain conditional blocks, without +having to update and retest all the old rules. +To facilitate this, posting 1 ignores +\f[C]amount\f[R]/\f[C]amount-in\f[R]/\f[C]amount-out\f[R] if any of +\f[C]amount1\f[R]/\f[C]amount1-in\f[R]/\f[C]amount1-out\f[R] are +assigned, and posting 2 ignores them if any of +\f[C]amount2\f[R]/\f[C]amount2-in\f[R]/\f[C]amount2-out\f[R] are +assigned, avoiding conflicts. .SS currency .PP If the CSV has the currency symbol in a separate field (ie, not part of @@ -620,13 +636,19 @@ REGEX .PP REGEX is a case-insensitive regular expression which tries to match anywhere within the CSV record. -It is a POSIX extended regular expressions with some additions (see -Regular expressions in the hledger manual). -Note: the \[dq]CSV record\[dq] it is matched against is not the original -record, but a synthetic one, with enclosing double quotes or whitespace -removed, and always comma-separated. -(Eg, an SSV record \f[C]2020-01-01; \[dq]Acme, Inc.\[dq]; 1,000\f[R] -appears to REGEX as \f[C]2020-01-01,Acme, Inc.,1,000\f[R]). +It is a POSIX ERE (extended regular expression) that also supports GNU +word boundaries (\f[C]\[rs]b\f[R], \f[C]\[rs]B\f[R], \f[C]\[rs]<\f[R], +\f[C]\[rs]>\f[R]), and nothing else. +If you have trouble, be sure to check our +https://hledger.org/hledger.html#regular-expressions doc. +.PP +Important note: the record that is matched is not the original record, +but a synthetic one, with any enclosing double quotes (but not enclosing +whitespace) removed, and always comma-separated (which means that a +field containing a comma will appear like two fields). +Eg, if the original record is +\f[C]2020-01-01; \[dq]Acme, Inc.\[dq]; 1,000\f[R], the REGEX will +actually see \f[C]2020-01-01,Acme, Inc., 1,000\f[R]). .PP Or, MATCHER can be a field matcher, like this: .IP diff --git a/hledger-lib/hledger_csv.info b/hledger-lib/hledger_csv.info index 4bef60a39..2f3fa8c7d 100644 --- a/hledger-lib/hledger_csv.info +++ b/hledger-lib/hledger_csv.info @@ -16,9 +16,9 @@ CSV output.) We describe each CSV file's format with a corresponding _rules file_. By default this is named like the CSV file with a '.rules' extension added. Eg when reading 'FILE.csv', hledger also looks for -'FILE.csv.rules' in the same directory. You can specify a different -rules file with the '--rules-file' option. If a rules file is not -found, hledger will create a sample rules file, which you'll need to +'FILE.csv.rules' in the same directory as 'FILE.csv'. You can specify a +different rules file with the '--rules-file' option. If a rules file is +not found, hledger will create a sample rules file, which you'll need to adjust. This file contains rules describing the CSV data (header line, fields @@ -465,7 +465,7 @@ File: hledger_csv.info, Node: account, Next: amount, Up: Posting field names 2.2.2.1 account ............... -'accountN', where N is 1 to 9, causes a posting to be generated, with +'accountN', where N is 1 to 99, causes a posting to be generated, with that account name. Most often there are two postings, so you'll want to set 'account1' @@ -484,13 +484,25 @@ File: hledger_csv.info, Node: amount, Next: currency, Prev: account, Up: Pos .............. 'amountN' sets posting N's amount. If the CSV uses separate fields for -debit and credit amounts, you can use 'amountN-in' and 'amountN-out' -instead. +inflows and outflows, you can use 'amountN-in' and 'amountN-out' +instead. By assigning to 'amount1', 'amount2', ... etc. you can +generate anywhere from 0 to 99 postings. - Also, for compatibility with hledger <1.17: 'amount' or -'amount-in'/'amount-out' with no number sets the amount for postings 1 -and 2. For posting 2 the amount is negated, and converted to cost if -there's a transaction price. + There is also an older, unnumbered form of these names, suitable for +2-posting transactions, which sets both posting 1's and (negated) +posting 2's amount: 'amount', or 'amount-in' and 'amount-out'. This is +still supported because it keeps pre-hledger-1.17 csv rules files +working, and because it can be more succinct, and because it converts +posting 2's amount to cost if there's a transaction price, which can be +useful. + + If you have an existing rules file using the unnumbered form, you +might want to use the numbered form in certain conditional blocks, +without having to update and retest all the old rules. To facilitate +this, posting 1 ignores 'amount'/'amount-in'/'amount-out' if any of +'amount1'/'amount1-in'/'amount1-out' are assigned, and posting 2 ignores +them if any of 'amount2'/'amount2-in'/'amount2-out' are assigned, +avoiding conflicts.  File: hledger_csv.info, Node: currency, Next: balance, Prev: amount, Up: Posting field names @@ -599,13 +611,17 @@ descriptions. REGEX REGEX is a case-insensitive regular expression which tries to match -anywhere within the CSV record. It is a POSIX extended regular -expressions with some additions (see Regular expressions in the hledger -manual). Note: the "CSV record" it is matched against is not the -original record, but a synthetic one, with enclosing double quotes or -whitespace removed, and always comma-separated. (Eg, an SSV record -'2020-01-01; "Acme, Inc."; 1,000' appears to REGEX as '2020-01-01,Acme, -Inc.,1,000'). +anywhere within the CSV record. It is a POSIX ERE (extended regular +expression) that also supports GNU word boundaries ('\b', '\B', '\<', +'\>'), and nothing else. If you have trouble, be sure to check our +https://hledger.org/hledger.html#regular-expressions doc. + + Important note: the record that is matched is not the original +record, but a synthetic one, with any enclosing double quotes (but not +enclosing whitespace) removed, and always comma-separated (which means +that a field containing a comma will appear like two fields). Eg, if +the original record is '2020-01-01; "Acme, Inc."; 1,000', the REGEX will +actually see '2020-01-01,Acme, Inc., 1,000'). Or, MATCHER can be a field matcher, like this: @@ -1019,74 +1035,74 @@ command the user specified.  Tag Table: Node: Top72 -Node: EXAMPLES2099 -Ref: #examples2205 -Node: Basic2413 -Ref: #basic2513 -Node: Bank of Ireland3055 -Ref: #bank-of-ireland3190 -Node: Amazon4652 -Ref: #amazon4770 -Node: Paypal6489 -Ref: #paypal6583 -Node: CSV RULES14227 -Ref: #csv-rules14336 -Node: skip14612 -Ref: #skip14705 -Node: fields15080 -Ref: #fields15202 -Node: Transaction field names16367 -Ref: #transaction-field-names16527 -Node: Posting field names16638 -Ref: #posting-field-names16790 -Node: account16860 -Ref: #account16976 -Node: amount17512 -Ref: #amount17643 -Node: currency18024 -Ref: #currency18159 -Node: balance18365 -Ref: #balance18499 -Node: comment18816 -Ref: #comment18933 -Node: field assignment19096 -Ref: #field-assignment19239 -Node: separator20057 -Ref: #separator20186 -Node: if20597 -Ref: #if20699 -Node: end22618 -Ref: #end22724 -Node: date-format22948 -Ref: #date-format23080 -Node: newest-first23829 -Ref: #newest-first23967 -Node: include24650 -Ref: #include24779 -Node: balance-type25223 -Ref: #balance-type25343 -Node: TIPS26043 -Ref: #tips26125 -Node: Rapid feedback26381 -Ref: #rapid-feedback26498 -Node: Valid CSV26958 -Ref: #valid-csv27088 -Node: File Extension27280 -Ref: #file-extension27432 -Node: Reading multiple CSV files27842 -Ref: #reading-multiple-csv-files28027 -Node: Valid transactions28268 -Ref: #valid-transactions28446 -Node: Deduplicating importing29074 -Ref: #deduplicating-importing29253 -Node: Setting amounts30286 -Ref: #setting-amounts30455 -Node: Setting currency/commodity31441 -Ref: #setting-currencycommodity31633 -Node: Referencing other fields32436 -Ref: #referencing-other-fields32636 -Node: How CSV rules are evaluated33533 -Ref: #how-csv-rules-are-evaluated33706 +Node: EXAMPLES2113 +Ref: #examples2219 +Node: Basic2427 +Ref: #basic2527 +Node: Bank of Ireland3069 +Ref: #bank-of-ireland3204 +Node: Amazon4666 +Ref: #amazon4784 +Node: Paypal6503 +Ref: #paypal6597 +Node: CSV RULES14241 +Ref: #csv-rules14350 +Node: skip14626 +Ref: #skip14719 +Node: fields15094 +Ref: #fields15216 +Node: Transaction field names16381 +Ref: #transaction-field-names16541 +Node: Posting field names16652 +Ref: #posting-field-names16804 +Node: account16874 +Ref: #account16990 +Node: amount17527 +Ref: #amount17658 +Node: currency18765 +Ref: #currency18900 +Node: balance19106 +Ref: #balance19240 +Node: comment19557 +Ref: #comment19674 +Node: field assignment19837 +Ref: #field-assignment19980 +Node: separator20798 +Ref: #separator20927 +Node: if21338 +Ref: #if21440 +Node: end23596 +Ref: #end23702 +Node: date-format23926 +Ref: #date-format24058 +Node: newest-first24807 +Ref: #newest-first24945 +Node: include25628 +Ref: #include25757 +Node: balance-type26201 +Ref: #balance-type26321 +Node: TIPS27021 +Ref: #tips27103 +Node: Rapid feedback27359 +Ref: #rapid-feedback27476 +Node: Valid CSV27936 +Ref: #valid-csv28066 +Node: File Extension28258 +Ref: #file-extension28410 +Node: Reading multiple CSV files28820 +Ref: #reading-multiple-csv-files29005 +Node: Valid transactions29246 +Ref: #valid-transactions29424 +Node: Deduplicating importing30052 +Ref: #deduplicating-importing30231 +Node: Setting amounts31264 +Ref: #setting-amounts31433 +Node: Setting currency/commodity32419 +Ref: #setting-currencycommodity32611 +Node: Referencing other fields33414 +Ref: #referencing-other-fields33614 +Node: How CSV rules are evaluated34511 +Ref: #how-csv-rules-are-evaluated34684  End Tag Table diff --git a/hledger-lib/hledger_csv.txt b/hledger-lib/hledger_csv.txt index f1e90c2ea..2a0808dce 100644 --- a/hledger-lib/hledger_csv.txt +++ b/hledger-lib/hledger_csv.txt @@ -15,9 +15,9 @@ DESCRIPTION We describe each CSV file's format with a corresponding rules file. By default this is named like the CSV file with a .rules extension added. Eg when reading FILE.csv, hledger also looks for FILE.csv.rules in the - same directory. You can specify a different rules file with the - --rules-file option. If a rules file is not found, hledger will create - a sample rules file, which you'll need to adjust. + same directory as FILE.csv. You can specify a different rules file + with the --rules-file option. If a rules file is not found, hledger + will create a sample rules file, which you'll need to adjust. This file contains rules describing the CSV data (header line, fields layout, date format etc.), and how to construct hledger journal entries @@ -377,7 +377,7 @@ CSV RULES Posting field names account - accountN, where N is 1 to 9, causes a posting to be generated, with + accountN, where N is 1 to 99, causes a posting to be generated, with that account name. Most often there are two postings, so you'll want to set account1 and @@ -391,27 +391,38 @@ CSV RULES amount amountN sets posting N's amount. If the CSV uses separate fields for - debit and credit amounts, you can use amountN-in and amountN-out in- - stead. + inflows and outflows, you can use amountN-in and amountN-out instead. + By assigning to amount1, amount2, ... etc. you can generate anywhere + from 0 to 99 postings. - Also, for compatibility with hledger <1.17: amount or amount-in/amount- - out with no number sets the amount for postings 1 and 2. For posting 2 - the amount is negated, and converted to cost if there's a transaction - price. + There is also an older, unnumbered form of these names, suitable for + 2-posting transactions, which sets both posting 1's and (negated) post- + ing 2's amount: amount, or amount-in and amount-out. This is still + supported because it keeps pre-hledger-1.17 csv rules files working, + and because it can be more succinct, and because it converts posting + 2's amount to cost if there's a transaction price, which can be useful. + + If you have an existing rules file using the unnumbered form, you might + want to use the numbered form in certain conditional blocks, without + having to update and retest all the old rules. To facilitate this, + posting 1 ignores amount/amount-in/amount-out if any of + amount1/amount1-in/amount1-out are assigned, and posting 2 ignores them + if any of amount2/amount2-in/amount2-out are assigned, avoiding con- + flicts. currency If the CSV has the currency symbol in a separate field (ie, not part of - the amount field), you can use currencyN to prepend it to posting N's + the amount field), you can use currencyN to prepend it to posting N's amount. Or, currency with no number affects all postings. balance - balanceN sets a balance assertion amount (or if the posting amount is + balanceN sets a balance assertion amount (or if the posting amount is left empty, a balance assignment) on posting N. - Also, for compatibility with hledger <1.17: balance with no number is + Also, for compatibility with hledger <1.17: balance with no number is equivalent to balance1. - You can adjust the type of assertion/assignment with the balance-type + You can adjust the type of assertion/assignment with the balance-type rule (see below). comment @@ -423,11 +434,11 @@ CSV RULES field assignment HLEDGERFIELDNAME FIELDVALUE - Instead of or in addition to a fields list, you can use a "field as- - signment" rule to set the value of a single hledger field, by writing - its name (any of the standard hledger field names above) followed by a - text value. The value may contain interpolated CSV fields, referenced - by their 1-based position in the CSV record (%N), or by the name they + Instead of or in addition to a fields list, you can use a "field as- + signment" rule to set the value of a single hledger field, by writing + its name (any of the standard hledger field names above) followed by a + text value. The value may contain interpolated CSV fields, referenced + by their 1-based position in the CSV record (%N), or by the name they were given in the fields list (%CSVFIELDNAME). Some examples: # set the amount to the 4th CSV field, with " USD" appended @@ -436,18 +447,18 @@ CSV RULES # combine three fields to make a comment, containing note: and date: tags comment note: %somefield - %anotherfield, date: %1 - Interpolation strips outer whitespace (so a CSV value like " 1 " be- + Interpolation strips outer whitespace (so a CSV value like " 1 " be- comes 1 when interpolated) (#1051). See TIPS below for more about ref- erencing other fields. separator - You can use the separator directive to read other kinds of character- + You can use the separator directive to read other kinds of character- separated data. Eg to read SSV (Semicolon Separated Values), use: separator ; - The separator directive accepts exactly one single byte character as a - separator. To specify whitespace characters, you may use the special + The separator directive accepts exactly one single byte character as a + separator. To specify whitespace characters, you may use the special words TAB or SPACE. Eg to read TSV (Tab Separated Values), use: separator TAB @@ -465,21 +476,26 @@ CSV RULES RULE RULE - Conditional blocks ("if blocks") are a block of rules that are applied - only to CSV records which match certain patterns. They are often used + Conditional blocks ("if blocks") are a block of rules that are applied + only to CSV records which match certain patterns. They are often used for customising account names based on transaction descriptions. Each MATCHER can be a record matcher, which looks like this: REGEX - REGEX is a case-insensitive regular expression which tries to match - anywhere within the CSV record. It is a POSIX extended regular expres- - sions with some additions (see Regular expressions in the hledger man- - ual). Note: the "CSV record" it is matched against is not the original - record, but a synthetic one, with enclosing double quotes or whitespace - removed, and always comma-separated. (Eg, an SSV record 2020-01-01; - "Acme, Inc."; 1,000 appears to REGEX as 2020-01-01,Acme, Inc.,1,000). + REGEX is a case-insensitive regular expression which tries to match + anywhere within the CSV record. It is a POSIX ERE (extended regular + expression) that also supports GNU word boundaries (\b, \B, \<, \>), + and nothing else. If you have trouble, be sure to check our + https://hledger.org/hledger.html#regular-expressions doc. + + Important note: the record that is matched is not the original record, + but a synthetic one, with any enclosing double quotes (but not enclos- + ing whitespace) removed, and always comma-separated (which means that a + field containing a comma will appear like two fields). Eg, if the + original record is 2020-01-01; "Acme, Inc."; 1,000, the REGEX will ac- + tually see 2020-01-01,Acme, Inc., 1,000). Or, MATCHER can be a field matcher, like this: @@ -834,4 +850,4 @@ SEE ALSO -hledger 1.17.99 March 2020 hledger_csv(5) +hledger 1.17.99 May 2020 hledger_csv(5) diff --git a/hledger-lib/hledger_journal.5 b/hledger-lib/hledger_journal.5 index 51588d2a3..003f9ea1a 100644 --- a/hledger-lib/hledger_journal.5 +++ b/hledger-lib/hledger_journal.5 @@ -1,6 +1,6 @@ .\"t -.TH "hledger_journal" "5" "March 2020" "hledger 1.17.99" "hledger User Manuals" +.TH "hledger_journal" "5" "May 2020" "hledger 1.17.99" "hledger User Manuals" @@ -63,7 +63,8 @@ a comment (any remaining text following a semicolon until end of line, and any following indented lines beginning with a semicolon) .IP \[bu] 2 0 or more indented \f[I]posting\f[R] lines, describing what was -transferred and the accounts involved. +transferred and the accounts involved (indented comment lines are also +allowed, but not blank lines or non-indented lines). .PP Here\[aq]s a simple journal file containing one transaction: .IP @@ -409,7 +410,7 @@ amount. This makes it easy to write account names containing spaces. But if you accidentally leave only one space (or tab) before the amount, the amount will be considered part of the account name. -.SS Virtual Postings +.SS Virtual postings .PP A posting with a parenthesised account name is called a \f[I]virtual posting\f[R] or \f[I]unbalanced posting\f[R], which means it is exempt @@ -504,9 +505,9 @@ be enclosed in double quotes: \f[R] .fi .PP -Amounts can be negative. -The minus sign can be written before or after a left-side commodity -symbol: +Amounts can be preceded by a minus sign (or a plus sign, though plus is +the default), The sign can be written before or after a left-side +commodity symbol: .IP .nf \f[C] @@ -515,6 +516,16 @@ $-1 \f[R] .fi .PP +One or more spaces between the sign and the number are acceptable when +parsing (but they won\[aq]t be displayed in output): +.IP +.nf +\f[C] ++ $1 +$- 1 +\f[R] +.fi +.PP Scientific E notation is allowed: .IP .nf @@ -586,7 +597,7 @@ the commodity, that format is used (see examples above). Otherwise the format of the first posting amount in that commodity seen in the journal is used. But the number of decimal places (\[dq]precision\[dq]) will be the -maximum from all posting amounts in that commmodity. +maximum from all posting amounts in that commodity. .IP \[bu] 2 Or if there are no such amounts in the journal, a default format is used (like \f[C]$1000.00\f[R]). @@ -659,9 +670,10 @@ hledger infer the price that balances the transaction: \f[R] .fi .RE -.PP -(Ledger users: Ledger uses a different syntax for fixed prices, -\f[C]{=UNITPRICE}\f[R], which hledger currently ignores). +.IP "5." 3 +Like 1 and 2, but the \f[C]\[at]\f[R] or \f[C]\[at]\[at]\f[R] is +parenthesised; this is for compatibility with Ledger journals (Virtual +posting costs), and in hledger is equivalent to 1 and 2. .PP Use the \f[C]-B/--cost\f[R] flag to convert amounts to their transaction price\[aq]s commodity, if any. @@ -700,7 +712,18 @@ $ hledger bal -N --flat -B \[Eu]100 assets:euros \f[R] .fi -.SS Balance Assertions +.SS Lot prices and lot dates +.PP +Ledger allows another kind of price, lot price (four variants: +\f[C]{UNITPRICE}\f[R], \f[C]{{TOTALPRICE}}\f[R], +\f[C]{=FIXEDUNITPRICE}\f[R], \f[C]{{=FIXEDTOTALPRICE}}\f[R]), and/or a +lot date (\f[C][DATE]\f[R]) to be specified. +These are normally used to select a lot when selling investments. +hledger will parse these, for compatibility with Ledger journals, but +currently ignores them. +A transaction price, lot price and/or lot date may appear in any order, +after the posting amount and before the balance assertion if any. +.SS Balance assertions .PP hledger supports Ledger-style balance assertions in journal files. These look like, for example, \f[C]= EXPECTEDBALANCE\f[R] following a @@ -856,7 +879,7 @@ always what is shown by reports. Eg a commodity directive may limit the display precision, but this will not affect balance assertions. Balance assertion failure messages show exact amounts. -.SS Balance Assignments +.SS Balance assignments .PP Ledger-style balance assignments are also supported. These are like balance assertions, but with no posting amount on the @@ -1237,7 +1260,7 @@ D $1,000.00 b \f[R] .fi -.SS Market prices +.SS Declaring market prices .PP The \f[C]P\f[R] directive declares a market price, which is an exchange rate between two commodities on a certain date. @@ -1270,8 +1293,9 @@ P 2010/1/1 \[Eu] $1.40 \f[R] .fi .PP -The \f[C]-V/--value\f[R] flag can be used to convert reported amounts to -another commodity using these prices. +The \f[C]-V\f[R], \f[C]-X\f[R] and \f[C]--value\f[R] flags use these +market prices to show amount values in another commodity. +See Valuation. .SS Declaring accounts .PP \f[C]account\f[R] directives can be used to pre-declare accounts. diff --git a/hledger-lib/hledger_journal.info b/hledger-lib/hledger_journal.info index 90eccfd6d..754ab8f55 100644 --- a/hledger-lib/hledger_journal.info +++ b/hledger-lib/hledger_journal.info @@ -62,7 +62,8 @@ optional fields, separated by spaces: * a comment (any remaining text following a semicolon until end of line, and any following indented lines beginning with a semicolon) * 0 or more indented _posting_ lines, describing what was transferred - and the accounts involved. + and the accounts involved (indented comment lines are also allowed, + but not blank lines or non-indented lines). Here's a simple journal file containing one transaction: @@ -81,8 +82,9 @@ optional fields, separated by spaces: * Account names:: * Amounts:: * Transaction prices:: -* Balance Assertions:: -* Balance Assignments:: +* Lot prices and lot dates:: +* Balance assertions:: +* Balance assignments:: * Directives:: * Periodic transactions:: * Auto postings:: @@ -377,12 +379,12 @@ the amount, the amount will be considered part of the account name. * Menu: -* Virtual Postings:: +* Virtual postings::  -File: hledger_journal.info, Node: Virtual Postings, Up: Postings +File: hledger_journal.info, Node: Virtual postings, Up: Postings -1.6.1 Virtual Postings +1.6.1 Virtual postings ---------------------- A posting with a parenthesised account name is called a _virtual @@ -459,12 +461,19 @@ must be enclosed in double quotes: 3 "no. 42 green apples" - Amounts can be negative. The minus sign can be written before or -after a left-side commodity symbol: + Amounts can be preceded by a minus sign (or a plus sign, though plus +is the default), The sign can be written before or after a left-side +commodity symbol: -$1 $-1 + One or more spaces between the sign and the number are acceptable +when parsing (but they won't be displayed in output): + ++ $1 +$- 1 + Scientific E notation is allowed: 1E-6 @@ -529,7 +538,7 @@ as written). The display style is chosen as follows: * Otherwise the format of the first posting amount in that commodity seen in the journal is used. But the number of decimal places ("precision") will be the maximum from all posting amounts in that - commmodity. + commodity. * Or if there are no such amounts in the journal, a default format is used (like '$1000.00'). @@ -550,7 +559,7 @@ hledger 1.17.1 this could vary if hledger happened to be built with an old version of Decimal (<0.5.1); since 1.17.1 it's guaranteed.)  -File: hledger_journal.info, Node: Transaction prices, Next: Balance Assertions, Prev: Amounts, Up: Transactions +File: hledger_journal.info, Node: Transaction prices, Next: Lot prices and lot dates, Prev: Amounts, Up: Transactions 1.9 Transaction prices ====================== @@ -584,8 +593,9 @@ certain date. assets:euros €100 ; one hundred euros purchased assets:dollars $-135 ; for $135 - (Ledger users: Ledger uses a different syntax for fixed prices, -'{=UNITPRICE}', which hledger currently ignores). + 4. 5. Like 1 and 2, but the '@' or '@@' is parenthesised; this is for + compatibility with Ledger journals (Virtual posting costs), and in + hledger is equivalent to 1 and 2. Use the '-B/--cost' flag to convert amounts to their transaction price's commodity, if any. (mnemonic: "B" is from "cost Basis", as in @@ -613,9 +623,24 @@ $ hledger bal -N --flat -B €100 assets:euros  -File: hledger_journal.info, Node: Balance Assertions, Next: Balance Assignments, Prev: Transaction prices, Up: Transactions +File: hledger_journal.info, Node: Lot prices and lot dates, Next: Balance assertions, Prev: Transaction prices, Up: Transactions -1.10 Balance Assertions +1.10 Lot prices and lot dates +============================= + +Ledger allows another kind of price, lot price (four variants: +'{UNITPRICE}', '{{TOTALPRICE}}', '{=FIXEDUNITPRICE}', +'{{=FIXEDTOTALPRICE}}'), and/or a lot date ('[DATE]') to be specified. +These are normally used to select a lot when selling investments. +hledger will parse these, for compatibility with Ledger journals, but +currently ignores them. A transaction price, lot price and/or lot date +may appear in any order, after the posting amount and before the balance +assertion if any. + + +File: hledger_journal.info, Node: Balance assertions, Next: Balance assignments, Prev: Lot prices and lot dates, Up: Transactions + +1.11 Balance assertions ======================= hledger supports Ledger-style balance assertions in journal files. @@ -651,9 +676,9 @@ does not disable balance assignments, below). * Assertions and precision::  -File: hledger_journal.info, Node: Assertions and ordering, Next: Assertions and included files, Up: Balance Assertions +File: hledger_journal.info, Node: Assertions and ordering, Next: Assertions and included files, Up: Balance assertions -1.10.1 Assertions and ordering +1.11.1 Assertions and ordering ------------------------------ hledger sorts an account's postings and assertions first by date and @@ -670,9 +695,9 @@ control over the order of postings and assertions within a day, so you can assert intra-day balances.  -File: hledger_journal.info, Node: Assertions and included files, Next: Assertions and multiple -f options, Prev: Assertions and ordering, Up: Balance Assertions +File: hledger_journal.info, Node: Assertions and included files, Next: Assertions and multiple -f options, Prev: Assertions and ordering, Up: Balance assertions -1.10.2 Assertions and included files +1.11.2 Assertions and included files ------------------------------------ With included files, things are a little more complicated. Including @@ -682,18 +707,18 @@ and you also want to assert the account's balance on the same day, you'll have to put the assertion in the right file.  -File: hledger_journal.info, Node: Assertions and multiple -f options, Next: Assertions and commodities, Prev: Assertions and included files, Up: Balance Assertions +File: hledger_journal.info, Node: Assertions and multiple -f options, Next: Assertions and commodities, Prev: Assertions and included files, Up: Balance assertions -1.10.3 Assertions and multiple -f options +1.11.3 Assertions and multiple -f options ----------------------------------------- Balance assertions don't work well across files specified with multiple -f options. Use include or concatenate the files instead.  -File: hledger_journal.info, Node: Assertions and commodities, Next: Assertions and prices, Prev: Assertions and multiple -f options, Up: Balance Assertions +File: hledger_journal.info, Node: Assertions and commodities, Next: Assertions and prices, Prev: Assertions and multiple -f options, Up: Balance assertions -1.10.4 Assertions and commodities +1.11.4 Assertions and commodities --------------------------------- The asserted balance must be a simple single-commodity amount, and in @@ -739,9 +764,9 @@ commodity into its own subaccount: a:euro 0 == 1€  -File: hledger_journal.info, Node: Assertions and prices, Next: Assertions and subaccounts, Prev: Assertions and commodities, Up: Balance Assertions +File: hledger_journal.info, Node: Assertions and prices, Next: Assertions and subaccounts, Prev: Assertions and commodities, Up: Balance assertions -1.10.5 Assertions and prices +1.11.5 Assertions and prices ---------------------------- Balance assertions ignore transaction prices, and should normally be @@ -757,9 +782,9 @@ to generate balance assertions with prices), and because balance _assignments_ do use them (see below).  -File: hledger_journal.info, Node: Assertions and subaccounts, Next: Assertions and virtual postings, Prev: Assertions and prices, Up: Balance Assertions +File: hledger_journal.info, Node: Assertions and subaccounts, Next: Assertions and virtual postings, Prev: Assertions and prices, Up: Balance assertions -1.10.6 Assertions and subaccounts +1.11.6 Assertions and subaccounts --------------------------------- The balance assertions above ('=' and '==') do not count the balance @@ -774,9 +799,9 @@ eg: checking 1 ==* 11  -File: hledger_journal.info, Node: Assertions and virtual postings, Next: Assertions and precision, Prev: Assertions and subaccounts, Up: Balance Assertions +File: hledger_journal.info, Node: Assertions and virtual postings, Next: Assertions and precision, Prev: Assertions and subaccounts, Up: Balance assertions -1.10.7 Assertions and virtual postings +1.11.7 Assertions and virtual postings -------------------------------------- Balance assertions are checked against all postings, both real and @@ -784,9 +809,9 @@ virtual. They are not affected by the '--real/-R' flag or 'real:' query.  -File: hledger_journal.info, Node: Assertions and precision, Prev: Assertions and virtual postings, Up: Balance Assertions +File: hledger_journal.info, Node: Assertions and precision, Prev: Assertions and virtual postings, Up: Balance assertions -1.10.8 Assertions and precision +1.11.8 Assertions and precision ------------------------------- Balance assertions compare the exactly calculated amounts, which are not @@ -795,9 +820,9 @@ display precision, but this will not affect balance assertions. Balance assertion failure messages show exact amounts.  -File: hledger_journal.info, Node: Balance Assignments, Next: Directives, Prev: Balance Assertions, Up: Transactions +File: hledger_journal.info, Node: Balance assignments, Next: Directives, Prev: Balance assertions, Up: Transactions -1.11 Balance Assignments +1.12 Balance assignments ======================== Ledger-style balance assignments are also supported. These are like @@ -832,9 +857,9 @@ hledger or do the calculations yourself, instead of just reading it. * Balance assignments and prices::  -File: hledger_journal.info, Node: Balance assignments and prices, Up: Balance Assignments +File: hledger_journal.info, Node: Balance assignments and prices, Up: Balance assignments -1.11.1 Balance assignments and prices +1.12.1 Balance assignments and prices ------------------------------------- A transaction price in a balance assignment will cause the calculated @@ -848,9 +873,9 @@ $ hledger print --explicit (a) $1 @ €2 = $1 @ €2  -File: hledger_journal.info, Node: Directives, Next: Periodic transactions, Prev: Balance Assignments, Up: Transactions +File: hledger_journal.info, Node: Directives, Next: Periodic transactions, Prev: Balance assignments, Up: Transactions -1.12 Directives +1.13 Directives =============== A directive is a line in the journal beginning with a special keyword, @@ -946,7 +971,7 @@ they affect, and whether they are focussed on input (parsing) or output * Default year:: * Declaring commodities:: * Default commodity:: -* Market prices:: +* Declaring market prices:: * Declaring accounts:: * Rewriting accounts:: * Default parent account:: @@ -954,7 +979,7 @@ they affect, and whether they are focussed on input (parsing) or output  File: hledger_journal.info, Node: Directives and multiple files, Next: Comment blocks, Up: Directives -1.12.1 Directives and multiple files +1.13.1 Directives and multiple files ------------------------------------ If you use multiple '-f'/'--file' options, or the 'include' directive, @@ -974,7 +999,7 @@ directives do not affect parent or sibling files (see below).  File: hledger_journal.info, Node: Comment blocks, Next: Including other files, Prev: Directives and multiple files, Up: Directives -1.12.2 Comment blocks +1.13.2 Comment blocks --------------------- A line containing just 'comment' starts a commented region of the file, @@ -984,7 +1009,7 @@ file) ends it. See also comments.  File: hledger_journal.info, Node: Including other files, Next: Default year, Prev: Comment blocks, Up: Directives -1.12.3 Including other files +1.13.3 Including other files ---------------------------- You can pull in the content of additional files by writing an include @@ -1002,7 +1027,7 @@ include journal, timeclock or timedot files, but not CSV files.  File: hledger_journal.info, Node: Default year, Next: Declaring commodities, Prev: Including other files, Up: Directives -1.12.4 Default year +1.13.4 Default year ------------------- You can set a default year to be used for subsequent dates which don't @@ -1028,7 +1053,7 @@ Y2010 ; change default year to 2010  File: hledger_journal.info, Node: Declaring commodities, Next: Default commodity, Prev: Default year, Up: Directives -1.12.5 Declaring commodities +1.13.5 Declaring commodities ---------------------------- The 'commodity' directive has several functions: @@ -1079,9 +1104,9 @@ a comma, followed by 0 or more decimal digits. zero decimal digits is "0". (More at Amount display style.)  -File: hledger_journal.info, Node: Default commodity, Next: Market prices, Prev: Declaring commodities, Up: Directives +File: hledger_journal.info, Node: Default commodity, Next: Declaring market prices, Prev: Declaring commodities, Up: Directives -1.12.6 Default commodity +1.13.6 Default commodity ------------------------ The 'D' directive sets a default commodity, to be used for amounts @@ -1106,10 +1131,10 @@ D $1,000.00 b  -File: hledger_journal.info, Node: Market prices, Next: Declaring accounts, Prev: Default commodity, Up: Directives +File: hledger_journal.info, Node: Declaring market prices, Next: Declaring accounts, Prev: Default commodity, Up: Directives -1.12.7 Market prices --------------------- +1.13.7 Declaring market prices +------------------------------ The 'P' directive declares a market price, which is an exchange rate between two commodities on a certain date. (In Ledger, they are called @@ -1132,13 +1157,13 @@ dollars during 2009, and $1.40 from 2010 onward: P 2009/1/1 € $1.35 P 2010/1/1 € $1.40 - The '-V/--value' flag can be used to convert reported amounts to -another commodity using these prices. + The '-V', '-X' and '--value' flags use these market prices to show +amount values in another commodity. See Valuation.  -File: hledger_journal.info, Node: Declaring accounts, Next: Rewriting accounts, Prev: Market prices, Up: Directives +File: hledger_journal.info, Node: Declaring accounts, Next: Rewriting accounts, Prev: Declaring market prices, Up: Directives -1.12.8 Declaring accounts +1.13.8 Declaring accounts ------------------------- 'account' directives can be used to pre-declare accounts. Though not @@ -1171,7 +1196,7 @@ account assets:bank:checking  File: hledger_journal.info, Node: Account comments, Next: Account subdirectives, Up: Declaring accounts -1.12.8.1 Account comments +1.13.8.1 Account comments ......................... Comments, beginning with a semicolon, can be added: @@ -1191,7 +1216,7 @@ account assets:bank:checking ; same-line comment, note 2+ spaces before ;  File: hledger_journal.info, Node: Account subdirectives, Next: Account types, Prev: Account comments, Up: Declaring accounts -1.12.8.2 Account subdirectives +1.13.8.2 Account subdirectives .............................. We also allow (and ignore) Ledger-style indented subdirectives, just for @@ -1209,7 +1234,7 @@ account ACCTNAME [ACCTTYPE] [;COMMENT]  File: hledger_journal.info, Node: Account types, Next: Account display order, Prev: Account subdirectives, Up: Declaring accounts -1.12.8.3 Account types +1.13.8.3 Account types ...................... hledger recognises five types (or classes) of account: Asset, Liability, @@ -1254,7 +1279,7 @@ account - ; type:L  File: hledger_journal.info, Node: Account display order, Prev: Account types, Up: Declaring accounts -1.12.8.4 Account display order +1.13.8.4 Account display order .............................. Account directives also set the order in which accounts are displayed, @@ -1300,7 +1325,7 @@ means:  File: hledger_journal.info, Node: Rewriting accounts, Next: Default parent account, Prev: Declaring accounts, Up: Directives -1.12.9 Rewriting accounts +1.13.9 Rewriting accounts ------------------------- You can define account alias rules which rewrite your account names, or @@ -1330,7 +1355,7 @@ hledger-web.  File: hledger_journal.info, Node: Basic aliases, Next: Regex aliases, Up: Rewriting accounts -1.12.9.1 Basic aliases +1.13.9.1 Basic aliases ...................... To set an account alias, use the 'alias' directive in your journal file. @@ -1353,7 +1378,7 @@ alias checking = assets:bank:wells fargo:checking  File: hledger_journal.info, Node: Regex aliases, Next: Combining aliases, Prev: Basic aliases, Up: Rewriting accounts -1.12.9.2 Regex aliases +1.13.9.2 Regex aliases ...................... There is also a more powerful variant that uses a regular expression, @@ -1378,7 +1403,7 @@ whitespace.  File: hledger_journal.info, Node: Combining aliases, Next: Aliases and multiple files, Prev: Regex aliases, Up: Rewriting accounts -1.12.9.3 Combining aliases +1.13.9.3 Combining aliases .......................... You can define as many aliases as you like, using journal directives @@ -1415,7 +1440,7 @@ which aliases are being applied when.  File: hledger_journal.info, Node: Aliases and multiple files, Next: end aliases, Prev: Combining aliases, Up: Rewriting accounts -1.12.9.4 Aliases and multiple files +1.13.9.4 Aliases and multiple files ................................... As explained at Directives and multiple files, 'alias' directives do not @@ -1447,7 +1472,7 @@ include c.journal ; also affected  File: hledger_journal.info, Node: end aliases, Prev: Aliases and multiple files, Up: Rewriting accounts -1.12.9.5 'end aliases' +1.13.9.5 'end aliases' ...................... You can clear (forget) all currently defined aliases with the 'end @@ -1458,7 +1483,7 @@ end aliases  File: hledger_journal.info, Node: Default parent account, Prev: Rewriting accounts, Up: Directives -1.12.10 Default parent account +1.13.10 Default parent account ------------------------------ You can specify a parent account which will be prepended to all accounts @@ -1499,7 +1524,7 @@ parent account.  File: hledger_journal.info, Node: Periodic transactions, Next: Auto postings, Prev: Directives, Up: Transactions -1.13 Periodic transactions +1.14 Periodic transactions ========================== Periodic transaction rules describe transactions that recur. They allow @@ -1544,7 +1569,7 @@ read this whole section - or at least these tips:  File: hledger_journal.info, Node: Periodic rule syntax, Next: Two spaces between period expression and description!, Up: Periodic transactions -1.13.1 Periodic rule syntax +1.14.1 Periodic rule syntax --------------------------- A periodic transaction rule looks like a normal journal entry, with the @@ -1567,7 +1592,7 @@ will be relative to Y/1/1.  File: hledger_journal.info, Node: Two spaces between period expression and description!, Next: Forecasting with periodic transactions, Prev: Periodic rule syntax, Up: Periodic transactions -1.13.2 Two spaces between period expression and description! +1.14.2 Two spaces between period expression and description! ------------------------------------------------------------ If the period expression is followed by a transaction description, these @@ -1592,7 +1617,7 @@ accidentally alter their meaning, as in this example:  File: hledger_journal.info, Node: Forecasting with periodic transactions, Next: Budgeting with periodic transactions, Prev: Two spaces between period expression and description!, Up: Periodic transactions -1.13.3 Forecasting with periodic transactions +1.14.3 Forecasting with periodic transactions --------------------------------------------- With the '--forecast' flag, each periodic transaction rule generates @@ -1645,7 +1670,7 @@ disables forecast transactions on previous dates.)  File: hledger_journal.info, Node: Budgeting with periodic transactions, Prev: Forecasting with periodic transactions, Up: Periodic transactions -1.13.4 Budgeting with periodic transactions +1.14.4 Budgeting with periodic transactions ------------------------------------------- With the '--budget' flag, currently supported by the balance command, @@ -1661,7 +1686,7 @@ Forecasting.  File: hledger_journal.info, Node: Auto postings, Prev: Periodic transactions, Up: Transactions -1.14 Auto postings +1.15 Auto postings ================== "Automated postings" or "auto postings" are extra postings which get @@ -1739,7 +1764,7 @@ $ hledger print --auto  File: hledger_journal.info, Node: Auto postings and multiple files, Next: Auto postings and dates, Up: Auto postings -1.14.1 Auto postings and multiple files +1.15.1 Auto postings and multiple files --------------------------------------- An auto posting rule can affect any transaction in the current file, or @@ -1749,7 +1774,7 @@ sibling files (when multiple '-f'/'--file' are used - see #1212).  File: hledger_journal.info, Node: Auto postings and dates, Next: Auto postings and transaction balancing / inferred amounts / balance assertions, Prev: Auto postings and multiple files, Up: Auto postings -1.14.2 Auto postings and dates +1.15.2 Auto postings and dates ------------------------------ A posting date (or secondary date) in the matched posting, or (taking @@ -1759,7 +1784,7 @@ used in the generated posting.  File: hledger_journal.info, Node: Auto postings and transaction balancing / inferred amounts / balance assertions, Next: Auto posting tags, Prev: Auto postings and dates, Up: Auto postings -1.14.3 Auto postings and transaction balancing / inferred amounts / +1.15.3 Auto postings and transaction balancing / inferred amounts / ------------------------------------------------------------------- balance assertions Currently, auto postings are added: @@ -1775,7 +1800,7 @@ for background.  File: hledger_journal.info, Node: Auto posting tags, Prev: Auto postings and transaction balancing / inferred amounts / balance assertions, Up: Auto postings -1.14.4 Auto posting tags +1.15.4 Auto posting tags ------------------------ Automated postings will have some extra tags: @@ -1799,120 +1824,122 @@ Tag Table: Node: Top76 Node: Transactions1875 Ref: #transactions1967 -Node: Dates3132 -Ref: #dates3231 -Node: Simple dates3296 -Ref: #simple-dates3422 -Node: Secondary dates3931 -Ref: #secondary-dates4085 -Node: Posting dates5421 -Ref: #posting-dates5550 -Node: Status6922 -Ref: #status7043 -Node: Description8751 -Ref: #description8885 -Node: Payee and note9205 -Ref: #payee-and-note9319 -Node: Comments9654 -Ref: #comments9780 -Node: Tags10974 -Ref: #tags11089 -Node: Postings12482 -Ref: #postings12610 -Node: Virtual Postings13636 -Ref: #virtual-postings13753 -Node: Account names15058 -Ref: #account-names15199 -Node: Amounts15686 -Ref: #amounts15825 -Node: Digit group marks16739 -Ref: #digit-group-marks16887 -Node: Amount display style17825 -Ref: #amount-display-style17979 -Node: Transaction prices19417 -Ref: #transaction-prices19583 -Node: Balance Assertions21849 -Ref: #balance-assertions22029 -Node: Assertions and ordering23062 -Ref: #assertions-and-ordering23250 -Node: Assertions and included files23950 -Ref: #assertions-and-included-files24193 -Node: Assertions and multiple -f options24526 -Ref: #assertions-and-multiple--f-options24782 -Node: Assertions and commodities24914 -Ref: #assertions-and-commodities25146 -Node: Assertions and prices26303 -Ref: #assertions-and-prices26517 -Node: Assertions and subaccounts26957 -Ref: #assertions-and-subaccounts27186 -Node: Assertions and virtual postings27510 -Ref: #assertions-and-virtual-postings27752 -Node: Assertions and precision27894 -Ref: #assertions-and-precision28087 -Node: Balance Assignments28354 -Ref: #balance-assignments28528 -Node: Balance assignments and prices29692 -Ref: #balance-assignments-and-prices29864 -Node: Directives30088 -Ref: #directives30247 -Node: Directives and multiple files35928 -Ref: #directives-and-multiple-files36111 -Node: Comment blocks36775 -Ref: #comment-blocks36958 -Node: Including other files37134 -Ref: #including-other-files37314 -Node: Default year37722 -Ref: #default-year37891 -Node: Declaring commodities38298 -Ref: #declaring-commodities38481 -Node: Default commodity40287 -Ref: #default-commodity40463 -Node: Market prices41352 -Ref: #market-prices41517 -Node: Declaring accounts42358 -Ref: #declaring-accounts42534 -Node: Account comments43459 -Ref: #account-comments43622 -Node: Account subdirectives44046 -Ref: #account-subdirectives44241 -Node: Account types44554 -Ref: #account-types44738 -Node: Account display order46377 -Ref: #account-display-order46547 -Node: Rewriting accounts47698 -Ref: #rewriting-accounts47883 -Node: Basic aliases48640 -Ref: #basic-aliases48786 -Node: Regex aliases49490 -Ref: #regex-aliases49662 -Node: Combining aliases50380 -Ref: #combining-aliases50573 -Node: Aliases and multiple files51849 -Ref: #aliases-and-multiple-files52058 -Node: end aliases52637 -Ref: #end-aliases52794 -Node: Default parent account52895 -Ref: #default-parent-account53063 -Node: Periodic transactions53947 -Ref: #periodic-transactions54122 -Node: Periodic rule syntax55994 -Ref: #periodic-rule-syntax56200 -Node: Two spaces between period expression and description!56904 -Ref: #two-spaces-between-period-expression-and-description57223 -Node: Forecasting with periodic transactions57907 -Ref: #forecasting-with-periodic-transactions58212 -Node: Budgeting with periodic transactions60238 -Ref: #budgeting-with-periodic-transactions60477 -Node: Auto postings60926 -Ref: #auto-postings61066 -Node: Auto postings and multiple files63245 -Ref: #auto-postings-and-multiple-files63449 -Node: Auto postings and dates63658 -Ref: #auto-postings-and-dates63932 -Node: Auto postings and transaction balancing / inferred amounts / balance assertions64107 -Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions64458 -Node: Auto posting tags64800 -Ref: #auto-posting-tags65015 +Node: Dates3251 +Ref: #dates3350 +Node: Simple dates3415 +Ref: #simple-dates3541 +Node: Secondary dates4050 +Ref: #secondary-dates4204 +Node: Posting dates5540 +Ref: #posting-dates5669 +Node: Status7041 +Ref: #status7162 +Node: Description8870 +Ref: #description9004 +Node: Payee and note9324 +Ref: #payee-and-note9438 +Node: Comments9773 +Ref: #comments9899 +Node: Tags11093 +Ref: #tags11208 +Node: Postings12601 +Ref: #postings12729 +Node: Virtual postings13755 +Ref: #virtual-postings13872 +Node: Account names15177 +Ref: #account-names15318 +Node: Amounts15805 +Ref: #amounts15944 +Node: Digit group marks17052 +Ref: #digit-group-marks17200 +Node: Amount display style18138 +Ref: #amount-display-style18292 +Node: Transaction prices19729 +Ref: #transaction-prices19901 +Node: Lot prices and lot dates22233 +Ref: #lot-prices-and-lot-dates22430 +Node: Balance assertions22918 +Ref: #balance-assertions23104 +Node: Assertions and ordering24137 +Ref: #assertions-and-ordering24325 +Node: Assertions and included files25025 +Ref: #assertions-and-included-files25268 +Node: Assertions and multiple -f options25601 +Ref: #assertions-and-multiple--f-options25857 +Node: Assertions and commodities25989 +Ref: #assertions-and-commodities26221 +Node: Assertions and prices27378 +Ref: #assertions-and-prices27592 +Node: Assertions and subaccounts28032 +Ref: #assertions-and-subaccounts28261 +Node: Assertions and virtual postings28585 +Ref: #assertions-and-virtual-postings28827 +Node: Assertions and precision28969 +Ref: #assertions-and-precision29162 +Node: Balance assignments29429 +Ref: #balance-assignments29603 +Node: Balance assignments and prices30767 +Ref: #balance-assignments-and-prices30939 +Node: Directives31163 +Ref: #directives31322 +Node: Directives and multiple files37013 +Ref: #directives-and-multiple-files37196 +Node: Comment blocks37860 +Ref: #comment-blocks38043 +Node: Including other files38219 +Ref: #including-other-files38399 +Node: Default year38807 +Ref: #default-year38976 +Node: Declaring commodities39383 +Ref: #declaring-commodities39566 +Node: Default commodity41372 +Ref: #default-commodity41558 +Node: Declaring market prices42447 +Ref: #declaring-market-prices42642 +Node: Declaring accounts43499 +Ref: #declaring-accounts43685 +Node: Account comments44610 +Ref: #account-comments44773 +Node: Account subdirectives45197 +Ref: #account-subdirectives45392 +Node: Account types45705 +Ref: #account-types45889 +Node: Account display order47528 +Ref: #account-display-order47698 +Node: Rewriting accounts48849 +Ref: #rewriting-accounts49034 +Node: Basic aliases49791 +Ref: #basic-aliases49937 +Node: Regex aliases50641 +Ref: #regex-aliases50813 +Node: Combining aliases51531 +Ref: #combining-aliases51724 +Node: Aliases and multiple files53000 +Ref: #aliases-and-multiple-files53209 +Node: end aliases53788 +Ref: #end-aliases53945 +Node: Default parent account54046 +Ref: #default-parent-account54214 +Node: Periodic transactions55098 +Ref: #periodic-transactions55273 +Node: Periodic rule syntax57145 +Ref: #periodic-rule-syntax57351 +Node: Two spaces between period expression and description!58055 +Ref: #two-spaces-between-period-expression-and-description58374 +Node: Forecasting with periodic transactions59058 +Ref: #forecasting-with-periodic-transactions59363 +Node: Budgeting with periodic transactions61389 +Ref: #budgeting-with-periodic-transactions61628 +Node: Auto postings62077 +Ref: #auto-postings62217 +Node: Auto postings and multiple files64396 +Ref: #auto-postings-and-multiple-files64600 +Node: Auto postings and dates64809 +Ref: #auto-postings-and-dates65083 +Node: Auto postings and transaction balancing / inferred amounts / balance assertions65258 +Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions65609 +Node: Auto posting tags65951 +Ref: #auto-posting-tags66166  End Tag Table diff --git a/hledger-lib/hledger_journal.txt b/hledger-lib/hledger_journal.txt index 4abc4b318..64167514f 100644 --- a/hledger-lib/hledger_journal.txt +++ b/hledger-lib/hledger_journal.txt @@ -57,7 +57,8 @@ FILE FORMAT line, and any following indented lines beginning with a semicolon) o 0 or more indented posting lines, describing what was transferred and - the accounts involved. + the accounts involved (indented comment lines are also allowed, but + not blank lines or non-indented lines). Here's a simple journal file containing one transaction: @@ -67,35 +68,35 @@ FILE FORMAT Dates Simple dates - Dates in the journal file use simple dates format: YYYY-MM-DD or + Dates in the journal file use simple dates format: YYYY-MM-DD or YYYY/MM/DD or YYYY.MM.DD, with leading zeros optional. The year may be - omitted, in which case it will be inferred from the context: the cur- - rent transaction, the default year set with a default year directive, - or the current date when the command is run. Some examples: + omitted, in which case it will be inferred from the context: the cur- + rent transaction, the default year set with a default year directive, + or the current date when the command is run. Some examples: 2010-01-31, 2010/01/31, 2010.1.31, 1/31. - (The UI also accepts simple dates, as well as the more flexible smart + (The UI also accepts simple dates, as well as the more flexible smart dates documented in the hledger manual.) Secondary dates - Real-life transactions sometimes involve more than one date - eg the + Real-life transactions sometimes involve more than one date - eg the date you write a cheque, and the date it clears in your bank. When you - want to model this, for more accurate daily balances, you can specify + want to model this, for more accurate daily balances, you can specify individual posting dates. - Or, you can use the older secondary date feature (Ledger calls it aux- - iliary date or effective date). Note: we support this for compatibil- - ity, but I usually recommend avoiding this feature; posting dates are + Or, you can use the older secondary date feature (Ledger calls it aux- + iliary date or effective date). Note: we support this for compatibil- + ity, but I usually recommend avoiding this feature; posting dates are almost always clearer and simpler. A secondary date is written after the primary date, following an equals - sign. If the year is omitted, the primary date's year is assumed. - When running reports, the primary (left) date is used by default, but - with the --date2 flag (or --aux-date or --effective), the secondary + sign. If the year is omitted, the primary date's year is assumed. + When running reports, the primary (left) date is used by default, but + with the --date2 flag (or --aux-date or --effective), the secondary (right) date will be used instead. - The meaning of secondary dates is up to you, but it's best to follow a - consistent rule. Eg "primary = the bank's clearing date, secondary = + The meaning of secondary dates is up to you, but it's best to follow a + consistent rule. Eg "primary = the bank's clearing date, secondary = date the transaction was initiated, if different", as shown here: 2010/2/23=2/19 movie ticket @@ -109,11 +110,11 @@ FILE FORMAT 2010-02-19 movie ticket assets:checking $-10 $-10 Posting dates - You can give individual postings a different date from their parent - transaction, by adding a posting comment containing a tag (see below) + You can give individual postings a different date from their parent + transaction, by adding a posting comment containing a tag (see below) like date:DATE. This is probably the best way to control posting dates - precisely. Eg in this example the expense should appear in May re- - ports, and the deduction from checking should be reported on 6/1 for + precisely. Eg in this example the expense should appear in May re- + ports, and the deduction from checking should be reported on 6/1 for easy bank reconciliation: 2015/5/30 @@ -126,22 +127,22 @@ FILE FORMAT $ hledger -f t.j register checking 2015-06-01 assets:checking $-10 $-10 - DATE should be a simple date; if the year is not specified it will use - the year of the transaction's date. You can set the secondary date - similarly, with date2:DATE2. The date: or date2: tags must have a - valid simple date value if they are present, eg a date: tag with no + DATE should be a simple date; if the year is not specified it will use + the year of the transaction's date. You can set the secondary date + similarly, with date2:DATE2. The date: or date2: tags must have a + valid simple date value if they are present, eg a date: tag with no value is not allowed. Ledger's earlier, more compact bracketed date syntax is also supported: - [DATE], [DATE=DATE2] or [=DATE2]. hledger will attempt to parse any + [DATE], [DATE=DATE2] or [=DATE2]. hledger will attempt to parse any square-bracketed sequence of the 0123456789/-.= characters in this way. - With this syntax, DATE infers its year from the transaction and DATE2 + With this syntax, DATE infers its year from the transaction and DATE2 infers its year from DATE. Status - Transactions, or individual postings within a transaction, can have a - status mark, which is a single character before the transaction de- - scription or posting account name, separated from it by a space, indi- + Transactions, or individual postings within a transaction, can have a + status mark, which is a single character before the transaction de- + scription or posting account name, separated from it by a space, indi- cating one of three statuses: mark status @@ -150,23 +151,23 @@ FILE FORMAT ! pending * cleared - When reporting, you can filter by status with the -U/--unmarked, - -P/--pending, and -C/--cleared flags; or the status:, status:!, and + When reporting, you can filter by status with the -U/--unmarked, + -P/--pending, and -C/--cleared flags; or the status:, status:!, and status:* queries; or the U, P, C keys in hledger-ui. - Note, in Ledger and in older versions of hledger, the "unmarked" state - is called "uncleared". As of hledger 1.3 we have renamed it to un- + Note, in Ledger and in older versions of hledger, the "unmarked" state + is called "uncleared". As of hledger 1.3 we have renamed it to un- marked for clarity. - To replicate Ledger and old hledger's behaviour of also matching pend- + To replicate Ledger and old hledger's behaviour of also matching pend- ing, combine -U and -P. - Status marks are optional, but can be helpful eg for reconciling with + Status marks are optional, but can be helpful eg for reconciling with real-world accounts. Some editor modes provide highlighting and short- - cuts for working with status. Eg in Emacs ledger-mode, you can toggle + cuts for working with status. Eg in Emacs ledger-mode, you can toggle transaction status with C-c C-e, or posting status with C-c C-c. - What "uncleared", "pending", and "cleared" actually mean is up to you. + What "uncleared", "pending", and "cleared" actually mean is up to you. Here's one suggestion: status meaning @@ -177,34 +178,34 @@ FILE FORMAT cleared complete, reconciled as far as possible, and considered cor- rect - With this scheme, you would use -PC to see the current balance at your + With this scheme, you would use -PC to see the current balance at your bank, -U to see things which will probably hit your bank soon (like un- - cashed checks), and no flags to see the most up-to-date state of your + cashed checks), and no flags to see the most up-to-date state of your finances. Description - A transaction's description is the rest of the line following the date - and status mark (or until a comment begins). Sometimes called the + A transaction's description is the rest of the line following the date + and status mark (or until a comment begins). Sometimes called the "narration" in traditional bookkeeping, it can be used for whatever you - wish, or left blank. Transaction descriptions can be queried, unlike + wish, or left blank. Transaction descriptions can be queried, unlike comments. Payee and note You can optionally include a | (pipe) character in descriptions to sub- divide the description into separate fields for payee/payer name on the left (up to the first |) and an additional note field on the right (af- - ter the first |). This may be worthwhile if you need to do more pre- + ter the first |). This may be worthwhile if you need to do more pre- cise querying and pivoting by payee or by note. Comments Lines in the journal beginning with a semicolon (;) or hash (#) or star - (*) are comments, and will be ignored. (Star comments cause org-mode - nodes to be ignored, allowing emacs users to fold and navigate their + (*) are comments, and will be ignored. (Star comments cause org-mode + nodes to be ignored, allowing emacs users to fold and navigate their journals with org-mode or orgstruct-mode.) - You can attach comments to a transaction by writing them after the de- + You can attach comments to a transaction by writing them after the de- scription and/or indented on the following lines (before the postings). - Similarly, you can attach comments to an individual posting by writing + Similarly, you can attach comments to an individual posting by writing them after the amount and/or indented on the following lines. Transac- tion and posting comments must begin with a semicolon (;). @@ -228,24 +229,24 @@ FILE FORMAT ; another comment line for posting 2 ; a file comment (because not indented) - You can also comment larger regions of a file using comment and end + You can also comment larger regions of a file using comment and end comment directives. Tags - Tags are a way to add extra labels or labelled data to postings and + Tags are a way to add extra labels or labelled data to postings and transactions, which you can then search or pivot on. - A simple tag is a word (which may contain hyphens) followed by a full + A simple tag is a word (which may contain hyphens) followed by a full colon, written inside a transaction or posting comment line: 2017/1/16 bought groceries ; sometag: - Tags can have a value, which is the text after the colon, up to the + Tags can have a value, which is the text after the colon, up to the next comma or end of line, with leading/trailing whitespace removed: expenses:food $10 ; a-posting-tag: the tag value - Note this means hledger's tag values can not contain commas or new- + Note this means hledger's tag values can not contain commas or new- lines. Ending at commas means you can write multiple short tags on one line, comma separated: @@ -259,57 +260,57 @@ FILE FORMAT o "tag2" is another tag, whose value is "some value ..." - Tags in a transaction comment affect the transaction and all of its - postings, while tags in a posting comment affect only that posting. - For example, the following transaction has three tags (A, TAG2, third- + Tags in a transaction comment affect the transaction and all of its + postings, while tags in a posting comment affect only that posting. + For example, the following transaction has three tags (A, TAG2, third- tag) and the posting has four (those plus posting-tag): 1/1 a transaction ; A:, TAG2: ; third-tag: a third transaction tag, <- with a value (a) $1 ; posting-tag: - Tags are like Ledger's metadata feature, except hledger's tag values + Tags are like Ledger's metadata feature, except hledger's tag values are simple strings. Postings - A posting is an addition of some amount to, or removal of some amount - from, an account. Each posting line begins with at least one space or + A posting is an addition of some amount to, or removal of some amount + from, an account. Each posting line begins with at least one space or tab (2 or 4 spaces is common), followed by: o (optional) a status character (empty, !, or *), followed by a space - o (required) an account name (any text, optionally containing single + o (required) an account name (any text, optionally containing single spaces, until end of line or a double space) o (optional) two or more spaces or tabs followed by an amount. - Positive amounts are being added to the account, negative amounts are + Positive amounts are being added to the account, negative amounts are being removed. The amounts within a transaction must always sum up to zero. As a con- - venience, one amount may be left blank; it will be inferred so as to + venience, one amount may be left blank; it will be inferred so as to balance the transaction. - Be sure to note the unusual two-space delimiter between account name - and amount. This makes it easy to write account names containing spa- - ces. But if you accidentally leave only one space (or tab) before the + Be sure to note the unusual two-space delimiter between account name + and amount. This makes it easy to write account names containing spa- + ces. But if you accidentally leave only one space (or tab) before the amount, the amount will be considered part of the account name. - Virtual Postings + Virtual postings A posting with a parenthesised account name is called a virtual posting - or unbalanced posting, which means it is exempt from the usual rule + or unbalanced posting, which means it is exempt from the usual rule that a transaction's postings must balance add up to zero. - This is not part of double entry accounting, so you might choose to - avoid this feature. Or you can use it sparingly for certain special - cases where it can be convenient. Eg, you could set opening balances + This is not part of double entry accounting, so you might choose to + avoid this feature. Or you can use it sparingly for certain special + cases where it can be convenient. Eg, you could set opening balances without using a balancing equity account: 1/1 opening balances (assets:checking) $1000 (assets:savings) $2000 - A posting with a bracketed account name is called a balanced virtual + A posting with a bracketed account name is called a balanced virtual posting. The balanced virtual postings in a transaction must add up to zero (separately from other postings). Eg: @@ -321,34 +322,34 @@ FILE FORMAT [assets:checking:available] $10 ; <- (something:else) $5 ; <- not required to balance - Ordinary non-parenthesised, non-bracketed postings are called real - postings. You can exclude virtual postings from reports with the + Ordinary non-parenthesised, non-bracketed postings are called real + postings. You can exclude virtual postings from reports with the -R/--real flag or real:1 query. Account names - Account names typically have several parts separated by a full colon, - from which hledger derives a hierarchical chart of accounts. They can - be anything you like, but in finance there are traditionally five top- + Account names typically have several parts separated by a full colon, + from which hledger derives a hierarchical chart of accounts. They can + be anything you like, but in finance there are traditionally five top- level accounts: assets, liabilities, income, expenses, and equity. - Account names may contain single spaces, eg: assets:accounts receiv- - able. Because of this, they must always be followed by two or more + Account names may contain single spaces, eg: assets:accounts receiv- + able. Because of this, they must always be followed by two or more spaces (or newline). Account names can be aliased. Amounts - After the account name, there is usually an amount. (Important: be- + After the account name, there is usually an amount. (Important: be- tween account name and amount, there must be two or more spaces.) - hledger's amount format is flexible, supporting several international - formats. Here are some examples. Amounts have a number (the "quan- + hledger's amount format is flexible, supporting several international + formats. Here are some examples. Amounts have a number (the "quan- tity"): 1 - ..and usually a currency or commodity name (the "commodity"). This is - a symbol, word, or phrase, to the left or right of the quantity, with + ..and usually a currency or commodity name (the "commodity"). This is + a symbol, word, or phrase, to the left or right of the quantity, with or without a separating space: $1 @@ -359,12 +360,19 @@ FILE FORMAT 3 "no. 42 green apples" - Amounts can be negative. The minus sign can be written before or after - a left-side commodity symbol: + Amounts can be preceded by a minus sign (or a plus sign, though plus is + the default), The sign can be written before or after a left-side com- + modity symbol: -$1 $-1 + One or more spaces between the sign and the number are acceptable when + parsing (but they won't be displayed in output): + + + $1 + $- 1 + Scientific E notation is allowed: 1E-6 @@ -376,8 +384,8 @@ FILE FORMAT 1,23456780000009 Digit group marks - In the integer part of the quantity (left of the decimal mark), groups - of digits can optionally be separated by a "digit group mark" - a + In the integer part of the quantity (left of the decimal mark), groups + of digits can optionally be separated by a "digit group mark" - a space, comma, or period (different from the decimal mark): $1,000,000.00 @@ -385,7 +393,7 @@ FILE FORMAT INR 9,99,99,999.00 1 000 000.9455 - Note, a number containing a single group mark and no decimal mark is + Note, a number containing a single group mark and no decimal mark is ambiguous. Are these group marks or decimal marks ? 1,000 @@ -393,9 +401,9 @@ FILE FORMAT hledger will treat them both as decimal marks by default (cf #793). If you use digit group marks, to prevent confusion and undetected typos we - recommend you write commodity directives at the top of the file to ex- - plicitly declare the decimal mark (and optionally a digit group mark). - Note, these formats ("amount styles") are specific to each commodity, + recommend you write commodity directives at the top of the file to ex- + plicitly declare the decimal mark (and optionally a digit group mark). + Note, these formats ("amount styles") are specific to each commodity, so if your data uses multiple formats, hledger can handle it: commodity $1,000.00 @@ -404,41 +412,41 @@ FILE FORMAT commodity 1 000 000.9455 Amount display style - For each commodity, hledger chooses a consistent format to use when - displaying amounts. (Except price amounts, which are always displayed + For each commodity, hledger chooses a consistent format to use when + displaying amounts. (Except price amounts, which are always displayed as written). The display style is chosen as follows: - o If there is a commodity directive (or default commodity directive) + o If there is a commodity directive (or default commodity directive) for the commodity, that format is used (see examples above). - o Otherwise the format of the first posting amount in that commodity + o Otherwise the format of the first posting amount in that commodity seen in the journal is used. But the number of decimal places ("pre- - cision") will be the maximum from all posting amounts in that comm- - modity. + cision") will be the maximum from all posting amounts in that commod- + ity. - o Or if there are no such amounts in the journal, a default format is + o Or if there are no such amounts in the journal, a default format is used (like $1000.00). - Transaction prices don't affect the amount display style directly, but - occasionally they can do so indirectly (eg when an posting's amount is - inferred using a transaction price). If you find this causing prob- + Transaction prices don't affect the amount display style directly, but + occasionally they can do so indirectly (eg when an posting's amount is + inferred using a transaction price). If you find this causing prob- lems, use a commodity directive to fix the display style. In summary: amounts will be displayed much as they appear in your jour- - nal, with the max observed number of decimal places. If you want to + nal, with the max observed number of decimal places. If you want to see fewer decimal places in reports, use a commodity directive to over- ride that. - hledger uses banker's rounding: it rounds to the nearest even number, - eg 0.5 displayed with zero decimal places is "0"). (Note, prior to - hledger 1.17.1 this could vary if hledger happened to be built with an + hledger uses banker's rounding: it rounds to the nearest even number, + eg 0.5 displayed with zero decimal places is "0"). (Note, prior to + hledger 1.17.1 this could vary if hledger happened to be built with an old version of Decimal (<0.5.1); since 1.17.1 it's guaranteed.) Transaction prices Within a transaction, you can note an amount's price in another commod- - ity. This can be used to document the cost (in a purchase) or selling - price (in a sale). For example, transaction prices are useful to - record purchases of a foreign currency. Note transaction prices are + ity. This can be used to document the cost (in a purchase) or selling + price (in a sale). For example, transaction prices are useful to + record purchases of a foreign currency. Note transaction prices are fixed at the time of the transaction, and do not change over time. See also market prices, which represent prevailing exchange rates on a cer- tain date. @@ -464,8 +472,9 @@ FILE FORMAT assets:euros EUR100 ; one hundred euros purchased assets:dollars $-135 ; for $135 - (Ledger users: Ledger uses a different syntax for fixed prices, {=UNIT- - PRICE}, which hledger currently ignores). + 5. Like 1 and 2, but the @ or @@ is parenthesised; this is for compati- + bility with Ledger journals (Virtual posting costs), and in hledger + is equivalent to 1 and 2. Use the -B/--cost flag to convert amounts to their transaction price's commodity, if any. (mnemonic: "B" is from "cost Basis", as in Ledger). @@ -491,7 +500,16 @@ FILE FORMAT EUR-100 assets:dollars # <- the dollars' selling price EUR100 assets:euros - Balance Assertions + Lot prices and lot dates + Ledger allows another kind of price, lot price (four variants: {UNIT- + PRICE}, {{TOTALPRICE}}, {=FIXEDUNITPRICE}, {{=FIXEDTOTALPRICE}}), + and/or a lot date ([DATE]) to be specified. These are normally used to + select a lot when selling investments. hledger will parse these, for + compatibility with Ledger journals, but currently ignores them. A + transaction price, lot price and/or lot date may appear in any order, + after the posting amount and before the balance assertion if any. + + Balance assertions hledger supports Ledger-style balance assertions in journal files. These look like, for example, = EXPECTEDBALANCE following a posting's amount. Eg here we assert the expected dollar balance in accounts a @@ -614,7 +632,7 @@ FILE FORMAT limit the display precision, but this will not affect balance asser- tions. Balance assertion failure messages show exact amounts. - Balance Assignments + Balance assignments Ledger-style balance assignments are also supported. These are like balance assertions, but with no posting amount on the left side of the equals sign; instead it is calculated automatically so as to satisfy @@ -710,6 +728,9 @@ FILE FORMAT commodity commodity in re- ports, when -V is used + + + Y declare a year for yearless following in- dates line/included en- tries until end of @@ -863,7 +884,7 @@ FILE FORMAT a 5 ; <- commodity-less amount, parsed as $5 and displayed as $5.00 b - Market prices + Declaring market prices The P directive declares a market price, which is an exchange rate be- tween two commodities on a certain date. (In Ledger, they are called "historical prices".) These are often obtained from a stock exchange, @@ -886,8 +907,8 @@ FILE FORMAT P 2009/1/1 EUR $1.35 P 2010/1/1 EUR $1.40 - The -V/--value flag can be used to convert reported amounts to another - commodity using these prices. + The -V, -X and --value flags use these market prices to show amount + values in another commodity. See Valuation. Declaring accounts account directives can be used to pre-declare accounts. Though not re- @@ -1458,4 +1479,4 @@ SEE ALSO -hledger 1.17.99 March 2020 hledger_journal(5) +hledger 1.17.99 May 2020 hledger_journal(5) diff --git a/hledger-lib/hledger_timeclock.5 b/hledger-lib/hledger_timeclock.5 index 13e9c862e..1b1ed13eb 100644 --- a/hledger-lib/hledger_timeclock.5 +++ b/hledger-lib/hledger_timeclock.5 @@ -1,5 +1,5 @@ -.TH "hledger_timeclock" "5" "March 2020" "hledger 1.17.99" "hledger User Manuals" +.TH "hledger_timeclock" "5" "May 2020" "hledger 1.17.99" "hledger User Manuals" diff --git a/hledger-lib/hledger_timeclock.txt b/hledger-lib/hledger_timeclock.txt index 6948a42f5..049a3d09c 100644 --- a/hledger-lib/hledger_timeclock.txt +++ b/hledger-lib/hledger_timeclock.txt @@ -78,4 +78,4 @@ SEE ALSO -hledger 1.17.99 March 2020 hledger_timeclock(5) +hledger 1.17.99 May 2020 hledger_timeclock(5) diff --git a/hledger-lib/hledger_timedot.5 b/hledger-lib/hledger_timedot.5 index e3db819dc..f366555bb 100644 --- a/hledger-lib/hledger_timedot.5 +++ b/hledger-lib/hledger_timedot.5 @@ -1,5 +1,5 @@ -.TH "hledger_timedot" "5" "March 2020" "hledger 1.17.99" "hledger User Manuals" +.TH "hledger_timedot" "5" "May 2020" "hledger 1.17.99" "hledger User Manuals" diff --git a/hledger-lib/hledger_timedot.txt b/hledger-lib/hledger_timedot.txt index cbaeff16f..0f52b6a92 100644 --- a/hledger-lib/hledger_timedot.txt +++ b/hledger-lib/hledger_timedot.txt @@ -161,4 +161,4 @@ SEE ALSO -hledger 1.17.99 March 2020 hledger_timedot(5) +hledger 1.17.99 May 2020 hledger_timedot(5) diff --git a/hledger-ui/defs.m4 b/hledger-ui/defs.m4 index d83314ca0..bdd331d09 100644 --- a/hledger-ui/defs.m4 +++ b/hledger-ui/defs.m4 @@ -4,4 +4,4 @@ m4_dnl Program version. Updated by make setversion. m4_define({{_version_}}, {{1.17.99}})m4_dnl m4_dnl m4_dnl Date to show in man pages. Updated by make setdate. -m4_define({{_monthyear_}}, {{March 2020}})m4_dnl +m4_define({{_monthyear_}}, {{May 2020}})m4_dnl diff --git a/hledger-ui/hledger-ui.1 b/hledger-ui/hledger-ui.1 index 3681e1048..bcc31c26e 100644 --- a/hledger-ui/hledger-ui.1 +++ b/hledger-ui/hledger-ui.1 @@ -1,5 +1,5 @@ -.TH "hledger-ui" "1" "March 2020" "hledger-ui 1.17.99" "hledger User Manuals" +.TH "hledger-ui" "1" "May 2020" "hledger-ui 1.17.99" "hledger User Manuals" diff --git a/hledger-ui/hledger-ui.txt b/hledger-ui/hledger-ui.txt index 88a60af84..b6d2ba4bb 100644 --- a/hledger-ui/hledger-ui.txt +++ b/hledger-ui/hledger-ui.txt @@ -441,4 +441,4 @@ SEE ALSO -hledger-ui 1.17.99 March 2020 hledger-ui(1) +hledger-ui 1.17.99 May 2020 hledger-ui(1) diff --git a/hledger-web/defs.m4 b/hledger-web/defs.m4 index d83314ca0..bdd331d09 100644 --- a/hledger-web/defs.m4 +++ b/hledger-web/defs.m4 @@ -4,4 +4,4 @@ m4_dnl Program version. Updated by make setversion. m4_define({{_version_}}, {{1.17.99}})m4_dnl m4_dnl m4_dnl Date to show in man pages. Updated by make setdate. -m4_define({{_monthyear_}}, {{March 2020}})m4_dnl +m4_define({{_monthyear_}}, {{May 2020}})m4_dnl diff --git a/hledger-web/hledger-web.1 b/hledger-web/hledger-web.1 index eb83117a1..5cf21245c 100644 --- a/hledger-web/hledger-web.1 +++ b/hledger-web/hledger-web.1 @@ -1,5 +1,5 @@ -.TH "hledger-web" "1" "March 2020" "hledger-web 1.17.99" "hledger User Manuals" +.TH "hledger-web" "1" "May 2020" "hledger-web 1.17.99" "hledger User Manuals" @@ -316,10 +316,20 @@ message until the file has been fixed. that both machine clocks are roughly in step.) .SH JSON API .PP -In addition to the web UI, hledger-web provides some API routes that -serve JSON in response to GET requests. -(And when started with \f[C]--serve-api\f[R], it provides only these -routes.): +In addition to the web UI, hledger-web also serves a JSON API that can +be used to get data or add new transactions. +If you want the JSON API only, you can use the \f[C]--serve-api\f[R] +flag. +Eg: +.IP +.nf +\f[C] +$ hledger-web -f examples/sample.journal --serve-api +\&... +\f[R] +.fi +.PP +You can get JSON data from these routes: .IP .nf \f[C] @@ -328,48 +338,201 @@ routes.): /prices /commodities /accounts -/accounttransactions/#AccountName +/accounttransactions/ACCOUNTNAME \f[R] .fi .PP -Also, you can append a new transaction to the journal by sending a PUT -request to \f[C]/add\f[R] (hledger-web only). -As with the web UI\[aq]s add form, hledger-web must be started with the -\f[C]add\f[R] capability for this (enabled by default). +Eg, all account names in the journal (similar to the accounts command): +.IP +.nf +\f[C] +$ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool +[ + \[dq]assets\[dq], + \[dq]assets:bank\[dq], + \[dq]assets:bank:checking\[dq], + \[dq]assets:bank:saving\[dq], + \[dq]assets:cash\[dq], + \[dq]expenses\[dq], + \[dq]expenses:food\[dq], + \[dq]expenses:supplies\[dq], + \[dq]income\[dq], + \[dq]income:gifts\[dq], + \[dq]income:salary\[dq], + \[dq]liabilities\[dq], + \[dq]liabilities:debts\[dq] +] +\f[R] +.fi .PP -The payload should be a valid hledger transaction as JSON, similar to -what you get from \f[C]/transactions\f[R] or -\f[C]/accounttransactions\f[R]. +Or all transactions: +.IP +.nf +\f[C] +$ curl -s http://127.0.0.1:5000/transactions | python -m json.tool +[ + { + \[dq]tcode\[dq]: \[dq]\[dq], + \[dq]tcomment\[dq]: \[dq]\[dq], + \[dq]tdate\[dq]: \[dq]2008-01-01\[dq], + \[dq]tdate2\[dq]: null, + \[dq]tdescription\[dq]: \[dq]income\[dq], + \[dq]tindex\[dq]: 1, + \[dq]tpostings\[dq]: [ + { + \[dq]paccount\[dq]: \[dq]assets:bank:checking\[dq], + \[dq]pamount\[dq]: [ + { + \[dq]acommodity\[dq]: \[dq]$\[dq], + \[dq]aismultiplier\[dq]: false, + \[dq]aprice\[dq]: null, +\&... +\f[R] +.fi .PP -Another way to generate test data is with the -\f[C]readJsonFile\f[R]/\f[C]writeJsonFile\f[R] helpers in -Hledger.Web.Json, which can write or read most of hledger\[aq]s data -types to or from a file. -Eg here we write the first transaction of a sample journal: +Most of the JSON corresponds to hledger\[aq]s data types; for details of +what the fields mean, see the Hledger.Data.Json haddock docs and click +on the various data types, eg Transaction. +And for a higher level understanding, see the journal manual. +.PP +In some cases there is outer JSON corresponding to a \[dq]Report\[dq] +type. +To understand that, go to the Hledger.Web.Handler.MiscR haddock and look +at the source for the appropriate handler to see what it returns. +Eg for \f[C]/accounttransactions\f[R] it\[aq]s getAccounttransactionsR, +returning a \[dq]\f[C]accountTransactionsReport ...\f[R]\[dq]. +Looking up the haddock for that we can see that /accounttransactions +returns an AccountTransactionsReport, which consists of a report title +and a list of AccountTransactionsReportItem (etc). +.PP +You can add a new transaction to the journal with a PUT request to +\f[C]/add\f[R], if hledger-web was started with the \f[C]add\f[R] +capability (enabled by default). +The payload must be the full, exact JSON representation of a hledger +transaction (partial data won\[aq]t do). +You can get sample JSON from \f[C]/transactions\f[R] or +\f[C]/accounttransactions\f[R], or you can export it with +hledger-lib\[aq]s \f[C]writeJsonFile\f[R] helper, like so: .IP .nf \f[C] $ make ghci-web ->>> :m +*Hledger.Web.Json ->>> writeJsonFile \[dq]txn.json\[dq] (head $ jtxns samplejournal) +>>> import Hledger +>>> writeJsonFile \[dq]txn.json\[dq] (head $ jtxns samplejournal) -- export samplejournal\[aq]s first txn >>> :q -$ python -m json.tool txn.pretty.json # optional: make human-readable \f[R] .fi .PP -(sample output & discussion) -.PP -And here\[aq]s how to test adding that with curl: +If you like, reformat the json to make it human-readable: .IP .nf \f[C] -$ curl -s http://127.0.0.1:5000/add -X PUT -H \[aq]Content-Type: application/json\[aq] --data-binary \[at]txn.pretty.json; echo +$ python -m json.tool txn.json >pretty +$ mv pretty txn.json \f[R] .fi .PP -By default, both the server-side HTML UI and the JSON API are served. -Running with \f[C]--serve-api\f[R] disables the former, useful if you -only want to serve the API. +Here\[aq]s how it looks as of hledger-1.17 (remember, this JSON +corresponds to hledger\[aq]s Transaction and related data types): +.IP +.nf +\f[C] +{ + \[dq]tcode\[dq]: \[dq]\[dq], + \[dq]tcomment\[dq]: \[dq]\[dq], + \[dq]tdate\[dq]: \[dq]2008-01-01\[dq], + \[dq]tdate2\[dq]: null, + \[dq]tdescription\[dq]: \[dq]income\[dq], + \[dq]tindex\[dq]: 1, + \[dq]tpostings\[dq]: [ + { + \[dq]paccount\[dq]: \[dq]assets:bank:checking\[dq], + \[dq]pamount\[dq]: [ + { + \[dq]acommodity\[dq]: \[dq]$\[dq], + \[dq]aismultiplier\[dq]: false, + \[dq]aprice\[dq]: null, + \[dq]aquantity\[dq]: { + \[dq]decimalMantissa\[dq]: 10000000000, + \[dq]decimalPlaces\[dq]: 10, + \[dq]floatingPoint\[dq]: 1 + }, + \[dq]astyle\[dq]: { + \[dq]ascommodityside\[dq]: \[dq]L\[dq], + \[dq]ascommodityspaced\[dq]: false, + \[dq]asdecimalpoint\[dq]: \[dq].\[dq], + \[dq]asdigitgroups\[dq]: null, + \[dq]asprecision\[dq]: 2 + } + } + ], + \[dq]pbalanceassertion\[dq]: null, + \[dq]pcomment\[dq]: \[dq]\[dq], + \[dq]pdate\[dq]: null, + \[dq]pdate2\[dq]: null, + \[dq]poriginal\[dq]: null, + \[dq]pstatus\[dq]: \[dq]Unmarked\[dq], + \[dq]ptags\[dq]: [], + \[dq]ptransaction_\[dq]: \[dq]1\[dq], + \[dq]ptype\[dq]: \[dq]RegularPosting\[dq] + }, + { + \[dq]paccount\[dq]: \[dq]income:salary\[dq], + \[dq]pamount\[dq]: [ + { + \[dq]acommodity\[dq]: \[dq]$\[dq], + \[dq]aismultiplier\[dq]: false, + \[dq]aprice\[dq]: null, + \[dq]aquantity\[dq]: { + \[dq]decimalMantissa\[dq]: -10000000000, + \[dq]decimalPlaces\[dq]: 10, + \[dq]floatingPoint\[dq]: -1 + }, + \[dq]astyle\[dq]: { + \[dq]ascommodityside\[dq]: \[dq]L\[dq], + \[dq]ascommodityspaced\[dq]: false, + \[dq]asdecimalpoint\[dq]: \[dq].\[dq], + \[dq]asdigitgroups\[dq]: null, + \[dq]asprecision\[dq]: 2 + } + } + ], + \[dq]pbalanceassertion\[dq]: null, + \[dq]pcomment\[dq]: \[dq]\[dq], + \[dq]pdate\[dq]: null, + \[dq]pdate2\[dq]: null, + \[dq]poriginal\[dq]: null, + \[dq]pstatus\[dq]: \[dq]Unmarked\[dq], + \[dq]ptags\[dq]: [], + \[dq]ptransaction_\[dq]: \[dq]1\[dq], + \[dq]ptype\[dq]: \[dq]RegularPosting\[dq] + } + ], + \[dq]tprecedingcomment\[dq]: \[dq]\[dq], + \[dq]tsourcepos\[dq]: { + \[dq]contents\[dq]: [ + \[dq]\[dq], + [ + 1, + 1 + ] + ], + \[dq]tag\[dq]: \[dq]JournalSourcePos\[dq] + }, + \[dq]tstatus\[dq]: \[dq]Unmarked\[dq], + \[dq]ttags\[dq]: [] +} +\f[R] +.fi +.PP +And here\[aq]s how to test adding it with curl. +This should add a new entry to your journal: +.IP +.nf +\f[C] +$ curl http://127.0.0.1:5000/add -X PUT -H \[aq]Content-Type: application/json\[aq] --data-binary \[at]txn.json +\f[R] +.fi .SH ENVIRONMENT .PP \f[B]LEDGER_FILE\f[R] The journal file path when not specified with diff --git a/hledger-web/hledger-web.info b/hledger-web/hledger-web.info index 4a0fabc99..2224183ba 100644 --- a/hledger-web/hledger-web.info +++ b/hledger-web/hledger-web.info @@ -330,45 +330,187 @@ File: hledger-web.info, Node: JSON API, Next: ENVIRONMENT, Prev: RELOADING, 5 JSON API ********** -In addition to the web UI, hledger-web provides some API routes that -serve JSON in response to GET requests. (And when started with -'--serve-api', it provides only these routes.): +In addition to the web UI, hledger-web also serves a JSON API that can +be used to get data or add new transactions. If you want the JSON API +only, you can use the '--serve-api' flag. Eg: + +$ hledger-web -f examples/sample.journal --serve-api +... + + You can get JSON data from these routes: /accountnames /transactions /prices /commodities /accounts -/accounttransactions/#AccountName +/accounttransactions/ACCOUNTNAME - Also, you can append a new transaction to the journal by sending a -PUT request to '/add' (hledger-web only). As with the web UI's add -form, hledger-web must be started with the 'add' capability for this -(enabled by default). + Eg, all account names in the journal (similar to the accounts +command): - The payload should be a valid hledger transaction as JSON, similar to -what you get from '/transactions' or '/accounttransactions'. +$ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool +[ + "assets", + "assets:bank", + "assets:bank:checking", + "assets:bank:saving", + "assets:cash", + "expenses", + "expenses:food", + "expenses:supplies", + "income", + "income:gifts", + "income:salary", + "liabilities", + "liabilities:debts" +] - Another way to generate test data is with the -'readJsonFile'/'writeJsonFile' helpers in Hledger.Web.Json, which can -write or read most of hledger's data types to or from a file. Eg here -we write the first transaction of a sample journal: + Or all transactions: + +$ curl -s http://127.0.0.1:5000/transactions | python -m json.tool +[ + { + "tcode": "", + "tcomment": "", + "tdate": "2008-01-01", + "tdate2": null, + "tdescription": "income", + "tindex": 1, + "tpostings": [ + { + "paccount": "assets:bank:checking", + "pamount": [ + { + "acommodity": "$", + "aismultiplier": false, + "aprice": null, +... + + Most of the JSON corresponds to hledger's data types; for details of +what the fields mean, see the Hledger.Data.Json haddock docs and click +on the various data types, eg Transaction. And for a higher level +understanding, see the journal manual. + + In some cases there is outer JSON corresponding to a "Report" type. +To understand that, go to the Hledger.Web.Handler.MiscR haddock and look +at the source for the appropriate handler to see what it returns. Eg +for '/accounttransactions' it's getAccounttransactionsR, returning a +"'accountTransactionsReport ...'". Looking up the haddock for that we +can see that /accounttransactions returns an AccountTransactionsReport, +which consists of a report title and a list of +AccountTransactionsReportItem (etc). + + You can add a new transaction to the journal with a PUT request to +'/add', if hledger-web was started with the 'add' capability (enabled by +default). The payload must be the full, exact JSON representation of a +hledger transaction (partial data won't do). You can get sample JSON +from '/transactions' or '/accounttransactions', or you can export it +with hledger-lib's 'writeJsonFile' helper, like so: $ make ghci-web ->>> :m +*Hledger.Web.Json ->>> writeJsonFile "txn.json" (head $ jtxns samplejournal) +>>> import Hledger +>>> writeJsonFile "txn.json" (head $ jtxns samplejournal) -- export samplejournal's first txn >>> :q -$ python -m json.tool txn.pretty.json # optional: make human-readable - (sample output & discussion) + If you like, reformat the json to make it human-readable: - And here's how to test adding that with curl: +$ python -m json.tool txn.json >pretty +$ mv pretty txn.json -$ curl -s http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.pretty.json; echo + Here's how it looks as of hledger-1.17 (remember, this JSON +corresponds to hledger's Transaction and related data types): - By default, both the server-side HTML UI and the JSON API are served. -Running with '--serve-api' disables the former, useful if you only want -to serve the API. +{ + "tcode": "", + "tcomment": "", + "tdate": "2008-01-01", + "tdate2": null, + "tdescription": "income", + "tindex": 1, + "tpostings": [ + { + "paccount": "assets:bank:checking", + "pamount": [ + { + "acommodity": "$", + "aismultiplier": false, + "aprice": null, + "aquantity": { + "decimalMantissa": 10000000000, + "decimalPlaces": 10, + "floatingPoint": 1 + }, + "astyle": { + "ascommodityside": "L", + "ascommodityspaced": false, + "asdecimalpoint": ".", + "asdigitgroups": null, + "asprecision": 2 + } + } + ], + "pbalanceassertion": null, + "pcomment": "", + "pdate": null, + "pdate2": null, + "poriginal": null, + "pstatus": "Unmarked", + "ptags": [], + "ptransaction_": "1", + "ptype": "RegularPosting" + }, + { + "paccount": "income:salary", + "pamount": [ + { + "acommodity": "$", + "aismultiplier": false, + "aprice": null, + "aquantity": { + "decimalMantissa": -10000000000, + "decimalPlaces": 10, + "floatingPoint": -1 + }, + "astyle": { + "ascommodityside": "L", + "ascommodityspaced": false, + "asdecimalpoint": ".", + "asdigitgroups": null, + "asprecision": 2 + } + } + ], + "pbalanceassertion": null, + "pcomment": "", + "pdate": null, + "pdate2": null, + "poriginal": null, + "pstatus": "Unmarked", + "ptags": [], + "ptransaction_": "1", + "ptype": "RegularPosting" + } + ], + "tprecedingcomment": "", + "tsourcepos": { + "contents": [ + "", + [ + 1, + 1 + ] + ], + "tag": "JournalSourcePos" + }, + "tstatus": "Unmarked", + "ttags": [] +} + + And here's how to test adding it with curl. This should add a new +entry to your journal: + +$ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json  File: hledger-web.info, Node: ENVIRONMENT, Next: FILES, Prev: JSON API, Up: Top @@ -437,12 +579,12 @@ Node: RELOADING10567 Ref: #reloading10701 Node: JSON API11134 Ref: #json-api11248 -Node: ENVIRONMENT12686 -Ref: #environment12802 -Node: FILES13535 -Ref: #files13635 -Node: BUGS13848 -Ref: #bugs13926 +Node: ENVIRONMENT16812 +Ref: #environment16928 +Node: FILES17661 +Ref: #files17761 +Node: BUGS17974 +Ref: #bugs18052  End Tag Table diff --git a/hledger-web/hledger-web.txt b/hledger-web/hledger-web.txt index ddb77d5dc..4a543f307 100644 --- a/hledger-web/hledger-web.txt +++ b/hledger-web/hledger-web.txt @@ -289,45 +289,186 @@ RELOADING that both machine clocks are roughly in step.) JSON API - In addition to the web UI, hledger-web provides some API routes that - serve JSON in response to GET requests. (And when started with - --serve-api, it provides only these routes.): + In addition to the web UI, hledger-web also serves a JSON API that can + be used to get data or add new transactions. If you want the JSON API + only, you can use the --serve-api flag. Eg: + + $ hledger-web -f examples/sample.journal --serve-api + ... + + You can get JSON data from these routes: /accountnames /transactions /prices /commodities /accounts - /accounttransactions/#AccountName + /accounttransactions/ACCOUNTNAME - Also, you can append a new transaction to the journal by sending a PUT - request to /add (hledger-web only). As with the web UI's add form, - hledger-web must be started with the add capability for this (enabled - by default). + Eg, all account names in the journal (similar to the accounts command): - The payload should be a valid hledger transaction as JSON, similar to - what you get from /transactions or /accounttransactions. + $ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool + [ + "assets", + "assets:bank", + "assets:bank:checking", + "assets:bank:saving", + "assets:cash", + "expenses", + "expenses:food", + "expenses:supplies", + "income", + "income:gifts", + "income:salary", + "liabilities", + "liabilities:debts" + ] - Another way to generate test data is with the readJsonFile/writeJson- - File helpers in Hledger.Web.Json, which can write or read most of - hledger's data types to or from a file. Eg here we write the first - transaction of a sample journal: + Or all transactions: + + $ curl -s http://127.0.0.1:5000/transactions | python -m json.tool + [ + { + "tcode": "", + "tcomment": "", + "tdate": "2008-01-01", + "tdate2": null, + "tdescription": "income", + "tindex": 1, + "tpostings": [ + { + "paccount": "assets:bank:checking", + "pamount": [ + { + "acommodity": "$", + "aismultiplier": false, + "aprice": null, + ... + + Most of the JSON corresponds to hledger's data types; for details of + what the fields mean, see the Hledger.Data.Json haddock docs and click + on the various data types, eg Transaction. And for a higher level un- + derstanding, see the journal manual. + + In some cases there is outer JSON corresponding to a "Report" type. To + understand that, go to the Hledger.Web.Handler.MiscR haddock and look + at the source for the appropriate handler to see what it returns. Eg + for /accounttransactions it's getAccounttransactionsR, returning a "ac- + countTransactionsReport ...". Looking up the haddock for that we can + see that /accounttransactions returns an AccountTransactionsReport, + which consists of a report title and a list of AccountTransactionsRe- + portItem (etc). + + You can add a new transaction to the journal with a PUT request to + /add, if hledger-web was started with the add capability (enabled by + default). The payload must be the full, exact JSON representation of a + hledger transaction (partial data won't do). You can get sample JSON + from /transactions or /accounttransactions, or you can export it with + hledger-lib's writeJsonFile helper, like so: $ make ghci-web - >>> :m +*Hledger.Web.Json - >>> writeJsonFile "txn.json" (head $ jtxns samplejournal) + >>> import Hledger + >>> writeJsonFile "txn.json" (head $ jtxns samplejournal) -- export samplejournal's first txn >>> :q - $ python -m json.tool txn.pretty.json # optional: make human-readable - (sample output & discussion) + If you like, reformat the json to make it human-readable: - And here's how to test adding that with curl: + $ python -m json.tool txn.json >pretty + $ mv pretty txn.json - $ curl -s http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.pretty.json; echo + Here's how it looks as of hledger-1.17 (remember, this JSON corresponds + to hledger's Transaction and related data types): - By default, both the server-side HTML UI and the JSON API are served. - Running with --serve-api disables the former, useful if you only want - to serve the API. + { + "tcode": "", + "tcomment": "", + "tdate": "2008-01-01", + "tdate2": null, + "tdescription": "income", + "tindex": 1, + "tpostings": [ + { + "paccount": "assets:bank:checking", + "pamount": [ + { + "acommodity": "$", + "aismultiplier": false, + "aprice": null, + "aquantity": { + "decimalMantissa": 10000000000, + "decimalPlaces": 10, + "floatingPoint": 1 + }, + "astyle": { + "ascommodityside": "L", + "ascommodityspaced": false, + "asdecimalpoint": ".", + "asdigitgroups": null, + "asprecision": 2 + } + } + ], + "pbalanceassertion": null, + "pcomment": "", + "pdate": null, + "pdate2": null, + "poriginal": null, + "pstatus": "Unmarked", + "ptags": [], + "ptransaction_": "1", + "ptype": "RegularPosting" + }, + { + "paccount": "income:salary", + "pamount": [ + { + "acommodity": "$", + "aismultiplier": false, + "aprice": null, + "aquantity": { + "decimalMantissa": -10000000000, + "decimalPlaces": 10, + "floatingPoint": -1 + }, + "astyle": { + "ascommodityside": "L", + "ascommodityspaced": false, + "asdecimalpoint": ".", + "asdigitgroups": null, + "asprecision": 2 + } + } + ], + "pbalanceassertion": null, + "pcomment": "", + "pdate": null, + "pdate2": null, + "poriginal": null, + "pstatus": "Unmarked", + "ptags": [], + "ptransaction_": "1", + "ptype": "RegularPosting" + } + ], + "tprecedingcomment": "", + "tsourcepos": { + "contents": [ + "", + [ + 1, + 1 + ] + ], + "tag": "JournalSourcePos" + }, + "tstatus": "Unmarked", + "ttags": [] + } + + And here's how to test adding it with curl. This should add a new en- + try to your journal: + + $ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json ENVIRONMENT LEDGER_FILE The journal file path when not specified with -f. Default: @@ -392,4 +533,4 @@ SEE ALSO -hledger-web 1.17.99 March 2020 hledger-web(1) +hledger-web 1.17.99 May 2020 hledger-web(1) diff --git a/hledger/defs.m4 b/hledger/defs.m4 index d83314ca0..bdd331d09 100644 --- a/hledger/defs.m4 +++ b/hledger/defs.m4 @@ -4,4 +4,4 @@ m4_dnl Program version. Updated by make setversion. m4_define({{_version_}}, {{1.17.99}})m4_dnl m4_dnl m4_dnl Date to show in man pages. Updated by make setdate. -m4_define({{_monthyear_}}, {{March 2020}})m4_dnl +m4_define({{_monthyear_}}, {{May 2020}})m4_dnl diff --git a/hledger/hledger.1 b/hledger/hledger.1 index 93bddce7c..54af914b2 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -1,6 +1,6 @@ .\"t -.TH "hledger" "1" "March 2020" "hledger 1.17.99" "hledger User Manuals" +.TH "hledger" "1" "May 2020" "hledger 1.17.99" "hledger User Manuals" @@ -1136,20 +1136,28 @@ account alias directives and options: \f[C]--alias /REGEX/=REPLACEMENT\f[R] .PP hledger\[aq]s regular expressions come from the regex-tdfa library. -In general they: -.IP \[bu] 2 -are case insensitive -.IP \[bu] 2 -are infix matching (do not need to match the entire thing being matched) -.IP \[bu] 2 -are POSIX extended regular expressions -.IP \[bu] 2 -also support GNU word boundaries (\[rs]<, \[rs]>, \[rs]b, \[rs]B) -.IP \[bu] 2 -and parenthesised capturing groups and numeric backreferences in -replacement strings -.IP \[bu] 2 -do not support mode modifiers like (?s) +If they\[aq]re not doing what you expect, it\[aq]s important to know +exactly what they support: +.IP "1." 3 +they are case insensitive +.IP "2." 3 +they are infix matching (they do not need to match the entire thing +being matched) +.IP "3." 3 +they are POSIX ERE (extended regular expressions) +.IP "4." 3 +they also support GNU word boundaries (\f[C]\[rs]b\f[R], +\f[C]\[rs]B\f[R], \f[C]\[rs]<\f[R], \f[C]\[rs]>\f[R]) +.IP "5." 3 +they do not support backreferences; if you write \f[C]\[rs]1\f[R], it +will match the digit \f[C]1\f[R]. +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. +.IP "6." 3 +they do not support mode modifiers (\f[C](?s)\f[R]), character classes +(\f[C]\[rs]w\f[R], \f[C]\[rs]d\f[R]), or anything else not mentioned +above. .PP Some things to note: .IP \[bu] 2 @@ -1671,31 +1679,48 @@ $ hledger balance --pivot member acct:. \f[R] .fi .SS Valuation +.PP +hledger can show cost reports, where amounts are converted to their cost +or sale amount at transaction time; or value reports, where amounts are +converted to their market value in another currency/commodity at a +specified date (using market prices inferred from your transactions, or +declared with P directives). +.PP +We call this \[dq]valuation\[dq], and it is controlled by the +\f[C]--value=VALUATIONTYPE[,COMMODITY]\f[R] option. +It can get a little involved, so we cover all the details below. +But most of the time, all you need to do is use these simpler flags +instead: +.IP \[bu] 2 +\f[C]-B\f[R] to convert to cost/sale amount, or +.IP \[bu] 2 +\f[C]-V\f[R] to convert to market value in your base currency. +Or occasionally, +.IP \[bu] 2 +\f[C]-X COMMODITY\f[R] to convert to market value in some other +currency. .SS -B: Cost .PP -The \f[C]-B/--cost\f[R] flag converts amounts to their cost (or selling -price) at transaction time, if they have a transaction price specified. -This flag is equivalent to \f[C]--value=cost\f[R], described below. -.SS -V: Market value +The \f[C]-B/--cost\f[R] flag converts amounts to their cost or sale +amount at transaction time, if they have a transaction price specified. +(It is equivalent to \f[C]--value=cost\f[R].) +.SS -V: Value .PP -The \f[C]-V/--market\f[R] flag converts reported amounts to their market -value in a default valuation commodity, using the market prices in -effect on a default valuation date. -For single period reports, the valuation date is today (equivalent to -\f[C]--value=now\f[R]); for multiperiod reports, it is the last day of -each subperiod (equivalent to \f[C]--value=end\f[R]). +The \f[C]-V/--market\f[R] flag converts reported amounts to market value +in their \f[I]default valuation commodity\f[R], using the market prices +in effect on a \f[I]default valuation date\f[R]. +(More on these below.) .PP The default valuation commodity is the one referenced in the latest applicable market price dated on or before the valuation date. -If most of your P declarations lead to a single home currency, this will -usually be what you want. -(To specify the commodity, see -X below.) +Typically your P declarations or currency exchange transactions +reference a single base currency, and -V will pick that. .PP -Note that in hledger, market prices are always declared explicitly with -P directives; we do not infer them from transaction prices as Ledger -does. +The default valuation date is today for single period reports +(equivalent to \f[C]--value=now\f[R]), or the last day of each subperiod +for multiperiod reports (equivalent to \f[C]--value=end\f[R]). .PP -Here\[aq]s a quick example of -V: +An example: .IP .nf \f[C] @@ -1743,8 +1768,31 @@ $ hledger -f t.j bal -N euros -V .PP The \f[C]-X/--exchange\f[R] option is like \f[C]-V\f[R], except it specifies the target commodity you would like to convert to. -It is equivalent to \f[C]--value=now,COMM\f[R] or -\f[C]--value=end,COMM\f[R]. +(It is equivalent to \f[C]--value=now,COMM\f[R] or +\f[C]--value=end,COMM\f[R].) +.SS Market prices +.PP +To convert a commodity A to commodity B, hledger looks for a suitable +market price (exchange rate) in the following ways, in this order of +preference: +.IP "1." 3 +a \f[I]declared market price\f[R] - the latest P directive specifying +the exchange rate from A to B, dated on or before the valuation date. +.IP "2." 3 +a \f[I]transaction-implied market price\f[R] - a market price matching +the transaction price used in the latest transaction where A is +converted to B, dated on or before the valuation date. +(\f[I]since hledger 1.18; experimental\f[R]) +.IP "3." 3 +a \f[I]reverse declared market price\f[R] - calculated by inverting a +declared market price from B to A. +.IP "4." 3 +a \f[I]reverse transaction-implied market price\f[R] - calculated by +inverting a transaction-implied market price from B to A. +.IP "5." 3 +an \f[I]indirect market price\f[R] - calculated by combining the +shortest chain of market prices (any of the above types) leading from A +to B. .SS --value: Flexible valuation .PP \f[I](experimental, added 201905)\f[R] @@ -2243,9 +2291,6 @@ otherwise the latest transaction date in the journal, otherwise today. \f[I]report interval\f[R] a flag (-D/-W/-M/-Q/-Y) or period expression that activates the report\[aq]s multi-period mode (whether showing one or many subperiods). -.SS Combining -B, -V, -X, --value -.PP -The rightmost of these flags wins. .SH COMMANDS .PP hledger provides a number of subcommands; \f[C]hledger\f[R] with no @@ -4173,7 +4218,7 @@ $ hledger test -- -pData.Amount --color=never .PP For help on these, see https://github.com/feuerbach/tasty#options (\f[C]-- --help\f[R] currently doesn\[aq]t show them). -.SS Add-on Commands +.SS Add-on commands .PP hledger also searches for external add-on commands, and will include these in the commands list. @@ -4312,45 +4357,42 @@ The command \f[C]env | grep LEDGER_FILE\f[R] should show it. You may need to use \f[C]export\f[R]. Here\[aq]s an explanation. .PP -\f[B]\[dq]Illegal byte sequence\[dq] or \[dq]Invalid or incomplete -multibyte or wide character\[dq] errors\f[R] +\f[B]Getting errors like \[dq]Illegal byte sequence\[dq] or \[dq]Invalid +or incomplete multibyte or wide character\[dq] or +\[dq]commitAndReleaseBuffer: invalid argument (invalid +character)\[dq]\f[R] .PD 0 .P .PD -In order to handle non-ascii letters and symbols (like \[Po]), hledger -needs an appropriate locale. -This is usually configured system-wide; you can also configure it -temporarily. -The locale may need to be one that supports UTF-8, if you built hledger -with GHC < 7.2 (or possibly always, I\[aq]m not sure yet). +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 +characters. .PP -Here\[aq]s an example of setting the locale temporarily, on ubuntu -gnu/linux: +To fix it, set the LANG environment variable to some locale which +supports UTF-8. +The locale you choose must be installed on your system. +.PP +Here\[aq]s an example of setting LANG temporarily, on Ubuntu GNU/Linux: .IP .nf \f[C] $ file my.journal -my.journal: UTF-8 Unicode text # <- the file is UTF8-encoded -$ locale -a +my.journal: UTF-8 Unicode text # the file is UTF8-encoded +$ echo $LANG +C # LANG is set to the default locale, which does not support UTF8 +$ locale -a # which locales are installed ? C -en_US.utf8 # <- a UTF8-aware locale is available +en_US.utf8 # here\[aq]s a UTF8-aware one we can use POSIX -$ LANG=en_US.utf8 hledger -f my.journal print # <- use it for this command +$ LANG=en_US.utf8 hledger -f my.journal print # ensure it is used for this command \f[R] .fi .PP -Here\[aq]s one way to set it permanently, there are probably better -ways: -.IP -.nf -\f[C] -$ echo \[dq]export LANG=en_US.UTF-8\[dq] >>\[ti]/.bash_profile -$ bash --login -\f[R] -.fi -.PP -If we preferred to use eg \f[C]fr_FR.utf8\f[R], we might have to install -that first: +If available, \f[C]C.UTF-8\f[R] will also work. +If your preferred locale isn\[aq]t listed by \f[C]locale -a\f[R], you +might need to install it. +Eg on Ubuntu/Debian: .IP .nf \f[C] @@ -4368,9 +4410,27 @@ $ LANG=fr_FR.utf8 hledger -f my.journal print \f[R] .fi .PP -Note some platforms allow variant locale spellings, but not all (ubuntu -accepts \f[C]fr_FR.UTF8\f[R], mac osx requires exactly -\f[C]fr_FR.UTF-8\f[R]). +Here\[aq]s how you could set it permanently, if you use a bash shell: +.IP +.nf +\f[C] +$ echo \[dq]export LANG=en_US.utf8\[dq] >>\[ti]/.bash_profile +$ bash --login +\f[R] +.fi +.PP +Exact spelling and capitalisation may be important. +Note the difference on MacOS (\f[C]UTF-8\f[R], not \f[C]utf8\f[R]). +Some platforms (eg ubuntu) allow variant spellings, but others (eg +macos) require it to be exact: +.IP +.nf +\f[C] +$ locale -a | grep -iE en_us.*utf +en_US.UTF-8 +$ LANG=en_US.UTF-8 hledger -f my.journal print +\f[R] +.fi .SH "REPORTING BUGS" diff --git a/hledger/hledger.info b/hledger/hledger.info index 383bed802..855a8f26d 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -1052,17 +1052,22 @@ hledger uses regular expressions in a number of places: * account alias directives and options: 'alias /REGEX/ = REPLACEMENT', '--alias /REGEX/=REPLACEMENT' - hledger's regular expressions come from the regex-tdfa library. In -general they: + 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: - * are case insensitive - * are infix matching (do not need to match the entire thing being - matched) - * are POSIX extended regular expressions - * also support GNU word boundaries (\<, \>, \b, \B) - * and parenthesised capturing groups and numeric backreferences in - replacement strings - * do not support mode modifiers like (?s) + 1. they are case insensitive + 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 to reference capturing groups in the search + regexp. + 6. they do not support mode modifiers ('(?s)'), character classes + ('\w', '\d'), or anything else not mentioned above. Some things to note: @@ -1365,47 +1370,61 @@ File: hledger.info, Node: Valuation, Prev: Pivoting, Up: OPTIONS 2.17 Valuation ============== +hledger can show cost reports, where amounts are converted to their cost +or sale amount at transaction time; or value reports, where amounts are +converted to their market value in another currency/commodity at a +specified date (using market prices inferred from your transactions, or +declared with P directives). + + We call this "valuation", and it is controlled by the +'--value=VALUATIONTYPE[,COMMODITY]' option. It can get a little +involved, so we cover all the details below. But most of the time, all +you need to do is use these simpler flags instead: + + * '-B' to convert to cost/sale amount, or + * '-V' to convert to market value in your base currency. Or + occasionally, + * '-X COMMODITY' to convert to market value in some other currency. + * Menu: * -B Cost:: -* -V Market value:: +* -V Value:: * -X Market value in specified commodity:: +* Market prices:: * --value Flexible valuation:: * Effect of --value on reports:: -* Combining -B -V -X --value::  -File: hledger.info, Node: -B Cost, Next: -V Market value, Up: Valuation +File: hledger.info, Node: -B Cost, Next: -V Value, Up: Valuation 2.17.1 -B: Cost --------------- -The '-B/--cost' flag converts amounts to their cost (or selling price) -at transaction time, if they have a transaction price specified. This -flag is equivalent to '--value=cost', described below. +The '-B/--cost' flag converts amounts to their cost or sale amount at +transaction time, if they have a transaction price specified. (It is +equivalent to '--value=cost'.)  -File: hledger.info, Node: -V Market value, Next: -X Market value in specified commodity, Prev: -B Cost, Up: Valuation +File: hledger.info, Node: -V Value, Next: -X Market value in specified commodity, Prev: -B Cost, Up: Valuation -2.17.2 -V: Market value ------------------------ +2.17.2 -V: Value +---------------- -The '-V/--market' flag converts reported amounts to their market value -in a default valuation commodity, using the market prices in effect on a -default valuation date. For single period reports, the valuation date -is today (equivalent to '--value=now'); for multiperiod reports, it is -the last day of each subperiod (equivalent to '--value=end'). +The '-V/--market' flag converts reported amounts to market value in +their _default valuation commodity_, using the market prices in effect +on a _default valuation date_. (More on these below.) The default valuation commodity is the one referenced in the latest -applicable market price dated on or before the valuation date. If most -of your P declarations lead to a single home currency, this will usually -be what you want. (To specify the commodity, see -X below.) +applicable market price dated on or before the valuation date. +Typically your P declarations or currency exchange transactions +reference a single base currency, and -V will pick that. - Note that in hledger, market prices are always declared explicitly -with P directives; we do not infer them from transaction prices as -Ledger does. + The default valuation date is today for single period reports +(equivalent to '--value=now'), or the last day of each subperiod for +multiperiod reports (equivalent to '--value=end'). - Here's a quick example of -V: + An example: ; one euro is worth this many dollars from nov 1 P 2016/11/01 € $1.10 @@ -1435,19 +1454,47 @@ $ hledger -f t.j bal -N euros -V $103.00 assets:euros  -File: hledger.info, Node: -X Market value in specified commodity, Next: --value Flexible valuation, Prev: -V Market value, Up: Valuation +File: hledger.info, Node: -X Market value in specified commodity, Next: Market prices, Prev: -V Value, Up: Valuation 2.17.3 -X: Market value in specified commodity ---------------------------------------------- The '-X/--exchange' option is like '-V', except it specifies the target -commodity you would like to convert to. It is equivalent to -'--value=now,COMM' or '--value=end,COMM'. +commodity you would like to convert to. (It is equivalent to +'--value=now,COMM' or '--value=end,COMM'.)  -File: hledger.info, Node: --value Flexible valuation, Next: Effect of --value on reports, Prev: -X Market value in specified commodity, Up: Valuation +File: hledger.info, Node: Market prices, Next: --value Flexible valuation, Prev: -X Market value in specified commodity, Up: Valuation -2.17.4 -value: Flexible valuation +2.17.4 Market prices +-------------------- + +To convert a commodity A to commodity B, hledger looks for a suitable +market price (exchange rate) in the following ways, in this order of +preference: + + 1. a _declared market price_ - the latest P directive specifying the + exchange rate from A to B, dated on or before the valuation date. + + 2. a _transaction-implied market price_ - a market price matching the + transaction price used in the latest transaction where A is + converted to B, dated on or before the valuation date. (_since + hledger 1.18; experimental_) + + 3. a _reverse declared market price_ - calculated by inverting a + declared market price from B to A. + + 4. a _reverse transaction-implied market price_ - calculated by + inverting a transaction-implied market price from B to A. + + 5. an _indirect market price_ - calculated by combining the shortest + chain of market prices (any of the above types) leading from A to + B. + + +File: hledger.info, Node: --value Flexible valuation, Next: Effect of --value on reports, Prev: Market prices, Up: Valuation + +2.17.5 -value: Flexible valuation --------------------------------- _(experimental, added 201905)_ @@ -1617,9 +1664,9 @@ $ hledger print -X A b -0.50A  -File: hledger.info, Node: Effect of --value on reports, Next: Combining -B -V -X --value, Prev: --value Flexible valuation, Up: Valuation +File: hledger.info, Node: Effect of --value on reports, Prev: --value Flexible valuation, Up: Valuation -2.17.5 Effect of -value on reports +2.17.6 Effect of -value on reports ---------------------------------- Here is a reference for how '--value' currently affects each part of @@ -1732,14 +1779,6 @@ _report interval_ report's multi-period mode (whether showing one or many subperiods). - -File: hledger.info, Node: Combining -B -V -X --value, Prev: Effect of --value on reports, Up: Valuation - -2.17.6 Combining -B, -V, -X, -value ------------------------------------ - -The rightmost of these flags wins. -  File: hledger.info, Node: COMMANDS, Next: ENVIRONMENT, Prev: OPTIONS, Up: Top @@ -1793,7 +1832,7 @@ detailed command help. * stats:: * tags:: * test:: -* Add-on Commands:: +* Add-on commands::  File: hledger.info, Node: accounts, Next: activity, Up: COMMANDS @@ -3494,7 +3533,7 @@ considered. With -values flag, the tags' unique values are listed instead.  -File: hledger.info, Node: test, Next: Add-on Commands, Prev: tags, Up: COMMANDS +File: hledger.info, Node: test, Next: Add-on commands, Prev: tags, Up: COMMANDS 3.29 test ========= @@ -3521,9 +3560,9 @@ $ hledger test -- -pData.Amount --color=never ('-- --help' currently doesn't show them).  -File: hledger.info, Node: Add-on Commands, Prev: test, Up: COMMANDS +File: hledger.info, Node: Add-on commands, Prev: test, Up: COMMANDS -3.30 Add-on Commands +3.30 Add-on commands ==================== hledger also searches for external add-on commands, and will include @@ -3562,7 +3601,7 @@ interfaces. These are maintained and released along with hledger: * interest::  -File: hledger.info, Node: ui, Next: web, Up: Add-on Commands +File: hledger.info, Node: ui, Next: web, Up: Add-on commands 3.30.1 ui --------- @@ -3570,7 +3609,7 @@ File: hledger.info, Node: ui, Next: web, Up: Add-on Commands hledger-ui provides an efficient terminal interface.  -File: hledger.info, Node: web, Next: iadd, Prev: ui, Up: Add-on Commands +File: hledger.info, Node: web, Next: iadd, Prev: ui, Up: Add-on commands 3.30.2 web ---------- @@ -3580,7 +3619,7 @@ hledger-web provides a simple web interface. Third party add-ons, maintained separately from hledger, include:  -File: hledger.info, Node: iadd, Next: interest, Prev: web, Up: Add-on Commands +File: hledger.info, Node: iadd, Next: interest, Prev: web, Up: Add-on commands 3.30.3 iadd ----------- @@ -3589,7 +3628,7 @@ hledger-iadd is a more interactive, terminal UI replacement for the add command.  -File: hledger.info, Node: interest, Prev: iadd, Up: Add-on Commands +File: hledger.info, Node: interest, Prev: iadd, Up: Add-on commands 3.30.4 interest --------------- @@ -3689,32 +3728,32 @@ file* variable. The command 'env | grep LEDGER_FILE' should show it. You may need to use 'export'. Here's an explanation. - *"Illegal byte sequence" or "Invalid or incomplete multibyte or wide -character" errors* -In order to handle non-ascii letters and symbols (like £), hledger needs -an appropriate locale. This is usually configured system-wide; you can -also configure it temporarily. The locale may need to be one that -supports UTF-8, if you built hledger with GHC < 7.2 (or possibly always, -I'm not sure yet). + *Getting errors like "Illegal byte sequence" or "Invalid or +incomplete multibyte or wide character" or "commitAndReleaseBuffer: +invalid argument (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 +characters. - Here's an example of setting the locale temporarily, on ubuntu -gnu/linux: + To fix it, set the LANG environment variable to some locale which +supports UTF-8. The locale you choose must be installed on your system. + + Here's an example of setting LANG temporarily, on Ubuntu GNU/Linux: $ file my.journal -my.journal: UTF-8 Unicode text # <- the file is UTF8-encoded -$ locale -a +my.journal: UTF-8 Unicode text # the file is UTF8-encoded +$ echo $LANG +C # LANG is set to the default locale, which does not support UTF8 +$ locale -a # which locales are installed ? C -en_US.utf8 # <- a UTF8-aware locale is available +en_US.utf8 # here's a UTF8-aware one we can use POSIX -$ LANG=en_US.utf8 hledger -f my.journal print # <- use it for this command +$ LANG=en_US.utf8 hledger -f my.journal print # ensure it is used for this command - Here's one way to set it permanently, there are probably better ways: - -$ echo "export LANG=en_US.UTF-8" >>~/.bash_profile -$ bash --login - - If we preferred to use eg 'fr_FR.utf8', we might have to install that -first: + 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/Debian: $ apt-get install language-pack-fr $ locale -a @@ -3728,8 +3767,18 @@ fr_LU.utf8 POSIX $ LANG=fr_FR.utf8 hledger -f my.journal print - Note some platforms allow variant locale spellings, but not all -(ubuntu accepts 'fr_FR.UTF8', mac osx requires exactly 'fr_FR.UTF-8'). + Here's how you could set it permanently, if you use a bash shell: + +$ echo "export LANG=en_US.utf8" >>~/.bash_profile +$ bash --login + + Exact spelling and capitalisation may be important. Note the +difference 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 +en_US.UTF-8 +$ LANG=en_US.UTF-8 hledger -f my.journal print  Tag Table: @@ -3780,141 +3829,141 @@ Node: Output format32576 Ref: #output-format32726 Node: Regular expressions34774 Ref: #regular-expressions34931 -Node: Smart dates36292 -Ref: #smart-dates36443 -Node: Report start & end date37804 -Ref: #report-start-end-date37976 -Node: Report intervals39414 -Ref: #report-intervals39579 -Node: Period expressions39969 -Ref: #period-expressions40129 -Node: Depth limiting44255 -Ref: #depth-limiting44399 -Node: Pivoting44741 -Ref: #pivoting44864 -Node: Valuation46540 -Ref: #valuation46642 -Node: -B Cost46822 -Ref: #b-cost46933 -Node: -V Market value47131 -Ref: #v-market-value47305 -Node: -X Market value in specified commodity48737 -Ref: #x-market-value-in-specified-commodity48976 -Node: --value Flexible valuation49152 -Ref: #value-flexible-valuation49378 -Node: Effect of --value on reports53883 -Ref: #effect-of---value-on-reports54099 -Node: Combining -B -V -X --value59645 -Ref: #combining--b--v--x---value59828 -Node: COMMANDS59864 -Ref: #commands59972 -Node: accounts61056 -Ref: #accounts61154 -Node: activity61853 -Ref: #activity61963 -Node: add62346 -Ref: #add62445 -Node: balance65184 -Ref: #balance65295 -Node: Classic balance report66753 -Ref: #classic-balance-report66926 -Node: Customising the classic balance report68295 -Ref: #customising-the-classic-balance-report68523 -Node: Colour support70599 -Ref: #colour-support70766 -Node: Flat mode70939 -Ref: #flat-mode71087 -Node: Depth limited balance reports71500 -Ref: #depth-limited-balance-reports71685 -Node: Percentages72141 -Ref: #percentages72307 -Node: Multicolumn balance report73444 -Ref: #multicolumn-balance-report73624 -Node: Budget report78886 -Ref: #budget-report79029 -Node: Nested budgets84295 -Ref: #nested-budgets84407 -Ref: #output-format-187888 -Node: balancesheet88085 -Ref: #balancesheet88221 -Node: balancesheetequity89687 -Ref: #balancesheetequity89836 -Node: cashflow90559 -Ref: #cashflow90687 -Node: check-dates91866 -Ref: #check-dates91993 -Node: check-dupes92272 -Ref: #check-dupes92396 -Node: close92689 -Ref: #close92803 -Node: close usage94325 -Ref: #close-usage94418 -Node: commodities97231 -Ref: #commodities97358 -Node: descriptions97440 -Ref: #descriptions97568 -Node: diff97749 -Ref: #diff97855 -Node: files98902 -Ref: #files99002 -Node: help99149 -Ref: #help99249 -Node: import100330 -Ref: #import100444 -Node: Importing balance assignments101337 -Ref: #importing-balance-assignments101485 -Node: incomestatement102134 -Ref: #incomestatement102267 -Node: notes103754 -Ref: #notes103867 -Node: payees103993 -Ref: #payees104099 -Node: prices104257 -Ref: #prices104363 -Node: print104704 -Ref: #print104814 -Node: print-unique109600 -Ref: #print-unique109726 -Node: register110011 -Ref: #register110138 -Node: Custom register output114310 -Ref: #custom-register-output114439 -Node: register-match115776 -Ref: #register-match115910 -Node: rewrite116261 -Ref: #rewrite116376 -Node: Re-write rules in a file118231 -Ref: #re-write-rules-in-a-file118365 -Node: Diff output format119575 -Ref: #diff-output-format119744 -Node: rewrite vs print --auto120836 -Ref: #rewrite-vs.-print---auto121015 -Node: roi121571 -Ref: #roi121669 -Node: stats122681 -Ref: #stats122780 -Node: tags123568 -Ref: #tags123666 -Node: test123960 -Ref: #test124068 -Node: Add-on Commands124815 -Ref: #add-on-commands124932 -Node: ui126275 -Ref: #ui126363 -Node: web126417 -Ref: #web126520 -Node: iadd126636 -Ref: #iadd126747 -Node: interest126829 -Ref: #interest126936 -Node: ENVIRONMENT127176 -Ref: #environment127288 -Node: FILES128117 -Ref: #files-1128220 -Node: LIMITATIONS128433 -Ref: #limitations128552 -Node: TROUBLESHOOTING129294 -Ref: #troubleshooting129407 +Node: Smart dates36667 +Ref: #smart-dates36818 +Node: Report start & end date38179 +Ref: #report-start-end-date38351 +Node: Report intervals39789 +Ref: #report-intervals39954 +Node: Period expressions40344 +Ref: #period-expressions40504 +Node: Depth limiting44630 +Ref: #depth-limiting44774 +Node: Pivoting45116 +Ref: #pivoting45239 +Node: Valuation46915 +Ref: #valuation47017 +Node: -B Cost47937 +Ref: #b-cost48041 +Node: -V Value48213 +Ref: #v-value48366 +Node: -X Market value in specified commodity49639 +Ref: #x-market-value-in-specified-commodity49858 +Node: Market prices50036 +Ref: #market-prices50221 +Node: --value Flexible valuation51146 +Ref: #value-flexible-valuation51347 +Node: Effect of --value on reports55852 +Ref: #effect-of---value-on-reports56033 +Node: COMMANDS61579 +Ref: #commands61687 +Node: accounts62771 +Ref: #accounts62869 +Node: activity63568 +Ref: #activity63678 +Node: add64061 +Ref: #add64160 +Node: balance66899 +Ref: #balance67010 +Node: Classic balance report68468 +Ref: #classic-balance-report68641 +Node: Customising the classic balance report70010 +Ref: #customising-the-classic-balance-report70238 +Node: Colour support72314 +Ref: #colour-support72481 +Node: Flat mode72654 +Ref: #flat-mode72802 +Node: Depth limited balance reports73215 +Ref: #depth-limited-balance-reports73400 +Node: Percentages73856 +Ref: #percentages74022 +Node: Multicolumn balance report75159 +Ref: #multicolumn-balance-report75339 +Node: Budget report80601 +Ref: #budget-report80744 +Node: Nested budgets86010 +Ref: #nested-budgets86122 +Ref: #output-format-189603 +Node: balancesheet89800 +Ref: #balancesheet89936 +Node: balancesheetequity91402 +Ref: #balancesheetequity91551 +Node: cashflow92274 +Ref: #cashflow92402 +Node: check-dates93581 +Ref: #check-dates93708 +Node: check-dupes93987 +Ref: #check-dupes94111 +Node: close94404 +Ref: #close94518 +Node: close usage96040 +Ref: #close-usage96133 +Node: commodities98946 +Ref: #commodities99073 +Node: descriptions99155 +Ref: #descriptions99283 +Node: diff99464 +Ref: #diff99570 +Node: files100617 +Ref: #files100717 +Node: help100864 +Ref: #help100964 +Node: import102045 +Ref: #import102159 +Node: Importing balance assignments103052 +Ref: #importing-balance-assignments103200 +Node: incomestatement103849 +Ref: #incomestatement103982 +Node: notes105469 +Ref: #notes105582 +Node: payees105708 +Ref: #payees105814 +Node: prices105972 +Ref: #prices106078 +Node: print106419 +Ref: #print106529 +Node: print-unique111315 +Ref: #print-unique111441 +Node: register111726 +Ref: #register111853 +Node: Custom register output116025 +Ref: #custom-register-output116154 +Node: register-match117491 +Ref: #register-match117625 +Node: rewrite117976 +Ref: #rewrite118091 +Node: Re-write rules in a file119946 +Ref: #re-write-rules-in-a-file120080 +Node: Diff output format121290 +Ref: #diff-output-format121459 +Node: rewrite vs print --auto122551 +Ref: #rewrite-vs.-print---auto122730 +Node: roi123286 +Ref: #roi123384 +Node: stats124396 +Ref: #stats124495 +Node: tags125283 +Ref: #tags125381 +Node: test125675 +Ref: #test125783 +Node: Add-on commands126530 +Ref: #add-on-commands126647 +Node: ui127990 +Ref: #ui128078 +Node: web128132 +Ref: #web128235 +Node: iadd128351 +Ref: #iadd128462 +Node: interest128544 +Ref: #interest128651 +Node: ENVIRONMENT128891 +Ref: #environment129003 +Node: FILES129832 +Ref: #files-1129935 +Node: LIMITATIONS130148 +Ref: #limitations130267 +Node: TROUBLESHOOTING131009 +Ref: #troubleshooting131122  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index 94686df2d..b969721c2 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -896,22 +896,26 @@ OPTIONS o account alias directives and options: alias /REGEX/ = REPLACEMENT, --alias /REGEX/=REPLACEMENT - hledger's regular expressions come from the regex-tdfa library. In - general they: + 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: - o are case insensitive + 1. they are case insensitive - o are infix matching (do not need to match the entire thing being - matched) + 2. they are infix matching (they do not need to match the entire thing + being matched) - o are POSIX extended regular expressions + 3. they are POSIX ERE (extended regular expressions) - o also support GNU word boundaries (\<, \>, \b, \B) + 4. they also support GNU word boundaries (\b, \B, \<, \>) - o and parenthesised capturing groups and numeric backreferences in re- - placement strings + 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. - o do not support mode modifiers like (?s) + 6. they do not support mode modifiers ((?s)), character classes (\w, + \d), or anything else not mentioned above. Some things to note: @@ -1069,8 +1073,6 @@ OPTIONS -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 2008/11/25" -p "quarterly from starts on 2009/04/01, ends on 2009/06/30, @@ -1183,28 +1185,44 @@ OPTIONS -2 EUR Valuation - -B: Cost - The -B/--cost flag converts amounts to their cost (or selling price) at - transaction time, if they have a transaction price specified. This - flag is equivalent to --value=cost, described below. + hledger can show cost reports, where amounts are converted to their + cost or sale amount at transaction time; or value reports, where + amounts are converted to their market value in another currency/commod- + ity at a specified date (using market prices inferred from your trans- + actions, or declared with P directives). - -V: Market value - The -V/--market flag converts reported amounts to their market value in - a default valuation commodity, using the market prices in effect on a - default valuation date. For single period reports, the valuation date - is today (equivalent to --value=now); for multiperiod reports, it is - the last day of each subperiod (equivalent to --value=end). + We call this "valuation", and it is controlled by the --value=VALUA- + TIONTYPE[,COMMODITY] option. It can get a little involved, so we cover + all the details below. But most of the time, all you need to do is use + these simpler flags instead: + + o -B to convert to cost/sale amount, or + + o -V to convert to market value in your base currency. Or occasion- + ally, + + o -X COMMODITY to convert to market value in some other currency. + + -B: Cost + The -B/--cost flag converts amounts to their cost or sale amount at + transaction time, if they have a transaction price specified. (It is + equivalent to --value=cost.) + + -V: Value + The -V/--market flag converts reported amounts to market value in their + default valuation commodity, using the market prices in effect on a de- + fault valuation date. (More on these below.) The default valuation commodity is the one referenced in the latest ap- - plicable market price dated on or before the valuation date. If most - of your P declarations lead to a single home currency, this will usu- - ally be what you want. (To specify the commodity, see -X below.) + plicable market price dated on or before the valuation date. Typically + your P declarations or currency exchange transactions reference a sin- + gle base currency, and -V will pick that. - Note that in hledger, market prices are always declared explicitly with - P directives; we do not infer them from transaction prices as Ledger - does. + The default valuation date is today for single period reports (equiva- + lent to --value=now), or the last day of each subperiod for multiperiod + reports (equivalent to --value=end). - Here's a quick example of -V: + An example: ; one euro is worth this many dollars from nov 1 P 2016/11/01 EUR $1.10 @@ -1235,8 +1253,30 @@ OPTIONS -X: Market value in specified commodity The -X/--exchange option is like -V, except it specifies the target - commodity you would like to convert to. It is equivalent to - --value=now,COMM or --value=end,COMM. + commodity you would like to convert to. (It is equivalent to + --value=now,COMM or --value=end,COMM.) + + Market prices + To convert a commodity A to commodity B, hledger looks for a suitable + market price (exchange rate) in the following ways, in this order of + preference: + + 1. a declared market price - the latest P directive specifying the ex- + change rate from A to B, dated on or before the valuation date. + + 2. a transaction-implied market price - a market price matching the + transaction price used in the latest transaction where A is con- + verted to B, dated on or before the valuation date. (since hledger + 1.18; experimental) + + 3. a reverse declared market price - calculated by inverting a declared + market price from B to A. + + 4. a reverse transaction-implied market price - calculated by inverting + a transaction-implied market price from B to A. + + 5. an indirect market price - calculated by combining the shortest + chain of market prices (any of the above types) leading from A to B. --value: Flexible valuation (experimental, added 201905) @@ -1256,48 +1296,48 @@ OPTIONS 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 a default valuation commodity, - using market prices on each posting's date. This is currently + using market prices on each posting's date. This is currently supported only by the print and register commands. --value=end Convert amounts to their value in a default valuation commodity, - using market prices on the last day of the report period (or if + 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 default valuation commodity + Convert amounts to their value in default valuation commodity using current market prices (as of when report is generated). --value=YYYY-MM-DD - Convert amounts to their value in default valuation commodity + Convert amounts to their value in default valuation commodity using market prices on this date. - The default valuation commodity is the commodity mentioned in the most + The default valuation commodity is the commodity mentioned in the most recent applicable market price declaration. When all your price decla- - rations lead to a single home currency, this will usually do what you + rations lead to a single home currency, this will usually do what you want. 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, using: o declared prices (from source commodity to valuation commodity) - o reverse prices (declared prices from valuation to source commodity, + o reverse prices (declared prices from valuation to source commodity, inverted) - o indirect prices (prices calculated from the shortest chain of de- + o indirect prices (prices calculated from the shortest chain of de- clared or reverse prices from source to valuation commodity) in that order. - 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 @@ -1335,7 +1375,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 @@ -1372,7 +1412,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 @@ -1386,10 +1426,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 @@ -1405,19 +1445,18 @@ OPTIONS b -0.50A Effect of --value on reports - Here is a reference for how --value currently affects each part of - hledger's reports. It's work in progress, but may be useful for trou- - bleshooting or reporting bugs. See also the definitions and notes be- - low. If you find problems, please report them, ideally with a repro- + Here is a reference for how --value currently affects each part of + hledger's reports. It's work in progress, but may be useful for trou- + bleshooting or reporting bugs. See also the definitions and notes be- + low. If you find problems, please report them, ideally with a repro- ducible example. Related: #329, #1083. Report type -B, -V, -X --value=then --value=end --value=DATE, --value=cost --value=now ------------------------------------------------------------------------------------------ - print posting cost value at re- value at value at re- value at - amounts port end or posting date port or DATE/today + amounts port end or posting date port or DATE/today today journal end balance as- unchanged unchanged unchanged unchanged unchanged sertions / @@ -1430,14 +1469,16 @@ 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- interval) val start + + running to- sum/average sum/average sum/average sum/average sum/average tal/average of displayed of displayed of displayed of displayed of displayed values values values values values @@ -1446,7 +1487,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 @@ -1462,7 +1503,7 @@ 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 @@ -1470,7 +1511,7 @@ OPTIONS 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 @@ -1482,63 +1523,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). - Combining -B, -V, -X, --value - The rightmost of these flags wins. - 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: @@ -1557,8 +1595,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: @@ -1573,22 +1611,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. @@ -1596,10 +1634,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. @@ -1608,7 +1646,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): @@ -1638,8 +1676,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 @@ -1647,29 +1685,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 @@ -1687,22 +1725,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 @@ -1711,7 +1749,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)" @@ -1729,7 +1767,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) @@ -1740,14 +1778,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) @@ -1764,14 +1802,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 @@ -1782,9 +1820,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. @@ -1793,8 +1831,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 @@ -1807,9 +1845,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 -% @@ -1819,32 +1857,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 @@ -1860,7 +1898,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 @@ -1876,8 +1914,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: @@ -1896,26 +1934,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: @@ -1936,21 +1974,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 @@ -1997,26 +2035,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 @@ -2058,12 +2096,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: @@ -2073,13 +2111,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: @@ -2105,9 +2143,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: @@ -2123,7 +2161,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 @@ -2142,17 +2180,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). @@ -2178,21 +2216,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: @@ -2222,15 +2260,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). @@ -2251,90 +2289,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: @@ -2389,18 +2427,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. @@ -2418,20 +2456,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: @@ -2458,9 +2496,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 @@ -2471,36 +2509,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 @@ -2525,13 +2563,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 @@ -2559,10 +2597,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 @@ -2570,11 +2608,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 @@ -2601,43 +2639,43 @@ 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) + tions The output formats supported are txt, csv, and (experimental) json. Here's an example of print's CSV output: @@ -2656,20 +2694,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 @@ -2693,7 +2731,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 @@ -2704,8 +2742,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 @@ -2715,18 +2753,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 @@ -2738,7 +2776,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 @@ -2755,7 +2793,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 @@ -2763,17 +2801,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): @@ -2792,27 +2830,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: @@ -2828,7 +2866,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: @@ -2838,16 +2876,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. @@ -2862,7 +2900,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. @@ -2875,12 +2913,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' @@ -2904,10 +2942,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: @@ -2915,48 +2953,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: @@ -2974,14 +3012,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. @@ -2989,13 +3027,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 -- @@ -3004,35 +3042,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 + Add-on commands + 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 @@ -3051,23 +3089,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 @@ -3078,13 +3116,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 @@ -3100,53 +3138,53 @@ 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. - "Illegal byte sequence" or "Invalid or incomplete multibyte or wide - character" errors - In order to handle non-ascii letters and symbols (like ), hledger needs - an appropriate locale. This is usually configured system-wide; you can - also configure it temporarily. The locale may need to be one that sup- - ports UTF-8, if you built hledger with GHC < 7.2 (or possibly always, - I'm not sure yet). + 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 + characters. - Here's an example of setting the locale temporarily, on ubuntu - gnu/linux: + 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: $ file my.journal - my.journal: UTF-8 Unicode text # <- the file is UTF8-encoded - $ locale -a + my.journal: UTF-8 Unicode text # the file is UTF8-encoded + $ echo $LANG + C # LANG is set to the default locale, which does not support UTF8 + $ locale -a # which locales are installed ? C - en_US.utf8 # <- a UTF8-aware locale is available + en_US.utf8 # here's a UTF8-aware one we can use POSIX - $ LANG=en_US.utf8 hledger -f my.journal print # <- use it for this command + $ LANG=en_US.utf8 hledger -f my.journal print # ensure it is used for this command - Here's one way to set it permanently, there are probably better ways: - - $ echo "export LANG=en_US.UTF-8" >>~/.bash_profile - $ bash --login - - If we preferred to use eg fr_FR.utf8, we might have to install that - first: + 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 $ locale -a @@ -3160,13 +3198,23 @@ TROUBLESHOOTING POSIX $ LANG=fr_FR.utf8 hledger -f my.journal print - Note some platforms allow variant locale spellings, but not all (ubuntu - accepts fr_FR.UTF8, mac osx requires exactly fr_FR.UTF-8). + Here's how you could set it permanently, if you use a bash shell: + + $ 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 + variant spellings, but others (eg macos) require it to be exact: + + $ locale -a | grep -iE en_us.*utf + en_US.UTF-8 + $ LANG=en_US.UTF-8 hledger -f my.journal print 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) @@ -3180,7 +3228,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) @@ -3188,4 +3236,4 @@ SEE ALSO -hledger 1.17.99 March 2020 hledger(1) +hledger 1.17.99 May 2020 hledger(1)