diff --git a/hledger-ui/hledger-ui.1 b/hledger-ui/hledger-ui.1 index 339793f5b..6a8359852 100644 --- a/hledger-ui/hledger-ui.1 +++ b/hledger-ui/hledger-ui.1 @@ -192,7 +192,7 @@ show general or COMMAND user manual with man show general or COMMAND user manual with info .TP \f[B]\f[CB]--version\f[B]\f[R] -show general or ADDONCOMMAND version +show general or ADDONCMD version .TP \f[B]\f[CB]--debug[=N]\f[B]\f[R] show debug output (levels 1-9, default: 1) diff --git a/hledger-ui/hledger-ui.info b/hledger-ui/hledger-ui.info index 3882c07b5..f88864704 100644 --- a/hledger-ui/hledger-ui.info +++ b/hledger-ui/hledger-ui.info @@ -206,7 +206,7 @@ the last one takes precedence. show general or COMMAND user manual with info '--version' - show general or ADDONCOMMAND version + show general or ADDONCMD version '--debug[=N]' show debug output (levels 1-9, default: 1) @@ -528,23 +528,23 @@ Tag Table: Node: Top71 Node: OPTIONS1488 Ref: #options1585 -Node: KEYS5772 -Ref: #keys5867 -Node: SCREENS10186 -Ref: #screens10291 -Node: Accounts screen10381 -Ref: #accounts-screen10509 -Node: Register screen12724 -Ref: #register-screen12879 -Node: Transaction screen14876 -Ref: #transaction-screen15034 -Node: Error screen15904 -Ref: #error-screen16026 -Node: ENVIRONMENT16270 -Ref: #environment16384 -Node: FILES17191 -Ref: #files17290 -Node: BUGS17503 -Ref: #bugs17580 +Node: KEYS5768 +Ref: #keys5863 +Node: SCREENS10182 +Ref: #screens10287 +Node: Accounts screen10377 +Ref: #accounts-screen10505 +Node: Register screen12720 +Ref: #register-screen12875 +Node: Transaction screen14872 +Ref: #transaction-screen15030 +Node: Error screen15900 +Ref: #error-screen16022 +Node: ENVIRONMENT16266 +Ref: #environment16380 +Node: FILES17187 +Ref: #files17286 +Node: BUGS17499 +Ref: #bugs17576  End Tag Table diff --git a/hledger-ui/hledger-ui.txt b/hledger-ui/hledger-ui.txt index ef7c84fe9..7159db4d3 100644 --- a/hledger-ui/hledger-ui.txt +++ b/hledger-ui/hledger-ui.txt @@ -185,7 +185,7 @@ OPTIONS --info show general or COMMAND user manual with info --version - show general or ADDONCOMMAND version + show general or ADDONCMD version --debug[=N] show debug output (levels 1-9, default: 1) diff --git a/hledger-web/hledger-web.1 b/hledger-web/hledger-web.1 index 237713c45..749e49f10 100644 --- a/hledger-web/hledger-web.1 +++ b/hledger-web/hledger-web.1 @@ -221,7 +221,7 @@ show general or COMMAND user manual with man show general or COMMAND user manual with info .TP \f[B]\f[CB]--version\f[B]\f[R] -show general or ADDONCOMMAND version +show general or ADDONCMD version .TP \f[B]\f[CB]--debug[=N]\f[B]\f[R] show debug output (levels 1-9, default: 1) diff --git a/hledger-web/hledger-web.info b/hledger-web/hledger-web.info index 3dd2a54ed..2779d862f 100644 --- a/hledger-web/hledger-web.info +++ b/hledger-web/hledger-web.info @@ -234,7 +234,7 @@ the last one takes precedence. show general or COMMAND user manual with info '--version' - show general or ADDONCOMMAND version + show general or ADDONCMD version '--debug[=N]' show debug output (levels 1-9, default: 1) @@ -598,19 +598,19 @@ Tag Table: Node: Top72 Node: OPTIONS1762 Ref: #options1867 -Node: PERMISSIONS9086 -Ref: #permissions9225 -Node: EDITING UPLOADING DOWNLOADING10437 -Ref: #editing-uploading-downloading10618 -Node: RELOADING11452 -Ref: #reloading11586 -Node: JSON API12019 -Ref: #json-api12133 -Node: ENVIRONMENT17623 -Ref: #environment17739 -Node: FILES18472 -Ref: #files18572 -Node: BUGS18785 -Ref: #bugs18863 +Node: PERMISSIONS9082 +Ref: #permissions9221 +Node: EDITING UPLOADING DOWNLOADING10433 +Ref: #editing-uploading-downloading10614 +Node: RELOADING11448 +Ref: #reloading11582 +Node: JSON API12015 +Ref: #json-api12129 +Node: ENVIRONMENT17619 +Ref: #environment17735 +Node: FILES18468 +Ref: #files18568 +Node: BUGS18781 +Ref: #bugs18859  End Tag Table diff --git a/hledger-web/hledger-web.txt b/hledger-web/hledger-web.txt index 7e2fcc14d..3bcc4a836 100644 --- a/hledger-web/hledger-web.txt +++ b/hledger-web/hledger-web.txt @@ -209,7 +209,7 @@ OPTIONS --info show general or COMMAND user manual with info --version - show general or ADDONCOMMAND version + show general or ADDONCMD version --debug[=N] show debug output (levels 1-9, default: 1) diff --git a/hledger/hledger.1 b/hledger/hledger.1 index ba325a43b..0d3000ad4 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -84,7 +84,7 @@ show general or COMMAND user manual with man show general or COMMAND user manual with info .TP \f[B]\f[CB]--version\f[B]\f[R] -show general or ADDONCOMMAND version +show general or ADDONCMD version .TP \f[B]\f[CB]--debug[=N]\f[B]\f[R] show debug output (levels 1-9, default: 1) @@ -3788,15 +3788,12 @@ print Show transaction journal entries, sorted by date. .PP The print command displays full journal entries (transactions) from the -journal file in date order, tidily formatted. -With --date2, transactions are sorted by secondary date instead. -.PP -print\[aq]s output is always a valid hledger journal. -.PD 0 -.P -.PD -It preserves all transaction information, but it does not preserve -directives or inter-transaction comments +journal file, sorted by date (or with \f[C]--date2\f[R], by secondary +date). +Amounts are shown right-aligned within each transaction (but not across +all transactions). +Directives and inter-transaction comments are not shown. +Eg: .IP .nf \f[C] @@ -3824,6 +3821,29 @@ $ hledger print \f[R] .fi .PP +print\[aq]s output is usually a valid hledger journal, and you can +process it again with a second hledger command. +This can be useful for certain kinds of search, eg: +.IP +.nf +\f[C] +# Show running total of food expenses paid from cash. +# -f- reads from stdin. -I/--ignore-assertions is sometimes needed. +$ hledger print assets:cash | hledger -f- -I reg expenses:food +\f[R] +.fi +.PP +There are some situations where print\[aq]s output can become +unparseable: +.IP \[bu] 2 +Rounding amounts according to commodity display styles can cause +transactions to appear unbalanced. +.IP \[bu] 2 +Valuation affects posting amounts but not balance assertion or balance +assignment amounts, potentially causing those to fail. +.IP \[bu] 2 +Auto postings can generate postings with too many missing amounts. +.PP Normally, the journal entry\[aq]s explicit or implicit amount style is preserved. For example, when an amount is omitted in the journal, it will not diff --git a/hledger/hledger.info b/hledger/hledger.info index 9ba28b1fc..3ad3415e0 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -112,7 +112,7 @@ by most hledger commands, run 'hledger -h'. show general or COMMAND user manual with info '--version' - show general or ADDONCOMMAND version + show general or ADDONCMD version '--debug[=N]' show debug output (levels 1-9, default: 1) @@ -3218,12 +3218,10 @@ print 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, -transactions 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 -directives or inter-transaction comments +the journal file, sorted by date (or with '--date2', by secondary date). +Amounts are shown right-aligned within each transaction (but not across +all transactions). Directives and inter-transaction comments are not +shown. Eg: $ hledger print 2008/01/01 income @@ -3247,6 +3245,23 @@ $ hledger print liabilities:debts $1 assets:bank:checking $-1 + print's output is usually a valid hledger journal, and you can +process it again with a second hledger command. This can be useful for +certain kinds of search, eg: + +# Show running total of food expenses paid from cash. +# -f- reads from stdin. -I/--ignore-assertions is sometimes needed. +$ hledger print assets:cash | hledger -f- -I reg expenses:food + + There are some situations where print's output can become +unparseable: + + * Rounding amounts according to commodity display styles can cause + transactions to appear unbalanced. + * Valuation affects posting amounts but not balance assertion or + balance assignment amounts, potentially causing those to fail. + * Auto postings can generate postings with too many missing amounts. + Normally, the journal entry's explicit or implicit amount style is preserved. For example, when an amount is omitted in the journal, it will not appear in the output. Similarly, when a transaction price is @@ -7836,421 +7851,421 @@ Node: OPTIONS2509 Ref: #options2610 Node: General options2752 Ref: #general-options2877 -Node: Command options6398 -Ref: #command-options6549 -Node: Command arguments6949 -Ref: #command-arguments7107 -Node: Special characters7987 -Ref: #special-characters8150 -Node: Single escaping shell metacharacters8313 -Ref: #single-escaping-shell-metacharacters8554 -Node: Double escaping regular expression metacharacters8955 -Ref: #double-escaping-regular-expression-metacharacters9266 -Node: Triple escaping for add-on commands9792 -Ref: #triple-escaping-for-add-on-commands10052 -Node: Less escaping10696 -Ref: #less-escaping10850 -Node: Unicode characters11174 -Ref: #unicode-characters11339 -Node: Regular expressions12751 -Ref: #regular-expressions12891 -Node: ENVIRONMENT14627 -Ref: #environment14743 -Node: DATA FILES15728 -Ref: #data-files15847 -Node: Data formats16386 -Ref: #data-formats16504 -Node: Multiple files17841 -Ref: #multiple-files17983 -Node: Strict mode18452 -Ref: #strict-mode18567 -Node: TIME PERIODS19215 -Ref: #time-periods19332 -Node: Smart dates19430 -Ref: #smart-dates19556 -Node: Report start & end date20882 -Ref: #report-start-end-date21057 -Node: Report intervals22590 -Ref: #report-intervals22758 -Node: Period expressions23148 -Ref: #period-expressions23288 -Node: DEPTH27731 -Ref: #depth27831 -Node: QUERIES28163 -Ref: #queries28264 -Node: VALUATION32226 -Ref: #valuation32334 -Node: -B Cost33023 -Ref: #b-cost33121 -Node: -V Value33254 -Ref: #v-value33394 -Node: -X Value in specified commodity33589 -Ref: #x-value-in-specified-commodity33782 -Node: Valuation date33931 -Ref: #valuation-date34093 -Node: Market prices34530 -Ref: #market-prices34704 -Node: --infer-value market prices from transactions35625 -Ref: #infer-value-market-prices-from-transactions35868 -Node: Valuation commodity37129 -Ref: #valuation-commodity37332 -Node: Simple valuation examples38537 -Ref: #simple-valuation-examples38733 -Node: --value Flexible valuation39392 -Ref: #value-flexible-valuation39594 -Node: More valuation examples41541 -Ref: #more-valuation-examples41744 -Node: Effect of valuation on reports43749 -Ref: #effect-of-valuation-on-reports43931 -Node: PIVOTING50950 -Ref: #pivoting51055 -Node: OUTPUT52731 -Ref: #output52831 -Node: Output destination52882 -Ref: #output-destination53013 -Node: Output format53438 -Ref: #output-format53559 -Node: COMMANDS55726 -Ref: #commands55838 -Node: accounts59203 -Ref: #accounts59303 -Node: activity59999 -Ref: #activity60111 -Node: add60494 -Ref: #add60597 -Node: aregister63390 -Ref: #aregister63504 -Node: aregister and custom posting dates64998 -Ref: #aregister-and-custom-posting-dates65164 -Node: balance65985 -Ref: #balance66104 -Node: Classic balance report67727 -Ref: #classic-balance-report67902 -Node: Customising the classic balance report69226 -Ref: #customising-the-classic-balance-report69456 -Node: Colour support71532 -Ref: #colour-support71701 -Node: Flat mode71797 -Ref: #flat-mode71947 -Node: Depth limited balance reports72360 -Ref: #depth-limited-balance-reports72547 -Node: Percentages73003 -Ref: #percentages73162 -Node: Sorting by amount74299 -Ref: #sorting-by-amount74467 -Node: Multicolumn balance report74961 -Ref: #multicolumn-balance-report75149 -Node: Budget report80746 -Ref: #budget-report80882 -Node: Budget report start date86171 -Ref: #budget-report-start-date86338 -Node: Nested budgets87670 -Ref: #nested-budgets87817 -Node: balancesheet91257 -Ref: #balancesheet91395 -Node: balancesheetequity93032 -Ref: #balancesheetequity93183 -Node: cashflow94402 -Ref: #cashflow94526 -Node: check95860 -Ref: #check95965 -Node: Basic checks96570 -Ref: #basic-checks96688 -Node: Strict checks97181 -Ref: #strict-checks97322 -Node: Other checks97565 -Ref: #other-checks97705 -Node: Add-on checks98003 -Ref: #add-on-checks98123 -Node: close98576 -Ref: #close98680 -Node: close usage100202 -Ref: #close-usage100297 -Node: codes103110 -Ref: #codes103220 -Node: commodities103932 -Ref: #commodities104061 -Node: descriptions104143 -Ref: #descriptions104273 -Node: diff104577 -Ref: #diff104685 -Node: files105732 -Ref: #files105834 -Node: help105981 -Ref: #help106083 -Node: import106810 -Ref: #import106926 -Node: Importing balance assignments107848 -Ref: #importing-balance-assignments108031 -Node: Commodity display styles108680 -Ref: #commodity-display-styles108853 -Node: incomestatement108982 -Ref: #incomestatement109117 -Node: notes110579 -Ref: #notes110694 -Node: payees111062 -Ref: #payees111170 -Node: prices111590 -Ref: #prices111698 -Node: print112039 -Ref: #print112151 -Node: print-unique116938 -Ref: #print-unique117066 -Node: register117351 -Ref: #register117480 -Node: Custom register output121926 -Ref: #custom-register-output122057 -Node: register-match123394 -Ref: #register-match123530 -Node: rewrite123881 -Ref: #rewrite123998 -Node: Re-write rules in a file125904 -Ref: #re-write-rules-in-a-file126067 -Node: Diff output format127216 -Ref: #diff-output-format127399 -Node: rewrite vs print --auto128491 -Ref: #rewrite-vs.-print---auto128651 -Node: roi129207 -Ref: #roi129307 -Node: stats141517 -Ref: #stats141618 -Node: tags142406 -Ref: #tags142506 -Node: test143025 -Ref: #test143141 -Node: About add-on commands143888 -Ref: #about-add-on-commands144025 -Node: JOURNAL FORMAT145156 -Ref: #journal-format145284 -Node: Transactions147450 -Ref: #transactions147565 -Node: Dates148579 -Ref: #dates148695 -Node: Simple dates148760 -Ref: #simple-dates148880 -Node: Secondary dates149389 -Ref: #secondary-dates149537 -Node: Posting dates150873 -Ref: #posting-dates150996 -Node: Status152368 -Ref: #status152485 -Node: Description154193 -Ref: #description154323 -Node: Payee and note154643 -Ref: #payee-and-note154751 -Node: Comments155086 -Ref: #comments155208 -Node: Tags156402 -Ref: #tags-1156513 -Node: Postings157906 -Ref: #postings158030 -Node: Virtual postings159056 -Ref: #virtual-postings159167 -Node: Account names160472 -Ref: #account-names160609 -Node: Amounts161096 -Ref: #amounts161231 -Node: Digit group marks162355 -Ref: #digit-group-marks162500 -Node: Commodity display style163438 -Ref: #commodity-display-style163612 -Node: Rounding165325 -Ref: #rounding165443 -Node: Transaction prices165855 -Ref: #transaction-prices166021 -Node: Lot prices lot dates168452 -Ref: #lot-prices-lot-dates168635 -Node: Balance assertions169123 -Ref: #balance-assertions169301 -Node: Assertions and ordering170334 -Ref: #assertions-and-ordering170516 -Node: Assertions and included files171216 -Ref: #assertions-and-included-files171453 -Node: Assertions and multiple -f options171786 -Ref: #assertions-and-multiple--f-options172036 -Node: Assertions and commodities172168 -Ref: #assertions-and-commodities172394 -Node: Assertions and prices173551 -Ref: #assertions-and-prices173759 -Node: Assertions and subaccounts174199 -Ref: #assertions-and-subaccounts174422 -Node: Assertions and virtual postings174746 -Ref: #assertions-and-virtual-postings174982 -Node: Assertions and precision175124 -Ref: #assertions-and-precision175311 -Node: Balance assignments175578 -Ref: #balance-assignments175748 -Node: Balance assignments and prices176912 -Ref: #balance-assignments-and-prices177078 -Node: Directives177302 -Ref: #directives177465 -Node: Directives and multiple files182708 -Ref: #directives-and-multiple-files182904 -Node: Comment blocks183568 -Ref: #comment-blocks183745 -Node: Including other files183921 -Ref: #including-other-files184095 -Node: Default year185019 -Ref: #default-year185182 -Node: Declaring commodities185589 -Ref: #declaring-commodities185766 -Node: Commodity error checking187610 -Ref: #commodity-error-checking187760 -Node: Default commodity188017 -Ref: #default-commodity188197 -Node: Declaring market prices189086 -Ref: #declaring-market-prices189275 -Node: Declaring accounts190132 -Ref: #declaring-accounts190312 -Node: Account error checking191514 -Ref: #account-error-checking191680 -Node: Account comments192859 -Ref: #account-comments193043 -Node: Account subdirectives193467 -Ref: #account-subdirectives193652 -Node: Account types193965 -Ref: #account-types194139 -Node: Declaring account types194875 -Ref: #declaring-account-types195054 -Node: Auto-detected account types195704 -Ref: #auto-detected-account-types195945 -Node: Interference from auto-detected account types196842 -Ref: #interference-from-auto-detected-account-types197119 -Node: Old account type syntax197602 -Ref: #old-account-type-syntax197799 -Node: Account display order198099 -Ref: #account-display-order198259 -Node: Rewriting accounts199410 -Ref: #rewriting-accounts199589 -Node: Basic aliases200346 -Ref: #basic-aliases200482 -Node: Regex aliases201186 -Ref: #regex-aliases201348 -Node: Combining aliases202067 -Ref: #combining-aliases202250 -Node: Aliases and multiple files203526 -Ref: #aliases-and-multiple-files203725 -Node: end aliases204304 -Ref: #end-aliases204451 -Node: Default parent account204552 -Ref: #default-parent-account204742 -Node: Periodic transactions205626 -Ref: #periodic-transactions205809 -Node: Periodic rule syntax207726 -Ref: #periodic-rule-syntax207926 -Node: Two spaces between period expression and description!208630 -Ref: #two-spaces-between-period-expression-and-description208943 -Node: Forecasting with periodic transactions209627 -Ref: #forecasting-with-periodic-transactions209926 -Node: Budgeting with periodic transactions211981 -Ref: #budgeting-with-periodic-transactions212214 -Node: Auto postings212623 -Ref: #auto-postings212759 -Node: Auto postings and multiple files214938 -Ref: #auto-postings-and-multiple-files215136 -Node: Auto postings and dates215345 -Ref: #auto-postings-and-dates215613 -Node: Auto postings and transaction balancing / inferred amounts / balance assertions215788 -Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions216133 -Node: Auto posting tags216475 -Ref: #auto-posting-tags216684 -Node: CSV FORMAT217320 -Ref: #csv-format217448 -Node: Examples220034 -Ref: #examples220137 -Node: Basic220345 -Ref: #basic220447 -Node: Bank of Ireland220989 -Ref: #bank-of-ireland221126 -Node: Amazon222588 -Ref: #amazon222708 -Node: Paypal224427 -Ref: #paypal224523 -Node: CSV rules232167 -Ref: #csv-rules232285 -Node: skip232597 -Ref: #skip232692 -Node: fields233067 -Ref: #fields233191 -Node: Transaction field names234356 -Ref: #transaction-field-names234518 -Node: Posting field names234629 -Ref: #posting-field-names234783 -Node: field assignment237153 -Ref: #field-assignment237298 -Node: separator238116 -Ref: #separator238253 -Node: if block238793 -Ref: #if-block238920 -Node: Matching the whole record239321 -Ref: #matching-the-whole-record239498 -Node: Matching individual fields240302 -Ref: #matching-individual-fields240508 -Node: Combining matchers240732 -Ref: #combining-matchers240930 -Node: Rules applied on successful match241243 -Ref: #rules-applied-on-successful-match241436 -Node: if table242090 -Ref: #if-table242211 -Node: end243949 -Ref: #end244063 -Node: date-format244287 -Ref: #date-format244421 -Node: decimal-mark245170 -Ref: #decimal-mark245315 -Node: newest-first245654 -Ref: #newest-first245797 -Node: include246480 -Ref: #include246613 -Node: balance-type247057 -Ref: #balance-type247179 -Node: Tips247879 -Ref: #tips247970 -Node: Rapid feedback248226 -Ref: #rapid-feedback248345 -Node: Valid CSV248805 -Ref: #valid-csv248937 -Node: File Extension249129 -Ref: #file-extension249283 -Node: Reading multiple CSV files249712 -Ref: #reading-multiple-csv-files249899 -Node: Valid transactions250140 -Ref: #valid-transactions250320 -Node: Deduplicating importing250948 -Ref: #deduplicating-importing251129 -Node: Setting amounts252162 -Ref: #setting-amounts252333 -Node: Setting currency/commodity253320 -Ref: #setting-currencycommodity253514 -Node: Referencing other fields254688 -Ref: #referencing-other-fields254890 -Node: How CSV rules are evaluated255787 -Ref: #how-csv-rules-are-evaluated255962 -Node: TIMECLOCK FORMAT257413 -Ref: #timeclock-format257553 -Node: TIMEDOT FORMAT259614 -Ref: #timedot-format259752 -Node: COMMON TASKS264028 -Ref: #common-tasks264157 -Node: Getting help264564 -Ref: #getting-help264698 -Node: Constructing command lines265251 -Ref: #constructing-command-lines265445 -Node: Starting a journal file266142 -Ref: #starting-a-journal-file266342 -Node: Setting opening balances267530 -Ref: #setting-opening-balances267728 -Node: Recording transactions270869 -Ref: #recording-transactions271051 -Node: Reconciling271607 -Ref: #reconciling271752 -Node: Reporting274009 -Ref: #reporting274151 -Node: Migrating to a new file278150 -Ref: #migrating-to-a-new-file278300 -Node: LIMITATIONS278599 -Ref: #limitations278727 -Node: TROUBLESHOOTING279470 -Ref: #troubleshooting279585 +Node: Command options6394 +Ref: #command-options6545 +Node: Command arguments6945 +Ref: #command-arguments7103 +Node: Special characters7983 +Ref: #special-characters8146 +Node: Single escaping shell metacharacters8309 +Ref: #single-escaping-shell-metacharacters8550 +Node: Double escaping regular expression metacharacters8951 +Ref: #double-escaping-regular-expression-metacharacters9262 +Node: Triple escaping for add-on commands9788 +Ref: #triple-escaping-for-add-on-commands10048 +Node: Less escaping10692 +Ref: #less-escaping10846 +Node: Unicode characters11170 +Ref: #unicode-characters11335 +Node: Regular expressions12747 +Ref: #regular-expressions12887 +Node: ENVIRONMENT14623 +Ref: #environment14739 +Node: DATA FILES15724 +Ref: #data-files15843 +Node: Data formats16382 +Ref: #data-formats16500 +Node: Multiple files17837 +Ref: #multiple-files17979 +Node: Strict mode18448 +Ref: #strict-mode18563 +Node: TIME PERIODS19211 +Ref: #time-periods19328 +Node: Smart dates19426 +Ref: #smart-dates19552 +Node: Report start & end date20878 +Ref: #report-start-end-date21053 +Node: Report intervals22586 +Ref: #report-intervals22754 +Node: Period expressions23144 +Ref: #period-expressions23284 +Node: DEPTH27727 +Ref: #depth27827 +Node: QUERIES28159 +Ref: #queries28260 +Node: VALUATION32222 +Ref: #valuation32330 +Node: -B Cost33019 +Ref: #b-cost33117 +Node: -V Value33250 +Ref: #v-value33390 +Node: -X Value in specified commodity33585 +Ref: #x-value-in-specified-commodity33778 +Node: Valuation date33927 +Ref: #valuation-date34089 +Node: Market prices34526 +Ref: #market-prices34700 +Node: --infer-value market prices from transactions35621 +Ref: #infer-value-market-prices-from-transactions35864 +Node: Valuation commodity37125 +Ref: #valuation-commodity37328 +Node: Simple valuation examples38533 +Ref: #simple-valuation-examples38729 +Node: --value Flexible valuation39388 +Ref: #value-flexible-valuation39590 +Node: More valuation examples41537 +Ref: #more-valuation-examples41740 +Node: Effect of valuation on reports43745 +Ref: #effect-of-valuation-on-reports43927 +Node: PIVOTING50946 +Ref: #pivoting51051 +Node: OUTPUT52727 +Ref: #output52827 +Node: Output destination52878 +Ref: #output-destination53009 +Node: Output format53434 +Ref: #output-format53555 +Node: COMMANDS55722 +Ref: #commands55834 +Node: accounts59199 +Ref: #accounts59299 +Node: activity59995 +Ref: #activity60107 +Node: add60490 +Ref: #add60593 +Node: aregister63386 +Ref: #aregister63500 +Node: aregister and custom posting dates64994 +Ref: #aregister-and-custom-posting-dates65160 +Node: balance65981 +Ref: #balance66100 +Node: Classic balance report67723 +Ref: #classic-balance-report67898 +Node: Customising the classic balance report69222 +Ref: #customising-the-classic-balance-report69452 +Node: Colour support71528 +Ref: #colour-support71697 +Node: Flat mode71793 +Ref: #flat-mode71943 +Node: Depth limited balance reports72356 +Ref: #depth-limited-balance-reports72543 +Node: Percentages72999 +Ref: #percentages73158 +Node: Sorting by amount74295 +Ref: #sorting-by-amount74463 +Node: Multicolumn balance report74957 +Ref: #multicolumn-balance-report75145 +Node: Budget report80742 +Ref: #budget-report80878 +Node: Budget report start date86167 +Ref: #budget-report-start-date86334 +Node: Nested budgets87666 +Ref: #nested-budgets87813 +Node: balancesheet91253 +Ref: #balancesheet91391 +Node: balancesheetequity93028 +Ref: #balancesheetequity93179 +Node: cashflow94398 +Ref: #cashflow94522 +Node: check95856 +Ref: #check95961 +Node: Basic checks96566 +Ref: #basic-checks96684 +Node: Strict checks97177 +Ref: #strict-checks97318 +Node: Other checks97561 +Ref: #other-checks97701 +Node: Add-on checks97999 +Ref: #add-on-checks98119 +Node: close98572 +Ref: #close98676 +Node: close usage100198 +Ref: #close-usage100293 +Node: codes103106 +Ref: #codes103216 +Node: commodities103928 +Ref: #commodities104057 +Node: descriptions104139 +Ref: #descriptions104269 +Node: diff104573 +Ref: #diff104681 +Node: files105728 +Ref: #files105830 +Node: help105977 +Ref: #help106079 +Node: import106806 +Ref: #import106922 +Node: Importing balance assignments107844 +Ref: #importing-balance-assignments108027 +Node: Commodity display styles108676 +Ref: #commodity-display-styles108849 +Node: incomestatement108978 +Ref: #incomestatement109113 +Node: notes110575 +Ref: #notes110690 +Node: payees111058 +Ref: #payees111166 +Node: prices111586 +Ref: #prices111694 +Node: print112035 +Ref: #print112147 +Node: print-unique117632 +Ref: #print-unique117760 +Node: register118045 +Ref: #register118174 +Node: Custom register output122620 +Ref: #custom-register-output122751 +Node: register-match124088 +Ref: #register-match124224 +Node: rewrite124575 +Ref: #rewrite124692 +Node: Re-write rules in a file126598 +Ref: #re-write-rules-in-a-file126761 +Node: Diff output format127910 +Ref: #diff-output-format128093 +Node: rewrite vs print --auto129185 +Ref: #rewrite-vs.-print---auto129345 +Node: roi129901 +Ref: #roi130001 +Node: stats142211 +Ref: #stats142312 +Node: tags143100 +Ref: #tags143200 +Node: test143719 +Ref: #test143835 +Node: About add-on commands144582 +Ref: #about-add-on-commands144719 +Node: JOURNAL FORMAT145850 +Ref: #journal-format145978 +Node: Transactions148144 +Ref: #transactions148259 +Node: Dates149273 +Ref: #dates149389 +Node: Simple dates149454 +Ref: #simple-dates149574 +Node: Secondary dates150083 +Ref: #secondary-dates150231 +Node: Posting dates151567 +Ref: #posting-dates151690 +Node: Status153062 +Ref: #status153179 +Node: Description154887 +Ref: #description155017 +Node: Payee and note155337 +Ref: #payee-and-note155445 +Node: Comments155780 +Ref: #comments155902 +Node: Tags157096 +Ref: #tags-1157207 +Node: Postings158600 +Ref: #postings158724 +Node: Virtual postings159750 +Ref: #virtual-postings159861 +Node: Account names161166 +Ref: #account-names161303 +Node: Amounts161790 +Ref: #amounts161925 +Node: Digit group marks163049 +Ref: #digit-group-marks163194 +Node: Commodity display style164132 +Ref: #commodity-display-style164306 +Node: Rounding166019 +Ref: #rounding166137 +Node: Transaction prices166549 +Ref: #transaction-prices166715 +Node: Lot prices lot dates169146 +Ref: #lot-prices-lot-dates169329 +Node: Balance assertions169817 +Ref: #balance-assertions169995 +Node: Assertions and ordering171028 +Ref: #assertions-and-ordering171210 +Node: Assertions and included files171910 +Ref: #assertions-and-included-files172147 +Node: Assertions and multiple -f options172480 +Ref: #assertions-and-multiple--f-options172730 +Node: Assertions and commodities172862 +Ref: #assertions-and-commodities173088 +Node: Assertions and prices174245 +Ref: #assertions-and-prices174453 +Node: Assertions and subaccounts174893 +Ref: #assertions-and-subaccounts175116 +Node: Assertions and virtual postings175440 +Ref: #assertions-and-virtual-postings175676 +Node: Assertions and precision175818 +Ref: #assertions-and-precision176005 +Node: Balance assignments176272 +Ref: #balance-assignments176442 +Node: Balance assignments and prices177606 +Ref: #balance-assignments-and-prices177772 +Node: Directives177996 +Ref: #directives178159 +Node: Directives and multiple files183402 +Ref: #directives-and-multiple-files183598 +Node: Comment blocks184262 +Ref: #comment-blocks184439 +Node: Including other files184615 +Ref: #including-other-files184789 +Node: Default year185713 +Ref: #default-year185876 +Node: Declaring commodities186283 +Ref: #declaring-commodities186460 +Node: Commodity error checking188304 +Ref: #commodity-error-checking188454 +Node: Default commodity188711 +Ref: #default-commodity188891 +Node: Declaring market prices189780 +Ref: #declaring-market-prices189969 +Node: Declaring accounts190826 +Ref: #declaring-accounts191006 +Node: Account error checking192208 +Ref: #account-error-checking192374 +Node: Account comments193553 +Ref: #account-comments193737 +Node: Account subdirectives194161 +Ref: #account-subdirectives194346 +Node: Account types194659 +Ref: #account-types194833 +Node: Declaring account types195569 +Ref: #declaring-account-types195748 +Node: Auto-detected account types196398 +Ref: #auto-detected-account-types196639 +Node: Interference from auto-detected account types197536 +Ref: #interference-from-auto-detected-account-types197813 +Node: Old account type syntax198296 +Ref: #old-account-type-syntax198493 +Node: Account display order198793 +Ref: #account-display-order198953 +Node: Rewriting accounts200104 +Ref: #rewriting-accounts200283 +Node: Basic aliases201040 +Ref: #basic-aliases201176 +Node: Regex aliases201880 +Ref: #regex-aliases202042 +Node: Combining aliases202761 +Ref: #combining-aliases202944 +Node: Aliases and multiple files204220 +Ref: #aliases-and-multiple-files204419 +Node: end aliases204998 +Ref: #end-aliases205145 +Node: Default parent account205246 +Ref: #default-parent-account205436 +Node: Periodic transactions206320 +Ref: #periodic-transactions206503 +Node: Periodic rule syntax208420 +Ref: #periodic-rule-syntax208620 +Node: Two spaces between period expression and description!209324 +Ref: #two-spaces-between-period-expression-and-description209637 +Node: Forecasting with periodic transactions210321 +Ref: #forecasting-with-periodic-transactions210620 +Node: Budgeting with periodic transactions212675 +Ref: #budgeting-with-periodic-transactions212908 +Node: Auto postings213317 +Ref: #auto-postings213453 +Node: Auto postings and multiple files215632 +Ref: #auto-postings-and-multiple-files215830 +Node: Auto postings and dates216039 +Ref: #auto-postings-and-dates216307 +Node: Auto postings and transaction balancing / inferred amounts / balance assertions216482 +Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions216827 +Node: Auto posting tags217169 +Ref: #auto-posting-tags217378 +Node: CSV FORMAT218014 +Ref: #csv-format218142 +Node: Examples220728 +Ref: #examples220831 +Node: Basic221039 +Ref: #basic221141 +Node: Bank of Ireland221683 +Ref: #bank-of-ireland221820 +Node: Amazon223282 +Ref: #amazon223402 +Node: Paypal225121 +Ref: #paypal225217 +Node: CSV rules232861 +Ref: #csv-rules232979 +Node: skip233291 +Ref: #skip233386 +Node: fields233761 +Ref: #fields233885 +Node: Transaction field names235050 +Ref: #transaction-field-names235212 +Node: Posting field names235323 +Ref: #posting-field-names235477 +Node: field assignment237847 +Ref: #field-assignment237992 +Node: separator238810 +Ref: #separator238947 +Node: if block239487 +Ref: #if-block239614 +Node: Matching the whole record240015 +Ref: #matching-the-whole-record240192 +Node: Matching individual fields240996 +Ref: #matching-individual-fields241202 +Node: Combining matchers241426 +Ref: #combining-matchers241624 +Node: Rules applied on successful match241937 +Ref: #rules-applied-on-successful-match242130 +Node: if table242784 +Ref: #if-table242905 +Node: end244643 +Ref: #end244757 +Node: date-format244981 +Ref: #date-format245115 +Node: decimal-mark245864 +Ref: #decimal-mark246009 +Node: newest-first246348 +Ref: #newest-first246491 +Node: include247174 +Ref: #include247307 +Node: balance-type247751 +Ref: #balance-type247873 +Node: Tips248573 +Ref: #tips248664 +Node: Rapid feedback248920 +Ref: #rapid-feedback249039 +Node: Valid CSV249499 +Ref: #valid-csv249631 +Node: File Extension249823 +Ref: #file-extension249977 +Node: Reading multiple CSV files250406 +Ref: #reading-multiple-csv-files250593 +Node: Valid transactions250834 +Ref: #valid-transactions251014 +Node: Deduplicating importing251642 +Ref: #deduplicating-importing251823 +Node: Setting amounts252856 +Ref: #setting-amounts253027 +Node: Setting currency/commodity254014 +Ref: #setting-currencycommodity254208 +Node: Referencing other fields255382 +Ref: #referencing-other-fields255584 +Node: How CSV rules are evaluated256481 +Ref: #how-csv-rules-are-evaluated256656 +Node: TIMECLOCK FORMAT258107 +Ref: #timeclock-format258247 +Node: TIMEDOT FORMAT260308 +Ref: #timedot-format260446 +Node: COMMON TASKS264722 +Ref: #common-tasks264851 +Node: Getting help265258 +Ref: #getting-help265392 +Node: Constructing command lines265945 +Ref: #constructing-command-lines266139 +Node: Starting a journal file266836 +Ref: #starting-a-journal-file267036 +Node: Setting opening balances268224 +Ref: #setting-opening-balances268422 +Node: Recording transactions271563 +Ref: #recording-transactions271745 +Node: Reconciling272301 +Ref: #reconciling272446 +Node: Reporting274703 +Ref: #reporting274845 +Node: Migrating to a new file278844 +Ref: #migrating-to-a-new-file278994 +Node: LIMITATIONS279293 +Ref: #limitations279421 +Node: TROUBLESHOOTING280164 +Ref: #troubleshooting280279  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index 85d52216e..e76fcb3b6 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -70,7 +70,7 @@ OPTIONS --info show general or COMMAND user manual with info --version - show general or ADDONCOMMAND version + show general or ADDONCMD version --debug[=N] show debug output (levels 1-9, default: 1) @@ -2715,12 +2715,10 @@ 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- - 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- - rectives or inter-transaction comments + journal file, sorted by date (or with --date2, by secondary date). + Amounts are shown right-aligned within each transaction (but not across + all transactions). Directives and inter-transaction comments are not + shown. Eg: $ hledger print 2008/01/01 income @@ -2744,45 +2742,63 @@ COMMANDS liabilities:debts $1 assets:bank:checking $-1 + print's output is usually a valid hledger journal, and you can process + it again with a second hledger command. This can be useful for certain + kinds of search, eg: + + # Show running total of food expenses paid from cash. + # -f- reads from stdin. -I/--ignore-assertions is sometimes needed. + $ hledger print assets:cash | hledger -f- -I reg expenses:food + + There are some situations where print's output can become unparseable: + + o Rounding amounts according to commodity display styles can cause + transactions to appear unbalanced. + + o Valuation affects posting amounts but not balance assertion or bal- + ance assignment amounts, potentially causing those to fail. + + o Auto postings can generate postings with too many missing amounts. + Normally, the journal entry's explicit or implicit amount style is pre- served. For example, when an amount is omitted in the journal, it will - not appear in the output. Similarly, when a transaction price is im- - plied but not written, it will not appear in the output. You can use - the -x/--explicit flag to make all amounts and transaction prices ex- - plicit, which can be useful for troubleshooting or for making your + not appear in the output. Similarly, when a transaction price is im- + plied but not written, it will not appear in the output. You can use + the -x/--explicit flag to make all amounts and transaction prices ex- + plicit, which can be useful for troubleshooting or for making your journal more readable and robust against data entry errors. -x is also implied by using any of -B,-V,-X,--value. - Note, -x/--explicit will cause postings with a multi-commodity amount - (these can arise when a multi-commodity transaction has an implicit - amount) to be split into multiple single-commodity postings, keeping + Note, -x/--explicit will cause postings with a multi-commodity amount + (these can arise when a multi-commodity transaction has an implicit + amount) to be split into multiple single-commodity postings, keeping the output parseable. - With -B/--cost, amounts with transaction prices are converted to cost + With -B/--cost, amounts with transaction prices are converted to cost using that price. This can be used for troubleshooting. - With -m/--match and a STR argument, print will show at most one trans- - action: the one one whose description is most similar to STR, and is - most recent. STR should contain at least two characters. If there is + With -m/--match and a STR argument, print will show at most one trans- + action: the one one whose description is most similar to STR, and is + most recent. STR should contain at least two characters. If there is no similar-enough match, no transaction will be shown. With --new, for each FILE being read, hledger reads (and writes) a spe- - cial state file (.latest.FILE in the same directory), containing the - latest transaction date(s) that were seen last time FILE was read. - When this file is found, only transactions with newer dates (and new - transactions on the latest date) are printed. This is useful for ig- - noring already-seen entries in import data, such as downloaded CSV + cial state file (.latest.FILE in the same directory), containing the + latest transaction date(s) that were seen last time FILE was read. + When this file is found, only transactions with newer dates (and new + transactions on the latest date) are printed. This is useful for ig- + noring already-seen entries in import data, such as downloaded CSV files. Eg: $ hledger -f bank1.csv print --new (shows transactions added since last print --new on this file) - This assumes that transactions added to FILE always have same or in- - creasing dates, and that transactions on the same day do not get re- + This assumes that transactions added to FILE always have same or in- + creasing dates, and that transactions on the same day do not get re- ordered. See also the import command. This command also supports the output destination and output format op- - tions The output formats supported are txt, csv, and (experimental) + tions The output formats supported are txt, csv, and (experimental) json and sql. Here's an example of print's CSV output: @@ -2801,20 +2817,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 @@ -2838,14 +2854,14 @@ COMMANDS Show postings and their running total. The register command displays matched postings, across all accounts, in - date order, with their running total or running historical balance. - (See also the aregister command, which shows matched transactions in a + date order, with their running total or running historical balance. + (See also the aregister command, which shows matched transactions in a specific account.) register normally shows line per posting, but note that multi-commodity amounts will occupy multiple lines (one line per commodity). - It is typically used with a query selecting a particular account, to + It is typically used with a query selecting a particular account, to see that account's activity: $ hledger register checking @@ -2856,8 +2872,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 @@ -2867,18 +2883,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 @@ -2890,7 +2906,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 @@ -2907,7 +2923,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 @@ -2915,17 +2931,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): @@ -2944,27 +2960,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: @@ -2980,7 +2996,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: @@ -2990,16 +3006,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. @@ -3014,7 +3030,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. @@ -3027,12 +3043,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' @@ -3056,10 +3072,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: @@ -3067,49 +3083,49 @@ COMMANDS https://github.com/simonmichael/hledger/issues/99 rewrite vs. print --auto - This command predates print --auto, and currently does much the same + This command predates print --auto, and currently does much the same thing, but with these differences: - o with multiple files, rewrite lets rules in any file affect all other - files. print --auto uses standard directive scoping; rules affect + o with multiple files, rewrite lets rules in any file affect all other + files. print --auto uses standard directive scoping; rules affect only child files. - o rewrite's query limits which transactions can be rewritten; all are + o rewrite's query limits which transactions can be rewritten; all are printed. print --auto's query limits which transactions are printed. - o rewrite applies rules specified on command line or in the journal. + o rewrite applies rules specified on command line or in the journal. print --auto applies rules specified in the journal. roi roi - Shows the time-weighted (TWR) and money-weighted (IRR) rate of return + Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on your investments. - This command assumes that you have account(s) that hold nothing but + This command assumes that you have account(s) that hold nothing but your investments and whenever you record current appraisal/valuation of these investments you offset unrealized profit and loss into account(s) that, again, hold nothing but unrealized profit and loss. - Any transactions affecting balance of investment account(s) and not - originating from unrealized profit and loss account(s) are assumed to + Any transactions affecting balance of investment account(s) and not + originating from unrealized profit and loss account(s) are assumed to be your investments or withdrawals. - At a minimum, you need to supply a query (which could be just an ac- + At a minimum, you need to supply a query (which could be just an ac- count name) to select your investments with --inv, and another query to identify your profit and loss transactions with --pnl. - This command will compute and display the internalized rate of return - (IRR) and time-weighted rate of return (TWR) for your investments for - the time period requested. Both rates of return are annualized before + This command will compute and display the internalized rate of return + (IRR) and time-weighted rate of return (TWR) for your investments for + the time period requested. Both rates of return are annualized before display, regardless of the length of reporting interval. Note, in some cases this report can fail, for these reasons: - o Error (NotBracketed): No solution for Internal Rate of Return (IRR). - Possible causes: IRR is huge (>1000000%), balance of investment be- + o Error (NotBracketed): No solution for Internal Rate of Return (IRR). + Possible causes: IRR is huge (>1000000%), balance of investment be- comes negative at some point in time. - o Error (SearchFailed): Failed to find solution for Internal Rate of + o Error (SearchFailed): Failed to find solution for Internal Rate of Return (IRR). Either search does not converge to a solution, or con- verges too slowly. @@ -3120,67 +3136,67 @@ COMMANDS More background: - "ROI" stands for "return on investment". Traditionally this was com- - puted as a difference between current value of investment and its ini- + "ROI" stands for "return on investment". Traditionally this was com- + puted as a difference between current value of investment and its ini- tial value, expressed in percentage of the initial value. However, this approach is only practical in simple cases, where invest- - ments receives no in-flows or out-flows of money, and where rate of + ments receives no in-flows or out-flows of money, and where rate of growth is fixed over time. For more complex scenarios you need differ- - ent ways to compute rate of return, and this command implements two of + ent ways to compute rate of return, and this command implements two of them: IRR and TWR. - Internal rate of return, or "IRR" (also called "money-weighted rate of - return") takes into account effects of in-flows and out-flows. + Internal rate of return, or "IRR" (also called "money-weighted rate of + return") takes into account effects of in-flows and out-flows. Naively, if you are withdrawing from your investment, your future gains - would be smaller (in absolute numbers), and will be a smaller percent- - age of your initial investment, and if you are adding to your invest- - ment, you will receive bigger absolute gains (but probably at the same - rate of return). IRR is a way to compute rate of return for each pe- - riod between in-flow or out-flow of money, and then combine them in a + would be smaller (in absolute numbers), and will be a smaller percent- + age of your initial investment, and if you are adding to your invest- + ment, you will receive bigger absolute gains (but probably at the same + rate of return). IRR is a way to compute rate of return for each pe- + riod between in-flow or out-flow of money, and then combine them in a way that gives you an annual rate of return that investment is expected to generate. - As mentioned before, in-flows and out-flows would be any cash that you - personally put in or withdraw, and for the "roi" command, these are - transactions that involve account(s) matching --inv argument and NOT + As mentioned before, in-flows and out-flows would be any cash that you + personally put in or withdraw, and for the "roi" command, these are + transactions that involve account(s) matching --inv argument and NOT involve account(s) matching --pnl argument. - Presumably, you will also record changes in the value of your invest- - ment, and balance them against "profit and loss" (or "unrealized + Presumably, you will also record changes in the value of your invest- + ment, and balance them against "profit and loss" (or "unrealized gains") account. Note that in order for IRR to compute the precise ef- - fect of your in-flows and out-flows on the rate of return, you will - need to record the value of your investement on or close to the days + fect of your in-flows and out-flows on the rate of return, you will + need to record the value of your investement on or close to the days when in- or out-flows occur. - Implementation of IRR in hledger should match the XIRR formula in Ex- + Implementation of IRR in hledger should match the XIRR formula in Ex- cel. - Second way to compute rate of return that roi command implements is + Second way to compute rate of return that roi command implements is called "time-weighted rate of return" or "TWR". Like IRR, it will also - break the history of your investment into periods between in-flows and + break the history of your investment into periods between in-flows and out-flows to compute rate of return per each period and then a compound rate of return. However, internal workings of TWR are quite different. - In technical terms, IRR uses the same approach as computation of net + In technical terms, IRR uses the same approach as computation of net present value, and tries to find a discount rate that makes net present value of all the cash flows of your investment to add up to zero. This - could be hard to wrap your head around, especially if you haven't done + could be hard to wrap your head around, especially if you haven't done discounted cash flow analysis before. - TWR represents your investment as an imaginary "unit fund" where in- - flows/ out-flows lead to buying or selling "units" of your investment + TWR represents your investment as an imaginary "unit fund" where in- + flows/ out-flows lead to buying or selling "units" of your investment and changes in its value change the value of "investment unit". Change - in "unit price" over the reporting period gives you rate of return of + in "unit price" over the reporting period gives you rate of return of your investment. - References: * Explanation of rate of return * Explanation of IRR * Ex- - planation of TWR * Examples of computing IRR and TWR and discussion of + References: * Explanation of rate of return * Explanation of IRR * Ex- + planation of TWR * Examples of computing IRR and TWR and discussion of the limitations of both metrics More examples: - Lets say that we found an investment in Snake Oil that is proising to + Lets say that we found an investment in Snake Oil that is proising to give us 10% annually: 2019-01-01 Investing in Snake Oil @@ -3191,7 +3207,7 @@ COMMANDS investment:snake oil = $110 equity:unrealized gains - For now, basic computation of the rate of return, as well as IRR and + For now, basic computation of the rate of return, as well as IRR and TWR, gives us the expected 10%: $ hledger roi -Y --inv investment --pnl "unrealized" @@ -3201,10 +3217,10 @@ COMMANDS | 1 || 2019-01-01 | 2019-12-31 || 0 | 100 | 110 | 10 || 10.00% | 10.00% | +---++------------+------------++---------------+----------+-------------+-----++--------+--------+ - However, lets say that shorty after investing in the Snake Oil we - started to have second thoughs, so we prompty withdrew $90, leaving - only $10 in. Before Christmas, though, we started to get the "fear of - mission out", so we put the $90 back in. So for most of the year, our + However, lets say that shorty after investing in the Snake Oil we + started to have second thoughs, so we prompty withdrew $90, leaving + only $10 in. Before Christmas, though, we started to get the "fear of + mission out", so we put the $90 back in. So for most of the year, our investment was just $10 dollars, and it gave us just $1 in growth: 2019-01-01 Investing in Snake Oil @@ -3235,10 +3251,10 @@ COMMANDS Here, IRR tells us that we made close to 10% on the $10 dollars that we had in the account most of the time. And TWR is ... just 1%? Why? - Based on the transactions in our journal, TWR "think" that we are buy- - ing back $90 worst of Snake Oil at the same price that it had at the + Based on the transactions in our journal, TWR "think" that we are buy- + ing back $90 worst of Snake Oil at the same price that it had at the beginning of they year, and then after that our $100 investment gets $1 - increase in value, or 1% of $100. Let's take a closer look at what is + increase in value, or 1% of $100. Let's take a closer look at what is happening here by asking for quarterly reports instead of annual: $ hledger roi -Q --inv investment --pnl "unrealized" @@ -3251,10 +3267,10 @@ COMMANDS | 4 || 2019-10-01 | 2019-12-31 || 10 | 90 | 101 | 1 || 37.80% | 4.03% | +---++------------+------------++---------------+----------+-------------+-----++--------+-------+ - Now both IRR and TWR are thrown off by the fact that all of the growth - for our investment happens in Q4 2019. This happes because IRR compu- + Now both IRR and TWR are thrown off by the fact that all of the growth + for our investment happens in Q4 2019. This happes because IRR compu- tation is still yielding 9.32% and TWR is still 1%, but this time these - are rates for three month period instead of twelve, so in order to get + are rates for three month period instead of twelve, so in order to get an annual rate they should be multiplied by four! Let's try to keep a better record of how Snake Oil grew in value: @@ -3299,10 +3315,10 @@ COMMANDS | 4 || 2019-10-01 | 2019-12-31 || 10.75 | 90 | 101.00 | 0.25 || 8.05% | 1.00% | +---++------------+------------++---------------+----------+-------------+------++--------+--------+ - Something is still wrong with TWR computation for Q4, and if you have - been paying attention you know what it is already: big $90 buy-back is - recorded prior to the only transaction that captures the change of - value of Snake Oil that happened in this time period. Lets combine + Something is still wrong with TWR computation for Q4, and if you have + been paying attention you know what it is already: big $90 buy-back is + recorded prior to the only transaction that captures the change of + value of Snake Oil that happened in this time period. Lets combine transactions from 30th and 31st of Dec into one: 2019-12-30 Fear of missing out and growth of Snake Oil @@ -3323,7 +3339,7 @@ COMMANDS | 4 || 2019-10-01 | 2019-12-31 || 10.75 | 90 | 101.00 | 0.25 || 8.05% | 9.57% | +---++------------+------------++---------------+----------+-------------+------++--------+--------+ - And for annual report, TWR now reports the exact profitability of our + And for annual report, TWR now reports the exact profitability of our investment: $ hledger roi -Y --inv investment --pnl "unrealized" @@ -3337,8 +3353,8 @@ COMMANDS stats Show some journal statistics. - The stats command displays summary information for the whole journal, - or a matched part of it. With a reporting interval, it shows a report + The stats command displays summary information for the whole journal, + or a matched part of it. With a reporting interval, it shows a report for each report period. Example: @@ -3356,35 +3372,35 @@ COMMANDS Commodities : 1 ($) Market prices : 12 ($) - This command also supports output destination and output format selec- + This command also supports output destination and output format selec- tion. tags tags - List the unique tag names used in the journal. With a TAGREGEX argu- + List the unique tag names used in the journal. With a TAGREGEX argu- ment, only tag names matching the regular expression (case insensitive) - are shown. With QUERY arguments, only transactions matching the query + are shown. With QUERY arguments, only transactions matching the query are considered. With the --values flag, the tags' unique values are listed instead. - With --parsed flag, all tags or values are shown in the order they are + With --parsed flag, all tags or values are shown in the order they are parsed from the input data, including duplicates. - With -E/--empty, any blank/empty values will also be shown, otherwise + With -E/--empty, any blank/empty values will also be shown, otherwise they are omitted. test test Run built-in unit tests. - This command runs the unit tests built in to hledger and hledger-lib, - printing the results on stdout. If any test fails, the exit code will + This command runs the unit tests built in to hledger and hledger-lib, + printing the results on stdout. If any test fails, the exit code will be non-zero. - This is mainly used by hledger developers, but you can also use it to - sanity-check the installed hledger executable on your platform. All - tests are expected to pass - if you ever see a failure, please report + This is mainly used by hledger developers, but you can also use it to + sanity-check the installed hledger executable on your platform. All + tests are expected to pass - if you ever see a failure, please report as a bug! This command also accepts tasty test runner options, written after a -- @@ -3393,7 +3409,7 @@ COMMANDS $ hledger test -- -pData.Amount --color=never - For help on these, see https://github.com/feuerbach/tasty#options (-- + For help on these, see https://github.com/feuerbach/tasty#options (-- --help currently doesn't show them). About add-on commands @@ -3401,16 +3417,16 @@ COMMANDS o whose name starts with hledger- - o whose name ends with a recognised file extension: .bat,.com,.exe, + o whose name ends with a recognised file extension: .bat,.com,.exe, .hs,.lhs,.pl,.py,.rb,.rkt,.sh or none o and (on unix, mac) which are executable by the current user. - Add-ons are a relatively easy way to add local features or experiment - with new ideas. They can be written in any language, but haskell - scripts have a big advantage: they can use the same hledger library - functions that built-in commands use for command-line options, parsing - and reporting. Some experimental/example add-on scripts can be found + Add-ons are a relatively easy way to add local features or experiment + with new ideas. They can be written in any language, but haskell + scripts have a big advantage: they can use the same hledger library + functions that built-in commands use for command-line options, parsing + and reporting. Some experimental/example add-on scripts can be found in the hledger repo's bin/ directory. Note in a hledger command line, add-on command flags must have a double @@ -3435,16 +3451,16 @@ JOURNAL FORMAT hledger's default file format, representing a General Journal. hledger's usual data source is a plain text file containing journal en- - tries in hledger journal format. This file represents a standard ac- - counting general journal. I use file names ending in .journal, but + tries in hledger journal format. This file represents a standard ac- + counting general journal. I use file names ending in .journal, but that's not required. The journal file contains a number of transaction entries, each describing a transfer of money (or any commodity) between two or more named accounts, in a simple format readable by both hledger and humans. - hledger's journal format is a compatible subset, mostly, of ledger's - journal format, so hledger can work with compatible ledger journal - files as well. It's safe, and encouraged, to run both hledger and + hledger's journal format is a compatible subset, mostly, of ledger's + journal format, so hledger can work with compatible ledger journal + files as well. It's safe, and encouraged, to run both hledger and ledger on the same journal file, eg to validate the results you're get- ting. @@ -3452,24 +3468,24 @@ JOURNAL FORMAT the add or web or import commands to create and update it. Many users, though, edit the journal file with a text editor, and track - changes with a version control system such as git. Editor addons such - as ledger-mode or hledger-mode for Emacs, vim-ledger for Vim, and + changes with a version control system such as git. Editor addons such + as ledger-mode or hledger-mode for Emacs, vim-ledger for Vim, and hledger-vscode for Visual Studio Code, make this easier, adding colour, formatting, tab completion, and useful commands. See Editor configura- tion at hledger.org for the full list. - Here's a description of each part of the file format (and hledger's - data model). These are mostly in the order you'll use them, but in - some cases related concepts have been grouped together for easy refer- - ence, or linked before they are introduced, so feel free to skip over + Here's a description of each part of the file format (and hledger's + data model). These are mostly in the order you'll use them, but in + some cases related concepts have been grouped together for easy refer- + ence, or linked before they are introduced, so feel free to skip over anything that looks unnecessary right now. Transactions - Transactions are the main unit of information in a journal file. They - represent events, typically a movement of some quantity of commodities + Transactions are the main unit of information in a journal file. They + represent events, typically a movement of some quantity of commodities between two or more named accounts. - Each transaction is recorded as a journal entry, beginning with a sim- + Each transaction is recorded as a journal entry, beginning with a sim- ple date in column 0. This can be followed by any of the following op- tional fields, separated by spaces: @@ -3479,11 +3495,11 @@ JOURNAL FORMAT o a description (any remaining text until end of line or a semicolon) - o a comment (any remaining text following a semicolon until end of + o a comment (any remaining text following a semicolon until end of line, and any following indented lines beginning with a semicolon) o 0 or more indented posting lines, describing what was transferred and - the accounts involved (indented comment lines are also allowed, but + the accounts involved (indented comment lines are also allowed, but not blank lines or non-indented lines). Here's a simple journal file containing one transaction: @@ -3494,35 +3510,35 @@ JOURNAL FORMAT Dates Simple dates - Dates in the journal file use simple dates format: YYYY-MM-DD or + Dates in the journal file use simple dates format: YYYY-MM-DD or YYYY/MM/DD or YYYY.MM.DD, with leading zeros optional. The year may be - omitted, in which case it will be inferred from the context: the cur- - rent transaction, the default year set with a default year directive, - or the current date when the command is run. Some examples: + omitted, in which case it will be inferred from the context: the cur- + rent transaction, the default year set with a default year directive, + or the current date when the command is run. Some examples: 2010-01-31, 2010/01/31, 2010.1.31, 1/31. - (The UI also accepts simple dates, as well as the more flexible smart + (The UI also accepts simple dates, as well as the more flexible smart dates documented in the hledger manual.) Secondary dates - Real-life transactions sometimes involve more than one date - eg the + Real-life transactions sometimes involve more than one date - eg the date you write a cheque, and the date it clears in your bank. When you - want to model this, for more accurate daily balances, you can specify + want to model this, for more accurate daily balances, you can specify individual posting dates. - Or, you can use the older secondary date feature (Ledger calls it aux- - iliary date or effective date). Note: we support this for compatibil- - ity, but I usually recommend avoiding this feature; posting dates are + Or, you can use the older secondary date feature (Ledger calls it aux- + iliary date or effective date). Note: we support this for compatibil- + ity, but I usually recommend avoiding this feature; posting dates are almost always clearer and simpler. A secondary date is written after the primary date, following an equals - sign. If the year is omitted, the primary date's year is assumed. - When running reports, the primary (left) date is used by default, but - with the --date2 flag (or --aux-date or --effective), the secondary + sign. If the year is omitted, the primary date's year is assumed. + When running reports, the primary (left) date is used by default, but + with the --date2 flag (or --aux-date or --effective), the secondary (right) date will be used instead. - The meaning of secondary dates is up to you, but it's best to follow a - consistent rule. Eg "primary = the bank's clearing date, secondary = + The meaning of secondary dates is up to you, but it's best to follow a + consistent rule. Eg "primary = the bank's clearing date, secondary = date the transaction was initiated, if different", as shown here: 2010/2/23=2/19 movie ticket @@ -3536,11 +3552,11 @@ JOURNAL FORMAT 2010-02-19 movie ticket assets:checking $-10 $-10 Posting dates - You can give individual postings a different date from their parent - transaction, by adding a posting comment containing a tag (see below) + You can give individual postings a different date from their parent + transaction, by adding a posting comment containing a tag (see below) like date:DATE. This is probably the best way to control posting dates - precisely. Eg in this example the expense should appear in May re- - ports, and the deduction from checking should be reported on 6/1 for + precisely. Eg in this example the expense should appear in May re- + ports, and the deduction from checking should be reported on 6/1 for easy bank reconciliation: 2015/5/30 @@ -3553,22 +3569,22 @@ JOURNAL FORMAT $ hledger -f t.j register checking 2015-06-01 assets:checking $-10 $-10 - DATE should be a simple date; if the year is not specified it will use - the year of the transaction's date. You can set the secondary date - similarly, with date2:DATE2. The date: or date2: tags must have a - valid simple date value if they are present, eg a date: tag with no + DATE should be a simple date; if the year is not specified it will use + the year of the transaction's date. You can set the secondary date + similarly, with date2:DATE2. The date: or date2: tags must have a + valid simple date value if they are present, eg a date: tag with no value is not allowed. Ledger's earlier, more compact bracketed date syntax is also supported: - [DATE], [DATE=DATE2] or [=DATE2]. hledger will attempt to parse any + [DATE], [DATE=DATE2] or [=DATE2]. hledger will attempt to parse any square-bracketed sequence of the 0123456789/-.= characters in this way. - With this syntax, DATE infers its year from the transaction and DATE2 + With this syntax, DATE infers its year from the transaction and DATE2 infers its year from DATE. Status - Transactions, or individual postings within a transaction, can have a - status mark, which is a single character before the transaction de- - scription or posting account name, separated from it by a space, indi- + Transactions, or individual postings within a transaction, can have a + status mark, which is a single character before the transaction de- + scription or posting account name, separated from it by a space, indi- cating one of three statuses: mark status @@ -3577,23 +3593,23 @@ JOURNAL FORMAT ! pending * cleared - When reporting, you can filter by status with the -U/--unmarked, - -P/--pending, and -C/--cleared flags; or the status:, status:!, and + When reporting, you can filter by status with the -U/--unmarked, + -P/--pending, and -C/--cleared flags; or the status:, status:!, and status:* queries; or the U, P, C keys in hledger-ui. - Note, in Ledger and in older versions of hledger, the "unmarked" state - is called "uncleared". As of hledger 1.3 we have renamed it to un- + Note, in Ledger and in older versions of hledger, the "unmarked" state + is called "uncleared". As of hledger 1.3 we have renamed it to un- marked for clarity. - To replicate Ledger and old hledger's behaviour of also matching pend- + To replicate Ledger and old hledger's behaviour of also matching pend- ing, combine -U and -P. - Status marks are optional, but can be helpful eg for reconciling with + Status marks are optional, but can be helpful eg for reconciling with real-world accounts. Some editor modes provide highlighting and short- - cuts for working with status. Eg in Emacs ledger-mode, you can toggle + cuts for working with status. Eg in Emacs ledger-mode, you can toggle transaction status with C-c C-e, or posting status with C-c C-c. - What "uncleared", "pending", and "cleared" actually mean is up to you. + What "uncleared", "pending", and "cleared" actually mean is up to you. Here's one suggestion: status meaning @@ -3604,34 +3620,34 @@ JOURNAL FORMAT cleared complete, reconciled as far as possible, and considered cor- rect - With this scheme, you would use -PC to see the current balance at your + With this scheme, you would use -PC to see the current balance at your bank, -U to see things which will probably hit your bank soon (like un- - cashed checks), and no flags to see the most up-to-date state of your + cashed checks), and no flags to see the most up-to-date state of your finances. Description - A transaction's description is the rest of the line following the date - and status mark (or until a comment begins). Sometimes called the + A transaction's description is the rest of the line following the date + and status mark (or until a comment begins). Sometimes called the "narration" in traditional bookkeeping, it can be used for whatever you - wish, or left blank. Transaction descriptions can be queried, unlike + wish, or left blank. Transaction descriptions can be queried, unlike comments. Payee and note You can optionally include a | (pipe) character in descriptions to sub- divide the description into separate fields for payee/payer name on the left (up to the first |) and an additional note field on the right (af- - ter the first |). This may be worthwhile if you need to do more pre- + ter the first |). This may be worthwhile if you need to do more pre- cise querying and pivoting by payee or by note. Comments Lines in the journal beginning with a semicolon (;) or hash (#) or star - (*) are comments, and will be ignored. (Star comments cause org-mode - nodes to be ignored, allowing emacs users to fold and navigate their + (*) are comments, and will be ignored. (Star comments cause org-mode + nodes to be ignored, allowing emacs users to fold and navigate their journals with org-mode or orgstruct-mode.) - You can attach comments to a transaction by writing them after the de- + You can attach comments to a transaction by writing them after the de- scription and/or indented on the following lines (before the postings). - Similarly, you can attach comments to an individual posting by writing + Similarly, you can attach comments to an individual posting by writing them after the amount and/or indented on the following lines. Transac- tion and posting comments must begin with a semicolon (;). @@ -3655,24 +3671,24 @@ JOURNAL FORMAT ; another comment line for posting 2 ; a file comment (because not indented) - You can also comment larger regions of a file using comment and end + You can also comment larger regions of a file using comment and end comment directives. Tags - Tags are a way to add extra labels or labelled data to postings and + Tags are a way to add extra labels or labelled data to postings and transactions, which you can then search or pivot on. - A simple tag is a word (which may contain hyphens) followed by a full + A simple tag is a word (which may contain hyphens) followed by a full colon, written inside a transaction or posting comment line: 2017/1/16 bought groceries ; sometag: - Tags can have a value, which is the text after the colon, up to the + Tags can have a value, which is the text after the colon, up to the next comma or end of line, with leading/trailing whitespace removed: expenses:food $10 ; a-posting-tag: the tag value - Note this means hledger's tag values can not contain commas or new- + Note this means hledger's tag values can not contain commas or new- lines. Ending at commas means you can write multiple short tags on one line, comma separated: @@ -3686,57 +3702,57 @@ JOURNAL FORMAT o "tag2" is another tag, whose value is "some value ..." - Tags in a transaction comment affect the transaction and all of its - postings, while tags in a posting comment affect only that posting. - For example, the following transaction has three tags (A, TAG2, third- + Tags in a transaction comment affect the transaction and all of its + postings, while tags in a posting comment affect only that posting. + For example, the following transaction has three tags (A, TAG2, third- tag) and the posting has four (those plus posting-tag): 1/1 a transaction ; A:, TAG2: ; third-tag: a third transaction tag, <- with a value (a) $1 ; posting-tag: - Tags are like Ledger's metadata feature, except hledger's tag values + Tags are like Ledger's metadata feature, except hledger's tag values are simple strings. Postings - A posting is an addition of some amount to, or removal of some amount - from, an account. Each posting line begins with at least one space or + A posting is an addition of some amount to, or removal of some amount + from, an account. Each posting line begins with at least one space or tab (2 or 4 spaces is common), followed by: o (optional) a status character (empty, !, or *), followed by a space - o (required) an account name (any text, optionally containing single + o (required) an account name (any text, optionally containing single spaces, until end of line or a double space) o (optional) two or more spaces or tabs followed by an amount. - Positive amounts are being added to the account, negative amounts are + Positive amounts are being added to the account, negative amounts are being removed. The amounts within a transaction must always sum up to zero. As a con- - venience, one amount may be left blank; it will be inferred so as to + venience, one amount may be left blank; it will be inferred so as to balance the transaction. - Be sure to note the unusual two-space delimiter between account name - and amount. This makes it easy to write account names containing spa- - ces. But if you accidentally leave only one space (or tab) before the + Be sure to note the unusual two-space delimiter between account name + and amount. This makes it easy to write account names containing spa- + ces. But if you accidentally leave only one space (or tab) before the amount, the amount will be considered part of the account name. Virtual postings A posting with a parenthesised account name is called a virtual posting - or unbalanced posting, which means it is exempt from the usual rule + or unbalanced posting, which means it is exempt from the usual rule that a transaction's postings must balance add up to zero. - This is not part of double entry accounting, so you might choose to - avoid this feature. Or you can use it sparingly for certain special - cases where it can be convenient. Eg, you could set opening balances + This is not part of double entry accounting, so you might choose to + avoid this feature. Or you can use it sparingly for certain special + cases where it can be convenient. Eg, you could set opening balances without using a balancing equity account: 1/1 opening balances (assets:checking) $1000 (assets:savings) $2000 - A posting with a bracketed account name is called a balanced virtual + A posting with a bracketed account name is called a balanced virtual posting. The balanced virtual postings in a transaction must add up to zero (separately from other postings). Eg: @@ -3748,34 +3764,34 @@ JOURNAL FORMAT [assets:checking:available] $10 ; <- (something:else) $5 ; <- not required to balance - Ordinary non-parenthesised, non-bracketed postings are called real - postings. You can exclude virtual postings from reports with the + Ordinary non-parenthesised, non-bracketed postings are called real + postings. You can exclude virtual postings from reports with the -R/--real flag or real:1 query. Account names - Account names typically have several parts separated by a full colon, - from which hledger derives a hierarchical chart of accounts. They can - be anything you like, but in finance there are traditionally five top- + 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 @@ -3787,13 +3803,13 @@ JOURNAL FORMAT 3 "no. 42 green apples" Amounts can be preceded by a minus sign (or a plus sign, though plus is - the default), The sign can be written before or after a left-side com- + the default), The sign can be written before or after a left-side com- modity symbol: -$1 $-1 - One or more spaces between the sign and the number are acceptable when + One or more spaces between the sign and the number are acceptable when parsing (but they won't be displayed in output): + $1 @@ -3810,8 +3826,8 @@ JOURNAL FORMAT 1,23456780000009 Digit group marks - In the integer part of the quantity (left of the decimal mark), groups - of digits can optionally be separated by a "digit group mark" - a + In the integer part of the quantity (left of the decimal mark), groups + of digits can optionally be separated by a "digit group mark" - a space, comma, or period (different from the decimal mark): $1,000,000.00 @@ -3819,7 +3835,7 @@ JOURNAL FORMAT INR 9,99,99,999.00 1 000 000.9455 - Note, a number containing a single group mark and no decimal mark is + Note, a number containing a single group mark and no decimal mark is ambiguous. Are these group marks or decimal marks ? 1,000 @@ -3827,9 +3843,9 @@ JOURNAL FORMAT hledger will treat them both as decimal marks by default (cf #793). If you use digit group marks, to prevent confusion and undetected typos we - recommend you write commodity directives at the top of the file to ex- - plicitly declare the decimal mark (and optionally a digit group mark). - Note, these formats ("amount styles") are specific to each commodity, + recommend you write commodity directives at the top of the file to ex- + plicitly declare the decimal mark (and optionally a digit group mark). + Note, these formats ("amount styles") are specific to each commodity, so if your data uses multiple formats, hledger can handle it: commodity $1,000.00 @@ -3839,43 +3855,43 @@ JOURNAL FORMAT Commodity display style For the amounts in each commodity, hledger chooses a consistent display - style. (Excluding price amounts, which are always displayed as writ- + style. (Excluding price amounts, which are always displayed as writ- ten). The display style is chosen as follows: - o If there is a commodity directive (or default commodity directive) + o If there is a commodity directive (or default commodity directive) for the commodity, its style is used (see examples above). - o Otherwise the style is inferred from the amounts in that commodity + o Otherwise the style is inferred from the amounts in that commodity seen in the journal. - o Or if there are no such amounts in the journal, a default style is + o Or if there are no such amounts in the journal, a default style is used (like $1000.00). A style is inferred from the journal amounts in a commodity as follows: - o Use the general style (decimal mark, symbol placement) of the first + o Use the general style (decimal mark, symbol placement) of the first amount - o Use the first-seen digit group style (digit group mark, digit group + o Use the first-seen digit group style (digit group mark, digit group sizes), if any o Use the maximum number of decimal places of all. - Transaction price amounts don't affect the commodity display style di- + Transaction price amounts don't affect the commodity display style di- rectly, but occasionally they can do so indirectly (eg when a posting's - amount is inferred using a transaction price). If you find this caus- + amount is inferred using a transaction price). If you find this caus- ing problems, use a commodity directive to fix the display style. In summary, each commodity's amounts will be normalised to o the style declared by a commodity directive - o or, the style of the first posting amount in the journal, with the - first-seen digit group style and the maximum-seen number of decimal + o or, the style of the first posting amount in the journal, with the + first-seen digit group style and the maximum-seen number of decimal places. So if your reports are showing amounts in a way you don't like, eg with - too many decimal places, use a commodity directive to set the commod- + too many decimal places, use a commodity directive to set the commod- ity's display style. For example: # declare euro, dollar and bitcoin commodities and set their display styles: @@ -3885,17 +3901,17 @@ JOURNAL FORMAT Rounding Amounts are stored internally as decimal numbers with up to 255 decimal - places, and displayed with the number of decimal places specified by - the commodity display style. Note, hledger uses banker's rounding: it - rounds to the nearest even number, eg 0.5 displayed with zero decimal - places is "0"). (Guaranteed since hledger 1.17.1; in older versions + places, and displayed with the number of decimal places specified by + the commodity display style. Note, hledger uses banker's rounding: it + rounds to the nearest even number, eg 0.5 displayed with zero decimal + places is "0"). (Guaranteed since hledger 1.17.1; in older versions this could vary if hledger was built with Decimal < 0.5.1.) Transaction prices Within a transaction, you can note an amount's price in another commod- - ity. This can be used to document the cost (in a purchase) or selling - price (in a sale). For example, transaction prices are useful to - record purchases of a foreign currency. Note transaction prices are + ity. This can be used to document the cost (in a purchase) or selling + price (in a sale). For example, transaction prices are useful to + record purchases of a foreign currency. Note transaction prices are fixed at the time of the transaction, and do not change over time. See also market prices, which represent prevailing exchange rates on a cer- tain date. @@ -3921,14 +3937,14 @@ JOURNAL FORMAT assets:euros EUR100 ; one hundred euros purchased assets:dollars $-135 ; for $135 - 4. Like 1, but the @ is parenthesised, i.e. (@); this is for compati- - bility with Ledger journals (Virtual posting costs), and is equiva- + 4. Like 1, but the @ is parenthesised, i.e. (@); this is for compati- + bility with Ledger journals (Virtual posting costs), and is equiva- lent to 1 in hledger. 5. Like 2, but as in 4 the @@ is parenthesised, i.e. (@@); in hledger, this is equivalent to 2. - Use the -B/--cost flag to convert amounts to their transaction price's + Use the -B/--cost flag to convert amounts to their transaction price's commodity, if any. (mnemonic: "B" is from "cost Basis", as in Ledger). Eg here is how -B affects the balance report for the example above: @@ -3939,8 +3955,8 @@ JOURNAL FORMAT $-135 assets:dollars $135 assets:euros # <- the euros' cost - Note -B is sensitive to the order of postings when a transaction price - is inferred: the inferred price will be in the commodity of the last + Note -B is sensitive to the order of postings when a transaction price + is inferred: the inferred price will be in the commodity of the last amount. So if example 3's postings are reversed, while the transaction is equivalent, -B shows something different: @@ -3953,18 +3969,18 @@ JOURNAL FORMAT EUR100 assets:euros Lot prices, lot dates - Ledger allows another kind of price, lot price (four variants: {UNIT- + Ledger allows another kind of price, lot price (four variants: {UNIT- PRICE}, {{TOTALPRICE}}, {=FIXEDUNITPRICE}, {{=FIXEDTOTALPRICE}}), and/or a lot date ([DATE]) to be specified. These are normally used to - select a lot when selling investments. hledger will parse these, for - compatibility with Ledger journals, but currently ignores them. A - transaction price, lot price and/or lot date may appear in any order, + select a lot when selling investments. hledger will parse these, for + compatibility with Ledger journals, but currently ignores them. A + transaction price, lot price and/or lot date may appear in any order, after the posting amount and before the balance assertion if any. Balance assertions - hledger supports Ledger-style balance assertions in journal files. - These look like, for example, = EXPECTEDBALANCE following a posting's - amount. Eg here we assert the expected dollar balance in accounts a + hledger supports Ledger-style balance assertions in journal files. + These look like, for example, = EXPECTEDBALANCE following a posting's + amount. Eg here we assert the expected dollar balance in accounts a and b after each posting: 2013/1/1 @@ -3976,32 +3992,32 @@ JOURNAL FORMAT b $-1 =$-2 After reading a journal file, hledger will check all balance assertions - and report an error if any of them fail. Balance assertions can pro- - tect you from, eg, inadvertently disrupting reconciled balances while - cleaning up old entries. You can disable them temporarily with the + and report an error if any of them fail. Balance assertions can pro- + tect you from, eg, inadvertently disrupting reconciled balances while + cleaning up old entries. You can disable them temporarily with the -I/--ignore-assertions flag, which can be useful for troubleshooting or - for reading Ledger files. (Note: this flag currently does not disable + for reading Ledger files. (Note: this flag currently does not disable balance assignments, below). Assertions and ordering - hledger sorts an account's postings and assertions first by date and - then (for postings on the same day) by parse order. Note this is dif- + hledger sorts an account's postings and assertions first by date and + then (for postings on the same day) by parse order. Note this is dif- ferent from Ledger, which sorts assertions only by parse order. (Also, - Ledger assertions do not see the accumulated effect of repeated post- + Ledger assertions do not see the accumulated effect of repeated post- ings to the same account within a transaction.) So, hledger balance assertions keep working if you reorder differently- - dated transactions within the journal. But if you reorder same-dated - transactions or postings, assertions might break and require updating. + dated transactions within the journal. But if you reorder same-dated + transactions or postings, assertions might break and require updating. This order dependence does bring an advantage: precise control over the order of postings and assertions within a day, so you can assert intra- day balances. Assertions and included files - With included files, things are a little more complicated. Including - preserves the ordering of postings and assertions. If you have multi- - ple postings to an account on the same day, split across different - files, and you also want to assert the account's balance on the same + With included files, things are a little more complicated. Including + preserves the ordering of postings and assertions. If you have multi- + ple postings to an account on the same day, split across different + files, and you also want to assert the account's balance on the same day, you'll have to put the assertion in the right file. Assertions and multiple -f options @@ -4009,15 +4025,15 @@ JOURNAL FORMAT -f options. Use include or concatenate the files instead. Assertions and commodities - The asserted balance must be a simple single-commodity amount, and in - fact the assertion checks only this commodity's balance within the - (possibly multi-commodity) account balance. This is how assertions + The asserted balance must be a simple single-commodity amount, and in + fact the assertion checks only this commodity's balance within the + (possibly multi-commodity) account balance. This is how assertions work in Ledger also. We could call this a "partial" balance assertion. To assert the balance of more than one commodity in an account, you can write multiple postings, each asserting one commodity's balance. - You can make a stronger "total" balance assertion by writing a double + You can make a stronger "total" balance assertion by writing a double equals sign (== EXPECTEDBALANCE). This asserts that there are no other unasserted commodities in the account (or, that their balance is 0). @@ -4037,7 +4053,7 @@ JOURNAL FORMAT a 0 == $1 It's not yet possible to make a complete assertion about a balance that - has multiple commodities. One workaround is to isolate each commodity + has multiple commodities. One workaround is to isolate each commodity into its own subaccount: 2013/1/1 @@ -4051,21 +4067,21 @@ JOURNAL FORMAT a:euro 0 == 1EUR Assertions and prices - Balance assertions ignore transaction prices, and should normally be + Balance assertions ignore transaction prices, and should normally be written without one: 2019/1/1 (a) $1 @ EUR1 = $1 - We do allow prices to be written there, however, and print shows them, - even though they don't affect whether the assertion passes or fails. - This is for backward compatibility (hledger's close command used to - generate balance assertions with prices), and because balance assign- + We do allow prices to be written there, however, and print shows them, + even though they don't affect whether the assertion passes or fails. + This is for backward compatibility (hledger's close command used to + generate balance assertions with prices), and because balance assign- ments do use them (see below). Assertions and subaccounts - The balance assertions above (= and ==) do not count the balance from - subaccounts; they check the account's exclusive balance only. You can + The balance assertions above (= and ==) do not count the balance from + subaccounts; they check the account's exclusive balance only. You can assert the balance including subaccounts by writing =* or ==*, eg: 2019/1/1 @@ -4079,16 +4095,16 @@ JOURNAL FORMAT tual. They are not affected by the --real/-R flag or real: query. Assertions and precision - Balance assertions compare the exactly calculated amounts, which are - not always what is shown by reports. Eg a commodity directive may - limit the display precision, but this will not affect balance asser- + Balance assertions compare the exactly calculated amounts, which are + not always what is shown by reports. Eg a commodity directive may + limit the display precision, but this will not affect balance asser- tions. Balance assertion failure messages show exact amounts. Balance assignments - Ledger-style balance assignments are also supported. These are like - balance assertions, but with no posting amount on the left side of the - equals sign; instead it is calculated automatically so as to satisfy - the assertion. This can be a convenience during data entry, eg when + Ledger-style balance assignments are also supported. These are like + balance assertions, but with no posting amount on the left side of the + equals sign; instead it is calculated automatically so as to satisfy + the assertion. This can be a convenience during data entry, eg when setting opening balances: ; starting a new journal, set asset account balances @@ -4106,14 +4122,14 @@ JOURNAL FORMAT expenses:misc The calculated amount depends on the account's balance in the commodity - at that point (which depends on the previously-dated postings of the - commodity to that account since the last balance assertion or assign- + at that point (which depends on the previously-dated postings of the + commodity to that account since the last balance assertion or assign- ment). Note that using balance assignments makes your journal a little less explicit; to know the exact amount posted, you have to run hledger or do the calculations yourself, instead of just reading it. Balance assignments and prices - A transaction price in a balance assignment will cause the calculated + A transaction price in a balance assignment will cause the calculated amount to have that price attached: 2019/1/1 @@ -4124,81 +4140,83 @@ JOURNAL FORMAT (a) $1 @ EUR2 = $1 @ EUR2 Directives - A directive is a line in the journal beginning with a special keyword, + A directive is a line in the journal beginning with a special keyword, that influences how the journal is processed. hledger's directives are based on a subset of Ledger's, but there are many differences (and also some differences between hledger versions). Directives' behaviour and interactions can get a little bit complex, so - here is a table summarising the directives and their effects, with - links to more detailed docs. Note part of this table is hidden when + here is a table summarising the directives and their effects, with + links to more detailed docs. Note part of this table is hidden when viewed in a web browser - scroll it sideways to see more. - direc- end di- subdi- purpose can affect (as of + direc- end di- subdi- purpose can affect (as of tive rective rec- 2018/06) tives ------------------------------------------------------------------------------------ - account any document account names, de- all entries in all - text clare account types & dis- files, before or + account any document account names, de- all entries in all + text clare account types & dis- files, before or play order after alias end rewrite account names following entries - aliases until end of cur- + aliases until end of cur- rent file or end directive - apply end apply prepend a common parent to following entries - account account account names until end of cur- + apply end apply prepend a common parent to following entries + account account account names until end of cur- rent file or end directive comment end com- ignore part of journal following entries - ment until end of cur- + ment until end of cur- rent file or end directive - commod- format declare a commodity and its number notation: + commod- format declare a commodity and its number notation: ity number notation & display following entries style in that commodity in all files ; dis- play style: amounts of that commodity in reports - D declare a commodity to be default commodity: + D declare a commodity to be default commodity: used for commodityless following commod- - amounts, and its number no- ityless entries un- - tation & display style til end of current - file; number nota- + amounts, and its number no- ityless entries un- + tation & display style til end of current + file; number nota- tion: following en- - tries in that com- + tries in that com- modity until end of - current file; dis- + current file; dis- play style: amounts of that commodity in reports include include entries/directives what the included from another file directives affect P declare a market price for a amounts of that - commodity commodity in re- - ports, when -V is + commodity commodity in re- + ports, when -V is used - Y declare a year for yearless following entries - dates until end of cur- + Y declare a year for yearless following entries + dates until end of cur- rent file - = declare an auto posting all entries in par- - rule, adding postings to ent/current/child + = declare an auto posting all entries in par- + rule, adding postings to ent/current/child other transactions files (but not sib- ling files, see #1212) And some definitions: - subdi- optional indented directive line immediately following a parent + subdi- optional indented directive line immediately following a parent rec- directive tive number how to interpret numbers when parsing journal entries (the iden- - nota- tity of the decimal separator character). (Currently each com- + nota- tity of the decimal separator character). (Currently each com- tion modity can have its own notation, even in the same file.) - dis- how to display amounts of a commodity in reports (symbol side + dis- how to display amounts of a commodity in reports (symbol side play and spacing, digit groups, decimal separator, decimal places) style - direc- which entries and (when there are multiple files) which files + + + direc- which entries and (when there are multiple files) which files tive are affected by a directive scope @@ -4207,35 +4225,35 @@ JOURNAL FORMAT ports). Some directives have multiple effects. Directives and multiple files - If you use multiple -f/--file options, or the include directive, - hledger will process multiple input files. But note that directives + If you use multiple -f/--file options, or the include directive, + hledger will process multiple input files. But note that directives which affect input (see above) typically last only until the end of the file in which they occur. This may seem inconvenient, but it's intentional; it makes reports sta- - ble and deterministic, independent of the order of input. Otherwise - you could see different numbers if you happened to write -f options in - a different order, or if you moved includes around while cleaning up + ble and deterministic, independent of the order of input. Otherwise + you could see different numbers if you happened to write -f options in + a different order, or if you moved includes around while cleaning up your files. - It can be surprising though; for example, it means that alias direc- + It can be surprising though; for example, it means that alias direc- tives do not affect parent or sibling files (see below). Comment blocks - A line containing just comment starts a commented region of the file, + A line containing just comment starts a commented region of the file, and a line containing just end comment (or the end of the current file) ends it. See also comments. Including other files - You can pull in the content of additional files by writing an include + You can pull in the content of additional files by writing an include directive, like this: include FILEPATH - Only journal files can include, and only journal, timeclock or timedot + Only journal files can include, and only journal, timeclock or timedot files can be included (not CSV files, currently). - If the file path does not begin with a slash, it is relative to the + If the file path does not begin with a slash, it is relative to the current file's folder. A tilde means home directory, eg: include ~/main.journal. @@ -4244,17 +4262,17 @@ JOURNAL FORMAT *.journal. There is limited support for recursive wildcards: **/ (the slash is re- - quired) matches 0 or more subdirectories. It's not super convenient - since you have to avoid include cycles and including directories, but + quired) matches 0 or more subdirectories. It's not super convenient + since you have to avoid include cycles and including directories, but this can be done, eg: include */**/*.journal. The path may also be prefixed to force a specific file format, overrid- - ing the file extension (as described in hledger.1 -> Input files): in- + ing the file extension (as described in hledger.1 -> Input files): in- clude timedot:~/notes/2020*.md. Default year - You can set a default year to be used for subsequent dates which don't - specify a year. This is a line beginning with Y followed by the year. + You can set a default year to be used for subsequent dates which don't + specify a year. This is a line beginning with Y followed by the year. Eg: Y2009 ; set default year to 2009 @@ -4276,19 +4294,19 @@ JOURNAL FORMAT Declaring commodities The commodity directive has several functions: - 1. It declares commodities which may be used in the journal. This is + 1. It declares commodities which may be used in the journal. This is currently not enforced, but can serve as documentation. - 2. It declares what decimal mark character (period or comma) to expect - when parsing input - useful to disambiguate international number - formats in your data. (Without this, hledger will parse both 1,000 + 2. It declares what decimal mark character (period or comma) to expect + when parsing input - useful to disambiguate international number + formats in your data. (Without this, hledger will parse both 1,000 and 1.000 as 1). - 3. It declares a commodity's display style in output - decimal and + 3. It declares a commodity's display style in output - decimal and digit group marks, number of decimal places, symbol placement etc. - You are likely to run into one of the problems solved by commodity di- - rectives, sooner or later, so it's a good idea to just always use them + You are likely to run into one of the problems solved by commodity di- + rectives, sooner or later, so it's a good idea to just always use them to declare your commodities. A commodity directive is just the word commodity followed by an amount. @@ -4301,8 +4319,8 @@ JOURNAL FORMAT ; separating thousands with comma. commodity 1,000.0000 AAAA - or on multiple lines, using the "format" subdirective. (In this case - the commodity symbol appears twice and should be the same in both + or on multiple lines, using the "format" subdirective. (In this case + the commodity symbol appears twice and should be the same in both places.): ; commodity SYMBOL @@ -4315,28 +4333,28 @@ JOURNAL FORMAT format INR 1,00,00,000.00 The quantity of the amount does not matter; only the format is signifi- - cant. The number must include a decimal mark: either a period or a + cant. The number must include a decimal mark: either a period or a comma, followed by 0 or more decimal digits. - Note hledger normally uses banker's rounding, so 0.5 displayed with + Note hledger normally uses banker's rounding, so 0.5 displayed with zero decimal digits is "0". (More at Commodity display style.) Commodity error checking - In strict mode, enabled with the -s/--strict flag, hledger will report - an error if a commodity symbol is used that has not been declared by a - commodity directive. This works similarly to account error checking, + In strict mode, enabled with the -s/--strict flag, hledger will report + an error if a commodity symbol is used that has not been declared by a + commodity directive. This works similarly to account error checking, see the notes there for more details. Default commodity - The D directive sets a default commodity, to be used for amounts with- + The D directive sets a default commodity, to be used for amounts with- out a commodity symbol (ie, plain numbers). This commodity will be ap- plied to all subsequent commodity-less amounts, or until the next D di- rective. (Note, this is different from Ledger's D.) - For compatibility/historical reasons, D also acts like a commodity di- + For compatibility/historical reasons, D also acts like a commodity di- rective, setting the commodity's display style (for output) and decimal mark (for parsing input). As with commodity, the amount must always be - written with a decimal mark (period or comma). If both directives are + written with a decimal mark (period or comma). If both directives are used, commodity's style takes precedence. The syntax is D AMOUNT. Eg: @@ -4350,9 +4368,9 @@ JOURNAL FORMAT b 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, + 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, cryptocurrency exchange, or the foreign exchange market. Here is the format: @@ -4363,78 +4381,78 @@ JOURNAL FORMAT o COMMODITYA is the symbol of the commodity being priced - o COMMODITYBAMOUNT is an amount (symbol and quantity) in a second com- + o COMMODITYBAMOUNT is an amount (symbol and quantity) in a second com- modity, giving the price in commodity B of one unit of commodity A. - These two market price directives say that one euro was worth 1.35 US + These two market price directives say that one euro was worth 1.35 US dollars during 2009, and $1.40 from 2010 onward: P 2009/1/1 EUR $1.35 P 2010/1/1 EUR $1.40 - The -V, -X and --value flags use these market prices to show amount + The -V, -X and --value flags use these market prices to show amount values in another commodity. See Valuation. Declaring accounts account directives can be used to declare accounts (ie, the places that - amounts are transferred from and to). Though not required, these dec- + amounts are transferred from and to). Though not required, these dec- larations can provide several benefits: o They can document your intended chart of accounts, providing a refer- ence. - o They can help hledger know your accounts' types (asset, liability, - equity, revenue, expense), useful for reports like balancesheet and + o They can help hledger know your accounts' types (asset, liability, + equity, revenue, expense), useful for reports like balancesheet and incomestatement. - o They control account display order in reports, allowing non-alpha- + o They control account display order in reports, allowing non-alpha- betic sorting (eg Revenues to appear above Expenses). - o They can store extra information about accounts (account numbers, + o They can store extra information about accounts (account numbers, notes, etc.) - o They help with account name completion in the add command, hledger- + o They help with account name completion in the add command, hledger- iadd, hledger-web, ledger-mode etc. - o In strict mode, they restrict which accounts may be posted to by + o In strict mode, they restrict which accounts may be posted to by transactions, which helps detect typos. - The simplest form is just the word account followed by a hledger-style + The simplest form is just the word account followed by a hledger-style account name, eg this account directive declares the assets:bank:check- ing account: account assets:bank:checking Account error checking - By default, accounts come into existence when a transaction references - them by name. This is convenient, but it means hledger can't warn you + By default, accounts come into existence when a transaction references + them by name. This is convenient, but it means hledger can't warn you when you mis-spell an account name in the journal. Usually you'll find - the error later, as an extra account in balance reports, or an incor- + the error later, as an extra account in balance reports, or an incor- rect balance when reconciling. - In strict mode, enabled with the -s/--strict flag, hledger will report - an error if any transaction uses an account name that has not been de- + In strict mode, enabled with the -s/--strict flag, hledger will report + an error if any transaction uses an account name that has not been de- clared by an account directive. Some notes: - o The declaration is case-sensitive; transactions must use the correct + o The declaration is case-sensitive; transactions must use the correct account name capitalisation. - o The account directive's scope is "whole file and below" (see direc- + o The account directive's scope is "whole file and below" (see direc- tives). This means it affects all of the current file, and any files - it includes, but not parent or sibling files. The position of ac- - count directives within the file does not matter, though it's usual + it includes, but not parent or sibling files. The position of ac- + count directives within the file does not matter, though it's usual to put them at the top. - o Accounts can only be declared in journal files (but will affect in- + o Accounts can only be declared in journal files (but will affect in- cluded files in other formats). - o It's currently not possible to declare "all possible subaccounts" + o It's currently not possible to declare "all possible subaccounts" with a wildcard; every account posted to must be declared. Account comments Comments, beginning with a semicolon, can be added: - o on the same line, after two or more spaces (because ; is allowed in + o on the same line, after two or more spaces (because ; is allowed in account names) o on the next lines, indented @@ -4448,7 +4466,7 @@ JOURNAL FORMAT Same-line comments are not supported by Ledger, or hledger <1.13. Account subdirectives - We also allow (and ignore) Ledger-style indented subdirectives, just + We also allow (and ignore) Ledger-style indented subdirectives, just for compatibility.: account assets:bank:checking @@ -4467,21 +4485,21 @@ JOURNAL FORMAT Asset, Liability, Equity, Revenue, Expense. These account types are important for controlling which accounts appear - in the balancesheet, balancesheetequity, incomestatement reports (and + in the balancesheet, balancesheetequity, incomestatement reports (and probably for other things in future). - Additionally, we recognise the Cash type, which is also an Asset, and - which causes accounts to appear in the cashflow report. ("Cash" here - means liquid assets, eg bank balances but typically not investments or + Additionally, we recognise the Cash type, which is also an Asset, and + which causes accounts to appear in the cashflow report. ("Cash" here + means liquid assets, eg bank balances but typically not investments or receivables.) Declaring account types Generally, to make these reports work you should declare your top-level accounts and their types, using account directives with type: tags. - The tag's value should be one of: Asset, Liability, Equity, Revenue, - Expense, Cash, A, L, E, R, X, C (all case insensitive). The type is - inherited by all subaccounts except where they override it. Here's a + The tag's value should be one of: Asset, Liability, Equity, Revenue, + Expense, Cash, A, L, E, R, X, C (all case insensitive). The type is + inherited by all subaccounts except where they override it. Here's a complete example: account assets ; type: Asset @@ -4493,8 +4511,8 @@ JOURNAL FORMAT account expenses ; type: Expense Auto-detected account types - If you happen to use common english top-level account names, you may - not need to declare account types, as they will be detected automati- + If you happen to use common english top-level account names, you may + not need to declare account types, as they will be detected automati- cally using the following rules: If name matches regular account type is: @@ -4507,7 +4525,7 @@ JOURNAL FORMAT ^(income|revenue)s?(:|$) Revenue ^expenses?(:|$) Expense - If account type is Asset and name does not contain regu- account type + If account type is Asset and name does not contain regu- account type lar expression: is: -------------------------------------------------------------------------- (investment|receivable|:A/R|:fixed) Cash @@ -4517,9 +4535,9 @@ JOURNAL FORMAT Interference from auto-detected account types If you assign any account type, it's a good idea to assign all of them, - to prevent any confusion from mixing declared and auto-detected types. - Although it's unlikely to happen in real life, here's an example: with - the following journal, balancesheetequity shows "liabilities" in both + to prevent any confusion from mixing declared and auto-detected types. + Although it's unlikely to happen in real life, here's an example: with + the following journal, balancesheetequity shows "liabilities" in both Liabilities and Equity sections. Declaring another account as type:Li- ability would fix it: @@ -4531,8 +4549,8 @@ JOURNAL FORMAT equity -2 Old account type syntax - In some hledger journals you might instead see this old syntax (the - letters ALERX, separated from the account name by two or more spaces); + In some hledger journals you might instead see this old syntax (the + letters ALERX, separated from the account name by two or more spaces); this is deprecated and may be removed soon: account assets A @@ -4542,8 +4560,8 @@ JOURNAL FORMAT account expenses X Account display order - Account directives also set the order in which accounts are displayed, - eg in reports, the hledger-ui accounts screen, and the hledger-web + Account directives also set the order in which accounts are displayed, + eg in reports, the hledger-ui accounts screen, and the hledger-web sidebar. By default accounts are listed in alphabetical order. But if you have these account directives in the journal: @@ -4565,20 +4583,20 @@ JOURNAL FORMAT Undeclared accounts, if any, are displayed last, in alphabetical order. - Note that sorting is done at each level of the account tree (within - each group of sibling accounts under the same parent). And currently, + Note that sorting is done at each level of the account tree (within + each group of sibling accounts under the same parent). And currently, this directive: account other:zoo - would influence the position of zoo among other's subaccounts, but not + would influence the position of zoo among other's subaccounts, but not the position of other among the top-level accounts. This means: - o you will sometimes declare parent accounts (eg account other above) + o you will sometimes declare parent accounts (eg account other above) that you don't intend to post to, just to customize their display or- der - o sibling accounts stay together (you couldn't display x:y in between + o sibling accounts stay together (you couldn't display x:y in between a:b and a:c). Rewriting accounts @@ -4596,14 +4614,14 @@ JOURNAL FORMAT o customising reports Account aliases also rewrite account names in account directives. They - do not affect account names being entered via hledger add or hledger- + do not affect account names being entered via hledger add or hledger- web. See also Rewrite account names. Basic aliases - To set an account alias, use the alias directive in your journal file. - This affects all subsequent journal entries in the current file or its + To set an account alias, use the alias directive in your journal file. + This affects all subsequent journal entries in the current file or its included files. The spaces around the = are optional: alias OLD = NEW @@ -4611,49 +4629,49 @@ JOURNAL FORMAT Or, you can use the --alias 'OLD=NEW' option on the command line. This affects all entries. It's useful for trying out aliases interactively. - OLD and NEW are case sensitive full account names. hledger will re- - place any occurrence of the old account name with the new one. Subac- + OLD and NEW are case sensitive full account names. hledger will re- + place any occurrence of the old account name with the new one. Subac- counts are also affected. Eg: alias checking = assets:bank:wells fargo:checking ; rewrites "checking" to "assets:bank:wells fargo:checking", or "checking:a" to "assets:bank:wells fargo:checking:a" Regex aliases - There is also a more powerful variant that uses a regular expression, + There is also a more powerful variant that uses a regular expression, indicated by the forward slashes: alias /REGEX/ = REPLACEMENT or --alias '/REGEX/=REPLACEMENT'. - REGEX is a case-insensitive regular expression. Anywhere it matches - inside an account name, the matched part will be replaced by REPLACE- - MENT. If REGEX contains parenthesised match groups, these can be ref- + REGEX is a case-insensitive regular expression. Anywhere it matches + inside an account name, the matched part will be replaced by REPLACE- + MENT. If REGEX contains parenthesised match groups, these can be ref- erenced by the usual numeric backreferences in REPLACEMENT. Eg: alias /^(.+):bank:([^:]+):(.*)/ = \1:\2 \3 ; rewrites "assets:bank:wells fargo:checking" to "assets:wells fargo checking" - Also note that REPLACEMENT continues to the end of line (or on command - line, to end of option argument), so it can contain trailing white- + Also note that REPLACEMENT continues to the end of line (or on command + line, to end of option argument), so it can contain trailing white- space. Combining aliases - You can define as many aliases as you like, using journal directives + You can define as many aliases as you like, using journal directives and/or command line options. - Recursive aliases - where an account name is rewritten by one alias, - then by another alias, and so on - are allowed. Each alias sees the + Recursive aliases - where an account name is rewritten by one alias, + then by another alias, and so on - are allowed. Each alias sees the effect of previously applied aliases. - In such cases it can be important to understand which aliases will be - applied and in which order. For (each account name in) each journal + In such cases it can be important to understand which aliases will be + applied and in which order. For (each account name in) each journal entry, we apply: - 1. alias directives preceding the journal entry, most recently parsed + 1. alias directives preceding the journal entry, most recently parsed first (ie, reading upward from the journal entry, bottom to top) - 2. --alias options, in the order they appeared on the command line + 2. --alias options, in the order they appeared on the command line (left to right). In other words, for (an account name in) a given journal entry: @@ -4664,20 +4682,20 @@ JOURNAL FORMAT o aliases defined after/below the entry do not affect it. - This gives nearby aliases precedence over distant ones, and helps pro- - vide semantic stability - aliases will keep working the same way inde- + This gives nearby aliases precedence over distant ones, and helps pro- + vide semantic stability - aliases will keep working the same way inde- pendent of which files are being read and in which order. - In case of trouble, adding --debug=6 to the command line will show + In case of trouble, adding --debug=6 to the command line will show which aliases are being applied when. Aliases and multiple files - As explained at Directives and multiple files, alias directives do not + As explained at Directives and multiple files, alias directives do not affect parent or sibling files. Eg in this command, hledger -f a.aliases -f b.journal - account aliases defined in a.aliases will not affect b.journal. In- + account aliases defined in a.aliases will not affect b.journal. In- cluding the aliases doesn't work either: include a.aliases @@ -4699,14 +4717,14 @@ JOURNAL FORMAT include c.journal ; also affected end aliases - You can clear (forget) all currently defined aliases with the end + You can clear (forget) all currently defined aliases with the end aliases directive: end aliases Default parent account - You can specify a parent account which will be prepended to all ac- - counts within a section of the journal. Use the apply account and end + You can specify a parent account which will be prepended to all ac- + counts within a section of the journal. Use the apply account and end apply account directives like so: apply account home @@ -4723,7 +4741,7 @@ JOURNAL FORMAT home:food $10 home:cash $-10 - If end apply account is omitted, the effect lasts to the end of the + If end apply account is omitted, the effect lasts to the end of the file. Included files are also affected, eg: apply account business @@ -4732,49 +4750,49 @@ JOURNAL FORMAT apply account personal include personal.journal - Prior to hledger 1.0, legacy account and end spellings were also sup- + Prior to hledger 1.0, legacy account and end spellings were also sup- ported. - A default parent account also affects account directives. It does not - affect account names being entered via hledger add or hledger-web. If - account aliases are present, they are applied after the default parent + A default parent account also affects account directives. It does not + affect account names being entered via hledger add or hledger-web. If + account aliases are present, they are applied after the default parent account. Periodic transactions - Periodic transaction rules describe transactions that recur. They al- - low hledger to generate temporary future transactions to help with - forecasting, so you don't have to write out each one in the journal, + Periodic transaction rules describe transactions that recur. They al- + low hledger to generate temporary future transactions to help with + forecasting, so you don't have to write out each one in the journal, and it's easy to try out different forecasts. - Periodic transactions can be a little tricky, so before you use them, + Periodic transactions can be a little tricky, so before you use them, read this whole section - or at least these tips: - 1. Two spaces accidentally added or omitted will cause you trouble - + 1. Two spaces accidentally added or omitted will cause you trouble - read about this below. - 2. For troubleshooting, show the generated transactions with hledger - print --forecast tag:generated or hledger register --forecast + 2. For troubleshooting, show the generated transactions with hledger + print --forecast tag:generated or hledger register --forecast tag:generated. - 3. Forecasted transactions will begin only after the last non-fore- + 3. Forecasted transactions will begin only after the last non-fore- casted transaction's date. - 4. Forecasted transactions will end 6 months from today, by default. + 4. Forecasted transactions will end 6 months from today, by default. See below for the exact start/end rules. - 5. period expressions can be tricky. Their documentation needs im- + 5. period expressions can be tricky. Their documentation needs im- provement, but is worth studying. - 6. Some period expressions with a repeating interval must begin on a - natural boundary of that interval. Eg in weekly from DATE, DATE - must be a monday. ~ weekly from 2019/10/1 (a tuesday) will give an + 6. Some period expressions with a repeating interval must begin on a + natural boundary of that interval. Eg in weekly from DATE, DATE + must be a monday. ~ weekly from 2019/10/1 (a tuesday) will give an error. 7. Other period expressions with an interval are automatically expanded - to cover a whole number of that interval. (This is done to improve + to cover a whole number of that interval. (This is done to improve reports, but it also affects periodic transactions. Yes, it's a bit - inconsistent with the above.) Eg: ~ every 10th day of month from - 2020/01, which is equivalent to ~ every 10th day of month from + inconsistent with the above.) Eg: ~ every 10th day of month from + 2020/01, which is equivalent to ~ every 10th day of month from 2020/01/01, will be adjusted to start on 2019/12/10. Periodic transaction rules also have a second meaning: they are used to @@ -4789,17 +4807,17 @@ JOURNAL FORMAT expenses:rent $2000 assets:bank:checking - There is an additional constraint on the period expression: the start - date must fall on a natural boundary of the interval. Eg monthly from + There is an additional constraint on the period expression: the start + date must fall on a natural boundary of the interval. Eg monthly from 2018/1/1 is valid, but monthly from 2018/1/15 is not. - Partial or relative dates (M/D, D, tomorrow, last week) in the period - expression can work (useful or not). They will be relative to today's - date, unless a Y default year directive is in effect, in which case + Partial or relative dates (M/D, D, tomorrow, last week) in the period + expression can work (useful or not). They will be relative to today's + date, unless a Y default year directive is in effect, in which case they will be relative to Y/1/1. Two spaces between period expression and description! - If the period expression is followed by a transaction description, + If the period expression is followed by a transaction description, these must be separated by two or more spaces. This helps hledger know where the period expression ends, so that descriptions can not acciden- tally alter their meaning, as in this example: @@ -4813,67 +4831,67 @@ JOURNAL FORMAT So, - o Do write two spaces between your period expression and your transac- + o Do write two spaces between your period expression and your transac- tion description, if any. - o Don't accidentally write two spaces in the middle of your period ex- + o Don't accidentally write two spaces in the middle of your period ex- pression. Forecasting with periodic transactions - The --forecast flag activates any periodic transaction rules in the - journal. They will generate temporary recurring transactions, which - are not saved in the journal, but will appear in all reports (eg + The --forecast flag activates any periodic transaction rules in the + journal. They will generate temporary recurring transactions, which + are not saved in the journal, but will appear in all reports (eg print). This can be useful for estimating balances into the future, or - experimenting with different scenarios. Or, it can be used as a data + experimenting with different scenarios. Or, it can be used as a data entry aid: describe recurring transactions, and every so often copy the output of print --forecast into the journal. - These transactions will have an extra tag indicating which periodic + These transactions will have an extra tag indicating which periodic rule generated them: generated-transaction:~ PERIODICEXPR. And a simi- - lar, hidden tag (beginning with an underscore) which, because it's - never displayed by print, can be used to match transactions generated + lar, hidden tag (beginning with an underscore) which, because it's + never displayed by print, can be used to match transactions generated "just now": _generated-transaction:~ PERIODICEXPR. - Periodic transactions are generated within some forecast period. By + Periodic transactions are generated within some forecast period. By default, this o begins on the later of o the report start date if specified with -b/-p/date: - o the day after the latest normal (non-periodic) transaction in the + o the day after the latest normal (non-periodic) transaction in the journal, or today if there are no normal transactions. - o ends on the report end date if specified with -e/-p/date:, or 6 + o ends on the report end date if specified with -e/-p/date:, or 6 months (180 days) from today. - This means that periodic transactions will begin only after the latest - recorded transaction. And a recorded transaction dated in the future - can prevent generation of periodic transactions. (You can avoid that + This means that periodic transactions will begin only after the latest + recorded transaction. And a recorded transaction dated in the future + can prevent generation of periodic transactions. (You can avoid that by writing the future transaction as a one-time periodic rule instead - put tilde before the date, eg ~ YYYY-MM-DD ...). Or, you can set your own arbitrary "forecast period", which can overlap - recorded transactions, and need not be in the future, by providing an - option argument, like --forecast=PERIODEXPR. Note the equals sign is + recorded transactions, and need not be in the future, by providing an + option argument, like --forecast=PERIODEXPR. Note the equals sign is required, a space won't work. PERIODEXPR is a period expression, which - can specify the start date, end date, or both, like in a date: query. - (See also hledger.1 -> Report start & end date). Some examples: + can specify the start date, end date, or both, like in a date: query. + (See also hledger.1 -> Report start & end date). Some examples: --forecast=202001-202004, --forecast=jan-, --forecast=2020. Budgeting with periodic transactions - With the --budget flag, currently supported by the balance command, - each periodic transaction rule declares recurring budget goals for the - specified accounts. Eg the first example above declares a goal of - spending $2000 on rent (and also, a goal of depositing $2000 into - checking) every month. Goals and actual performance can then be com- + With the --budget flag, currently supported by the balance command, + each periodic transaction rule declares recurring budget goals for the + specified accounts. Eg the first example above declares a goal of + spending $2000 on rent (and also, a goal of depositing $2000 into + checking) every month. Goals and actual performance can then be com- pared in budget reports. See also: Budgeting and Forecasting. Auto postings - "Automated postings" or "auto postings" are extra postings which get - added automatically to transactions which match certain queries, de- + "Automated postings" or "auto postings" are extra postings which get + added automatically to transactions which match certain queries, de- fined by "auto posting rules", when you use the --auto flag. An auto posting rule looks a bit like a transaction: @@ -4883,27 +4901,27 @@ JOURNAL FORMAT ... ACCOUNT [AMOUNT] - except the first line is an equals sign (mnemonic: = suggests match- - ing), followed by a query (which matches existing postings), and each - "posting" line describes a posting to be generated, and the posting + except the first line is an equals sign (mnemonic: = suggests match- + ing), followed by a query (which matches existing postings), and each + "posting" line describes a posting to be generated, and the posting amounts can be: - o a normal amount with a commodity symbol, eg $2. This will be used + o a normal amount with a commodity symbol, eg $2. This will be used as-is. o a number, eg 2. The commodity symbol (if any) from the matched post- ing will be added to this. - o a numeric multiplier, eg *2 (a star followed by a number N). The + o a numeric multiplier, eg *2 (a star followed by a number N). The matched posting's amount (and total price, if any) will be multiplied by N. - o a multiplier with a commodity symbol, eg *$2 (a star, number N, and + o a multiplier with a commodity symbol, eg *$2 (a star, number N, and symbol S). The matched posting's amount will be multiplied by N, and its commodity symbol will be replaced with S. - Any query term containing spaces must be enclosed in single or double - quotes, as on the command line. Eg, note the quotes around the second + Any query term containing spaces must be enclosed in single or double + quotes, as on the command line. Eg, note the quotes around the second query term below: = expenses:groceries 'expenses:dining out' @@ -4942,24 +4960,24 @@ JOURNAL FORMAT Auto postings and multiple files An auto posting rule can affect any transaction in the current file, or - in any parent file or child file. Note, currently it will not affect + in any parent file or child file. Note, currently it will not affect sibling files (when multiple -f/--file are used - see #1212). Auto postings and dates - A posting date (or secondary date) in the matched posting, or (taking - precedence) a posting date in the auto posting rule itself, will also + A posting date (or secondary date) in the matched posting, or (taking + precedence) a posting date in the auto posting rule itself, will also be used in the generated posting. Auto postings and transaction balancing / inferred amounts / balance asser- tions Currently, auto postings are added: - o after missing amounts are inferred, and transactions are checked for + o after missing amounts are inferred, and transactions are checked for balancedness, o but before balance assertions are checked. - Note this means that journal entries must be balanced both before and + Note this means that journal entries must be balanced both before and after auto postings are added. This changed in hledger 1.12+; see #893 for background. @@ -4969,11 +4987,11 @@ JOURNAL FORMAT o generated-posting:= QUERY - shows this was generated by an auto post- ing rule, and the query - o _generated-posting:= QUERY - a hidden tag, which does not appear in + o _generated-posting:= QUERY - a hidden tag, which does not appear in hledger's output. This can be used to match postings generated "just now", rather than generated in the past and saved to the journal. - Also, any transaction that has been changed by auto posting rules will + Also, any transaction that has been changed by auto posting rules will have these tags added: o modified: - this transaction was modified @@ -4984,20 +5002,20 @@ JOURNAL FORMAT CSV FORMAT How hledger reads CSV data, and the CSV rules file format. - hledger can read CSV files (Character Separated Value - usually comma, - semicolon, or tab) containing dated records as if they were journal + hledger can read CSV files (Character Separated Value - usually comma, + semicolon, or tab) containing dated records as if they were journal files, automatically converting each CSV record into a transaction. (To learn about writing CSV, see 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 as FILE.csv. You can specify a different rules file - with the --rules-file option. If a rules file is not found, hledger + 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 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 + This file contains rules describing the CSV data (header line, fields layout, date format etc.), and how to construct hledger journal entries (transactions) from it. Often there will also be a list of conditional rules for categorising transactions based on their descriptions. @@ -5006,38 +5024,40 @@ CSV FORMAT skip skip one or more header lines or matched CSV records - fields name CSV fields, assign them to hledger + fields name CSV fields, assign them to hledger fields - field assignment assign a value to one hledger field, + field assignment assign a value to one hledger field, with interpolation separator a custom field separator - if block apply some rules to CSV records matched + if block apply some rules to CSV records matched by patterns - if table apply some rules to CSV records matched + if table apply some rules to CSV records matched by patterns, alternate syntax end skip the remaining CSV records date-format how to parse dates in CSV records + + decimal-mark the decimal mark used in CSV amounts, if ambiguous - newest-first disambiguate record order when there's + newest-first disambiguate record order when there's only one date include inline another CSV rules file balance-type choose which type of balance assignments to use - Note, for best error messages when reading CSV files, use a .csv, .tsv + Note, for best error messages when reading CSV files, use a .csv, .tsv or .ssv file extension or file prefix - see File Extension below. There's an introductory Convert CSV files tutorial on hledger.org. Examples - Here are some sample hledger CSV rules files. See also the full col- + Here are some sample hledger CSV rules files. See also the full col- lection at: https://github.com/simonmichael/hledger/tree/master/examples/csv Basic - At minimum, the rules file must identify the date and amount fields, - and often it also specifies the date format and how many header lines + At minimum, the rules file must identify the date and amount fields, + and often it also specifies the date format and how many header lines there are. Here's a simple CSV file and a rules file for it: Date, Description, Id, Amount @@ -5056,8 +5076,8 @@ CSV FORMAT Default account names are chosen, since we didn't set them. Bank of Ireland - Here's a CSV with two amount fields (Debit and Credit), and a balance - field, which we can use to add balance assertions, which is not neces- + Here's a CSV with two amount fields (Debit and Credit), and a balance + field, which we can use to add balance assertions, which is not neces- sary but provides extra error checking: Date,Details,Debit,Credit,Balance @@ -5099,13 +5119,13 @@ CSV FORMAT assets:bank:boi:checking EUR-5.0 = EUR126.0 expenses:unknown EUR5.0 - The balance assertions don't raise an error above, because we're read- - ing directly from CSV, but they will be checked if these entries are + The balance assertions don't raise an error above, because we're read- + ing directly from CSV, but they will be checked if these entries are imported into a journal file. Amazon Here we convert amazon.com order history, and use an if block to gener- - ate a third posting if there's a fee. (In practice you'd probably get + ate a third posting if there's a fee. (In practice you'd probably get this data from your bank instead, but it's an example.) "Date","Type","To/From","Name","Status","Amount","Fees","Transaction ID" @@ -5157,7 +5177,7 @@ CSV FORMAT expenses:fees $1.00 Paypal - Here's a real-world rules file for (customised) Paypal CSV, with some + Here's a real-world rules file for (customised) Paypal CSV, with some Paypal-specific rules, and a second rules file included: "Date","Time","TimeZone","Name","Type","Status","Currency","Gross","Fee","Net","From Email Address","To Email Address","Transaction ID","Item Title","Item ID","Reference Txn ID","Receipt ID","Balance","Note" @@ -5312,9 +5332,9 @@ CSV FORMAT skip skip N - The word "skip" followed by a number (or no number, meaning 1) tells - hledger to ignore this many non-empty lines preceding the CSV data. - (Empty/blank lines are skipped automatically.) You'll need this when- + The word "skip" followed by a number (or no number, meaning 1) tells + hledger to ignore this many non-empty lines preceding the CSV data. + (Empty/blank lines are skipped automatically.) You'll need this when- ever your CSV data contains header lines. It also has a second purpose: it can be used inside if blocks to ignore @@ -5323,27 +5343,27 @@ CSV FORMAT fields fields FIELDNAME1, FIELDNAME2, ... - A fields list (the word "fields" followed by comma-separated field - names) is the quick way to assign CSV field values to hledger fields. + A fields list (the word "fields" followed by comma-separated field + names) is the quick way to assign CSV field values to hledger fields. It does two things: - 1. it names the CSV fields. This is optional, but can be convenient + 1. it names the CSV fields. This is optional, but can be convenient later for interpolating them. 2. when you use a standard hledger field name, it assigns the CSV value to that part of the hledger transaction. - Here's an example that says "use the 1st, 2nd and 4th fields as the - transaction's date, description and amount; name the last two fields + Here's an example that says "use the 1st, 2nd and 4th fields as the + transaction's date, description and amount; name the last two fields for later reference; and ignore the others": fields date, description, , amount, , , somefield, anotherfield - Field names may not contain whitespace. Fields you don't care about - can be left unnamed. Currently there must be least two items (there + Field names may not contain whitespace. Fields you don't care about + can be left unnamed. Currently there must be least two items (there must be at least one comma). - Note, always use comma in the fields list, even if your CSV uses an- + Note, always use comma in the fields list, even if your CSV uses an- other separator character. Here are the standard hledger field/pseudo-field names. For more about @@ -5356,52 +5376,52 @@ CSV FORMAT Posting field names account - accountN, where N is 1 to 99, 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 - account2. Typically account1 is associated with the CSV file, and is - set once with a top-level assignment, while account2 is set based on + Most often there are two postings, so you'll want to set account1 and + account2. Typically account1 is associated with the CSV file, and is + set once with a top-level assignment, while account2 is set based on each transaction's description, and in conditional blocks. - If a posting's account name is left unset but its amount is set (see - below), a default account name will be chosen (like "expenses:unknown" + If a posting's account name is left unset but its amount is set (see + below), a default account name will be chosen (like "expenses:unknown" or "income:unknown"). amount - amountN sets posting N's amount. If the CSV uses separate fields for - inflows and outflows, you can use amountN-in and amountN-out instead. - By assigning to amount1, amount2, ... etc. you can generate anywhere + amountN sets posting N's amount. If the CSV uses separate fields for + 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. - There is also an older, unnumbered form of these names, suitable for + 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 + 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 + 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- + 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 @@ -5413,11 +5433,11 @@ CSV FORMAT 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 @@ -5426,14 +5446,14 @@ CSV FORMAT # 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 rule to read other kinds of character-sepa- - rated data. The argument is any single separator character, or the - words tab or space (case insensitive). Eg, for comma-separated values + You can use the separator rule to read other kinds of character-sepa- + rated data. The argument is any single separator character, or the + words tab or space (case insensitive). Eg, for comma-separated values (CSV): separator , @@ -5446,7 +5466,7 @@ CSV FORMAT separator TAB - If the input file has a .csv, .ssv or .tsv file extension (or a csv:, + If the input file has a .csv, .ssv or .tsv file extension (or a csv:, ssv:, tsv: prefix), the appropriate separator will be inferred automat- ically, and you won't need this rule. @@ -5461,8 +5481,8 @@ CSV FORMAT 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. Matching the whole record @@ -5470,16 +5490,16 @@ CSV FORMAT REGEX - 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, \<, \>), + 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- + 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 + 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). @@ -5488,14 +5508,14 @@ CSV FORMAT %CSVFIELD REGEX - which matches just the content of a particular CSV field. CSVFIELD is - a percent sign followed by the field's name or column number, like + which matches just the content of a particular CSV field. CSVFIELD is + a percent sign followed by the field's name or column number, like %date or %1. Combining matchers A single matcher can be written on the same line as the "if"; or multi- ple matchers can be written on the following lines, non-indented. Mul- - tiple matchers are OR'd (any one of them can match), unless one begins + tiple matchers are OR'd (any one of them can match), unless one begins with an & symbol, in which case it is AND'ed with the previous matcher. if @@ -5504,8 +5524,8 @@ CSV FORMAT RULE Rules applied on successful match - After the patterns there should be one or more rules to apply, all in- - dented by at least one space. Three kinds of rule are allowed in con- + After the patterns there should be one or more rules to apply, all in- + dented by at least one space. Three kinds of rule are allowed in con- ditional blocks: o field assignments (to set a hledger field) @@ -5535,11 +5555,11 @@ CSV FORMAT MATCHER3,VALUE31,VALUE32,...,VALUE3n - Conditional tables ("if tables") are a different syntax to specify - field assignments that will be applied only to CSV records which match + Conditional tables ("if tables") are a different syntax to specify + field assignments that will be applied only to CSV records which match certain patterns. - MATCHER could be either field or record matcher, as described above. + MATCHER could be either field or record matcher, as described above. When MATCHER matches, values from that row would be assigned to the CSV fields named on the if line, in the same order. @@ -5563,17 +5583,17 @@ CSV FORMAT ... CSVFIELDNAMEn VALUE3n - Each line starting with MATCHER should contain enough (possibly empty) + Each line starting with MATCHER should contain enough (possibly empty) values for all the listed fields. - Rules would be checked and applied in the order they are listed in the + Rules would be checked and applied in the order they are listed in the table and, like with if blocks, later rules (in the same or another ta- ble) or if blocks could override the effect of any rule. - Instead of ',' you can use a variety of other non-alphanumeric charac- + Instead of ',' you can use a variety of other non-alphanumeric charac- ters as a separator. First character after if is taken to be the sepa- - rator for the rest of the table. It is the responsibility of the user - to ensure that separator does not occur inside MATCHERs and values - + rator for the rest of the table. It is the responsibility of the user + to ensure that separator does not occur inside MATCHERs and values - there is no way to escape separator. Example: @@ -5584,7 +5604,7 @@ CSV FORMAT 2020/01/12.*Plumbing LLC,expenses:house:upkeep,emergency plumbing call-out end - This rule can be used inside if blocks (only), to make hledger stop + This rule can be used inside if blocks (only), to make hledger stop reading this CSV file and move on to the next input file, or to command execution. Eg: @@ -5595,10 +5615,10 @@ CSV FORMAT date-format date-format DATEFMT - This is a helper for the date (and date2) fields. If your CSV dates - are not formatted like YYYY-MM-DD, YYYY/MM/DD or YYYY.MM.DD, you'll - need to add a date-format rule describing them with a strptime date - parsing pattern, which must parse the CSV date value completely. Some + This is a helper for the date (and date2) fields. If your CSV dates + are not formatted like YYYY-MM-DD, YYYY/MM/DD or YYYY.MM.DD, you'll + need to add a date-format rule describing them with a strptime date + parsing pattern, which must parse the CSV date value completely. Some examples: # MM/DD/YY @@ -5626,22 +5646,22 @@ CSV FORMAT decimal-mark , - hledger automatically accepts either period or comma as a decimal mark - when parsing numbers (cf Amounts). However if any numbers in the CSV - contain digit group marks, such as thousand-separating commas, you - should declare the decimal mark explicitly with this rule, to avoid + hledger automatically accepts either period or comma as a decimal mark + when parsing numbers (cf Amounts). However if any numbers in the CSV + contain digit group marks, such as thousand-separating commas, you + should declare the decimal mark explicitly with this rule, to avoid misparsed numbers. newest-first - hledger always sorts the generated transactions by date. Transactions - on the same date should appear in the same order as their CSV records, - as hledger can usually auto-detect whether the CSV's normal order is + hledger always sorts the generated transactions by date. Transactions + on the same date should appear in the same order as their CSV records, + as hledger can usually auto-detect whether the CSV's normal order is oldest first or newest first. But if all of the following are true: - o the CSV might sometimes contain just one day of data (all records + o the CSV might sometimes contain just one day of data (all records having the same date) - o the CSV records are normally in reverse chronological order (newest + o the CSV records are normally in reverse chronological order (newest at the top) o and you care about preserving the order of same-day transactions @@ -5654,9 +5674,9 @@ CSV FORMAT include include RULESFILE - This includes the contents of another CSV rules file at this point. - RULESFILE is an absolute file path or a path relative to the current - file's directory. This can be useful for sharing common rules between + This includes the contents of another CSV rules file at this point. + RULESFILE is an absolute file path or a path relative to the current + file's directory. This can be useful for sharing common rules between several rules files, eg: # someaccount.csv.rules @@ -5671,10 +5691,10 @@ CSV FORMAT balance-type Balance assertions generated by assigning to balanceN are of the simple - = type by default, which is a single-commodity, subaccount-excluding + = type by default, which is a single-commodity, subaccount-excluding assertion. You may find the subaccount-including variants more useful, - eg if you have created some virtual subaccounts of checking to help - with budgeting. You can select a different type of assertion with the + eg if you have created some virtual subaccounts of checking to help + with budgeting. You can select a different type of assertion with the balance-type rule: # balance assertions will consider all commodities and all subaccounts @@ -5689,19 +5709,19 @@ CSV FORMAT Tips Rapid feedback - It's a good idea to get rapid feedback while creating/troubleshooting + It's a good idea to get rapid feedback while creating/troubleshooting CSV rules. Here's a good way, using entr from http://eradman.com/entr- project : $ ls foo.csv* | entr bash -c 'echo ----; hledger -f foo.csv print desc:SOMEDESC' - A desc: query (eg) is used to select just one, or a few, transactions - of interest. "bash -c" is used to run multiple commands, so we can - echo a separator each time the command re-runs, making it easier to + A desc: query (eg) is used to select just one, or a few, transactions + of interest. "bash -c" is used to run multiple commands, so we can + echo a separator each time the command re-runs, making it easier to read the output. Valid CSV - hledger accepts CSV conforming to RFC 4180. When CSV values are en- + hledger accepts CSV conforming to RFC 4180. When CSV values are en- closed in quotes, note: o they must be double quotes (not single quotes) @@ -5709,9 +5729,9 @@ CSV FORMAT o spaces outside the quotes are not allowed File Extension - To help hledger identify the format and show the right error messages, - CSV/SSV/TSV files should normally be named with a .csv, .ssv or .tsv - filename extension. Or, the file path should be prefixed with csv:, + To help hledger identify the format and show the right error messages, + CSV/SSV/TSV files should normally be named with a .csv, .ssv or .tsv + filename extension. Or, the file path should be prefixed with csv:, ssv: or tsv:. Eg: $ hledger -f foo.ssv print @@ -5720,48 +5740,48 @@ CSV FORMAT $ cat foo | hledger -f ssv:- foo - You can override the file extension with a separator rule if needed. + You can override the file extension with a separator rule if needed. See also: Input files in the hledger manual. Reading multiple CSV files - If you use multiple -f options to read multiple CSV files at once, - hledger will look for a correspondingly-named rules file for each CSV - file. But if you use the --rules-file option, that rules file will be + If you use multiple -f options to read multiple CSV files at once, + hledger will look for a correspondingly-named rules file for each CSV + file. But if you use the --rules-file option, that rules file will be used for all the CSV files. Valid transactions After reading a CSV file, hledger post-processes and validates the gen- erated journal entries as it would for a journal file - balancing them, - applying balance assignments, and canonicalising amount styles. Any - errors at this stage will be reported in the usual way, displaying the + applying balance assignments, and canonicalising amount styles. Any + errors at this stage will be reported in the usual way, displaying the problem entry. There is one exception: balance assertions, if you have generated them, - will not be checked, since normally these will work only when the CSV - data is part of the main journal. If you do need to check balance as- + will not be checked, since normally these will work only when the CSV + data is part of the main journal. If you do need to check balance as- sertions generated from CSV right away, pipe into another hledger: $ hledger -f file.csv print | hledger -f- print Deduplicating, importing - When you download a CSV file periodically, eg to get your latest bank - transactions, the new file may overlap with the old one, containing + When you download a CSV file periodically, eg to get your latest bank + transactions, the new file may overlap with the old one, containing some of the same records. The import command will (a) detect the new transactions, and (b) append just those transactions to your main journal. It is idempotent, so you - don't have to remember how many times you ran it or with which version - of the CSV. (It keeps state in a hidden .latest.FILE.csv file.) This + don't have to remember how many times you ran it or with which version + of the CSV. (It keeps state in a hidden .latest.FILE.csv file.) This is the easiest way to import CSV data. Eg: # download the latest CSV files, then run this command. # Note, no -f flags needed here. $ hledger import *.csv [--dry] - This method works for most CSV files. (Where records have a stable + This method works for most CSV files. (Where records have a stable chronological order, and new records appear only at the new end.) - A number of other tools and workflows, hledger-specific and otherwise, + A number of other tools and workflows, hledger-specific and otherwise, exist for converting, deduplicating, classifying and managing CSV data. See: @@ -5772,30 +5792,30 @@ CSV FORMAT Setting amounts A posting amount can be set in one of these ways: - o by assigning (with a fields list or field assignment) to amountN + o by assigning (with a fields list or field assignment) to amountN (posting N's amount) or amount (posting 1's amount) - o by assigning to amountN-in and amountN-out (or amount-in and amount- - out). For each CSV record, whichever of these has a non-zero value - will be used, with appropriate sign. If both contain a non-zero + o by assigning to amountN-in and amountN-out (or amount-in and amount- + out). For each CSV record, whichever of these has a non-zero value + will be used, with appropriate sign. If both contain a non-zero value, this may not work. - o by assigning to balanceN (or balance) instead of the above, setting - the amount indirectly via a balance assignment. If you do this the + o by assigning to balanceN (or balance) instead of the above, setting + the amount indirectly via a balance assignment. If you do this the default account name may be wrong, so you should set that explicitly. There is some special handling for an amount's sign: - o If an amount value is parenthesised, it will be de-parenthesised and + o If an amount value is parenthesised, it will be de-parenthesised and sign-flipped. - o If an amount value begins with a double minus sign, those cancel out + o If an amount value begins with a double minus sign, those cancel out and are removed. o If an amount value begins with a plus sign, that will be removed Setting currency/commodity - If the currency/commodity symbol is included in the CSV's amount + If the currency/commodity symbol is included in the CSV's amount field(s): 2020-01-01,foo,$123.00 @@ -5814,7 +5834,7 @@ CSV FORMAT 2020-01-01,foo,USD,123.00 You can assign that to the currency pseudo-field, which has the special - effect of prepending itself to every amount in the transaction (on the + effect of prepending itself to every amount in the transaction (on the left, with no separating space): fields date,description,currency,amount @@ -5823,7 +5843,7 @@ CSV FORMAT expenses:unknown USD123.00 income:unknown USD-123.00 - Or, you can use a field assignment to construct the amount yourself, + Or, you can use a field assignment to construct the amount yourself, with more control. Eg to put the symbol on the right, and separated by a space: @@ -5834,13 +5854,13 @@ CSV FORMAT expenses:unknown 123.00 USD income:unknown -123.00 USD - Note we used a temporary field name (cur) that is not currency - that + Note we used a temporary field name (cur) that is not currency - that would trigger the prepending effect, which we don't want here. Referencing other fields - In field assignments, you can interpolate only CSV fields, not hledger - fields. In the example below, there's both a CSV field and a hledger - field named amount1, but %amount1 always means the CSV field, not the + In field assignments, you can interpolate only CSV fields, not hledger + fields. In the example below, there's both a CSV field and a hledger + field named amount1, but %amount1 always means the CSV field, not the hledger field: # Name the third CSV field "amount1" @@ -5852,7 +5872,7 @@ CSV FORMAT # Set comment to the CSV amount1 (not the amount1 assigned above) comment %amount1 - Here, since there's no CSV amount1 field, %amount1 will produce a lit- + Here, since there's no CSV amount1 field, %amount1 will produce a lit- eral "amount1": fields date,description,csvamount @@ -5860,7 +5880,7 @@ CSV FORMAT # Can't interpolate amount1 here comment %amount1 - When there are multiple field assignments to the same hledger field, + When there are multiple field assignments to the same hledger field, only the last one takes effect. Here, comment's value will be be B, or C if "something" is matched, but never A: @@ -5870,14 +5890,14 @@ CSV FORMAT comment C How CSV rules are evaluated - Here's how to think of CSV rules being evaluated (if you really need + Here's how to think of CSV rules being evaluated (if you really need to). First, - o include - all includes are inlined, from top to bottom, depth first. - (At each include point the file is inlined and scanned for further + o include - all includes are inlined, from top to bottom, depth first. + (At each include point the file is inlined and scanned for further includes, recursively, before proceeding.) - Then "global" rules are evaluated, top to bottom. If a rule is re- + Then "global" rules are evaluated, top to bottom. If a rule is re- peated, the last one wins: o skip (at top level) @@ -5891,33 +5911,33 @@ CSV FORMAT Then for each CSV record in turn: - o test all if blocks. If any of them contain a end rule, skip all re- - maining CSV records. Otherwise if any of them contain a skip rule, - skip that many CSV records. If there are multiple matched skip + o test all if blocks. If any of them contain a end rule, skip all re- + maining CSV records. Otherwise if any of them contain a skip rule, + skip that many CSV records. If there are multiple matched skip rules, the first one wins. - o collect all field assignments at top level and in matched if blocks. - When there are multiple assignments for a field, keep only the last + o collect all field assignments at top level and in matched if blocks. + When there are multiple assignments for a field, keep only the last one. - o compute a value for each hledger field - either the one that was as- + o compute a value for each hledger field - either the one that was as- signed to it (and interpolate the %CSVFIELDNAME references), or a de- fault o generate a synthetic hledger transaction from these values. - This is all part of the CSV reader, one of several readers hledger can - use to parse input files. When all files have been read successfully, - the transactions are passed as input to whichever hledger command the + This is all part of the CSV reader, one of several readers hledger can + use to parse input files. When all files have been read successfully, + the transactions are passed as input to whichever hledger command the user specified. TIMECLOCK FORMAT The time logging format of timeclock.el, as read by hledger. - hledger can read time logs in timeclock format. As with Ledger, these + hledger can read time logs in timeclock format. As with Ledger, these are (a subset of) timeclock.el's format, containing clock-in and clock- - out entries as in the example below. The date is a simple date. The - time format is HH:MM[:SS][+-ZZZZ]. Seconds and timezone are optional. + out entries as in the example below. The date is a simple date. The + time format is HH:MM[:SS][+-ZZZZ]. Seconds and timezone are optional. The timezone, if present, must be four digits and is ignored (currently the time is always interpreted as a local time). @@ -5926,9 +5946,9 @@ TIMECLOCK FORMAT i 2015/03/31 22:21:45 another account o 2015/04/01 02:00:34 - hledger treats each clock-in/clock-out pair as a transaction posting - some number of hours to an account. Or if the session spans more than - one day, it is split into several transactions, one for each day. For + hledger treats each clock-in/clock-out pair as a transaction posting + some number of hours to an account. Or if the session spans more than + one day, it is split into several transactions, one for each day. For the above time log, hledger print generates these journal entries: $ hledger -f t.timeclock print @@ -5949,69 +5969,69 @@ TIMECLOCK FORMAT To generate time logs, ie to clock in and clock out, you could: - o use emacs and the built-in timeclock.el, or the extended timeclock- + o use emacs and the built-in timeclock.el, or the extended timeclock- x.el and perhaps the extras in ledgerutils.el o at the command line, use these bash aliases: shell alias ti="echo - i `date '+%Y-%m-%d %H:%M:%S'` \$* >>$TIMELOG" alias to="echo o + i `date '+%Y-%m-%d %H:%M:%S'` \$* >>$TIMELOG" alias to="echo o `date '+%Y-%m-%d %H:%M:%S'` >>$TIMELOG" o or use the old ti and to scripts in the ledger 2.x repository. These - rely on a "timeclock" executable which I think is just the ledger 2 + rely on a "timeclock" executable which I think is just the ledger 2 executable renamed. TIMEDOT FORMAT hledger's human-friendly time logging format. - Timedot is a plain text format for logging dated, categorised quanti- - ties (of time, usually), supported by hledger. It is convenient for - approximate and retroactive time logging, eg when the real-time clock- - in/out required with a timeclock file is too precise or too interrup- - tive. It can be formatted like a bar chart, making clear at a glance + Timedot is a plain text format for logging dated, categorised quanti- + ties (of time, usually), supported by hledger. It is convenient for + approximate and retroactive time logging, eg when the real-time clock- + in/out required with a timeclock file is too precise or too interrup- + tive. It can be formatted like a bar chart, making clear at a glance where time was spent. - Though called "timedot", this format is read by hledger as commodity- - less quantities, so it could be used to represent dated quantities + Though called "timedot", this format is read by hledger as commodity- + less quantities, so it could be used to represent dated quantities other than time. In the docs below we'll assume it's time. - A timedot file contains a series of day entries. A day entry begins - with a non-indented hledger-style simple date (Y-M-D, Y/M/D, Y.M.D..) - Any additional text on the same line is used as a transaction descrip- + A timedot file contains a series of day entries. A day entry begins + with a non-indented hledger-style simple date (Y-M-D, Y/M/D, Y.M.D..) + Any additional text on the same line is used as a transaction descrip- tion for this day. This is followed by optionally-indented timelog items for that day, one - per line. Each timelog item is a note, usually a hledger:style:ac- - count:name representing a time category, followed by two or more spa- - ces, and a quantity. Each timelog item generates a hledger transac- + per line. Each timelog item is a note, usually a hledger:style:ac- + count:name representing a time category, followed by two or more spa- + ces, and a quantity. Each timelog item generates a hledger transac- tion. Quantities can be written as: - o dots: a sequence of dots (.) representing quarter hours. Spaces may + o dots: a sequence of dots (.) representing quarter hours. Spaces may optionally be used for grouping. Eg: .... .. o an integral or decimal number, representing hours. Eg: 1.5 - o an integral or decimal number immediately followed by a unit symbol - s, m, h, d, w, mo, or y, representing seconds, minutes, hours, days + o an integral or decimal number immediately followed by a unit symbol + s, m, h, d, w, mo, or y, representing seconds, minutes, hours, days weeks, months or years respectively. Eg: 90m. The following equiva- - lencies are assumed, currently: 1m = 60s, 1h = 60m, 1d = 24h, 1w = + lencies are assumed, currently: 1m = 60s, 1h = 60m, 1d = 24h, 1w = 7d, 1mo = 30d, 1y=365d. - There is some flexibility allowing notes and todo lists to be kept + There is some flexibility allowing notes and todo lists to be kept right in the time log, if needed: o Blank lines and lines beginning with # or ; are ignored. o Lines not ending with a double-space and quantity are parsed as items - taking no time, which will not appear in balance reports by default. + taking no time, which will not appear in balance reports by default. (Add -E to see them.) - o Org mode headlines (lines beginning with one or more * followed by a - space) can be used as date lines or timelog items (the stars are ig- - nored). Also all org headlines before the first date line are ig- - nored. This means org users can manage their timelog as an org out- - line (eg using org-mode/orgstruct-mode in Emacs), for organisation, + o Org mode headlines (lines beginning with one or more * followed by a + space) can be used as date lines or timelog items (the stars are ig- + nored). Also all org headlines before the first date line are ig- + nored. This means org users can manage their timelog as an org out- + line (eg using org-mode/orgstruct-mode in Emacs), for organisation, faster navigation, controlling visibility etc. Examples: @@ -6076,7 +6096,7 @@ TIMEDOT FORMAT ------------++---------------------------------------- || 7.75 2.25 8.00 - I prefer to use period for separating account components. We can make + I prefer to use period for separating account components. We can make this work with an account alias: 2016/2/4 @@ -6093,9 +6113,9 @@ TIMEDOT FORMAT Here is a sample.timedot. COMMON TASKS - Here are some quick examples of how to do some basic tasks with - hledger. For more details, see the reference section below, the - hledger_journal(5) manual, or the more extensive docs at + Here are some quick examples of how to do some basic tasks with + hledger. For more details, see the reference section below, the + hledger_journal(5) manual, or the more extensive docs at https://hledger.org. Getting help @@ -6111,26 +6131,26 @@ COMMON TASKS https://hledger.org#help-feedback Constructing command lines - hledger has an extensive and powerful command line interface. We + hledger has an extensive and powerful command line interface. We strive to keep it simple and ergonomic, but you may run into one of the confusing real world details described in OPTIONS, below. If that hap- pens, here are some tips that may help: - o command-specific options must go after the command (it's fine to put + o command-specific options must go after the command (it's fine to put all options there) (hledger CMD OPTS ARGS) - o running add-on executables directly simplifies command line parsing + o running add-on executables directly simplifies command line parsing (hledger-ui OPTS ARGS) o enclose "problematic" args in single quotes - o if needed, also add a backslash to hide regular expression metachar- + o if needed, also add a backslash to hide regular expression metachar- acters from the shell o to see how a misbehaving command is being parsed, add --debug=2. Starting a journal file - hledger looks for your accounting data in a journal file, + hledger looks for your accounting data in a journal file, $HOME/.hledger.journal by default: $ hledger stats @@ -6138,9 +6158,9 @@ COMMON TASKS Please create it first, eg with "hledger add" or a text editor. Or, specify an existing journal file with -f or LEDGER_FILE. - You can override this by setting the LEDGER_FILE environment variable. + You can override this by setting the LEDGER_FILE environment variable. It's a good practice to keep this important file under version control, - and to start a new file each year. So you could do something like + and to start a new file each year. So you could do something like this: $ mkdir ~/finance @@ -6164,20 +6184,20 @@ COMMON TASKS Market prices : 0 () Setting opening balances - Pick a starting date for which you can look up the balances of some - real-world assets (bank accounts, wallet..) and liabilities (credit + Pick a starting date for which you can look up the balances of some + real-world assets (bank accounts, wallet..) and liabilities (credit cards..). - To avoid a lot of data entry, you may want to start with just one or + To avoid a lot of data entry, you may want to start with just one or two accounts, like your checking account or cash wallet; and pick a re- - cent starting date, like today or the start of the week. You can al- - ways come back later and add more accounts and older transactions, eg + cent starting date, like today or the start of the week. You can al- + ways come back later and add more accounts and older transactions, eg going back to january 1st. - Add an opening balances transaction to the journal, declaring the bal- + Add an opening balances transaction to the journal, declaring the bal- ances on this date. Here are two ways to do it: - o The first way: open the journal in any text editor and save an entry + o The first way: open the journal in any text editor and save an entry like this: 2020-01-01 * opening balances @@ -6187,19 +6207,19 @@ COMMON TASKS liabilities:creditcard $-50 = $-50 equity:opening/closing balances - These are start-of-day balances, ie whatever was in the account at + These are start-of-day balances, ie whatever was in the account at the end of the previous day. - The * after the date is an optional status flag. Here it means + The * after the date is an optional status flag. Here it means "cleared & confirmed". - The currency symbols are optional, but usually a good idea as you'll + The currency symbols are optional, but usually a good idea as you'll be dealing with multiple currencies sooner or later. - The = amounts are optional balance assertions, providing extra error + The = amounts are optional balance assertions, providing extra error checking. - o The second way: run hledger add and follow the prompts to record a + o The second way: run hledger add and follow the prompts to record a similar transaction: $ hledger add @@ -6236,18 +6256,18 @@ COMMON TASKS Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2020-01-01]: . - If you're using version control, this could be a good time to commit + If you're using version control, this could be a good time to commit the journal. Eg: $ git commit -m 'initial balances' 2020.journal Recording transactions - As you spend or receive money, you can record these transactions using - one of the methods above (text editor, hledger add) or by using the - hledger-iadd or hledger-web add-ons, or by using the import command to + As you spend or receive money, you can record these transactions using + one of the methods above (text editor, hledger add) or by using the + hledger-iadd or hledger-web add-ons, or by using the import command to convert CSV data downloaded from your bank. - Here are some simple transactions, see the hledger_journal(5) manual + Here are some simple transactions, see the hledger_journal(5) manual and hledger.org for more ideas: 2020/1/10 * gift received @@ -6263,22 +6283,22 @@ COMMON TASKS assets:bank:checking $1000 Reconciling - Periodically you should reconcile - compare your hledger-reported bal- - ances against external sources of truth, like bank statements or your - bank's website - to be sure that your ledger accurately represents the - real-world balances (and, that the real-world institutions have not - made a mistake!). This gets easy and fast with (1) practice and (2) - frequency. If you do it daily, it can take 2-10 minutes. If you let - it pile up, expect it to take longer as you hunt down errors and dis- + Periodically you should reconcile - compare your hledger-reported bal- + ances against external sources of truth, like bank statements or your + bank's website - to be sure that your ledger accurately represents the + real-world balances (and, that the real-world institutions have not + made a mistake!). This gets easy and fast with (1) practice and (2) + frequency. If you do it daily, it can take 2-10 minutes. If you let + it pile up, expect it to take longer as you hunt down errors and dis- crepancies. A typical workflow: - 1. Reconcile cash. Count what's in your wallet. Compare with what - hledger reports (hledger bal cash). If they are different, try to - remember the missing transaction, or look for the error in the al- - ready-recorded transactions. A register report can be helpful - (hledger reg cash). If you can't find the error, add an adjustment + 1. Reconcile cash. Count what's in your wallet. Compare with what + hledger reports (hledger bal cash). If they are different, try to + remember the missing transaction, or look for the error in the al- + ready-recorded transactions. A register report can be helpful + (hledger reg cash). If you can't find the error, add an adjustment transaction. Eg if you have $105 after the above, and can't explain the missing $2, it could be: @@ -6288,26 +6308,26 @@ COMMON TASKS 2. Reconcile checking. Log in to your bank's website. Compare today's (cleared) balance with hledger's cleared balance (hledger bal check- - ing -C). If they are different, track down the error or record the - missing transaction(s) or add an adjustment transaction, similar to + ing -C). If they are different, track down the error or record the + missing transaction(s) or add an adjustment transaction, similar to the above. Unlike the cash case, you can usually compare the trans- - action history and running balance from your bank with the one re- - ported by hledger reg checking -C. This will be easier if you gen- - erally record transaction dates quite similar to your bank's clear- + action history and running balance from your bank with the one re- + ported by hledger reg checking -C. This will be easier if you gen- + erally record transaction dates quite similar to your bank's clear- ing dates. 3. Repeat for other asset/liability accounts. - Tip: instead of the register command, use hledger-ui to see a live-up- + Tip: instead of the register command, use hledger-ui to see a live-up- dating register while you edit the journal: hledger-ui --watch --regis- ter checking -C - After reconciling, it could be a good time to mark the reconciled - transactions' status as "cleared and confirmed", if you want to track - that, by adding the * marker. Eg in the paycheck transaction above, + After reconciling, it could be a good time to mark the reconciled + transactions' status as "cleared and confirmed", if you want to track + that, by adding the * marker. Eg in the paycheck transaction above, insert * between 2020-01-15 and paycheck - If you're using version control, this can be another good time to com- + If you're using version control, this can be another good time to com- mit: $ git commit -m 'txns' 2020.journal @@ -6379,7 +6399,7 @@ COMMON TASKS -------------------- 0 - Show only asset and liability balances, as a flat list, limited to + Show only asset and liability balances, as a flat list, limited to depth 2: $ hledger bal assets liabilities --flat -2 @@ -6389,7 +6409,7 @@ COMMON TASKS -------------------- $4055 - Show the same thing without negative numbers, formatted as a simple + Show the same thing without negative numbers, formatted as a simple balance sheet: $ hledger bs --flat -2 @@ -6456,15 +6476,15 @@ COMMON TASKS 2020-01-13 **** Migrating to a new file - At the end of the year, you may want to continue your journal in a new + At the end of the year, you may want to continue your journal in a new file, so that old transactions don't slow down or clutter your reports, - and to help ensure the integrity of your accounting history. See the + and to help ensure the integrity of your accounting history. See the close command. If using version control, don't forget to git add the new file. LIMITATIONS - The need to precede add-on command options with -- when invoked from + The need to precede add-on command options with -- when invoked from hledger is awkward. When input data contains non-ascii characters, a suitable system locale @@ -6480,36 +6500,36 @@ LIMITATIONS In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger add. - Not all of Ledger's journal file syntax is supported. See file format + Not all of Ledger's journal file syntax is supported. See file format differences. - On large data files, hledger is slower and uses more memory than + On large data files, hledger is slower and uses more memory than Ledger. TROUBLESHOOTING - Here are some issues you might encounter when you run hledger (and re- - member you can also seek help from the IRC channel, mail list or bug + Here are some issues you might encounter when you run hledger (and re- + member you can also seek help from the IRC channel, mail list or bug tracker): Successfully installed, but "No command 'hledger' found" stack and cabal install binaries into a special directory, which should - be added to your PATH environment variable. Eg on unix-like systems, + be added to your PATH environment variable. Eg on unix-like systems, that is ~/.local/bin and ~/.cabal/bin respectively. I set a custom LEDGER_FILE, but hledger is still using the default file - LEDGER_FILE should be a real environment variable, not just a shell - variable. The command env | grep LEDGER_FILE should show it. You may + LEDGER_FILE should be a real environment variable, not just a shell + variable. The command env | grep LEDGER_FILE should show it. You may need to use export. Here's an explanation. - Getting errors like "Illegal byte sequence" or "Invalid or incomplete - multibyte or wide character" or "commitAndReleaseBuffer: invalid argu- + Getting errors like "Illegal byte sequence" or "Invalid or incomplete + multibyte or wide character" or "commitAndReleaseBuffer: invalid argu- ment (invalid character)" Programs compiled with GHC (hledger, haskell build tools, etc.) need to have a UTF-8-aware locale configured in the environment, otherwise they - will fail with these kinds of errors when they encounter non-ascii + will fail with these kinds of errors when they encounter non-ascii characters. - To fix it, set the LANG environment variable to some locale which sup- + To fix it, set the LANG environment variable to some locale which sup- ports UTF-8. The locale you choose must be installed on your system. Here's an example of setting LANG temporarily, on Ubuntu GNU/Linux: @@ -6524,8 +6544,8 @@ TROUBLESHOOTING POSIX $ LANG=en_US.utf8 hledger -f my.journal print # ensure it is used for this command - If available, C.UTF-8 will also work. If your preferred locale isn't - listed by locale -a, you might need to install it. Eg on Ubuntu/De- + If available, C.UTF-8 will also work. If your preferred locale isn't + listed by locale -a, you might need to install it. Eg on Ubuntu/De- bian: $ apt-get install language-pack-fr @@ -6545,8 +6565,8 @@ TROUBLESHOOTING $ echo "export LANG=en_US.utf8" >>~/.bash_profile $ bash --login - Exact spelling and capitalisation may be important. Note the differ- - ence on MacOS (UTF-8, not utf8). Some platforms (eg ubuntu) allow + Exact spelling and capitalisation may be important. Note the differ- + ence on MacOS (UTF-8, not utf8). Some platforms (eg ubuntu) allow variant spellings, but others (eg macos) require it to be exact: $ locale -a | grep -iE en_us.*utf @@ -6556,7 +6576,7 @@ TROUBLESHOOTING REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel + Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel or hledger mail list)