From 2af744292a2cf1a3701f92bdd0a02f9c91dc7787 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 21 Feb 2023 00:17:02 -1000 Subject: [PATCH] ;doc: update manuals --- hledger-ui/hledger-ui.1 | 2 +- hledger-ui/hledger-ui.txt | 2 +- hledger-web/hledger-web.1 | 2 +- hledger-web/hledger-web.txt | 2 +- hledger/hledger.1 | 1141 +++++++-------- hledger/hledger.info | 2617 +++++++++++++++++---------------- hledger/hledger.txt | 2719 ++++++++++++++++++----------------- 7 files changed, 3220 insertions(+), 3265 deletions(-) diff --git a/hledger-ui/hledger-ui.1 b/hledger-ui/hledger-ui.1 index 31ed13eb5..e52e9e3d6 100644 --- a/hledger-ui/hledger-ui.1 +++ b/hledger-ui/hledger-ui.1 @@ -1,5 +1,5 @@ -.TH "HLEDGER-UI" "1" "January 2023" "hledger-ui-1.28.99 " "hledger User Manuals" +.TH "HLEDGER-UI" "1" "February 2023" "hledger-ui-1.28.99 " "hledger User Manuals" diff --git a/hledger-ui/hledger-ui.txt b/hledger-ui/hledger-ui.txt index e96ca0d4d..cbd81b2fe 100644 --- a/hledger-ui/hledger-ui.txt +++ b/hledger-ui/hledger-ui.txt @@ -598,4 +598,4 @@ SEE ALSO -hledger-ui-1.28.99 January 2023 HLEDGER-UI(1) +hledger-ui-1.28.99 February 2023 HLEDGER-UI(1) diff --git a/hledger-web/hledger-web.1 b/hledger-web/hledger-web.1 index 8846b0e24..381836133 100644 --- a/hledger-web/hledger-web.1 +++ b/hledger-web/hledger-web.1 @@ -1,5 +1,5 @@ -.TH "HLEDGER-WEB" "1" "January 2023" "hledger-web-1.28.99 " "hledger User Manuals" +.TH "HLEDGER-WEB" "1" "February 2023" "hledger-web-1.28.99 " "hledger User Manuals" diff --git a/hledger-web/hledger-web.txt b/hledger-web/hledger-web.txt index 5ff0a3817..5da709142 100644 --- a/hledger-web/hledger-web.txt +++ b/hledger-web/hledger-web.txt @@ -608,4 +608,4 @@ SEE ALSO -hledger-web-1.28.99 January 2023 HLEDGER-WEB(1) +hledger-web-1.28.99 February 2023 HLEDGER-WEB(1) diff --git a/hledger/hledger.1 b/hledger/hledger.1 index c6b3eec53..137d2e06e 100644 --- a/hledger/hledger.1 +++ b/hledger/hledger.1 @@ -1,6 +1,6 @@ .\"t -.TH "HLEDGER" "1" "January 2023" "hledger-1.28.99 " "hledger User Manuals" +.TH "HLEDGER" "1" "February 2023" "hledger-1.28.99 " "hledger User Manuals" @@ -514,7 +514,7 @@ query terms, on the command line and in the hledger-web search form: .IP \[bu] 2 CSV rules conditional blocks: \f[V]if REGEX ...\f[R] .IP \[bu] 2 -account alias directives and options: +account alias directive and \f[V]--alias\f[R] option: \f[V]alias /REGEX/ = REPLACEMENT\f[R], \f[V]--alias /REGEX/=REPLACEMENT\f[R] .PP @@ -881,6 +881,7 @@ Y T}@T{ Y T}@T{ +Y T}@T{ Y T}@T{ @@ -1307,14 +1308,7 @@ P 2022-01-01 AAAA $1.40 expenses:tax:us:2021 $500 ; plus means added to this account (debit) ; revenue/expense categories are also \[dq]accounts\[dq] -2022-01-01 Whole Foods | payee name and description can be separated by a pipe char - ; Transaction or posting comments can contain searchable tags, - ; written NAME: or NAME:VALUE (value ends at comma or end of line). - ; Here\[aq]s tag1:with a value, and an empty tag2: - ; A few tags have special meaning. A \[dq]date:\[dq] tag on a posting adjusts its date. - assets:checking $-50 ; date:2022-01-03, checking cleared two days later - expenses:food - +Kv 2022-01-01 ; The description is optional. ; Any currency/commodity symbols are allowed, on either side. assets:cash:wallet GBP -10 @@ -1449,8 +1443,8 @@ Dates in the journal file use \f[I]simple dates\f[R] format: \f[V]YYYY-MM-DD\f[R] or \f[V]YYYY/MM/DD\f[R] or \f[V]YYYY.MM.DD\f[R], with leading zeros optional. The year may be omitted, in which case it will be inferred from the -context: the current transaction, the default year set with a default -year directive, or the current date when the command is run. +context: the current transaction, the default year set with a +\f[V]Y\f[R] directive, or the current date when the command is run. Some examples: \f[V]2010-01-31\f[R], \f[V]2010/01/31\f[R], \f[V]2010.1.31\f[R], \f[V]1/31\f[R]. .PP @@ -2608,7 +2602,7 @@ cleaning up your files. .PP It can be surprising though; for example, it means that \f[V]alias\f[R] directives do not affect parent or sibling files (see below). -.SS Accounts +.SS \f[V]account\f[R] directive .PP \f[V]account\f[R] directives can be used to declare accounts (ie, the places that amounts are transferred from and to). @@ -2823,7 +2817,6 @@ These are just a convenience that sometimes help new users get going; if they don\[aq]t work for you, just ignore them and declare your account types. See also Regular expressions. -Note the Cash regexp changed in hledger 1.24.99.2. .RS 2 .IP .nf @@ -2876,7 +2869,7 @@ $ hledger accounts --types [ACCTPAT] [-DEPTH] [type:TYPECODES] \f[R] .fi .RE -.SS Account aliases +.SS \f[V]alias\f[R] directive .PP You can define account alias rules which rewrite your account names, or parts of them, before generating reports. @@ -3049,7 +3042,7 @@ alias bar=Bar include c.journal ; also affected \f[R] .fi -.SS \f[V]end aliases\f[R] +.SS \f[V]end aliases\f[R] directive .PP You can clear (forget) all currently defined aliases (seen in the journal so far, or defined on the command line) with this directive: @@ -3123,7 +3116,7 @@ command, eg something like: $ hledger accounts --alias assets=bassetts type:a \f[R] .fi -.SS Commodities +.SS \f[V]commodity\f[R] directive .PP You can use \f[V]commodity\f[R] directives to declare your commodities. In fact the \f[V]commodity\f[R] directive performs several functions at @@ -3223,7 +3216,7 @@ currently it\[aq]s not possible (?) to declare the \[dq]no-symbol\[dq] commodity with a directive. This is one exception for convenience: zero amounts are always allowed to have no commodity symbol. -.SS Decimal mark +.SS \f[V]decimal-mark\f[R] directive .PP You can use a \f[V]decimal-mark\f[R] directive - usually one per file, at the top of the file - to declare which character represents a decimal @@ -3247,7 +3240,7 @@ decimal-mark , This prevents any ambiguity when parsing numbers in the file, so we recommend it, especially if the file contains digit group marks (eg thousands separators). -.SS Include files +.SS \f[V]include\f[R] directive .PP You can pull in the content of additional files by writing an include directive, like this: @@ -3278,12 +3271,14 @@ including directories, but this can be done, eg: The path may also be prefixed to force a specific file format, overriding the file extension (as described in hledger.1 -> Input files): \f[V]include timedot:\[ti]/notes/2020*.md\f[R]. -.SS Market prices +.SS \f[V]P\f[R] directive .PP The \f[V]P\f[R] directive declares a market price, which is a conversion rate between two commodities on a certain date. -These are often obtained from a stock exchange, cryptocurrency exchange, -or the foreign exchange market. +This allows value reports to convert amounts of one commodity to their +value in another, on or after that date. +These prices are often obtained from a stock exchange, cryptocurrency +exchange, the or foreign exchange market. .PP The format is: .IP @@ -3312,10 +3307,12 @@ The \f[V]-V\f[R], \f[V]-X\f[R] and \f[V]--value\f[R] flags use these market prices to show amount values in another commodity. See Valuation. .PP -.SS Payees +.SS \f[V]payee\f[R] directive .PP -The \f[V]payee\f[R] directive can be used to declare a limited set of -payees which may appear in transaction descriptions. +\f[V]payee PAYEE NAME\f[R] +.PP +This directive can be used to declare a limited set of payees which may +appear in transaction descriptions. The \[dq]payees\[dq] check will report an error if any transaction refers to a payee that has not been declared. Eg: @@ -3327,11 +3324,34 @@ payee Whole Foods .fi .PP Any indented subdirectives are currently ignored. +.SS \f[V]tag\f[R] directive +.PP +\f[V]tag TAGNAME\f[R] +.PP +This directive can be used to declare a limited set of tag names allowed +in tags. +TAGNAME should be a valid tag name (no spaces). +Eg: +.IP +.nf +\f[C] +tag item-id +\f[R] +.fi +.PP +Any indented subdirectives are currently ignored. +.PP +The \[dq]tags\[dq] check will report an error if any undeclared tag name +is used. +It is quite easy to accidentally create a tag through normal use of +colons in comments(#comments]; if you want to prevent this, you can +declare and check your tags . .SS Periodic transactions .PP -Periodic transaction rules describe transactions that recur. -They allow hledger to generate temporary future transactions (visible -only in reports) to help with forecasting or budgeting. +The \f[V]\[ti]\f[R] directive declares recurring transactions. +Such directives allow hledger to generate temporary future transactions +(visible in reports, not in the journal file) to help with forecasting +or budgeting. .PP Periodic transactions can be a little tricky, so before you use them, read this whole section, or at least these tips: @@ -3374,16 +3394,22 @@ wave.): .IP .nf \f[C] +# every first of month \[ti] monthly expenses:rent $2000 assets:bank:checking + +# every 15th of month in 2023\[aq]s first quarter: +\[ti] monthly from 2023-04-15 to 2023-06-16 + expenses:utilities $400 + assets:bank:checking \f[R] .fi .PP -There is an additional constraint on the period expression: the start -date must fall on a natural boundary of the interval. -Eg \f[V]monthly from 2018/1/1\f[R] is valid, but -\f[V]monthly from 2018/1/15\f[R] is not. +The period expression is the same syntax used for specifying +multi-period reports, just interpreted differently; there, it specifies +report periods; here it specifies recurrence dates (the periods\[aq] +start dates). .SS Periodic rules and relative dates .PP Partial or relative dates (like \f[V]12/31\f[R], \f[V]25\f[R], @@ -3437,10 +3463,10 @@ less important or even not recommended for most users. Downsides are mentioned to help you decide if you want to use them. .SS Auto postings .PP -\[dq]Automated postings\[dq] or \[dq]auto postings\[dq] are extra -postings which get added automatically to transactions which match -certain queries, defined by \[dq]auto posting rules\[dq], when you use -the \f[V]--auto\f[R] flag. +The \f[V]=\f[R] directive declares a rule for automatically adding +temporary extra postings (visible in reports, not in the journal file) +to all transactions matched by a certain query, when you use the +\f[V]--auto\f[R] flag. .PP Downsides: depending on generated data for your reports makes your financial data less portable, less future-proof, and less trustworthy in @@ -3649,21 +3675,22 @@ infers its year from DATE. Downsides: another syntax to learn, redundant with hledger\[aq]s \f[V]date:\f[R]/\f[V]date2:\f[R] tags, and confusingly similar to Ledger\[aq]s lot date syntax. -.SS Default commodity +.SS \f[V]D\f[R] directive .PP -The \f[V]D\f[R] directive sets a default commodity, to be used for any -subsequent commodityless amounts (ie, plain numbers) seen while parsing -the journal. +\f[V]D AMOUNT\f[R] +.PP +This directive sets a default commodity, to be used for any subsequent +commodityless amounts (ie, plain numbers) seen while parsing the +journal. This effect lasts until the next \f[V]D\f[R] directive, or the end of the journal. .PP For compatibility/historical reasons, \f[V]D\f[R] also acts like a \f[V]commodity\f[R] directive (setting the commodity\[aq]s decimal mark for parsing and display style for output). -.PP -The syntax is \f[V]D AMOUNT\f[R]. -As with \f[V]commodity\f[R], the amount must include a decimal mark -(either period or comma). +So its argument is not just a commodity symbol, but a full amount +demonstrating the style. +The amount must include a decimal mark (either period or comma). Eg: .IP .nf @@ -3678,27 +3705,31 @@ D $1,000.00 \f[R] .fi .PP -If both \f[V]commodity\f[R] and \f[V]D\f[R] directives are found for a -commodity, \f[V]commodity\f[R] takes precedence for setting decimal mark -and display style. +Interactions with other directives: .PP -If you are using \f[V]D\f[R] and also checking commodities, you will -need to add a \f[V]commodity\f[R] directive similar to the \f[V]D\f[R]. -(The \f[V]hledger check commodities\f[R] command expects -\f[V]commodity\f[R] directives, and ignores \f[V]D\f[R]). +For setting a commodity\[aq]s display style, a \f[V]commodity\f[R] +directive has highest priority, then a \f[V]D\f[R] directive. +.PP +For detecting a commodity\[aq]s decimal mark during parsing, +\f[V]decimal-mark\f[R] has highest priority, then \f[V]commodity\f[R], +then \f[V]D\f[R]. +.PP +For checking commodity symbols with the check command, a +\f[V]commodity\f[R] directive is required +(\f[V]hledger check commodities\f[R] ignores \f[V]D\f[R] directives). .PP Downsides: omitting commodity symbols makes your financial data less explicit, less portable, and less trustworthy in an audit. It is usually an unsustainable shortcut; sooner or later you will want to track multiple commodities. D is overloaded with functions redundant with \f[V]commodity\f[R] and -\f[V]decimal mark\f[R]. +\f[V]decimal-mark\f[R]. And it works differently from Ledger\[aq]s \f[V]D\f[R]. -.SS Default parent account +.SS \f[V]apply account\f[R] directive .PP -The \f[V]apply account\f[R] directive sets a parent account which will -be prepended to all accounts in following entries, until an -\f[V]end apply account\f[R] directive or end of current file. +This directive sets a default parent account, which will be prepended to +all accounts in following entries, until an \f[V]end apply account\f[R] +directive or end of current file. Eg: .IP .nf @@ -3733,12 +3764,17 @@ prepended. .PP Downsides: this can make your financial data less explicit, less portable, and less trustworthy in an audit. -.SS Default year +.SS \f[V]Y\f[R] directive .PP -You can set a default year to be used for subsequent dates which -don\[aq]t specify a year. -This is a line beginning with \f[V]Y\f[R] (or \f[V]year\f[R] or -\f[V]apply year\f[R]) followed by the year. +\f[V]Y YEAR\f[R] +.PP +or (deprecated backward-compatible forms): +.PP +\f[V]year YEAR\f[R] \f[V]apply year YEAR\f[R] +.PP +The space is optional. +This sets a default year to be used for subsequent dates which don\[aq]t +specify a year. Eg: .IP .nf @@ -5817,7 +5853,7 @@ A sample.timedot file. .SS Report start & end date .PP By default, most hledger reports will show the full span of time -represented by the journal data. +represented by the journal. The report start date will be the earliest transaction or posting date, and the report end date will be the latest transaction, posting, or market price date. @@ -5843,8 +5879,8 @@ start/end dates from options and that from \f[V]date:\f[R] queries. That is, \f[V]date:2019-01 date:2019 -p\[aq]2000 to 2030\[aq]\f[R] yields January 2019, the smallest common time span. .IP \[bu] 2 -A report interval (see below) will adjust start/end dates, when needed, -so that they fall on subperiod boundaries. +In some cases a report interval will adjust start/end dates to fall on +interval boundaries (see below). .PP Examples: .PP @@ -5893,13 +5929,12 @@ T} .TE .SS Smart dates .PP -hledger\[aq]s user interfaces accept a flexible \[dq]smart date\[dq] -syntax. -Smart dates allow some english words, can be relative to today\[aq]s -date, and can have less-significant date parts omitted (defaulting to -1). -.PP -Examples: +hledger\[aq]s user interfaces accept a \[dq]smart date\[dq] syntax for +added convenience. +Smart dates optionally can be relative to today\[aq]s date, be written +with english words, and have less-significant parts omitted (missing +parts are inferred as 1). +Some examples: .PP .TS tab(@); @@ -5972,7 +6007,7 @@ T}@T{ T} .TE .PP -Counterexamples - malformed digit sequences might give surprising +Some counterexamples - malformed digit sequences might give surprising results: .PP .TS @@ -6000,19 +6035,18 @@ T}@T{ T} .TE .PP -Note \[dq]today\[aq]s date\[dq] can be overridden with the -\f[V]--today\f[R] option, in case it\[aq]s needed for testing or for -recreating old reports. -(Except for periodic transaction rules; those are not affected by +\[dq]Today\[aq]s date\[dq] can be overridden with the \f[V]--today\f[R] +option, in case it\[aq]s needed for testing or for recreating old +reports. +(Except for periodic transaction rules, which are not affected by \f[V]--today\f[R].) .SS Report intervals .PP -A report interval can be specified so that commands like register, -balance and activity become multi-period, showing each subperiod as a +A report interval can be specified so that reports like register, +balance or activity become multi-period, showing each subperiod as a separate row or column. .PP -The following \[dq]standard\[dq] report intervals can be enabled by -using their corresponding flag: +The following standard intervals can be enabled with command-line flags: .IP \[bu] 2 \f[V]-D/--daily\f[R] .IP \[bu] 2 @@ -6024,50 +6058,53 @@ using their corresponding flag: .IP \[bu] 2 \f[V]-Y/--yearly\f[R] .PP -These standard intervals always start on natural interval boundaries: eg -\f[V]--weekly\f[R] starts on mondays, \f[V]--monthly\f[R] starts on the -first of the month, \f[V]--yearly\f[R] always starts on January 1st, -etc. +More complex intervals can be specified using \f[V]-p/--period\f[R], +described below. +.SS Date adjustment .PP -Certain more complex intervals, and more flexible boundary dates, can be -specified by \f[V]-p/--period\f[R]. -These are described in period expressions, below. -.PP -Report intervals can only be specified by the flags above, and not by -query arguments, currently. -.PP -Report intervals have another effect: multi-period reports are always -expanded to fill a whole number of subperiods. -So if you use a report interval (other than \f[V]--daily\f[R]), and you -have specified a start or end date, you may notice those dates being -overridden (ie, the report starts earlier than your requested start -date, or ends later than your requested end date). -This is done to ensure \[dq]full\[dq] first and last subperiods, so that -all subperiods\[aq] numbers are comparable. -.PP -To summarise: +With a report interval (other than daily), report start / end dates +which have not been specified explicitly and in full (eg not +\f[V]-b 2023-01-01\f[R], but \f[V]-b 2023-01\f[R] or \f[V]-b 2023\f[R] +or unspecified) are considered flexible: .IP \[bu] 2 -In multiperiod reports, all subperiods are forced to be the same length, -to simplify reporting. +A flexible start date will be automatically adjusted earlier if needed +to fall on a natural interval boundary. .IP \[bu] 2 -Reports with the standard -\f[V]--weekly\f[R]/\f[V]--monthly\f[R]/\f[V]--quarterly\f[R]/\f[V]--yearly\f[R] -intervals are required to start on the first day of a -week/month/quarter/year. -We\[aq]d like more flexibility here but it isn\[aq]t supported yet. +Similarly, a flexible end date will be adjusted later if needed to make +the last period a whole interval (the same length as the others). +.PP +This is convenient for producing clean periodic reports (this is +traditional hledger behaviour). +By contrast, fully-specified exact dates will not be adjusted (this is +new in hledger 1.29). +.PP +An example: with a journal whose first date is 2023-01-10 and last date +is 2023-03-20: .IP \[bu] 2 -\f[V]--period\f[R] (below) can specify more complex intervals, starting -on any date. +\f[V]hledger bal -M -b 2023/1/15 -e 2023/3/10\f[R] +.PD 0 +.P +.PD +The report periods will begin on the 15th day of each month, starting +from 2023-01-15, and the last period\[aq]s last day will be 2023-03-09. +(Exact start and end dates, neither is adjusted.) +.IP \[bu] 2 +\f[V]hledger bal -M -b 2023-01 -e 2023-04\f[R] or +\f[V]hledger bal -M\f[R] +.PD 0 +.P +.PD +The report periods will begin on the 1st of each month, starting from +2023-01-01, and the last period\[aq]s last day will be 2023-03-31. +(Flexible start and end dates, both are adjusted.) .SS Period expressions .PP -The \f[V]-p/--period\f[R] option accepts period expressions, a shorthand -way of expressing a start date, end date, and/or report interval all at -once. +The \f[V]-p/--period\f[R] option specifies a period expression, which is +a compact way of expressing a start date, end date, and/or report +interval. .PP -Here\[aq]s a basic period expression specifying the first quarter of -2009. -Note, hledger always treats start dates as inclusive and end dates as -exclusive: +Here\[aq]s a period expression with a start and end date (specifying the +first quarter of 2009): .PP .TS tab(@); @@ -6077,10 +6114,12 @@ T{ T} .TE .PP -Keywords like \[dq]from\[dq] and \[dq]to\[dq] are optional, and so are -the spaces, as long as you don\[aq]t run two dates together. +Several keywords like \[dq]from\[dq] and \[dq]to\[dq] are supported for +readability; these are optional. \[dq]to\[dq] can also be written as \[dq]..\[dq] or \[dq]-\[dq]. -These are equivalent to the above: +The spaces are also optional, as long as you don\[aq]t run two dates +together. +So the following are equivalent to the above: .PP .TS tab(@); @@ -6096,8 +6135,8 @@ T{ T} .TE .PP -Dates are smart dates, so if the current year is 2009, the above can -also be written as: +Dates are smart dates, so if the current year is 2009, these are also +equivalent to the above: .PP .TS tab(@); @@ -6106,7 +6145,7 @@ T{ \f[V]-p \[dq]1/1 4/1\[dq]\f[R] T} T{ -\f[V]-p \[dq]january-apr\[dq]\f[R] +\f[V]-p \[dq]jan-apr\[dq]\f[R] T} T{ \f[V]-p \[dq]this year to 4/1\[dq]\f[R] @@ -6114,7 +6153,7 @@ T} .TE .PP If you specify only one date, the missing start or end date will be the -earliest or latest transaction in your journal: +earliest or latest transaction date in the journal: .PP .TS tab(@); @@ -6141,12 +6180,11 @@ everything before january 1, 2009 T} .TE .PP -A single date with no \[dq]from\[dq] or \[dq]to\[dq] defines both the -start and end date like so: +You can also specify a period by writing a single partial or full date: .PP .TS tab(@); -lw(15.3n) lw(54.7n). +lw(14.5n) lw(55.5n). T{ \f[V]-p \[dq]2009\[dq]\f[R] T}@T{ @@ -6155,16 +6193,16 @@ T} T{ \f[V]-p \[dq]2009/1\[dq]\f[R] T}@T{ -the month of jan; equivalent to \[lq]2009/1/1 to 2009/2/1\[rq] +the month of january 2009; equivalent to \[lq]2009/1/1 to 2009/2/1\[rq] T} T{ \f[V]-p \[dq]2009/1/1\[dq]\f[R] T}@T{ -just that day; equivalent to \[lq]2009/1/1 to 2009/1/2\[rq] +the first day of 2009; equivalent to \[lq]2009/1/1 to 2009/1/2\[rq] T} .TE .PP -Or you can specify a single quarter like so: +or by using the \[dq]Q\[dq] quarter-year syntax (case insensitive): .PP .TS tab(@); @@ -6182,14 +6220,8 @@ T} .TE .SS Period expressions with a report interval .PP -\f[V]-p/--period\f[R]\[aq]s argument can also begin with, or entirely -consist of, a report interval. -This should be separated from the start/end dates (if any) by a space, -or the word \f[V]in\f[R]. -The basic intervals (which can also be written as command line flags) -are \f[V]daily\f[R], \f[V]weekly\f[R], \f[V]monthly\f[R], -\f[V]quarterly\f[R], and \f[V]yearly\f[R]. -Some examples: +A period expression can also begin with a report interval, separated +from the start/end dates (if any) by a space or the word \f[V]in\f[R]: .PP .TS tab(@); @@ -6204,84 +6236,22 @@ T{ \f[V]-p \[dq]quarterly\[dq]\f[R] T} .TE -.PP -As mentioned above, the \f[V]weekly\f[R], \f[V]monthly\f[R], -\f[V]quarterly\f[R] and \f[V]yearly\f[R] intervals require a report -start date that is the first day of a week, month, quarter or year. -And, report start/end dates will be expanded if needed to span a whole -number of intervals. -.PP -For example: -.PP -.TS -tab(@); -lw(25.5n) lw(44.5n). -T{ -\f[V]-p \[dq]weekly from 2009/1/1 to 2009/4/1\[dq]\f[R] -T}@T{ -starts on 2008/12/29, closest preceding Monday -T} -T{ -\f[V]-p \[dq]monthly in 2008/11/25\[dq]\f[R] -T}@T{ -starts on 2018/11/01 -T} -T{ -\f[V]-p \[dq]quarterly from 2009-05-05 to 2009-06-01\[dq]\f[R] -T}@T{ -starts on 2009/04/01, ends on 2009/06/30, which are first and last days -of Q2 2009 -T} -T{ -\f[V]-p \[dq]yearly from 2009-12-29\[dq]\f[R] -T}@T{ -starts on 2009/01/01, first day of 2009 -T} -.TE .SS More complex report intervals .PP -Some more complex kinds of interval are also supported in period -expressions: +Some more complex intervals can be specified within period expressions, +such as: .IP \[bu] 2 -\f[V]biweekly\f[R] +\f[V]biweekly\f[R] (every two weeks) .IP \[bu] 2 \f[V]fortnightly\f[R] .IP \[bu] 2 -\f[V]bimonthly\f[R] +\f[V]bimonthly\f[R] (every two months) .IP \[bu] 2 \f[V]every day|week|month|quarter|year\f[R] .IP \[bu] 2 \f[V]every N days|weeks|months|quarters|years\f[R] .PP -These too will cause report start/end dates to be expanded, if needed, -to span a whole number of intervals. -Examples: -.PP -.TS -tab(@); -lw(26.0n) lw(44.0n). -T{ -\f[V]-p \[dq]bimonthly from 2008\[dq]\f[R] -T}@T{ -periods will have boundaries on 2008/01/01, 2008/03/01, ... -T} -T{ -\f[V]-p \[dq]every 2 weeks\[dq]\f[R] -T}@T{ -starts on closest preceding Monday -T} -T{ -\f[V]-p \[dq]every 5 months from 2009/03\[dq]\f[R] -T}@T{ -periods will have boundaries on 2009/03/01, 2009/08/01, ... -T} -.TE -.SS Intervals with custom start date -.PP -All intervals mentioned above are required to start on their natural -calendar boundaries, but the following intervals can start on any date: -.PP -Weekly on custom day: +Weekly on a custom day: .IP \[bu] 2 \f[V]every Nth day of week\f[R] (\f[V]th\f[R], \f[V]nd\f[R], \f[V]rd\f[R], or \f[V]st\f[R] are all accepted after the number) @@ -6289,13 +6259,13 @@ Weekly on custom day: \f[V]every WEEKDAYNAME\f[R] (full or three-letter english weekday name, case insensitive) .PP -Monthly on custom day: +Monthly on a custom day: .IP \[bu] 2 \f[V]every Nth day [of month]\f[R] .IP \[bu] 2 \f[V]every Nth WEEKDAYNAME [of month]\f[R] .PP -Yearly on custom day: +Yearly on a custom day: .IP \[bu] 2 \f[V]every MM/DD [of year]\f[R] (month number and day of month number) .IP \[bu] 2 @@ -6308,7 +6278,19 @@ Examples: .PP .TS tab(@); -lw(23.9n) lw(46.1n). +lw(26.8n) lw(43.2n). +T{ +\f[V]-p \[dq]bimonthly from 2008\[dq]\f[R] +T}@T{ +T} +T{ +\f[V]-p \[dq]every 2 weeks\[dq]\f[R] +T}@T{ +T} +T{ +\f[V]-p \[dq]every 5 months from 2009/03\[dq]\f[R] +T}@T{ +T} T{ \f[V]-p \[dq]every 2nd day of week\[dq]\f[R] T}@T{ @@ -6363,31 +6345,21 @@ tuesday (N is both (inclusive) start date and (exclusive) end date): $ hledger register checking -p \[dq]every 3rd day of week\[dq] \f[R] .fi -.SS Periods or dates ? +.SS Multiple weekday intervals .PP -Report intervals like the above are most often used with -\f[V]-p|--period\f[R], to divide reports into multiple subperiods - each -generated date marks a subperiod boundary. -Here, the periods between the dates are what\[aq]s important. +This special form is also supported: +.IP \[bu] 2 +\f[V]every WEEKDAYNAME,WEEKDAYNAME,...\f[R] (full or three-letter +english weekday names, case insensitive) .PP -But report intervals can also be used with \f[V]--forecast\f[R] to -generate future transactions, or with \f[V]balance --budget\f[R] to -generate budget goal-setting transactions. -For these, the dates themselves are what matters. -.SS Events on multiple weekdays -.PP -The \f[V]every WEEKDAYNAME\f[R] form has a special variant with multiple -day names, comma-separated. -Eg: \f[V]every mon,thu,sat\f[R]. Also, \f[V]weekday\f[R] and \f[V]weekendday\f[R] are shorthand for -\f[V]mon,tue,wed,thu,fri\f[R] and \f[V]sat,sun\f[R] respectively. +\f[V]mon,tue,wed,thu,fri\f[R] and \f[V]sat,sun\f[R]. .PP -This form is mainly intended for use with \f[V]--forecast\f[R], to -generate periodic transactions on arbitrary days of the week. +This is mainly intended for use with \f[V]--forecast\f[R], to generate +periodic transactions on arbitrary days of the week. It may be less useful with \f[V]-p\f[R], since it divides each week into -subperiods of unequal length. -(Because gaps between periods are not allowed; if you\[aq]d like to -change this, see #1632.) +subperiods of unequal length, which is unusual. +(Related: #1632) .PP Examples: .PP @@ -6659,11 +6631,6 @@ Some queries can also be expressed as command-line options: \f[V]date:2020\f[R] is equivalent to \f[V]-p 2020\f[R], etc. When you mix command options and query arguments, generally the resulting query is their intersection. -.SS Queries and account aliases -.PP -When account names are rewritten with \f[V]--alias\f[R] or -\f[V]alias\f[R], \f[V]acct:\f[R] will match either the old or the new -account name. .SS Queries and valuation .PP When amounts are converted to other commodities in cost or value @@ -6956,14 +6923,16 @@ cost reporting more difficult for PTA tools. .PP Happily, current hledger can read either notation, or convert one to the other when needed, so you can use the one you prefer. +.PP +You can even use cost notation and equivalent conversion postings at the +same time, for clarity. +hledger will ignore the redundancy. +But be sure the cost and conversion posting amounts match, or you\[aq]ll +see a not-so-clear transaction balancing error message. .SS Inferring equity postings from cost .PP With \f[V]--infer-equity\f[R], hledger detects transactions written with -PTA cost notation and adds equity conversion postings to them (and -temporarily permits the coexistence of equity conversion postings and -cost notation, which normally would cause an unbalanced transaction -error). -Eg: +PTA cost notation and adds equity conversion postings to them: .IP .nf \f[C] @@ -6995,9 +6964,7 @@ for sharing with non-PTA-users. .PP The reverse operation is possible using \f[V]--infer-costs\f[R], which detects transactions written with equity conversion postings and adds -PTA cost notation to them (and temporarily permits the coexistence of -equity conversion postings and cost notation). -Eg: +cost notation to them: .IP .nf \f[C] @@ -7048,20 +7015,15 @@ be named \f[V]equity:conversion\f[R], \f[V]equity:trade\f[R], \f[V]equity:trading\f[R] or subaccounts of these) .IP "4." 3 the equity postings\[aq] amounts must exactly match the non-equity -postings\[aq] amounts -.IP "5." 3 -all of the amounts must be explicit, with none missing +postings\[aq] amounts. .PP -Multiple such exchanges can coexist within a single transaction, should -you need that. +Multiple such exchanges can coexist within a single transaction. .PP When inferring cost, the order of postings matters: the cost is added to the first of the non-equity postings involved in the exchange, in the commodity of the last non-equity posting involved in the exchange. -If you don\[aq]t want to write your postings in the required order, the -alternative is not to infer cost; instead, use explicit cost notation, -omitting the equity postings, inferring them later with --infer-equity -if needed. +If you don\[aq]t want to write your postings in the required order, you +can use explicit cost notation instead. .PP --infer-equity and --infer-costs can be used together, if you have a mixture of both notations in your journal. @@ -7184,8 +7146,6 @@ Cost reporting requires adding the --infer-costs flag .SS Conversion with equity postings and explicit cost .PP Here both equity postings and \[at] notation are used together. -hledger will usually complain about this redundancy, but when using the ---infer-costs flag it is accepted. .IP .nf \f[C] @@ -7211,27 +7171,26 @@ Con: .IP \[bu] 2 Most verbose .IP \[bu] 2 -Requires the --infer-costs flag -.IP \[bu] 2 Not compatible with ledger .SS Cost tips .IP \[bu] 2 -Recording the conversion rate explicitly is good because it makes that -clear and helps detect errors. +Recording the cost/conversion rate explicitly is good because it makes +that clear and helps detect errors. .IP \[bu] 2 Recording equity postings is good because it is correct bookkeeping and preserves the accounting equation. .IP \[bu] 2 -Combining these is possible by using the --infer-costs flag (which -requires well-ordered postings). +Combining these is possible. .IP \[bu] 2 When you want to see the cost (or sale proceeds) of things, use -\f[V]-B\f[R] (or \f[V]--cost\f[R]). -If you use equity conversion postings notation, use -\f[V]-B --infer-costs\f[R]. +\f[V]-B\f[R] (short form of \f[V]--cost\f[R]). .IP \[bu] 2 -If you use PTA cost notation, and you want to see a balanced balance -sheet or print correct journal entries, use \f[V]--infer-equity\f[R]. +If you use conversion postings without cost notation, add +\f[V]--infer-costs\f[R] also. +.IP \[bu] 2 +If you use cost notation without conversion postings, and you want to +see a balanced balance sheet or print correct journal entries, use +\f[V]--infer-equity\f[R]. .IP \[bu] 2 Conversion to cost is performed before valuation (described next). .SH Valuation @@ -8035,50 +7994,52 @@ a flag (-D/-W/-M/-Q/-Y) or period expression that activates the report\[aq]s multi-period mode (whether showing one or many subperiods). .SH PART 4: COMMANDS .PP -Here are the built-in commands, with the most often-used in bold: -.PP -\f[B]Data entry:\f[R] +Here are the built-in commands: +.SS DATA ENTRY .PP These data entry commands are the only ones which can modify your journal file. .IP \[bu] 2 -\f[B]add\f[R] - add transactions using guided prompts +add - add transactions using guided prompts .IP \[bu] 2 -\f[B]import\f[R] - add any new transactions from other files (eg csv) -.PP -\f[B]Data management:\f[R] +import - add any new transactions from other files (eg csv) +.SS DATA CREATION +.IP \[bu] 2 +close - generate balance-resetting transactions +.IP \[bu] 2 +rewrite - generate extra postings, similar to print --auto +.SS DATA MANAGEMENT .IP \[bu] 2 check - check for various kinds of issue in the data .IP \[bu] 2 -close (equity) - generate balance-resetting transactions -.IP \[bu] 2 diff - compare account transactions in two journal files +.SS REPORTS, FINANCIAL .IP \[bu] 2 -rewrite - generate extra postings, similar to print --auto -.PP -\f[B]Financial statements:\f[R] +aregister (areg) - show transactions in a particular account .IP \[bu] 2 -\f[B]aregister (areg)\f[R] - show transactions in a particular account -.IP \[bu] 2 -\f[B]balancesheet (bs)\f[R] - show assets, liabilities and net worth +balancesheet (bs) - show assets, liabilities and net worth .IP \[bu] 2 balancesheetequity (bse) - show assets, liabilities and equity .IP \[bu] 2 cashflow (cf) - show changes in liquid assets .IP \[bu] 2 -\f[B]incomestatement (is)\f[R] - show revenues and expenses +incomestatement (is) - show revenues and expenses +.SS REPORTS, VERSATILE +.IP \[bu] 2 +balance (bal) - show balance changes/end balances/budgets in any +accounts +.IP \[bu] 2 +print - show transactions (journal entries) +.IP \[bu] 2 +register (reg) - show postings in one or more accounts & running total .IP \[bu] 2 roi - show return on investments -.PP -\f[B]Miscellaneous reports:\f[R] +.SS REPORTS, BASIC .IP \[bu] 2 accounts - show account names .IP \[bu] 2 activity - show postings-per-interval bar charts .IP \[bu] 2 -\f[B]balance (bal)\f[R] - show balance changes/end balances/budgets in -any accounts -.IP \[bu] 2 codes - show transaction codes .IP \[bu] 2 commodities - show commodity/currency symbols @@ -8087,49 +8048,44 @@ descriptions - show unique transaction descriptions .IP \[bu] 2 files - show input file paths .IP \[bu] 2 -help - show hledger user manuals in several formats -.IP \[bu] 2 notes - show unique note segments of transaction descriptions .IP \[bu] 2 payees - show unique payee segments of transaction descriptions .IP \[bu] 2 prices - show market price records .IP \[bu] 2 -\f[B]print\f[R] - show transactions (journal entries) -.IP \[bu] 2 -\f[B]register (reg)\f[R] - show postings in one or more accounts & -running total -.IP \[bu] 2 stats - show journal statistics .IP \[bu] 2 tags - show tag names .IP \[bu] 2 test - run self tests +.SS HELP +.IP \[bu] 2 +help - show hledger user manuals in several formats .PP +.SS ADD-ONS .PP -And here are some typical add-on commands installed by the -hledger-install script. -If installed, these will also appear in hledger\[aq]s commands list, -with a \f[V]+\f[R] mark: +And here are some typical add-on commands. +Some of these are installed by the hledger-install script. +If installed, they will appear in hledger\[aq]s commands list: .IP \[bu] 2 -\f[B]ui\f[R] - hledger\[aq]s official curses-style TUI +ui - hledger\[aq]s official terminal UI .IP \[bu] 2 -\f[B]web\f[R] - hledger\[aq]s official web UI +web - hledger\[aq]s official web UI .IP \[bu] 2 -iadd - a popular alternative to hledger\[aq]s \f[V]add\f[R] command. +iadd - an alternative to hledger\[aq]s \f[V]add\f[R] command (currently +hard to build) .IP \[bu] 2 interest - generates interest transactions .IP \[bu] 2 -stockquotes - downloads market prices. -\f[I](Alpha quality, needs your help.)\f[R] +stockquotes - downloads market prices +.IP \[bu] 2 +Scripts and add-ons - check-fancyassertions, edit, fifo, git, move, +pijul, plot, and more.. .PP Next, each command is described in detail, in alphabetical order. .SS accounts .PP -accounts -.PD 0 -.P -.PD Show account names. .PP This command lists account names. @@ -8197,10 +8153,6 @@ $ hledger check accounts .fi .SS activity .PP -activity -.PD 0 -.P -.PD Show an ascii barchart of posting counts per interval. .PP The activity command displays an ascii histogram showing transaction @@ -8221,10 +8173,6 @@ $ hledger activity --quarterly .fi .SS add .PP -add -.PD 0 -.P -.PD Prompt for transactions and add them to the journal. Any arguments will be used as default inputs for the first N prompts. .PP @@ -8305,10 +8253,7 @@ On Microsoft Windows, the add command makes sure that no part of the file path ends with a period, as that would cause problems (#1056). .SS aregister .PP -aregister, areg -.PD 0 -.P -.PD +(areg) .PP Show the transactions and running historical balance of a single account, with each transaction displayed as one line. @@ -8398,10 +8343,8 @@ If you use this flag and some of your postings have custom dates, it\[aq]s probably best to assume the running balance is wrong. .SS balance .PP -balance, bal -.PD 0 -.P -.PD +(bal) +.PP Show accounts and their balances. .PP \f[V]balance\f[R] is one of hledger\[aq]s oldest and most versatile @@ -9169,6 +9112,27 @@ Budget performance in 2017/11/01-2017/12/31: \f[R] .fi .PP +It\[aq]s common to limit budgets/budget reports to just expenses +.IP +.nf +\f[C] +hledger bal -M --budget expenses +\f[R] +.fi +.PP +or just revenues and expenses (eg, using account types): +.IP +.nf +\f[C] +hledger bal -M --budget type:rx +\f[R] +.fi +.PP +It\[aq]s also common to limit or convert them to a single currency +(\f[V]cur:COMM\f[R] or \f[V]-X COMM [--infer-market-prices]\f[R]). +If showing multiple currencies, \f[V]--layout bare\f[R] or +\f[V]--layout tall\f[R] can help. +.PP For more examples and notes, see Budgeting. .SS Budget report start date .PP @@ -9330,8 +9294,8 @@ Budget performance in 2019/01: The budget report evaluates periodic transaction rules to generate special \[dq]goal transactions\[dq], which generate the goal amounts for each account in each report subperiod. -When troubleshooting, you can use the print command to show these as -forecasted transactions: +When troubleshooting, you can use \f[V]print --forecast\f[R] to show +these as forecasted transactions: .IP .nf \f[C] @@ -9353,6 +9317,63 @@ regular expression or query). This means you can give your periodic rules descriptions (remember that two spaces are needed), and then select from multiple budgets defined in your journal. +.SS Budget vs forecast +.PP +\f[V]hledger --forecast ...\f[R] and +\f[V]hledger balance --budget ...\f[R] are separate features, though +both of them use the periodic transaction rules defined in the journal, +and both of them generate temporary transactions for reporting purposes +(\[dq]forecast transactions\[dq] and \[dq]budget goal transactions\[dq], +respectively). +You can use both features at the same time if you want. +Here are some differences between them, as of hledger 1.29: +.PP +CLI: +.IP \[bu] 2 +--forecast is a general hledger option, usable with any command +.IP \[bu] 2 +--budget is a \f[V]balance\f[R] command option, usable only with that +command. +.PP +Visibility of generated transactions: +.IP \[bu] 2 +forecast transactions are visible in any report, like ordinary +transactions +.IP \[bu] 2 +budget goal transactions are invisible except for the goal amounts they +produce in --budget reports. +.PP +Periodic transaction rules: +.IP \[bu] 2 +--forecast uses all available periodic transaction rules +.IP \[bu] 2 +--budget uses all periodic rules (\f[V]--budget\f[R]) or a selected +subset (\f[V]--budget=DESCPAT\f[R]) +.PP +Period of generated transactions: +.IP \[bu] 2 +--forecast generates forecast transactions +.RS 2 +.IP \[bu] 2 +from after the last regular transaction to the end of the report period +(\f[V]--forecast\f[R]) +.IP \[bu] 2 +or, during a specified period (\f[V]--forecast=PERIODEXPR\f[R]) +.IP \[bu] 2 +possibly further restricted by a period specified in the periodic +transaction rule +.IP \[bu] 2 +and always restricted within the bounds of the report period +.RE +.IP \[bu] 2 +--budget generates budget goal transactions +.RS 2 +.IP \[bu] 2 +throughout the report period +.IP \[bu] 2 +possibly restricted by a period specified in the periodic transaction +rule. +.RE .SS Data layout .PP The \f[V]--layout\f[R] option affects how balance reports show @@ -9641,10 +9662,8 @@ Show monthly change in market value of investment assets. Show top gainers [or losers] last week .SS balancesheet .PP -balancesheet, bs -.PD 0 -.P -.PD +(bs) +.PP This command displays a balance sheet, showing historical ending balances of asset and liability accounts. (To see equity as well, use the balancesheetequity command.) @@ -9694,10 +9713,8 @@ options The output formats supported are \f[V]txt\f[R], \f[V]csv\f[R], \f[V]html\f[R], and (experimental) \f[V]json\f[R]. .SS balancesheetequity .PP -balancesheetequity, bse -.PD 0 -.P -.PD +(bse) +.PP This command displays a balance sheet, showing historical ending balances of asset, liability and equity accounts. Amounts are shown with normal positive sign, as in conventional @@ -9752,10 +9769,8 @@ options The output formats supported are \f[V]txt\f[R], \f[V]csv\f[R], \f[V]html\f[R], and (experimental) \f[V]json\f[R]. .SS cashflow .PP -cashflow, cf -.PD 0 -.P -.PD +(cf) +.PP This command displays a cashflow statement, showing the inflows and outflows affecting \[dq]cash\[dq] (ie, liquid, easily convertible) assets. @@ -9811,10 +9826,6 @@ options The output formats supported are \f[V]txt\f[R], \f[V]csv\f[R], \f[V]html\f[R], and (experimental) \f[V]json\f[R]. .SS check .PP -check -.PD 0 -.P -.PD Check for various kinds of errors in your data. .PP hledger provides a number of built-in error checks to help prevent @@ -9883,6 +9894,8 @@ file \f[B]recentassertions\f[R] - all accounts with balance assertions have a balance assertion no more than 7 days before their latest posting .IP \[bu] 2 +\f[B]tags\f[R] - all tags used by transactions have been declared +.IP \[bu] 2 \f[B]uniqueleafnames\f[R] - all account leaf names are unique .SS Custom checks .PP @@ -9913,301 +9926,230 @@ use the manual-review-and-mark-cleared phase as a reminder to check the latest assertions against real-world balances. .SS close .PP -close, equity -.PD 0 -.P -.PD -Prints a sample \[dq]closing\[dq] transaction bringing specified account -balances to zero, and an inverse \[dq]opening\[dq] transaction restoring -the same account balances. +\f[V]close [--retain | --migrate | --open] [QUERY]\f[R] .PP -If like most people you split your journal files by time, eg by year: at -the end of the year you can use this command to \[dq]close out\[dq] your -asset and liability (and perhaps equity) balances in the old file, and -reinitialise them in the new file. -This helps ensure that report balances remain correct whether you are -including old files or not. -(Because all closing/opening transactions except the very first will -cancel out - see example below.) +By default: prints a transaction that zeroes out (\[dq]closes\[dq]) all +accounts, transferring their balances to an equity account. +Query arguments can be added to override the accounts selection. +Three other modes are supported: .PP -Some people also use this command to close out revenue and expense -balances at the end of an accounting period. -This properly records the period\[aq]s profit/loss as \[dq]retained -earnings\[dq] (part of equity), and allows the accounting equation -(A-L=E) to balance, which you could then check by the bse report\[aq]s -zero total. +\f[V]--retain\f[R]: prints a transaction closing revenue and expense +balances. +This is traditionally done by businesses at the end of each accounting +period; it is less necessary in personal and computer-based accounting, +but it can help balance the accounting equation A=L+E. .PP -You can print just the closing transaction by using the -\f[V]--close\f[R] flag, or just the opening transaction with the -\f[V]--open\f[R] flag. +\f[V]--migrate\f[R]: prints a transaction to close asset, liability and +most equity balances, and another transaction to re-open them. +This can be useful when starting a new file (for performance or data +protection). +Adding the closing transaction to the old file allows old and new files +to be combined. .PP -Their descriptions are \f[V]closing balances\f[R] and -\f[V]opening balances\f[R] by default; you can customise these with the -\f[V]--close-desc\f[R] and \f[V]--open-desc\f[R] options. +\f[V]--open\f[R]: as above, but prints just the opening transaction. +This can be useful for starting a new file, leaving the old file +unchanged. +Similar to Ledger\[aq]s equity command. .PP -Just one balancing equity posting is used by default, with the amount -left implicit. -The default account name is \f[V]equity:opening/closing balances\f[R]. -You can customise the account name(s) with \f[V]--close-acct\f[R] and -\f[V]--open-acct\f[R]. -(If you specify only one of these, it will be used for both.) +You can change the equity account name with \f[V]--close-acct ACCT\f[R]. +It defaults to \f[V]equity:retained earnings\f[R] with +\f[V]--retain\f[R], or \f[V]equity:opening/closing balances\f[R] +otherwise. .PP -With \f[V]--x/--explicit\f[R], the equity posting\[aq]s amount will be -shown explicitly, and if it involves multiple commodities, there will be -a separate equity posting for each commodity (as in the print command). +You can change the transaction description(s) with +\f[V]--close-desc \[aq]DESC\[aq]\f[R] and +\f[V]--open-desc \[aq]DESC\[aq]\f[R]. +It defaults to \f[V]retain earnings\f[R] with \f[V]--retain\f[R], or +\f[V]closing balances\f[R] and \f[V]opening balances\f[R] otherwise. +.PP +Just one posting to the equity account will be used by default, with an +implicit amount. +.PP +With \f[V]--x/--explicit\f[R] the amount will be shown explicitly, and +if it involves multiple commodities, a separate posting will be +generated for each commodity. .PP With \f[V]--interleaved\f[R], each equity posting is shown next to the -posting it balances (good for troubleshooting). -.SS close and costs +corresponding source/destination posting. .PP -Costs are ignored (and discarded) by closing/opening transactions, by -default. -With \f[V]--show-costs\f[R], they are preserved; there will be a -separate equity posting for each cost in each commodity. -This means \f[V]balance -B\f[R] reports will look the same after the -transition. -Note if you have many foreign currency or investment transactions, this -will generate very large journal entries. -.SS close date +The default closing date is yesterday or the journal\[aq]s end date, +whichever is later. +You can change this by specifying a report end date; the last day of the +report period will be the closing date. +Eg \f[V]-e 2022\f[R] means \[dq]close on 2022-12-31\[dq]. .PP The default closing date is yesterday, or the journal\[aq]s end date, whichever is later. +You can change this by specifying a report end date; (The report start +date does not matter.) +The last day of the report period will be the closing date; eg +\f[V]-e 2022\f[R] means \[dq]close on 2022-12-31\[dq]. +The opening date is always the day after the closing date. +.SS close and costs .PP -Unless you are running \f[V]close\f[R] on exactly the first day of the -new period, you\[aq]ll want to override the closing date. -This is done by specifying a report end date, where \[dq]last day of the -report period\[dq] will be the closing date. -The opening date is always the following day. -So to close on (end of) 2020-12-31 and open on (start of) 2021-01-01, -any of these will work: +With \f[V]--show-costs\f[R], any amount costs are shown, with separate +postings for each cost. +(This currently the best way to view investment assets, showing lots and +cost bases.) +If you have many currency conversion or investment transactions, it can +generate very large journal entries. +.SS close and balance assertions .PP -.TS -tab(@); -lw(14.9n) lw(55.1n). -T{ -end date argument -T}@T{ -explanation -T} -_ -T{ -\f[V]-e 2021-01-01\f[R] -T}@T{ -end dates are exclusive -T} -T{ -\f[V]-e 2021\f[R] -T}@T{ -equivalent, per smart dates -T} -T{ -\f[V]-p 2020\f[R] -T}@T{ -equivalent, the period\[aq]s begin date is ignored -T} -T{ -\f[V]date:2020\f[R] -T}@T{ -equivalent query -T} -.TE -.SS Example: close asset/liability accounts for file transition +Balance assertions will be generated, verifying that the accounts have +been reset to zero (and then restored to their previous balances, if +there is an opening transaction). .PP -Carrying asset/liability balances from 2020.journal into a new file for -2021: +These provide useful error checking, but you can ignore them temporarily +with \f[V]-I\f[R], or remove them if you prefer. +.PP +You probably should avoid filtering transactions by status or realness +(\f[V]-C\f[R], \f[V]-R\f[R], \f[V]status:\f[R]), or generating postings +(\f[V]--auto\f[R]), with this command, since the balance assertions +would depend on these. +.PP +Note custom posting dates spanning the file boundary will disrupt the +balance assertions: .IP .nf \f[C] -$ hledger close -f 2020.journal -p 2020 assets liabilities -# copy/paste the closing transaction to the end of 2020.journal -# copy/paste the opening transaction to the start of 2021.journal +2023-12-30 a purchase made in december, cleared in january + expenses:food 5 + assets:bank:checking -5 ; date: 2023-01-02 \f[R] .fi .PP -Or: +To solve that you can transfer the money to and from a temporary +account, in effect splitting the multi-day transaction into two +single-day transactions: .IP .nf \f[C] -$ hledger close -f 2020.journal -p 2020 assets liabilities --open >> 2021.journal # add 2021\[aq]s first transaction -$ hledger close -f 2020.journal -p 2020 assets liabilities --close >> 2020.journal # add 2020\[aq]s last transaction +; in 2022.journal: +2022-12-30 a purchase made in december, cleared in january + expenses:food 5 + equity:pending -5 + +; in 2023.journal: +2023-01-02 last year\[aq]s transaction cleared + equity:pending 5 = 0 + assets:bank:checking -5 +\f[R] +.fi +.SS Example: retain earnings +.PP +Record 2022\[aq]s revenues/expenses as retained earnings on 2022-12-31, +appending the generated transaction to the journal: +.IP +.nf +\f[C] +$ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal \f[R] .fi .PP -Now, +Now 2022\[aq]s income statement will show only zeroes. +To see it again, exclude the retain transaction. +Eg: .IP .nf \f[C] -$ hledger bs -f 2021.journal # just new file - balances correct -$ hledger bs -f 2020.journal -f 2021.journal # old and new files - balances correct -$ hledger bs -f 2020.journal # just old files - balances are zero ? - # (exclude final closing txn, see below) +$ hledger -f 2022.journal is not:desc:\[aq]retain earnings\[aq] \f[R] .fi -.SS Hiding opening/closing transactions +.SS Example: migrate balances to a new file .PP -Although the closing/opening transactions cancel out, they will be -visible in reports like \f[V]print\f[R] and \f[V]register\f[R], creating -some visual clutter. -You can exclude them all with a query, like: +Close assets/liabilities/equity on 2022-12-31 and re-open them on +2023-01-01: .IP .nf \f[C] -$ hledger print not:desc:\[aq]opening|closing\[aq] # less typing -$ hledger print not:\[aq]equity:opening/closing balances\[aq] # more precise +$ hledger close --migrate -f 2022.journal -p 2022 +# copy/paste the closing transaction to the end of 2022.journal +# copy/paste the opening transaction to the start of 2023.journal \f[R] .fi .PP -But when reporting on multiple files, this can get a bit tricky; you may -need to keep the earliest opening balances, for a historical register -report; or you may need to suppress a closing transaction, to see -year-end balances. -If you find yourself needing more precise queries, here\[aq]s one -solution: add more easily-matched tags to opening/closing transactions, -like this: +Now 2022\[aq]s balance sheet will show only zeroes, indicating a +balanced accounting equation. +(Unless you are using \[at]/\[at]\[at] notation - in that case, try +adding --infer-equity.) +To see it again, exclude the closing transaction. +Eg: .IP .nf \f[C] -; 2019.journal -2019-01-01 opening balances ; earliest opening txn, no tag here -\&... -2019-12-31 closing balances ; clopen:2020 -\&... -\f[R] -.fi -.IP -.nf -\f[C] -; 2020.journal -2020-01-01 opening balances ; clopen:2020 -\&... -2020-12-31 closing balances ; clopen:2021 -\&... +$ hledger -f 2022.journal bs not:desc:\[aq]closing balances\[aq] \f[R] .fi +.SS Example: excluding closing/opening transactions +.PP +When combining many files for multi-year reports, the closing/opening +transactions cause some noise in reports like \f[V]print\f[R] and +\f[V]register\f[R]. +You can exclude them as shown above, but \f[V]not:desc:...\f[R] could be +fragile, and also you will need to avoid excluding the very first +opening transaction, which can be awkward. +Here is a way to do it, using tags: add \f[V]clopen:\f[R] tags to all +opening/closing balances transactions except the first, like this: .IP .nf \f[C] ; 2021.journal -2021-01-01 opening balances ; clopen:2021 +2021-06-01 first opening balances +\&... +2021-12-31 closing balances ; clopen:2022 +\&... +\f[R] +.fi +.IP +.nf +\f[C] +; 2022.journal +2022-01-01 opening balances ; clopen:2022 +\&... +2022-12-31 closing balances ; clopen:2023 +\&... +\f[R] +.fi +.IP +.nf +\f[C] +; 2023.journal +2023-01-01 opening balances ; clopen:2023 \&... \f[R] .fi .PP -Now with +Now, assuming a combined journal like: .IP .nf \f[C] ; all.journal -include 2019.journal -include 2020.journal include 2021.journal +include 2022.journal +include 2023.journal \f[R] .fi .PP -you could do eg: +The \f[V]clopen:\f[R] tag can exclude all but the first opening +transaction. +To show a clean multi-year checking register: .IP .nf \f[C] -$ hledger -f all.journal reg -H checking not:tag:clopen - # all years checking register, hiding non-essential opening/closing txns - -$ hledger -f all.journal bs -p 2020 not:tag:clopen=2020 - # 2020 year end balances, suppressing 2020 closing txn -\f[R] -.fi -.SS close and balance assertions -.PP -The closing and opening transactions will include balance assertions, -verifying that the accounts have first been reset to zero and then -restored to their previous balance. -These provide valuable error checking, alerting you when things get out -of line, but you can ignore them temporarily with \f[V]-I\f[R] or just -remove them if you prefer. -.PP -You probably shouldn\[aq]t use status or realness filters (like -C or -R -or \f[V]status:\f[R]) with \f[V]close\f[R], or the generated balance -assertions will depend on these flags. -Likewise, if you run this command with \f[V]--auto\f[R], the balance -assertions would probably always require \f[V]--auto\f[R]. -.PP -Multi-day transactions (where some postings have a different date) break -the balance assertions, because the money is temporarily -\[dq]invisible\[dq] while in transit: -.IP -.nf -\f[C] -2020/12/30 a purchase made in december, cleared in the next year - expenses:food 5 - assets:bank:checking -5 ; date: 2021/1/2 +$ hledger -f all.journal areg checking not:tag:clopen \f[R] .fi .PP -To fix the assertions, you can add a temporary account to track such -in-transit money (splitting the multi-day transaction into two -single-day transactions): +And the year values allow more precision. +To show 2022\[aq]s year-end balance sheet: .IP .nf \f[C] -; in 2020.journal: -2020/12/30 a purchase made in december, cleared in the next year - expenses:food 5 - liabilities:pending - -; in 2021.journal: -2021/1/2 clearance of last year\[aq]s pending transactions - liabilities:pending 5 = 0 - assets:bank:checking -\f[R] -.fi -.SS Example: close revenue/expense accounts to retained earnings -.PP -For this, use \f[V]--close\f[R] to suppress the opening transaction, as -it\[aq]s not needed. -Also you\[aq]ll want to change the equity account name to your -equivalent of \[dq]equity:retained earnings\[dq]. -.PP -Closing 2021\[aq]s first quarter revenues/expenses: -.IP -.nf -\f[C] -$ hledger close -f 2021.journal --close revenues expenses -p 2021Q1 \[rs] - --close-acct=\[aq]equity:retained earnings\[aq] >> 2021.journal -\f[R] -.fi -.PP -The same, using the default journal and current year: -.IP -.nf -\f[C] -$ hledger close --close revenues expenses -p Q1 \[rs] - --close-acct=\[aq]equity:retained earnings\[aq] >> $LEDGER_FILE -\f[R] -.fi -.PP -Now, the first quarter\[aq]s balance sheet should show a zero (unless -you are using \[at]/\[at]\[at] notation without equity postings): -.IP -.nf -\f[C] -$ hledger bse -p Q1 -\f[R] -.fi -.PP -And we must suppress the closing transaction to see the first -quarter\[aq]s income statement (using the description; -\f[V]not:\[aq]retained earnings\[aq]\f[R] won\[aq]t work here): -.IP -.nf -\f[C] -$ hledger is -p Q1 not:desc:\[aq]closing balances\[aq] +$ hledger -f all.journal bs -e2023 not:tag:clopen=2023 \f[R] .fi .SS codes .PP -codes -.PD 0 -.P -.PD List the codes seen in transactions, in the order parsed. .PP This command prints the value of each transaction\[aq]s code field, in @@ -10265,17 +10207,9 @@ $ hledger codes -E .fi .SS commodities .PP -commodities -.PD 0 -.P -.PD List all commodity/currency symbols used or declared in the journal. .SS descriptions .PP -descriptions -.PD 0 -.P -.PD List the unique descriptions that appear in transactions. .PP This command lists the unique descriptions that appear in transactions, @@ -10294,10 +10228,6 @@ Person A .fi .SS diff .PP -diff -.PD 0 -.P -.PD Compares a particular account\[aq]s transactions in two input files. It shows any transactions to this account which are in one file but not in the other. @@ -10331,19 +10261,11 @@ These transactions are in the second file only: .fi .SS files .PP -files -.PD 0 -.P -.PD List all files included in the journal. With a REGEX argument, only file names matching the regular expression (case sensitive) are shown. .SS help .PP -help -.PD 0 -.P -.PD Show the hledger user manual in the terminal, with \f[V]info\f[R], \f[V]man\f[R], or a pager. With a TOPIC argument, open it at that topic if possible. @@ -10373,10 +10295,6 @@ $ hledger help journal # show the journal topic in the hledger manual .fi .SS import .PP -import -.PD 0 -.P -.PD Read new transactions added to each FILE since last run, and add them to the journal. Or with --dry-run, just print the transactions that would be added. @@ -10465,6 +10383,13 @@ or (live updating): $ ls bank.csv* | entr bash -c \[aq]echo ====; hledger import --dry bank.csv | hledger -f- -I print unknown\[aq] \f[R] .fi +.PP +Note: when importing from multiple files at once, it\[aq]s currently +possible for some .latest files to be updated successfully, while the +actual import fails because of a problem in one of the files, leaving +them out of sync (and causing some transactions to be missed). +To prevent this, do a --dry-run first and fix any problems before the +real import. .SS Importing balance assignments .PP Entries added by import will have their posting amounts made explicit @@ -10491,10 +10416,8 @@ Imported amounts will be formatted according to the canonical commodity styles (declared or inferred) in the main journal file. .SS incomestatement .PP -incomestatement, is -.PD 0 -.P -.PD +(is) +.PP This command displays an income statement, showing revenues and expenses during one or more periods. Amounts are shown with normal positive sign, as in conventional @@ -10546,10 +10469,6 @@ options The output formats supported are \f[V]txt\f[R], \f[V]csv\f[R], \f[V]html\f[R], and (experimental) \f[V]json\f[R]. .SS notes .PP -notes -.PD 0 -.P -.PD List the unique notes that appear in transactions. .PP This command lists the unique notes that appear in transactions, in @@ -10569,10 +10488,6 @@ Snacks .fi .SS payees .PP -payees -.PD 0 -.P -.PD List the unique payee/payer names that appear in transactions. .PP This command lists unique payee/payer names which have been declared @@ -10597,10 +10512,6 @@ Person A .fi .SS prices .PP -prices -.PD 0 -.P -.PD Print market price directives from the journal. With --infer-market-prices, generate additional market prices from costs. @@ -10610,10 +10521,6 @@ Prices can be filtered by a query. Price amounts are displayed with their full precision. .SS print .PP -print -.PD 0 -.P -.PD Show transaction journal entries, sorted by date. .PP The print command displays full journal entries (transactions) from the @@ -10757,10 +10664,8 @@ The numeric amount is repeated in either the \[dq]credit\[dq] or negative amounts under credit and zero or greater amounts under debit.) .SS register .PP -register, reg -.PD 0 -.P -.PD +(reg) +.PP Show postings and their running total. .PP The register command displays matched postings, across all accounts, in @@ -10928,10 +10833,6 @@ options The output formats supported are \f[V]txt\f[R], \f[V]csv\f[R], and (experimental) \f[V]json\f[R]. .SS rewrite .PP -rewrite -.PD 0 -.P -.PD Print all transactions, rewriting the postings of matched transactions. For now the only rewrite available is adding new postings, like print --auto. @@ -11100,10 +11001,6 @@ rewrite applies rules specified on command line or in the journal. print --auto applies rules specified in the journal. .SS roi .PP -roi -.PD 0 -.P -.PD Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on your investments. .PP @@ -11305,10 +11202,6 @@ Examples of computing IRR and TWR and discussion of the limitations of both metrics .SS stats .PP -stats -.PD 0 -.P -.PD Show journal and performance statistics. .PP The stats command displays summary information for the whole journal, or @@ -11349,10 +11242,6 @@ This command supports the -o/--output-file option (but not -O/--output-format selection). .SS tags .PP -tags -.PD 0 -.P -.PD List the tags used in the journal, or their values. .PP This command lists the tag names used in the journal, whether on @@ -11379,10 +11268,6 @@ also acquire tags from their account and transaction, transactions also acquire tags from their postings. .SS test .PP -test -.PD 0 -.P -.PD Run built-in unit tests. .PP This command runs the unit tests built in to hledger and hledger-lib, diff --git a/hledger/hledger.info b/hledger/hledger.info index 9c307ed56..71a2ec353 100644 --- a/hledger/hledger.info +++ b/hledger/hledger.info @@ -496,7 +496,7 @@ hledger uses regular expressions in a number of places: • query terms, on the command line and in the hledger-web search form: ‘REGEX’, ‘desc:REGEX’, ‘cur:REGEX’, ‘tag:...=REGEX’ • CSV rules conditional blocks: ‘if REGEX ...’ - • account alias directives and options: ‘alias /REGEX/ = + • account alias directive and ‘--alias’ option: ‘alias /REGEX/ = REPLACEMENT’, ‘--alias /REGEX/=REPLACEMENT’ hledger’s regular expressions come from the regex-tdfa library. If @@ -793,7 +793,7 @@ terminal. Here are those commands and the formats currently supported: - txt csv html json sql ----------------------------------------------------------------------------- -aregister Y Y Y +aregister Y Y Y Y balance Y _1_ Y _1_ Y _1,2_ Y balancesheet Y _1_ Y _1_ Y _1_ Y balancesheetequity Y _1_ Y _1_ Y _1_ Y @@ -1088,13 +1088,14 @@ cheatsheet/mini-tutorial, or you can skip ahead to About journal format. * Posting comments:: * Tags:: * Directives:: -* Accounts:: -* Account aliases:: -* Commodities:: -* Decimal mark:: -* Include files:: -* Market prices:: -* Payees:: +* account directive:: +* alias directive:: +* commodity directive:: +* decimal-mark directive:: +* include directive:: +* P directive:: +* payee directive:: +* tag directive:: * Periodic transactions:: * Other syntax:: @@ -1165,14 +1166,7 @@ P 2022-01-01 AAAA $1.40 expenses:tax:us:2021 $500 ; plus means added to this account (debit) ; revenue/expense categories are also "accounts" -2022-01-01 Whole Foods | payee name and description can be separated by a pipe char - ; Transaction or posting comments can contain searchable tags, - ; written NAME: or NAME:VALUE (value ends at comma or end of line). - ; Here's tag1:with a value, and an empty tag2: - ; A few tags have special meaning. A "date:" tag on a posting adjusts its date. - assets:checking $-50 ; date:2022-01-03, checking cleared two days later - expenses:food - +Kv 2022-01-01 ; The description is optional. ; Any currency/commodity symbols are allowed, on either side. assets:cash:wallet GBP -10 @@ -1315,9 +1309,9 @@ File: hledger.info, Node: Simple dates, Next: Posting dates, Up: Dates 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 -current 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’. +current transaction, the default year set with a ‘Y’ 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 dates documented in the hledger manual.) @@ -2144,7 +2138,7 @@ override a tag’s value or remove a tag.) match by tag value with a ‘tag:NAMEREGEX=VALUEREGEX’ query.  -File: hledger.info, Node: Directives, Next: Accounts, Prev: Tags, Up: Journal +File: hledger.info, Node: Directives, Next: account directive, Prev: Tags, Up: Journal 10.17 Directives ================ @@ -2275,10 +2269,10 @@ files. directives do not affect parent or sibling files (see below).  -File: hledger.info, Node: Accounts, Next: Account aliases, Prev: Directives, Up: Journal +File: hledger.info, Node: account directive, Next: alias directive, Prev: Directives, Up: Journal -10.18 Accounts -============== +10.18 ‘account’ directive +========================= ‘account’ directives can be used to declare accounts (ie, the places that amounts are transferred from and to). Though not required, these @@ -2318,7 +2312,7 @@ account (assets:bank:checking) * Account types::  -File: hledger.info, Node: Account comments, Next: Account subdirectives, Up: Accounts +File: hledger.info, Node: Account comments, Next: Account subdirectives, Up: account directive 10.18.1 Account comments ------------------------ @@ -2336,7 +2330,7 @@ account assets:bank:checking ; same-line comment, at least 2 spaces before th ; some tags - type:A, acctnum:12345  -File: hledger.info, Node: Account subdirectives, Next: Account error checking, Prev: Account comments, Up: Accounts +File: hledger.info, Node: Account subdirectives, Next: Account error checking, Prev: Account comments, Up: account directive 10.18.2 Account subdirectives ----------------------------- @@ -2348,7 +2342,7 @@ account assets:bank:checking format subdirective is ignored  -File: hledger.info, Node: Account error checking, Next: Account display order, Prev: Account subdirectives, Up: Accounts +File: hledger.info, Node: Account error checking, Next: Account display order, Prev: Account subdirectives, Up: account directive 10.18.3 Account error checking ------------------------------ @@ -2376,7 +2370,7 @@ been declared by an account directive. Some notes: with a wildcard; every account posted to must be declared.  -File: hledger.info, Node: Account display order, Next: Account types, Prev: Account error checking, Up: Accounts +File: hledger.info, Node: Account display order, Next: Account types, Prev: Account error checking, Up: account directive 10.18.4 Account display order ----------------------------- @@ -2420,7 +2414,7 @@ means: between ‘a:b’ and ‘a:c’).  -File: hledger.info, Node: Account types, Prev: Account display order, Up: Accounts +File: hledger.info, Node: Account types, Prev: Account display order, Up: account directive 10.18.5 Account types --------------------- @@ -2470,8 +2464,7 @@ account equity:conversion ; type: V • The rules for inferring types from account names are as follows. These are just a convenience that sometimes help new users get going; if they don’t work for you, just ignore them and declare - your account types. See also Regular expressions. Note the Cash - regexp changed in hledger 1.24.99.2. + your account types. See also Regular expressions. If account's name contains this (CI) regular expression: | its type is: --------------------------------------------------------------------|------------- @@ -2507,10 +2500,10 @@ account equity:conversion ; type: V $ hledger accounts --types [ACCTPAT] [-DEPTH] [type:TYPECODES]  -File: hledger.info, Node: Account aliases, Next: Commodities, Prev: Accounts, Up: Journal +File: hledger.info, Node: alias directive, Next: commodity directive, Prev: account directive, Up: Journal -10.19 Account aliases -===================== +10.19 ‘alias’ directive +======================= You can define account alias rules which rewrite your account names, or parts of them, before generating reports. This can be useful for: @@ -2539,12 +2532,12 @@ more on this below. * Regex aliases:: * Combining aliases:: * Aliases and multiple files:: -* end aliases:: +* end aliases directive:: * Aliases can generate bad account names:: * Aliases and account types::  -File: hledger.info, Node: Basic aliases, Next: Regex aliases, Up: Account aliases +File: hledger.info, Node: Basic aliases, Next: Regex aliases, Up: alias directive 10.19.1 Basic aliases --------------------- @@ -2568,7 +2561,7 @@ 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"  -File: hledger.info, Node: Regex aliases, Next: Combining aliases, Prev: Basic aliases, Up: Account aliases +File: hledger.info, Node: Regex aliases, Next: Combining aliases, Prev: Basic aliases, Up: alias directive 10.19.2 Regex aliases --------------------- @@ -2602,7 +2595,7 @@ alias /^(.+):bank:([^:]+):(.*)/ = \1:\2 \3 of option argument), so it can contain trailing whitespace.  -File: hledger.info, Node: Combining aliases, Next: Aliases and multiple files, Prev: Regex aliases, Up: Account aliases +File: hledger.info, Node: Combining aliases, Next: Aliases and multiple files, Prev: Regex aliases, Up: alias directive 10.19.3 Combining aliases ------------------------- @@ -2639,7 +2632,7 @@ independent of which files are being read and in which order. which aliases are being applied when.  -File: hledger.info, Node: Aliases and multiple files, Next: end aliases, Prev: Combining aliases, Up: Account aliases +File: hledger.info, Node: Aliases and multiple files, Next: end aliases directive, Prev: Combining aliases, Up: alias directive 10.19.4 Aliases and multiple files ---------------------------------- @@ -2671,10 +2664,10 @@ alias bar=Bar include c.journal ; also affected  -File: hledger.info, Node: end aliases, Next: Aliases can generate bad account names, Prev: Aliases and multiple files, Up: Account aliases +File: hledger.info, Node: end aliases directive, Next: Aliases can generate bad account names, Prev: Aliases and multiple files, Up: alias directive -10.19.5 ‘end aliases’ ---------------------- +10.19.5 ‘end aliases’ directive +------------------------------- You can clear (forget) all currently defined aliases (seen in the journal so far, or defined on the command line) with this directive: @@ -2682,7 +2675,7 @@ journal so far, or defined on the command line) with this directive: end aliases  -File: hledger.info, Node: Aliases can generate bad account names, Next: Aliases and account types, Prev: end aliases, Up: Account aliases +File: hledger.info, Node: Aliases can generate bad account names, Next: Aliases and account types, Prev: end aliases directive, Up: alias directive 10.19.6 Aliases can generate bad account names ---------------------------------------------- @@ -2713,7 +2706,7 @@ $ hledger print --alias old="new USD" | hledger -f- print other  -File: hledger.info, Node: Aliases and account types, Prev: Aliases can generate bad account names, Up: Account aliases +File: hledger.info, Node: Aliases and account types, Prev: Aliases can generate bad account names, Up: alias directive 10.19.7 Aliases and account types --------------------------------- @@ -2737,10 +2730,10 @@ command, eg something like: $ hledger accounts --alias assets=bassetts type:a  -File: hledger.info, Node: Commodities, Next: Decimal mark, Prev: Account aliases, Up: Journal +File: hledger.info, Node: commodity directive, Next: decimal-mark directive, Prev: alias directive, Up: Journal -10.20 Commodities -================= +10.20 ‘commodity’ directive +=========================== You can use ‘commodity’ directives to declare your commodities. In fact the ‘commodity’ directive performs several functions at once: @@ -2815,7 +2808,7 @@ style can still be overridden by supplying a command line option. * Commodity error checking::  -File: hledger.info, Node: Commodity error checking, Up: Commodities +File: hledger.info, Node: Commodity error checking, Up: commodity directive 10.20.1 Commodity error checking -------------------------------- @@ -2831,10 +2824,10 @@ with a directive. This is one exception for convenience: zero amounts are always allowed to have no commodity symbol.  -File: hledger.info, Node: Decimal mark, Next: Include files, Prev: Commodities, Up: Journal +File: hledger.info, Node: decimal-mark directive, Next: include directive, Prev: commodity directive, Up: Journal -10.21 Decimal mark -================== +10.21 ‘decimal-mark’ directive +============================== You can use a ‘decimal-mark’ directive - usually one per file, at the top of the file - to declare which character represents a decimal mark @@ -2851,10 +2844,10 @@ recommend it, especially if the file contains digit group marks (eg thousands separators).  -File: hledger.info, Node: Include files, Next: Market prices, Prev: Decimal mark, Up: Journal +File: hledger.info, Node: include directive, Next: P directive, Prev: decimal-mark directive, Up: Journal -10.22 Include files -=================== +10.22 ‘include’ directive +========================= You can pull in the content of additional files by writing an include directive, like this: @@ -2882,15 +2875,16 @@ overriding the file extension (as described in hledger.1 -> Input files): ‘include timedot:~/notes/2020*.md’.  -File: hledger.info, Node: Market prices, Next: Payees, Prev: Include files, Up: Journal +File: hledger.info, Node: P directive, Next: payee directive, Prev: include directive, Up: Journal -10.23 Market prices +10.23 ‘P’ directive =================== The ‘P’ directive declares a market price, which is a conversion rate -between two commodities on a certain date. These are often obtained -from a stock exchange, cryptocurrency exchange, or the foreign exchange -market. +between two commodities on a certain date. This allows value reports to +convert amounts of one commodity to their value in another, on or after +that date. These prices are often obtained from a stock exchange, +cryptocurrency exchange, the or foreign exchange market. The format is: @@ -2911,14 +2905,16 @@ P 2010-01-01 € $1.40 amount values in another commodity. See Valuation.  -File: hledger.info, Node: Payees, Next: Periodic transactions, Prev: Market prices, Up: Journal +File: hledger.info, Node: payee directive, Next: tag directive, Prev: P directive, Up: Journal -10.24 Payees -============ +10.24 ‘payee’ directive +======================= -The ‘payee’ directive can be used to declare a limited set of payees -which may appear in transaction descriptions. The "payees" check will -report an error if any transaction refers to a payee that has not been +‘payee PAYEE NAME’ + + This directive can be used to declare a limited set of payees which +may appear in transaction descriptions. The "payees" check will report +an error if any transaction refers to a payee that has not been declared. Eg: payee Whole Foods @@ -2926,14 +2922,34 @@ payee Whole Foods Any indented subdirectives are currently ignored.  -File: hledger.info, Node: Periodic transactions, Next: Other syntax, Prev: Payees, Up: Journal +File: hledger.info, Node: tag directive, Next: Periodic transactions, Prev: payee directive, Up: Journal -10.25 Periodic transactions +10.25 ‘tag’ directive +===================== + +‘tag TAGNAME’ + + This directive can be used to declare a limited set of tag names +allowed in tags. TAGNAME should be a valid tag name (no spaces). Eg: + +tag item-id + + Any indented subdirectives are currently ignored. + + The "tags" check will report an error if any undeclared tag name is +used. It is quite easy to accidentally create a tag through normal use +of colons in comments(#comments]; if you want to prevent this, you can +declare and check your tags . + + +File: hledger.info, Node: Periodic transactions, Next: Other syntax, Prev: tag directive, Up: Journal + +10.26 Periodic transactions =========================== -Periodic transaction rules describe transactions that recur. They allow -hledger to generate temporary future transactions (visible only in -reports) to help with forecasting or budgeting. +The ‘~’ directive declares recurring transactions. Such directives +allow hledger to generate temporary future transactions (visible in +reports, not in the journal file) to help with forecasting or budgeting. Periodic transactions can be a little tricky, so before you use them, read this whole section, or at least these tips: @@ -2970,25 +2986,32 @@ read this whole section, or at least these tips:  File: hledger.info, Node: Periodic rule syntax, Next: Periodic rules and relative dates, Up: Periodic transactions -10.25.1 Periodic rule syntax +10.26.1 Periodic rule syntax ---------------------------- A periodic transaction rule looks like a normal journal entry, with the date replaced by a tilde (‘~’) followed by a period expression (mnemonic: ‘~’ looks like a recurring sine wave.): +# every first of month ~ monthly 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 -2018/1/1’ is valid, but ‘monthly from 2018/1/15’ is not. +# every 15th of month in 2023's first quarter: +~ monthly from 2023-04-15 to 2023-06-16 + expenses:utilities $400 + assets:bank:checking + + The period expression is the same syntax used for specifying +multi-period reports, just interpreted differently; there, it specifies +report periods; here it specifies recurrence dates (the periods’ start +dates).  File: hledger.info, Node: Periodic rules and relative dates, Next: Two spaces between period expression and description!, Prev: Periodic rule syntax, Up: Periodic transactions -10.25.2 Periodic rules and relative dates +10.26.2 Periodic rules and relative dates ----------------------------------------- Partial or relative dates (like ‘12/31’, ‘25’, ‘tomorrow’, ‘last week’, @@ -3007,7 +3030,7 @@ dates.  File: hledger.info, Node: Two spaces between period expression and description!, Prev: Periodic rules and relative dates, Up: Periodic transactions -10.25.3 Two spaces between period expression and description! +10.26.3 Two spaces between period expression and description! ------------------------------------------------------------- If the period expression is followed by a transaction description, these @@ -3032,7 +3055,7 @@ accidentally alter their meaning, as in this example:  File: hledger.info, Node: Other syntax, Prev: Periodic transactions, Up: Journal -10.26 Other syntax +10.27 Other syntax ================== hledger journal format supports quite a few other features, mainly to @@ -3047,9 +3070,9 @@ you decide if you want to use them. * Auto postings:: * Balance assignments:: * Bracketed posting dates:: -* Default commodity:: -* Default parent account:: -* Default year:: +* D directive:: +* apply account directive:: +* Y directive:: * Secondary dates:: * Star comments:: * Valuation expressions:: @@ -3059,12 +3082,12 @@ you decide if you want to use them.  File: hledger.info, Node: Auto postings, Next: Balance assignments, Up: Other syntax -10.26.1 Auto postings +10.27.1 Auto postings --------------------- -"Automated postings" or "auto postings" are extra postings which get -added automatically to transactions which match certain queries, defined -by "auto posting rules", when you use the ‘--auto’ flag. +The ‘=’ directive declares a rule for automatically adding temporary +extra postings (visible in reports, not in the journal file) to all +transactions matched by a certain query, when you use the ‘--auto’ flag. Downsides: depending on generated data for your reports makes your financial data less portable, less future-proof, and less trustworthy in @@ -3142,7 +3165,7 @@ $ hledger print --auto  File: hledger.info, Node: Auto postings and multiple files, Next: Auto postings and dates, Up: Auto postings -10.26.1.1 Auto postings and multiple files +10.27.1.1 Auto postings and multiple files .......................................... An auto posting rule can affect any transaction in the current file, or @@ -3152,7 +3175,7 @@ sibling files (when multiple ‘-f’/‘--file’ are used - see #1212).  File: hledger.info, Node: Auto postings and dates, Next: Auto postings and transaction balancing / inferred amounts / balance assertions, Prev: Auto postings and multiple files, Up: Auto postings -10.26.1.2 Auto postings and dates +10.27.1.2 Auto postings and dates ................................. A posting date (or secondary date) in the matched posting, or (taking @@ -3162,7 +3185,7 @@ used in the generated posting.  File: hledger.info, Node: Auto postings and transaction balancing / inferred amounts / balance assertions, Next: Auto posting tags, Prev: Auto postings and dates, Up: Auto postings -10.26.1.3 Auto postings and transaction balancing / inferred +10.27.1.3 Auto postings and transaction balancing / inferred ............................................................ amounts / balance assertions Currently, auto postings are added: @@ -3182,7 +3205,7 @@ infer amounts.  File: hledger.info, Node: Auto posting tags, Prev: Auto postings and transaction balancing / inferred amounts / balance assertions, Up: Auto postings -10.26.1.4 Auto posting tags +10.27.1.4 Auto posting tags ........................... Automated postings will have some extra tags: @@ -3204,7 +3227,7 @@ will have these tags added:  File: hledger.info, Node: Balance assignments, Next: Bracketed posting dates, Prev: Auto postings, Up: Other syntax -10.26.2 Balance assignments +10.27.2 Balance assignments --------------------------- Ledger-style balance assignments are also supported. These are like @@ -3246,7 +3269,7 @@ trustworthy in an audit.  File: hledger.info, Node: Balance assignments and prices, Up: Balance assignments -10.26.2.1 Balance assignments and prices +10.27.2.1 Balance assignments and prices ........................................ A cost in a balance assignment will cause the calculated amount to have @@ -3260,9 +3283,9 @@ $ hledger print --explicit (a) $1 @ €2 = $1 @ €2  -File: hledger.info, Node: Bracketed posting dates, Next: Default commodity, Prev: Balance assignments, Up: Other syntax +File: hledger.info, Node: Bracketed posting dates, Next: D directive, Prev: Balance assignments, Up: Other syntax -10.26.3 Bracketed posting dates +10.27.3 Bracketed posting dates ------------------------------- For setting posting dates and secondary posting dates, Ledger’s @@ -3277,21 +3300,22 @@ DATE2 infers its year from DATE. syntax.  -File: hledger.info, Node: Default commodity, Next: Default parent account, Prev: Bracketed posting dates, Up: Other syntax +File: hledger.info, Node: D directive, Next: apply account directive, Prev: Bracketed posting dates, Up: Other syntax -10.26.4 Default commodity -------------------------- +10.27.4 ‘D’ directive +--------------------- -The ‘D’ directive sets a default commodity, to be used for any +‘D AMOUNT’ + + This directive sets a default commodity, to be used for any subsequent commodityless amounts (ie, plain numbers) seen while parsing the journal. This effect lasts until the next ‘D’ directive, or the end of the journal. For compatibility/historical reasons, ‘D’ also acts like a ‘commodity’ directive (setting the commodity’s decimal mark for parsing -and display style for output). - - The syntax is ‘D AMOUNT’. As with ‘commodity’, the amount must +and display style for output). So its argument is not just a commodity +symbol, but a full amount demonstrating the style. The amount must include a decimal mark (either period or comma). Eg: ; commodity-less amounts should be treated as dollars @@ -3302,29 +3326,34 @@ D $1,000.00 a 5 ; <- commodity-less amount, parsed as $5 and displayed as $5.00 b - If both ‘commodity’ and ‘D’ directives are found for a commodity, -‘commodity’ takes precedence for setting decimal mark and display style. + Interactions with other directives: - If you are using ‘D’ and also checking commodities, you will need to -add a ‘commodity’ directive similar to the ‘D’. (The ‘hledger check -commodities’ command expects ‘commodity’ directives, and ignores ‘D’). + For setting a commodity’s display style, a ‘commodity’ directive has +highest priority, then a ‘D’ directive. + + For detecting a commodity’s decimal mark during parsing, +‘decimal-mark’ has highest priority, then ‘commodity’, then ‘D’. + + For checking commodity symbols with the check command, a ‘commodity’ +directive is required (‘hledger check commodities’ ignores ‘D’ +directives). Downsides: omitting commodity symbols makes your financial data less explicit, less portable, and less trustworthy in an audit. It is usually an unsustainable shortcut; sooner or later you will want to track multiple commodities. D is overloaded with functions redundant -with ‘commodity’ and ‘decimal mark’. And it works differently from +with ‘commodity’ and ‘decimal-mark’. And it works differently from Ledger’s ‘D’.  -File: hledger.info, Node: Default parent account, Next: Default year, Prev: Default commodity, Up: Other syntax +File: hledger.info, Node: apply account directive, Next: Y directive, Prev: D directive, Up: Other syntax -10.26.5 Default parent account ------------------------------- +10.27.5 ‘apply account’ directive +--------------------------------- -The ‘apply account’ directive sets a parent account which will be -prepended to all accounts in following entries, until an ‘end apply -account’ directive or end of current file. Eg: +This directive sets a default parent account, which will be prepended to +all accounts in following entries, until an ‘end apply account’ +directive or end of current file. Eg: apply account home @@ -3353,14 +3382,19 @@ prepended. portable, and less trustworthy in an audit.  -File: hledger.info, Node: Default year, Next: Secondary dates, Prev: Default parent account, Up: Other syntax +File: hledger.info, Node: Y directive, Next: Secondary dates, Prev: apply account directive, Up: Other syntax -10.26.6 Default year --------------------- +10.27.6 ‘Y’ directive +--------------------- -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’ (or ‘year’ or ‘apply -year’) followed by the year. Eg: +‘Y YEAR’ + + or (deprecated backward-compatible forms): + + ‘year YEAR’ ‘apply year YEAR’ + + The space is optional. This sets a default year to be used for +subsequent dates which don’t specify a year. Eg: Y2009 ; set default year to 2009 @@ -3386,9 +3420,9 @@ your editor. A missing Y directive makes reports dependent on today’s date.  -File: hledger.info, Node: Secondary dates, Next: Star comments, Prev: Default year, Up: Other syntax +File: hledger.info, Node: Secondary dates, Next: Star comments, Prev: Y directive, Up: Other syntax -10.26.7 Secondary dates +10.27.7 Secondary dates ----------------------- A secondary date is written after the primary date, following an equals @@ -3410,7 +3444,7 @@ better.  File: hledger.info, Node: Star comments, Next: Valuation expressions, Prev: Secondary dates, Up: Other syntax -10.26.8 Star comments +10.27.8 Star comments --------------------- Lines beginning with ‘*’ (star/asterisk) are also comment lines. This @@ -3427,7 +3461,7 @@ losing ledger mode’s features.  File: hledger.info, Node: Valuation expressions, Next: Virtual postings, Prev: Star comments, Up: Other syntax -10.26.9 Valuation expressions +10.27.9 Valuation expressions ----------------------------- Ledger allows a valuation function or value to be written in double @@ -3436,7 +3470,7 @@ parentheses after an amount. hledger ignores these.  File: hledger.info, Node: Virtual postings, Next: Other Ledger directives, Prev: Valuation expressions, Up: Other syntax -10.26.10 Virtual postings +10.27.10 Virtual postings ------------------------- A posting with parentheses around the account name is called a _virtual @@ -3475,7 +3509,7 @@ and less trustworthy in an audit.  File: hledger.info, Node: Other Ledger directives, Prev: Virtual postings, Up: Other syntax -10.26.11 Other Ledger directives +10.27.11 Other Ledger directives -------------------------------- These other Ledger directives are currently accepted but ignored. This @@ -5190,6 +5224,7 @@ File: hledger.info, Node: Time periods, Next: Depth, Prev: PART 3 REPORTING C * Report start & end date:: * Smart dates:: * Report intervals:: +* Date adjustment:: * Period expressions::  @@ -5199,9 +5234,9 @@ File: hledger.info, Node: Report start & end date, Next: Smart dates, Up: Tim ============================ By default, most hledger reports will show the full span of time -represented by the journal data. The report start date will be the -earliest transaction or posting date, and the report end date will be -the latest transaction, posting, or market price date. +represented by the journal. The report start date will be the earliest +transaction or posting date, and the report end date will be the latest +transaction, posting, or market price date. Often you will want to see a shorter time span, such as the current month. You can specify a start and/or end date using ‘-b/--begin’, @@ -5218,8 +5253,8 @@ these accept the smart date syntax (below). the start/end dates from options and that from ‘date:’ queries. That is, ‘date:2019-01 date:2019 -p'2000 to 2030'’ yields January 2019, the smallest common time span. - • A report interval (see below) will adjust start/end dates, when - needed, so that they fall on subperiod boundaries. + • In some cases a report interval will adjust start/end dates to fall + on interval boundaries (see below). Examples: @@ -5243,11 +5278,10 @@ File: hledger.info, Node: Smart dates, Next: Report intervals, Prev: Report s 15.2 Smart dates ================ -hledger’s user interfaces accept a flexible "smart date" syntax. Smart -dates allow some english words, can be relative to today’s date, and can -have less-significant date parts omitted (defaulting to 1). - - Examples: +hledger’s user interfaces accept a "smart date" syntax for added +convenience. Smart dates optionally can be relative to today’s date, be +written with english words, and have less-significant parts omitted +(missing parts are inferred as 1). Some examples: ‘2004/10/1’, exact date, several separators allowed. Year ‘2004-01-01’, is 4+ digits, month is 1-12, day is 1-31 @@ -5273,8 +5307,8 @@ ago’ day ‘201812’ 6 digit YYYYMM with valid year and month - Counterexamples - malformed digit sequences might give surprising -results: + Some counterexamples - malformed digit sequences might give +surprising results: ‘201813’ 6 digits with an invalid month is parsed as start of 6-digit year @@ -5283,22 +5317,22 @@ results: ‘20181232’ 8 digits with an invalid day gives an error ‘201801012’ 9+ digits beginning with a valid YYYYMMDD gives an error - Note "today’s date" can be overridden with the ‘--today’ option, in -case it’s needed for testing or for recreating old reports. (Except for -periodic transaction rules; those are not affected by ‘--today’.) + "Today’s date" can be overridden with the ‘--today’ option, in case +it’s needed for testing or for recreating old reports. (Except for +periodic transaction rules, which are not affected by ‘--today’.)  -File: hledger.info, Node: Report intervals, Next: Period expressions, Prev: Smart dates, Up: Time periods +File: hledger.info, Node: Report intervals, Next: Date adjustment, Prev: Smart dates, Up: Time periods 15.3 Report intervals ===================== -A report interval can be specified so that commands like register, -balance and activity become multi-period, showing each subperiod as a +A report interval can be specified so that reports like register, +balance or activity become multi-period, showing each subperiod as a separate row or column. - The following "standard" report intervals can be enabled by using -their corresponding flag: + The following standard intervals can be enabled with command-line +flags: • ‘-D/--daily’ • ‘-W/--weekly’ @@ -5306,83 +5340,92 @@ their corresponding flag: • ‘-Q/--quarterly’ • ‘-Y/--yearly’ - These standard intervals always start on natural interval boundaries: -eg ‘--weekly’ starts on mondays, ‘--monthly’ starts on the first of the -month, ‘--yearly’ always starts on January 1st, etc. - - Certain more complex intervals, and more flexible boundary dates, can -be specified by ‘-p/--period’. These are described in period -expressions, below. - - Report intervals can only be specified by the flags above, and not by -query arguments, currently. - - Report intervals have another effect: multi-period reports are always -expanded to fill a whole number of subperiods. So if you use a report -interval (other than ‘--daily’), and you have specified a start or end -date, you may notice those dates being overridden (ie, the report starts -earlier than your requested start date, or ends later than your -requested end date). This is done to ensure "full" first and last -subperiods, so that all subperiods’ numbers are comparable. - - To summarise: - - • In multiperiod reports, all subperiods are forced to be the same - length, to simplify reporting. - • Reports with the standard - ‘--weekly’/‘--monthly’/‘--quarterly’/‘--yearly’ intervals are - required to start on the first day of a week/month/quarter/year. - We’d like more flexibility here but it isn’t supported yet. - • ‘--period’ (below) can specify more complex intervals, starting on - any date. + More complex intervals can be specified using ‘-p/--period’, +described below.  -File: hledger.info, Node: Period expressions, Prev: Report intervals, Up: Time periods +File: hledger.info, Node: Date adjustment, Next: Period expressions, Prev: Report intervals, Up: Time periods -15.4 Period expressions +15.4 Date adjustment +==================== + +With a report interval (other than daily), report start / end dates +which have not been specified explicitly and in full (eg not ‘-b +2023-01-01’, but ‘-b 2023-01’ or ‘-b 2023’ or unspecified) are +considered flexible: + + • A flexible start date will be automatically adjusted earlier if + needed to fall on a natural interval boundary. + • Similarly, a flexible end date will be adjusted later if needed to + make the last period a whole interval (the same length as the + others). + + This is convenient for producing clean periodic reports (this is +traditional hledger behaviour). By contrast, fully-specified exact +dates will not be adjusted (this is new in hledger 1.29). + + An example: with a journal whose first date is 2023-01-10 and last +date is 2023-03-20: + + • ‘hledger bal -M -b 2023/1/15 -e 2023/3/10’ + The report periods will begin on the 15th day of each month, + starting from 2023-01-15, and the last period’s last day will be + 2023-03-09. (Exact start and end dates, neither is adjusted.) + + • ‘hledger bal -M -b 2023-01 -e 2023-04’ or ‘hledger bal -M’ + The report periods will begin on the 1st of each month, starting + from 2023-01-01, and the last period’s last day will be 2023-03-31. + (Flexible start and end dates, both are adjusted.) + + +File: hledger.info, Node: Period expressions, Prev: Date adjustment, Up: Time periods + +15.5 Period expressions ======================= -The ‘-p/--period’ option accepts period expressions, a shorthand way of -expressing a start date, end date, and/or report interval all at once. +The ‘-p/--period’ option specifies a period expression, which is a +compact way of expressing a start date, end date, and/or report +interval. - Here’s a basic period expression specifying the first quarter of -2009. Note, hledger always treats start dates as inclusive and end -dates as exclusive: + Here’s a period expression with a start and end date (specifying the +first quarter of 2009): ‘-p "from 2009/1/1 to 2009/4/1"’ - Keywords like "from" and "to" are optional, and so are the spaces, as -long as you don’t run two dates together. "to" can also be written as -".." or "-". These are equivalent to the above: + Several keywords like "from" and "to" are supported for readability; +these are optional. "to" can also be written as ".." or "-". The +spaces are also optional, as long as you don’t run two dates together. +So the following are equivalent to the above: ‘-p "2009/1/1 2009/4/1"’ ‘-p2009/1/1to2009/4/1’ ‘-p2009/1/1..2009/4/1’ - Dates are smart dates, so if the current year is 2009, the above can -also be written as: + Dates are smart dates, so if the current year is 2009, these are also +equivalent to the above: ‘-p "1/1 4/1"’ -‘-p "january-apr"’ +‘-p "jan-apr"’ ‘-p "this year to 4/1"’ If you specify only one date, the missing start or end date will be -the earliest or latest transaction in your journal: +the earliest or latest transaction date in the journal: ‘-p "from 2009/1/1"’ everything after january 1, 2009 ‘-p "since 2009/1"’ the same, since is a synonym ‘-p "from 2009"’ the same ‘-p "to 2009"’ everything before january 1, 2009 - A single date with no "from" or "to" defines both the start and end -date like so: + You can also specify a period by writing a single partial or full +date: -‘-p "2009"’ the year 2009; equivalent to “2009/1/1 to 2010/1/1” -‘-p "2009/1"’ the month of jan; equivalent to “2009/1/1 to 2009/2/1” -‘-p just that day; equivalent to “2009/1/1 to 2009/1/2” -"2009/1/1"’ +‘-p "2009"’ the year 2009; equivalent to “2009/1/1 to 2010/1/1” +‘-p "2009/1"’ the month of january 2009; equivalent to “2009/1/1 to + 2009/2/1” +‘-p the first day of 2009; equivalent to “2009/1/1 to +"2009/1/1"’ 2009/1/2” - Or you can specify a single quarter like so: + or by using the "Q" quarter-year syntax (case insensitive): ‘-p "2009Q1"’ first quarter of 2009, equivalent to “2009/1/1 to 2009/4/1” @@ -5392,89 +5435,49 @@ date like so: * Period expressions with a report interval:: * More complex report intervals:: -* Intervals with custom start date:: -* Periods or dates ?:: -* Events on multiple weekdays:: +* Multiple weekday intervals::  File: hledger.info, Node: Period expressions with a report interval, Next: More complex report intervals, Up: Period expressions -15.4.1 Period expressions with a report interval +15.5.1 Period expressions with a report interval ------------------------------------------------ -‘-p/--period’’s argument can also begin with, or entirely consist of, a -report interval. This should be separated from the start/end dates (if -any) by a space, or the word ‘in’. The basic intervals (which can also -be written as command line flags) are ‘daily’, ‘weekly’, ‘monthly’, -‘quarterly’, and ‘yearly’. Some examples: +A period expression can also begin with a report interval, separated +from the start/end dates (if any) by a space or the word ‘in’: ‘-p "weekly from 2009/1/1 to 2009/4/1"’ ‘-p "monthly in 2008"’ ‘-p "quarterly"’ - As mentioned above, the ‘weekly’, ‘monthly’, ‘quarterly’ and ‘yearly’ -intervals require a report start date that is the first day of a week, -month, quarter or year. And, report start/end dates will be expanded if -needed to span a whole number of intervals. - - For example: - -‘-p "weekly from starts on 2008/12/29, closest preceding -2009/1/1 to 2009/4/1"’ Monday -‘-p "monthly in starts on 2018/11/01 -2008/11/25"’ -‘-p "quarterly from starts on 2009/04/01, ends on 2009/06/30, -2009-05-05 to which are first and last days of Q2 2009 -2009-06-01"’ -‘-p "yearly from starts on 2009/01/01, first day of 2009 -2009-12-29"’ -  -File: hledger.info, Node: More complex report intervals, Next: Intervals with custom start date, Prev: Period expressions with a report interval, Up: Period expressions +File: hledger.info, Node: More complex report intervals, Next: Multiple weekday intervals, Prev: Period expressions with a report interval, Up: Period expressions -15.4.2 More complex report intervals +15.5.2 More complex report intervals ------------------------------------ -Some more complex kinds of interval are also supported in period -expressions: +Some more complex intervals can be specified within period expressions, +such as: - • ‘biweekly’ + • ‘biweekly’ (every two weeks) • ‘fortnightly’ - • ‘bimonthly’ + • ‘bimonthly’ (every two months) • ‘every day|week|month|quarter|year’ • ‘every N days|weeks|months|quarters|years’ - These too will cause report start/end dates to be expanded, if -needed, to span a whole number of intervals. Examples: - -‘-p "bimonthly from periods will have boundaries on 2008/01/01, -2008"’ 2008/03/01, ... -‘-p "every 2 weeks"’ starts on closest preceding Monday -‘-p "every 5 months from periods will have boundaries on 2009/03/01, -2009/03"’ 2009/08/01, ... - - -File: hledger.info, Node: Intervals with custom start date, Next: Periods or dates ?, Prev: More complex report intervals, Up: Period expressions - -15.4.3 Intervals with custom start date ---------------------------------------- - -All intervals mentioned above are required to start on their natural -calendar boundaries, but the following intervals can start on any date: - - Weekly on custom day: + Weekly on a custom day: • ‘every Nth day of week’ (‘th’, ‘nd’, ‘rd’, or ‘st’ are all accepted after the number) • ‘every WEEKDAYNAME’ (full or three-letter english weekday name, case insensitive) - Monthly on custom day: + Monthly on a custom day: • ‘every Nth day [of month]’ • ‘every Nth WEEKDAYNAME [of month]’ - Yearly on custom day: + Yearly on a custom day: • ‘every MM/DD [of year]’ (month number and day of month number) • ‘every MONTHNAME DDth [of year]’ (full or three-letter english @@ -5483,18 +5486,22 @@ calendar boundaries, but the following intervals can start on any date: Examples: -‘-p "every 2nd day of periods will go from Tue to Tue +‘-p "bimonthly from +2008"’ +‘-p "every 2 weeks"’ +‘-p "every 5 months from +2009/03"’ +‘-p "every 2nd day of periods will go from Tue to Tue week"’ -‘-p "every Tue"’ same -‘-p "every 15th day"’ period boundaries will be on 15th of each - month -‘-p "every 2nd period boundaries will be on second Monday of -Monday"’ each month -‘-p "every 11/05"’ yearly periods with boundaries on 5th of - November -‘-p "every 5th same -November"’ -‘-p "every Nov 5th"’ same +‘-p "every Tue"’ same +‘-p "every 15th day"’ period boundaries will be on 15th of each + month +‘-p "every 2nd Monday"’ period boundaries will be on second Monday + of each month +‘-p "every 11/05"’ yearly periods with boundaries on 5th of + November +‘-p "every 5th November"’ same +‘-p "every Nov 5th"’ same Show historical balances at end of the 15th day of each month (N is an end date, exclusive as always): @@ -5507,37 +5514,23 @@ tuesday (N is both (inclusive) start date and (exclusive) end date): $ hledger register checking -p "every 3rd day of week"  -File: hledger.info, Node: Periods or dates ?, Next: Events on multiple weekdays, Prev: Intervals with custom start date, Up: Period expressions +File: hledger.info, Node: Multiple weekday intervals, Prev: More complex report intervals, Up: Period expressions -15.4.4 Periods or dates ? -------------------------- +15.5.3 Multiple weekday intervals +--------------------------------- -Report intervals like the above are most often used with ‘-p|--period’, -to divide reports into multiple subperiods - each generated date marks a -subperiod boundary. Here, the periods between the dates are what’s -important. +This special form is also supported: - But report intervals can also be used with ‘--forecast’ to generate -future transactions, or with ‘balance --budget’ to generate budget -goal-setting transactions. For these, the dates themselves are what -matters. + • ‘every WEEKDAYNAME,WEEKDAYNAME,...’ (full or three-letter english + weekday names, case insensitive) - -File: hledger.info, Node: Events on multiple weekdays, Prev: Periods or dates ?, Up: Period expressions + Also, ‘weekday’ and ‘weekendday’ are shorthand for +‘mon,tue,wed,thu,fri’ and ‘sat,sun’. -15.4.5 Events on multiple weekdays ----------------------------------- - -The ‘every WEEKDAYNAME’ form has a special variant with multiple day -names, comma-separated. Eg: ‘every mon,thu,sat’. Also, ‘weekday’ and -‘weekendday’ are shorthand for ‘mon,tue,wed,thu,fri’ and ‘sat,sun’ -respectively. - - This form is mainly intended for use with ‘--forecast’, to generate + This is mainly intended for use with ‘--forecast’, to generate periodic transactions on arbitrary days of the week. It may be less useful with ‘-p’, since it divides each week into subperiods of unequal -length. (Because gaps between periods are not allowed; if you’d like to -change this, see #1632.) +length, which is unusual. (Related: #1632) Examples: @@ -5597,7 +5590,6 @@ arguments to restrict their scope. The syntax is as follows: * Query types:: * Combining query terms:: * Queries and command options:: -* Queries and account aliases:: * Queries and valuation:: * Querying with account aliases:: * Querying with cost or value:: @@ -5728,7 +5720,7 @@ here are some tricks that can help: $ hledger print cash | hledger -f- -I balance food  -File: hledger.info, Node: Queries and command options, Next: Queries and account aliases, Prev: Combining query terms, Up: Queries +File: hledger.info, Node: Queries and command options, Next: Queries and valuation, Prev: Combining query terms, Up: Queries 17.3 Queries and command options ================================ @@ -5739,18 +5731,9 @@ When you mix command options and query arguments, generally the resulting query is their intersection.  -File: hledger.info, Node: Queries and account aliases, Next: Queries and valuation, Prev: Queries and command options, Up: Queries +File: hledger.info, Node: Queries and valuation, Next: Querying with account aliases, Prev: Queries and command options, Up: Queries -17.4 Queries and account aliases -================================ - -When account names are rewritten with ‘--alias’ or ‘alias’, ‘acct:’ will -match either the old or the new account name. - - -File: hledger.info, Node: Queries and valuation, Next: Querying with account aliases, Prev: Queries and account aliases, Up: Queries - -17.5 Queries and valuation +17.4 Queries and valuation ========================== When amounts are converted to other commodities in cost or value @@ -5761,7 +5744,7 @@ reversed, see #1625).  File: hledger.info, Node: Querying with account aliases, Next: Querying with cost or value, Prev: Queries and valuation, Up: Queries -17.6 Querying with account aliases +17.5 Querying with account aliases ================================== When account names are rewritten with ‘--alias’ or ‘alias’, note that @@ -5770,7 +5753,7 @@ When account names are rewritten with ‘--alias’ or ‘alias’, note that  File: hledger.info, Node: Querying with cost or value, Prev: Querying with account aliases, Up: Queries -17.7 Querying with cost or value +17.6 Querying with cost or value ================================ When amounts are converted to other commodities in cost or value @@ -6032,6 +6015,11 @@ reporting more difficult for PTA tools. Happily, current hledger can read either notation, or convert one to the other when needed, so you can use the one you prefer. + You can even use cost notation and equivalent conversion postings at +the same time, for clarity. hledger will ignore the redundancy. But be +sure the cost and conversion posting amounts match, or you’ll see a +not-so-clear transaction balancing error message. +  File: hledger.info, Node: Inferring equity postings from cost, Next: Inferring cost from equity postings, Prev: Equity conversion postings, Up: Cost reporting @@ -6039,10 +6027,7 @@ File: hledger.info, Node: Inferring equity postings from cost, Next: Inferring ======================================== With ‘--infer-equity’, hledger detects transactions written with PTA -cost notation and adds equity conversion postings to them (and -temporarily permits the coexistence of equity conversion postings and -cost notation, which normally would cause an unbalanced transaction -error). Eg: +cost notation and adds equity conversion postings to them: 2022-01-01 assets:dollars -$135 @@ -6070,9 +6055,8 @@ File: hledger.info, Node: Inferring cost from equity postings, Next: When to i ======================================== The reverse operation is possible using ‘--infer-costs’, which detects -transactions written with equity conversion postings and adds PTA cost -notation to them (and temporarily permits the coexistence of equity -conversion postings and cost notation). Eg: +transactions written with equity conversion postings and adds cost +notation to them: 2022-01-01 assets:dollars $-135 @@ -6108,19 +6092,15 @@ postings: ‘equity:conversion’, ‘equity:trade’, ‘equity:trading’ or subaccounts of these) 4. the equity postings’ amounts must exactly match the non-equity - postings’ amounts - 5. all of the amounts must be explicit, with none missing + postings’ amounts. - Multiple such exchanges can coexist within a single transaction, -should you need that. + Multiple such exchanges can coexist within a single transaction. When inferring cost, the order of postings matters: the cost is added to the first of the non-equity postings involved in the exchange, in the commodity of the last non-equity posting involved in the exchange. If -you don’t want to write your postings in the required order, the -alternative is not to infer cost; instead, use explicit cost notation, -omitting the equity postings, inferring them later with –infer-equity if -needed. +you don’t want to write your postings in the required order, you can use +explicit cost notation instead. –infer-equity and –infer-costs can be used together, if you have a mixture of both notations in your journal. @@ -6256,9 +6236,7 @@ File: hledger.info, Node: Conversion with equity postings and explicit cost, P 22.6.4 Conversion with equity postings and explicit cost -------------------------------------------------------- -Here both equity postings and @ notation are used together. hledger -will usually complain about this redundancy, but when using the -–infer-costs flag it is accepted. +Here both equity postings and @ notation are used together. 2021-01-01 assets:cash -100 EUR @ 1.20 USD @@ -6276,7 +6254,6 @@ will usually complain about this redundancy, but when using the Con: • Most verbose - • Requires the –infer-costs flag • Not compatible with ledger  @@ -6285,18 +6262,18 @@ File: hledger.info, Node: Cost tips, Prev: How to record conversions, Up: Cos 22.7 Cost tips ============== - • Recording the conversion rate explicitly is good because it makes - that clear and helps detect errors. + • Recording the cost/conversion rate explicitly is good because it + makes that clear and helps detect errors. • Recording equity postings is good because it is correct bookkeeping and preserves the accounting equation. - • Combining these is possible by using the –infer-costs flag (which - requires well-ordered postings). + • Combining these is possible. • When you want to see the cost (or sale proceeds) of things, use - ‘-B’ (or ‘--cost’). If you use equity conversion postings - notation, use ‘-B --infer-costs’. - • If you use PTA cost notation, and you want to see a balanced - balance sheet or print correct journal entries, use - ‘--infer-equity’. + ‘-B’ (short form of ‘--cost’). + • If you use conversion postings without cost notation, add + ‘--infer-costs’ also. + • If you use cost notation without conversion postings, and you want + to see a balanced balance sheet or print correct journal entries, + use ‘--infer-equity’. • Conversion to cost is performed before valuation (described next).  @@ -6889,68 +6866,18 @@ File: hledger.info, Node: PART 4 COMMANDS, Next: PART 5 COMMON TASKS, Prev: V 24 PART 4: COMMANDS ******************* -Here are the built-in commands, with the most often-used in bold: - - *Data entry:* - - These data entry commands are the only ones which can modify your -journal file. - - • *add* - add transactions using guided prompts - • *import* - add any new transactions from other files (eg csv) - - *Data management:* - - • check - check for various kinds of issue in the data - • close (equity) - generate balance-resetting transactions - • diff - compare account transactions in two journal files - • rewrite - generate extra postings, similar to print –auto - - *Financial statements:* - - • *aregister (areg)* - show transactions in a particular account - • *balancesheet (bs)* - show assets, liabilities and net worth - • balancesheetequity (bse) - show assets, liabilities and equity - • cashflow (cf) - show changes in liquid assets - • *incomestatement (is)* - show revenues and expenses - • roi - show return on investments - - *Miscellaneous reports:* - - • accounts - show account names - • activity - show postings-per-interval bar charts - • *balance (bal)* - show balance changes/end balances/budgets in any - accounts - • codes - show transaction codes - • commodities - show commodity/currency symbols - • descriptions - show unique transaction descriptions - • files - show input file paths - • help - show hledger user manuals in several formats - • notes - show unique note segments of transaction descriptions - • payees - show unique payee segments of transaction descriptions - • prices - show market price records - • *print* - show transactions (journal entries) - • *register (reg)* - show postings in one or more accounts & running - total - • stats - show journal statistics - • tags - show tag names - • test - run self tests - - And here are some typical add-on commands installed by the -hledger-install script. If installed, these will also appear in -hledger’s commands list, with a ‘+’ mark: - - • *ui* - hledger’s official curses-style TUI - • *web* - hledger’s official web UI - • iadd - a popular alternative to hledger’s ‘add’ command. - • interest - generates interest transactions - • stockquotes - downloads market prices. _(Alpha quality, needs your - help.)_ - - Next, each command is described in detail, in alphabetical order. +Here are the built-in commands: * Menu: +* DATA ENTRY:: +* DATA CREATION:: +* DATA MANAGEMENT:: +* REPORTS FINANCIAL:: +* REPORTS VERSATILE:: +* REPORTS BASIC:: +* HELP:: +* ADD-ONS:: * accounts:: * activity:: * add:: @@ -6981,12 +6908,114 @@ hledger’s commands list, with a ‘+’ mark: * test::  -File: hledger.info, Node: accounts, Next: activity, Up: PART 4 COMMANDS +File: hledger.info, Node: DATA ENTRY, Next: DATA CREATION, Up: PART 4 COMMANDS -24.1 accounts +24.1 DATA ENTRY +=============== + +These data entry commands are the only ones which can modify your +journal file. + + • add - add transactions using guided prompts + • import - add any new transactions from other files (eg csv) + + +File: hledger.info, Node: DATA CREATION, Next: DATA MANAGEMENT, Prev: DATA ENTRY, Up: PART 4 COMMANDS + +24.2 DATA CREATION +================== + + • close - generate balance-resetting transactions + • rewrite - generate extra postings, similar to print –auto + + +File: hledger.info, Node: DATA MANAGEMENT, Next: REPORTS FINANCIAL, Prev: DATA CREATION, Up: PART 4 COMMANDS + +24.3 DATA MANAGEMENT +==================== + + • check - check for various kinds of issue in the data + • diff - compare account transactions in two journal files + + +File: hledger.info, Node: REPORTS FINANCIAL, Next: REPORTS VERSATILE, Prev: DATA MANAGEMENT, Up: PART 4 COMMANDS + +24.4 REPORTS, FINANCIAL +======================= + + • aregister (areg) - show transactions in a particular account + • balancesheet (bs) - show assets, liabilities and net worth + • balancesheetequity (bse) - show assets, liabilities and equity + • cashflow (cf) - show changes in liquid assets + • incomestatement (is) - show revenues and expenses + + +File: hledger.info, Node: REPORTS VERSATILE, Next: REPORTS BASIC, Prev: REPORTS FINANCIAL, Up: PART 4 COMMANDS + +24.5 REPORTS, VERSATILE +======================= + + • balance (bal) - show balance changes/end balances/budgets in any + accounts + • print - show transactions (journal entries) + • register (reg) - show postings in one or more accounts & running + total + • roi - show return on investments + + +File: hledger.info, Node: REPORTS BASIC, Next: HELP, Prev: REPORTS VERSATILE, Up: PART 4 COMMANDS + +24.6 REPORTS, BASIC +=================== + + • accounts - show account names + • activity - show postings-per-interval bar charts + • codes - show transaction codes + • commodities - show commodity/currency symbols + • descriptions - show unique transaction descriptions + • files - show input file paths + • notes - show unique note segments of transaction descriptions + • payees - show unique payee segments of transaction descriptions + • prices - show market price records + • stats - show journal statistics + • tags - show tag names + • test - run self tests + + +File: hledger.info, Node: HELP, Next: ADD-ONS, Prev: REPORTS BASIC, Up: PART 4 COMMANDS + +24.7 HELP +========= + + • help - show hledger user manuals in several formats + + +File: hledger.info, Node: ADD-ONS, Next: accounts, Prev: HELP, Up: PART 4 COMMANDS + +24.8 ADD-ONS +============ + +And here are some typical add-on commands. Some of these are installed +by the hledger-install script. If installed, they will appear in +hledger’s commands list: + + • ui - hledger’s official terminal UI + • web - hledger’s official web UI + • iadd - an alternative to hledger’s ‘add’ command (currently hard to + build) + • interest - generates interest transactions + • stockquotes - downloads market prices + • Scripts and add-ons - check-fancyassertions, edit, fifo, git, move, + pijul, plot, and more.. + + Next, each command is described in detail, in alphabetical order. + + +File: hledger.info, Node: accounts, Next: activity, Prev: ADD-ONS, Up: PART 4 COMMANDS + +24.9 accounts ============= -accounts Show account names. This command lists account names. By default it shows all known @@ -7041,10 +7070,9 @@ $ hledger check accounts  File: hledger.info, Node: activity, Next: add, Prev: accounts, Up: PART 4 COMMANDS -24.2 activity -============= +24.10 activity +============== -activity Show an ascii barchart of posting counts per interval. The activity command displays an ascii histogram showing transaction @@ -7062,10 +7090,9 @@ $ hledger activity --quarterly  File: hledger.info, Node: add, Next: aregister, Prev: activity, Up: PART 4 COMMANDS -24.3 add -======== +24.11 add +========= -add Prompt for transactions and add them to the journal. Any arguments will be used as default inputs for the first N prompts. @@ -7133,10 +7160,10 @@ file path ends with a period, as that would cause problems (#1056).  File: hledger.info, Node: aregister, Next: balance, Prev: add, Up: PART 4 COMMANDS -24.4 aregister -============== +24.12 aregister +=============== -aregister, areg +(areg) Show the transactions and running historical balance of a single account, with each transaction displayed as one line. @@ -7208,8 +7235,8 @@ options. The output formats supported are ‘txt’, ‘csv’, and ‘json’.  File: hledger.info, Node: aregister and custom posting dates, Up: aregister -24.4.1 aregister and custom posting dates ------------------------------------------ +24.12.1 aregister and custom posting dates +------------------------------------------ Transactions whose date is outside the report period can still be shown, if they have a posting to this account dated inside the report period. @@ -7224,11 +7251,12 @@ it’s probably best to assume the running balance is wrong.  File: hledger.info, Node: balance, Next: balancesheet, Prev: aregister, Up: PART 4 COMMANDS -24.5 balance -============ +24.13 balance +============= -balance, bal -Show accounts and their balances. +(bal) + + Show accounts and their balances. ‘balance’ is one of hledger’s oldest and most versatile commands, for listing account balances, balance changes, values, value changes and @@ -7262,8 +7290,8 @@ more control, then use ‘balance’.  File: hledger.info, Node: balance features, Next: Simple balance report, Up: balance -24.5.1 balance features ------------------------ +24.13.1 balance features +------------------------ Here’s a quick overview of the ‘balance’ command’s features, followed by more detailed descriptions and examples. Many of these work with the @@ -7324,8 +7352,8 @@ in the transactions of the postings which would normally be shown.  File: hledger.info, Node: Simple balance report, Next: Balance report line format, Prev: balance features, Up: balance -24.5.2 Simple balance report ----------------------------- +24.13.2 Simple balance report +----------------------------- With no arguments, ‘balance’ shows a list of all accounts and their change of balance - ie, the sum of posting amounts, both inflows and @@ -7373,8 +7401,8 @@ $ hledger -f examples/sample.journal bal -E  File: hledger.info, Node: Balance report line format, Next: Filtered balance report, Prev: Simple balance report, Up: balance -24.5.3 Balance report line format ---------------------------------- +24.13.3 Balance report line format +---------------------------------- For single-period balance reports displayed in the terminal (only), you can use ‘--format FMT’ to customise the format and content of each line. @@ -7436,8 +7464,8 @@ may be needed to get pleasing results.  File: hledger.info, Node: Filtered balance report, Next: List or tree mode, Prev: Balance report line format, Up: balance -24.5.4 Filtered balance report ------------------------------- +24.13.4 Filtered balance report +------------------------------- You can show fewer accounts, a different time period, totals from cleared transactions only, etc. by using query arguments or options to @@ -7451,8 +7479,8 @@ $ hledger -f examples/sample.journal bal --cleared assets date:200806  File: hledger.info, Node: List or tree mode, Next: Depth limiting, Prev: Filtered balance report, Up: balance -24.5.5 List or tree mode ------------------------- +24.13.5 List or tree mode +------------------------- By default, or with ‘-l/--flat’, accounts are shown as a flat list with their full names visible, as in the examples above. @@ -7494,8 +7522,8 @@ $ hledger -f examples/sample.journal balance  File: hledger.info, Node: Depth limiting, Next: Dropping top-level accounts, Prev: List or tree mode, Up: balance -24.5.6 Depth limiting ---------------------- +24.13.6 Depth limiting +---------------------- With a ‘depth:NUM’ query, or ‘--depth NUM’ option, or just ‘-NUM’ (eg: ‘-3’) balance reports will show accounts only to the specified depth, @@ -7516,8 +7544,8 @@ $ hledger -f examples/sample.journal balance -1  File: hledger.info, Node: Dropping top-level accounts, Next: Showing declared accounts, Prev: Depth limiting, Up: balance -24.5.7 Dropping top-level accounts ----------------------------------- +24.13.7 Dropping top-level accounts +----------------------------------- You can also hide one or more top-level account name parts, using ‘--drop NUM’. This can be useful for hiding repetitive top-level @@ -7532,8 +7560,8 @@ $ hledger -f examples/sample.journal bal expenses --drop 1  File: hledger.info, Node: Showing declared accounts, Next: Sorting by amount, Prev: Dropping top-level accounts, Up: balance -24.5.8 Showing declared accounts --------------------------------- +24.13.8 Showing declared accounts +--------------------------------- With ‘--declared’, accounts which have been declared with an account directive will be included in the balance report, even if they have no @@ -7550,8 +7578,8 @@ accounts yet.  File: hledger.info, Node: Sorting by amount, Next: Percentages, Prev: Showing declared accounts, Up: balance -24.5.9 Sorting by amount ------------------------- +24.13.9 Sorting by amount +------------------------- With ‘-S/--sort-amount’, accounts with the largest (most positive) balances are shown first. Eg: ‘hledger bal expenses -MAS’ shows your @@ -7568,8 +7596,8 @@ which flip the sign automatically. Eg: ‘hledger incomestatement -MAS’).  File: hledger.info, Node: Percentages, Next: Multi-period balance report, Prev: Sorting by amount, Up: balance -24.5.10 Percentages -------------------- +24.13.10 Percentages +-------------------- With ‘-%/--percent’, balance reports show each account’s value expressed as a percentage of the (column) total. @@ -7591,8 +7619,8 @@ $ hledger bal -% cur:€  File: hledger.info, Node: Multi-period balance report, Next: Balance change end balance, Prev: Percentages, Up: balance -24.5.11 Multi-period balance report ------------------------------------ +24.13.11 Multi-period balance report +------------------------------------ With a report interval (set by the ‘-D/--daily’, ‘-W/--weekly’, ‘-M/--monthly’, ‘-Q/--quarterly’, ‘-Y/--yearly’, or ‘-p/--period’ flag), @@ -7646,8 +7674,8 @@ viewing in the terminal. Here are some ways to handle that:  File: hledger.info, Node: Balance change end balance, Next: Balance report types, Prev: Multi-period balance report, Up: balance -24.5.12 Balance change, end balance ------------------------------------ +24.13.12 Balance change, end balance +------------------------------------ It’s important to be clear on the meaning of the numbers shown in balance reports. Here is some terminology we use: @@ -7683,8 +7711,8 @@ historical end balances:  File: hledger.info, Node: Balance report types, Next: Budget report, Prev: Balance change end balance, Up: balance -24.5.13 Balance report types ----------------------------- +24.13.13 Balance report types +----------------------------- The balance command is quite flexible; here is the full detail on how to control what it reports. If the following seems complicated, don’t @@ -7706,8 +7734,8 @@ time and experimentation to get clear on all these report modes.  File: hledger.info, Node: Calculation type, Next: Accumulation type, Up: Balance report types -24.5.13.1 Calculation type -.......................... +24.13.13.1 Calculation type +........................... The basic calculation to perform for each table cell. It is one of: @@ -7723,8 +7751,8 @@ The basic calculation to perform for each table cell. It is one of:  File: hledger.info, Node: Accumulation type, Next: Valuation type, Prev: Calculation type, Up: Balance report types -24.5.13.2 Accumulation type -........................... +24.13.13.2 Accumulation type +............................ How amounts should accumulate across report periods. Another way to say it: which time period’s postings should contribute to each cell’s @@ -7748,8 +7776,8 @@ calculation. It is one of:  File: hledger.info, Node: Valuation type, Next: Combining balance report types, Prev: Accumulation type, Up: Balance report types -24.5.13.3 Valuation type -........................ +24.13.13.3 Valuation type +......................... Which kind of value or cost conversion should be applied, if any, before displaying the report. It is one of: @@ -7779,8 +7807,8 @@ displaying the report. It is one of:  File: hledger.info, Node: Combining balance report types, Prev: Valuation type, Up: Balance report types -24.5.13.4 Combining balance report types -........................................ +24.13.13.4 Combining balance report types +......................................... Most combinations of these options should produce reasonable reports, but if you find any that seem wrong or misleading, let us know. The @@ -7818,8 +7846,8 @@ Accumulation:v YYYY-MM-DD  File: hledger.info, Node: Budget report, Next: Data layout, Prev: Balance report types, Up: balance -24.5.14 Budget report ---------------------- +24.13.14 Budget report +---------------------- The ‘--budget’ report type activates extra columns showing any budget goals for each account and period. The budget goals are defined by @@ -7931,6 +7959,18 @@ Budget performance in 2017/11/01-2017/12/31: ----------------------++---------------------------------------------------- || 0 [ 0] 0 [ 0] + It’s common to limit budgets/budget reports to just expenses + +hledger bal -M --budget expenses + + or just revenues and expenses (eg, using account types): + +hledger bal -M --budget type:rx + + It’s also common to limit or convert them to a single currency +(‘cur:COMM’ or ‘-X COMM [--infer-market-prices]’). If showing multiple +currencies, ‘--layout bare’ or ‘--layout tall’ can help. + For more examples and notes, see Budgeting. * Menu: @@ -7938,12 +7978,13 @@ Budget performance in 2017/11/01-2017/12/31: * Budget report start date:: * Budgets and subaccounts:: * Selecting budget goals:: +* Budget vs forecast::  File: hledger.info, Node: Budget report start date, Next: Budgets and subaccounts, Up: Budget report -24.5.14.1 Budget report start date -.................................. +24.13.14.1 Budget report start date +................................... This might be a bug, but for now: when making budget reports, it’s a good idea to explicitly set the report’s start date to the first day of @@ -7986,8 +8027,8 @@ Budget performance in 2020-01-01..2020-01-15:  File: hledger.info, Node: Budgets and subaccounts, Next: Selecting budget goals, Prev: Budget report start date, Up: Budget report -24.5.14.2 Budgets and subaccounts -................................. +24.13.14.2 Budgets and subaccounts +.................................. You can add budgets to any account in your account hierarchy. If you have budgets on both parent account and some of its children, then @@ -8072,15 +8113,15 @@ Budget performance in 2019/01: || 0 [ 0]  -File: hledger.info, Node: Selecting budget goals, Prev: Budgets and subaccounts, Up: Budget report +File: hledger.info, Node: Selecting budget goals, Next: Budget vs forecast, Prev: Budgets and subaccounts, Up: Budget report -24.5.14.3 Selecting budget goals -................................ +24.13.14.3 Selecting budget goals +................................. The budget report evaluates periodic transaction rules to generate special "goal transactions", which generate the goal amounts for each -account in each report subperiod. When troubleshooting, you can use the -print command to show these as forecasted transactions: +account in each report subperiod. When troubleshooting, you can use +‘print --forecast’ to show these as forecasted transactions: $ hledger print --forecast=BUDGETREPORTPERIOD tag:generated @@ -8097,11 +8138,59 @@ regular expression or query). This means you can give your periodic rules descriptions (remember that two spaces are needed), and then select from multiple budgets defined in your journal. + +File: hledger.info, Node: Budget vs forecast, Prev: Selecting budget goals, Up: Budget report + +24.13.14.4 Budget vs forecast +............................. + +‘hledger --forecast ...’ and ‘hledger balance --budget ...’ are separate +features, though both of them use the periodic transaction rules defined +in the journal, and both of them generate temporary transactions for +reporting purposes ("forecast transactions" and "budget goal +transactions", respectively). You can use both features at the same +time if you want. Here are some differences between them, as of hledger +1.29: + + CLI: + + • –forecast is a general hledger option, usable with any command + • –budget is a ‘balance’ command option, usable only with that + command. + + Visibility of generated transactions: + + • forecast transactions are visible in any report, like ordinary + transactions + • budget goal transactions are invisible except for the goal amounts + they produce in –budget reports. + + Periodic transaction rules: + + • –forecast uses all available periodic transaction rules + • –budget uses all periodic rules (‘--budget’) or a selected subset + (‘--budget=DESCPAT’) + + Period of generated transactions: + + • –forecast generates forecast transactions + • from after the last regular transaction to the end of the + report period (‘--forecast’) + • or, during a specified period (‘--forecast=PERIODEXPR’) + • possibly further restricted by a period specified in the + periodic transaction rule + • and always restricted within the bounds of the report period + + • –budget generates budget goal transactions + • throughout the report period + • possibly restricted by a period specified in the periodic + transaction rule. +  File: hledger.info, Node: Data layout, Next: Useful balance reports, Prev: Budget report, Up: balance -24.5.15 Data layout -------------------- +24.13.15 Data layout +-------------------- The ‘--layout’ option affects how balance reports show multi-commodity amounts and commodity symbols, which can improve readability. It can @@ -8235,8 +8324,8 @@ tidy Y  File: hledger.info, Node: Useful balance reports, Prev: Data layout, Up: balance -24.5.16 Useful balance reports ------------------------------- +24.13.16 Useful balance reports +------------------------------- Some frequently used ‘balance’ options/reports are: @@ -8275,11 +8364,12 @@ Some frequently used ‘balance’ options/reports are:  File: hledger.info, Node: balancesheet, Next: balancesheetequity, Prev: balance, Up: PART 4 COMMANDS -24.6 balancesheet -================= +24.14 balancesheet +================== -balancesheet, bs -This command displays a balance sheet, showing historical ending +(bs) + + This command displays a balance sheet, showing historical ending balances of asset and liability accounts. (To see equity as well, use the balancesheetequity command.) Amounts are shown with normal positive sign, as in conventional financial statements. @@ -8323,11 +8413,12 @@ options The output formats supported are ‘txt’, ‘csv’, ‘html’, and  File: hledger.info, Node: balancesheetequity, Next: cashflow, Prev: balancesheet, Up: PART 4 COMMANDS -24.7 balancesheetequity -======================= +24.15 balancesheetequity +======================== -balancesheetequity, bse -This command displays a balance sheet, showing historical ending +(bse) + + This command displays a balance sheet, showing historical ending balances of asset, liability and equity accounts. Amounts are shown with normal positive sign, as in conventional financial statements. @@ -8376,11 +8467,12 @@ options The output formats supported are ‘txt’, ‘csv’, ‘html’, and  File: hledger.info, Node: cashflow, Next: check, Prev: balancesheetequity, Up: PART 4 COMMANDS -24.8 cashflow -============= +24.16 cashflow +============== -cashflow, cf -This command displays a cashflow statement, showing the inflows and +(cf) + + This command displays a cashflow statement, showing the inflows and outflows affecting "cash" (ie, liquid, easily convertible) assets. Amounts are shown with normal positive sign, as in conventional financial statements. @@ -8428,10 +8520,9 @@ options The output formats supported are ‘txt’, ‘csv’, ‘html’, and  File: hledger.info, Node: check, Next: close, Prev: cashflow, Up: PART 4 COMMANDS -24.9 check -========== +24.17 check +=========== -check Check for various kinds of errors in your data. hledger provides a number of built-in error checks to help prevent @@ -8462,8 +8553,8 @@ run these checks, providing instant feedback as you edit the journal.  File: hledger.info, Node: Basic checks, Next: Strict checks, Up: check -24.9.1 Basic checks -------------------- +24.17.1 Basic checks +-------------------- These checks are always run automatically, by (almost) all hledger commands, including ‘check’: @@ -8481,8 +8572,8 @@ commands, including ‘check’:  File: hledger.info, Node: Strict checks, Next: Other checks, Prev: Basic checks, Up: check -24.9.2 Strict checks --------------------- +24.17.2 Strict checks +--------------------- These additional checks are run when the ‘-s’/‘--strict’ (strict mode) flag is used. Or, they can be run by giving their names as arguments to @@ -8499,8 +8590,8 @@ flag is used. Or, they can be run by giving their names as arguments to  File: hledger.info, Node: Other checks, Next: Custom checks, Prev: Strict checks, Up: check -24.9.3 Other checks -------------------- +24.17.3 Other checks +-------------------- These checks can be run only by giving their names as arguments to ‘check’. They are more specialised and not desirable for everyone, @@ -8513,13 +8604,15 @@ therefore optional: • *recentassertions* - all accounts with balance assertions have a balance assertion no more than 7 days before their latest posting + • *tags* - all tags used by transactions have been declared + • *uniqueleafnames* - all account leaf names are unique  File: hledger.info, Node: Custom checks, Next: More about specific checks, Prev: Other checks, Up: check -24.9.4 Custom checks --------------------- +24.17.4 Custom checks +--------------------- A few more checks are are available as separate add-on commands, in https://github.com/simonmichael/hledger/tree/master/bin: @@ -8536,8 +8629,8 @@ See: Cookbook -> Scripting.  File: hledger.info, Node: More about specific checks, Prev: Custom checks, Up: check -24.9.5 More about specific checks ---------------------------------- +24.17.5 More about specific checks +---------------------------------- ‘hledger check recentassertions’ will complain if any balance-asserted account does not have a balance assertion within 7 days before its @@ -8554,248 +8647,206 @@ assertions against real-world balances.  File: hledger.info, Node: close, Next: codes, Prev: check, Up: PART 4 COMMANDS -24.10 close +24.18 close =========== -close, equity -Prints a sample "closing" transaction bringing specified account -balances to zero, and an inverse "opening" transaction restoring the -same account balances. +‘close [--retain | --migrate | --open] [QUERY]’ - If like most people you split your journal files by time, eg by year: -at the end of the year you can use this command to "close out" your -asset and liability (and perhaps equity) balances in the old file, and -reinitialise them in the new file. This helps ensure that report -balances remain correct whether you are including old files or not. -(Because all closing/opening transactions except the very first will -cancel out - see example below.) + By default: prints a transaction that zeroes out ("closes") all +accounts, transferring their balances to an equity account. Query +arguments can be added to override the accounts selection. Three other +modes are supported: - Some people also use this command to close out revenue and expense -balances at the end of an accounting period. This properly records the -period’s profit/loss as "retained earnings" (part of equity), and allows -the accounting equation (A-L=E) to balance, which you could then check -by the bse report’s zero total. + ‘--retain’: prints a transaction closing revenue and expense +balances. This is traditionally done by businesses at the end of each +accounting period; it is less necessary in personal and computer-based +accounting, but it can help balance the accounting equation A=L+E. - You can print just the closing transaction by using the ‘--close’ -flag, or just the opening transaction with the ‘--open’ flag. + ‘--migrate’: prints a transaction to close asset, liability and most +equity balances, and another transaction to re-open them. This can be +useful when starting a new file (for performance or data protection). +Adding the closing transaction to the old file allows old and new files +to be combined. - Their descriptions are ‘closing balances’ and ‘opening balances’ by -default; you can customise these with the ‘--close-desc’ and -‘--open-desc’ options. + ‘--open’: as above, but prints just the opening transaction. This +can be useful for starting a new file, leaving the old file unchanged. +Similar to Ledger’s equity command. - Just one balancing equity posting is used by default, with the amount -left implicit. The default account name is ‘equity:opening/closing -balances’. You can customise the account name(s) with ‘--close-acct’ -and ‘--open-acct’. (If you specify only one of these, it will be used -for both.) + You can change the equity account name with ‘--close-acct ACCT’. It +defaults to ‘equity:retained earnings’ with ‘--retain’, or +‘equity:opening/closing balances’ otherwise. - With ‘--x/--explicit’, the equity posting’s amount will be shown -explicitly, and if it involves multiple commodities, there will be a -separate equity posting for each commodity (as in the print command). + You can change the transaction description(s) with ‘--close-desc +'DESC'’ and ‘--open-desc 'DESC'’. It defaults to ‘retain earnings’ with +‘--retain’, or ‘closing balances’ and ‘opening balances’ otherwise. + + Just one posting to the equity account will be used by default, with +an implicit amount. + + With ‘--x/--explicit’ the amount will be shown explicitly, and if it +involves multiple commodities, a separate posting will be generated for +each commodity. With ‘--interleaved’, each equity posting is shown next to the -posting it balances (good for troubleshooting). +corresponding source/destination posting. + + The default closing date is yesterday or the journal’s end date, +whichever is later. You can change this by specifying a report end +date; the last day of the report period will be the closing date. Eg +‘-e 2022’ means "close on 2022-12-31". + + The default closing date is yesterday, or the journal’s end date, +whichever is later. You can change this by specifying a report end +date; (The report start date does not matter.) The last day of the +report period will be the closing date; eg ‘-e 2022’ means "close on +2022-12-31". The opening date is always the day after the closing date. * Menu: * close and costs:: -* close date:: -* Example close asset/liability accounts for file transition:: -* Hiding opening/closing transactions:: * close and balance assertions:: -* Example close revenue/expense accounts to retained earnings:: +* Example retain earnings:: +* Example migrate balances to a new file:: +* Example excluding closing/opening transactions::  -File: hledger.info, Node: close and costs, Next: close date, Up: close +File: hledger.info, Node: close and costs, Next: close and balance assertions, Up: close -24.10.1 close and costs +24.18.1 close and costs ----------------------- -Costs are ignored (and discarded) by closing/opening transactions, by -default. With ‘--show-costs’, they are preserved; there will be a -separate equity posting for each cost in each commodity. This means -‘balance -B’ reports will look the same after the transition. Note if -you have many foreign currency or investment transactions, this will -generate very large journal entries. +With ‘--show-costs’, any amount costs are shown, with separate postings +for each cost. (This currently the best way to view investment assets, +showing lots and cost bases.) If you have many currency conversion or +investment transactions, it can generate very large journal entries.  -File: hledger.info, Node: close date, Next: Example close asset/liability accounts for file transition, Prev: close and costs, Up: close +File: hledger.info, Node: close and balance assertions, Next: Example retain earnings, Prev: close and costs, Up: close -24.10.2 close date ------------------- - -The default closing date is yesterday, or the journal’s end date, -whichever is later. - - Unless you are running ‘close’ on exactly the first day of the new -period, you’ll want to override the closing date. This is done by -specifying a report end date, where "last day of the report period" will -be the closing date. The opening date is always the following day. So -to close on (end of) 2020-12-31 and open on (start of) 2021-01-01, any -of these will work: - -end date explanation -argument --------------------------------------------------------------------------- -‘-e end dates are exclusive -2021-01-01’ -‘-e 2021’ equivalent, per smart dates -‘-p 2020’ equivalent, the period’s begin date is ignored -‘date:2020’ equivalent query - - -File: hledger.info, Node: Example close asset/liability accounts for file transition, Next: Hiding opening/closing transactions, Prev: close date, Up: close - -24.10.3 Example: close asset/liability accounts for file transition -------------------------------------------------------------------- - -Carrying asset/liability balances from 2020.journal into a new file for -2021: - -$ hledger close -f 2020.journal -p 2020 assets liabilities -# copy/paste the closing transaction to the end of 2020.journal -# copy/paste the opening transaction to the start of 2021.journal - - Or: - -$ hledger close -f 2020.journal -p 2020 assets liabilities --open >> 2021.journal # add 2021's first transaction -$ hledger close -f 2020.journal -p 2020 assets liabilities --close >> 2020.journal # add 2020's last transaction - - Now, - -$ hledger bs -f 2021.journal # just new file - balances correct -$ hledger bs -f 2020.journal -f 2021.journal # old and new files - balances correct -$ hledger bs -f 2020.journal # just old files - balances are zero ? - # (exclude final closing txn, see below) - - -File: hledger.info, Node: Hiding opening/closing transactions, Next: close and balance assertions, Prev: Example close asset/liability accounts for file transition, Up: close - -24.10.4 Hiding opening/closing transactions -------------------------------------------- - -Although the closing/opening transactions cancel out, they will be -visible in reports like ‘print’ and ‘register’, creating some visual -clutter. You can exclude them all with a query, like: - -$ hledger print not:desc:'opening|closing' # less typing -$ hledger print not:'equity:opening/closing balances' # more precise - - But when reporting on multiple files, this can get a bit tricky; you -may need to keep the earliest opening balances, for a historical -register report; or you may need to suppress a closing transaction, to -see year-end balances. If you find yourself needing more precise -queries, here’s one solution: add more easily-matched tags to -opening/closing transactions, like this: - -; 2019.journal -2019-01-01 opening balances ; earliest opening txn, no tag here -... -2019-12-31 closing balances ; clopen:2020 -... - -; 2020.journal -2020-01-01 opening balances ; clopen:2020 -... -2020-12-31 closing balances ; clopen:2021 -... - -; 2021.journal -2021-01-01 opening balances ; clopen:2021 -... - - Now with - -; all.journal -include 2019.journal -include 2020.journal -include 2021.journal - - you could do eg: - -$ hledger -f all.journal reg -H checking not:tag:clopen - # all years checking register, hiding non-essential opening/closing txns - -$ hledger -f all.journal bs -p 2020 not:tag:clopen=2020 - # 2020 year end balances, suppressing 2020 closing txn - - -File: hledger.info, Node: close and balance assertions, Next: Example close revenue/expense accounts to retained earnings, Prev: Hiding opening/closing transactions, Up: close - -24.10.5 close and balance assertions +24.18.2 close and balance assertions ------------------------------------ -The closing and opening transactions will include balance assertions, -verifying that the accounts have first been reset to zero and then -restored to their previous balance. These provide valuable error -checking, alerting you when things get out of line, but you can ignore -them temporarily with ‘-I’ or just remove them if you prefer. +Balance assertions will be generated, verifying that the accounts have +been reset to zero (and then restored to their previous balances, if +there is an opening transaction). - You probably shouldn’t use status or realness filters (like -C or -R -or ‘status:’) with ‘close’, or the generated balance assertions will -depend on these flags. Likewise, if you run this command with ‘--auto’, -the balance assertions would probably always require ‘--auto’. + These provide useful error checking, but you can ignore them +temporarily with ‘-I’, or remove them if you prefer. - Multi-day transactions (where some postings have a different date) -break the balance assertions, because the money is temporarily -"invisible" while in transit: + You probably should avoid filtering transactions by status or +realness (‘-C’, ‘-R’, ‘status:’), or generating postings (‘--auto’), +with this command, since the balance assertions would depend on these. -2020/12/30 a purchase made in december, cleared in the next year + Note custom posting dates spanning the file boundary will disrupt the +balance assertions: + +2023-12-30 a purchase made in december, cleared in january expenses:food 5 - assets:bank:checking -5 ; date: 2021/1/2 + assets:bank:checking -5 ; date: 2023-01-02 - To fix the assertions, you can add a temporary account to track such -in-transit money (splitting the multi-day transaction into two -single-day transactions): + To solve that you can transfer the money to and from a temporary +account, in effect splitting the multi-day transaction into two +single-day transactions: -; in 2020.journal: -2020/12/30 a purchase made in december, cleared in the next year +; in 2022.journal: +2022-12-30 a purchase made in december, cleared in january expenses:food 5 - liabilities:pending + equity:pending -5 -; in 2021.journal: -2021/1/2 clearance of last year's pending transactions - liabilities:pending 5 = 0 - assets:bank:checking +; in 2023.journal: +2023-01-02 last year's transaction cleared + equity:pending 5 = 0 + assets:bank:checking -5  -File: hledger.info, Node: Example close revenue/expense accounts to retained earnings, Prev: close and balance assertions, Up: close +File: hledger.info, Node: Example retain earnings, Next: Example migrate balances to a new file, Prev: close and balance assertions, Up: close -24.10.6 Example: close revenue/expense accounts to retained earnings --------------------------------------------------------------------- +24.18.3 Example: retain earnings +-------------------------------- -For this, use ‘--close’ to suppress the opening transaction, as it’s not -needed. Also you’ll want to change the equity account name to your -equivalent of "equity:retained earnings". +Record 2022’s revenues/expenses as retained earnings on 2022-12-31, +appending the generated transaction to the journal: - Closing 2021’s first quarter revenues/expenses: +$ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal -$ hledger close -f 2021.journal --close revenues expenses -p 2021Q1 \ - --close-acct='equity:retained earnings' >> 2021.journal + Now 2022’s income statement will show only zeroes. To see it again, +exclude the retain transaction. Eg: - The same, using the default journal and current year: +$ hledger -f 2022.journal is not:desc:'retain earnings' -$ hledger close --close revenues expenses -p Q1 \ - --close-acct='equity:retained earnings' >> $LEDGER_FILE + +File: hledger.info, Node: Example migrate balances to a new file, Next: Example excluding closing/opening transactions, Prev: Example retain earnings, Up: close - Now, the first quarter’s balance sheet should show a zero (unless you -are using @/@@ notation without equity postings): +24.18.4 Example: migrate balances to a new file +----------------------------------------------- -$ hledger bse -p Q1 +Close assets/liabilities/equity on 2022-12-31 and re-open them on +2023-01-01: - And we must suppress the closing transaction to see the first -quarter’s income statement (using the description; ‘not:'retained -earnings'’ won’t work here): +$ hledger close --migrate -f 2022.journal -p 2022 +# copy/paste the closing transaction to the end of 2022.journal +# copy/paste the opening transaction to the start of 2023.journal -$ hledger is -p Q1 not:desc:'closing balances' + Now 2022’s balance sheet will show only zeroes, indicating a balanced +accounting equation. (Unless you are using @/@@ notation - in that +case, try adding –infer-equity.) To see it again, exclude the closing +transaction. Eg: + +$ hledger -f 2022.journal bs not:desc:'closing balances' + + +File: hledger.info, Node: Example excluding closing/opening transactions, Prev: Example migrate balances to a new file, Up: close + +24.18.5 Example: excluding closing/opening transactions +------------------------------------------------------- + +When combining many files for multi-year reports, the closing/opening +transactions cause some noise in reports like ‘print’ and ‘register’. +You can exclude them as shown above, but ‘not:desc:...’ could be +fragile, and also you will need to avoid excluding the very first +opening transaction, which can be awkward. Here is a way to do it, +using tags: add ‘clopen:’ tags to all opening/closing balances +transactions except the first, like this: + +; 2021.journal +2021-06-01 first opening balances +... +2021-12-31 closing balances ; clopen:2022 +... + +; 2022.journal +2022-01-01 opening balances ; clopen:2022 +... +2022-12-31 closing balances ; clopen:2023 +... + +; 2023.journal +2023-01-01 opening balances ; clopen:2023 +... + + Now, assuming a combined journal like: + +; all.journal +include 2021.journal +include 2022.journal +include 2023.journal + + The ‘clopen:’ tag can exclude all but the first opening transaction. +To show a clean multi-year checking register: + +$ hledger -f all.journal areg checking not:tag:clopen + + And the year values allow more precision. To show 2022’s year-end +balance sheet: + +$ hledger -f all.journal bs -e2023 not:tag:clopen=2023  File: hledger.info, Node: codes, Next: commodities, Prev: close, Up: PART 4 COMMANDS -24.11 codes +24.19 codes =========== -codes List the codes seen in transactions, in the order parsed. This command prints the value of each transaction’s code field, in @@ -8841,19 +8892,17 @@ $ hledger codes -E  File: hledger.info, Node: commodities, Next: descriptions, Prev: codes, Up: PART 4 COMMANDS -24.12 commodities +24.20 commodities ================= -commodities List all commodity/currency symbols used or declared in the journal.  File: hledger.info, Node: descriptions, Next: diff, Prev: commodities, Up: PART 4 COMMANDS -24.13 descriptions +24.21 descriptions ================== -descriptions List the unique descriptions that appear in transactions. This command lists the unique descriptions that appear in @@ -8870,10 +8919,9 @@ Person A  File: hledger.info, Node: diff, Next: files, Prev: descriptions, Up: PART 4 COMMANDS -24.14 diff +24.22 diff ========== -diff Compares a particular account’s transactions in two input files. It shows any transactions to this account which are in one file but not in the other. @@ -8905,20 +8953,18 @@ These transactions are in the second file only:  File: hledger.info, Node: files, Next: help, Prev: diff, Up: PART 4 COMMANDS -24.15 files +24.23 files =========== -files List all files included in the journal. With a REGEX argument, only file names matching the regular expression (case sensitive) are shown.  File: hledger.info, Node: help, Next: import, Prev: files, Up: PART 4 COMMANDS -24.16 help +24.24 help ========== -help Show the hledger user manual in the terminal, with ‘info’, ‘man’, or a pager. With a TOPIC argument, open it at that topic if possible. TOPIC can be any heading in the manual, or a heading prefix, case insensitive. @@ -8943,10 +8989,9 @@ $ hledger help journal # show the journal topic in the hledger manual  File: hledger.info, Node: import, Next: incomestatement, Prev: help, Up: PART 4 COMMANDS -24.17 import +24.25 import ============ -import Read new transactions added to each FILE since last run, and add them to the journal. Or with –dry-run, just print the transactions that would be added. Or with –catchup, just mark all of the FILEs’ transactions as @@ -8976,7 +9021,7 @@ most common import source, and these docs focus on that case.  File: hledger.info, Node: Deduplication, Next: Import testing, Up: import -24.17.1 Deduplication +24.25.1 Deduplication --------------------- As a convenience ‘import’ does _deduplication_ while reading @@ -9020,7 +9065,7 @@ certain date.  File: hledger.info, Node: Import testing, Next: Importing balance assignments, Prev: Deduplication, Up: import -24.17.2 Import testing +24.25.2 Import testing ---------------------- With ‘--dry-run’, the transactions that will be imported are printed to @@ -9035,10 +9080,17 @@ $ hledger import --dry bank.csv | hledger -f- -I print unknown $ ls bank.csv* | entr bash -c 'echo ====; hledger import --dry bank.csv | hledger -f- -I print unknown' + Note: when importing from multiple files at once, it’s currently +possible for some .latest files to be updated successfully, while the +actual import fails because of a problem in one of the files, leaving +them out of sync (and causing some transactions to be missed). To +prevent this, do a –dry-run first and fix any problems before the real +import. +  File: hledger.info, Node: Importing balance assignments, Next: Commodity display styles, Prev: Import testing, Up: import -24.17.3 Importing balance assignments +24.25.3 Importing balance assignments ------------------------------------- Entries added by import will have their posting amounts made explicit @@ -9057,7 +9109,7 @@ please test it and send a pull request.)  File: hledger.info, Node: Commodity display styles, Prev: Importing balance assignments, Up: import -24.17.4 Commodity display styles +24.25.4 Commodity display styles -------------------------------- Imported amounts will be formatted according to the canonical commodity @@ -9066,13 +9118,14 @@ styles (declared or inferred) in the main journal file.  File: hledger.info, Node: incomestatement, Next: notes, Prev: import, Up: PART 4 COMMANDS -24.18 incomestatement +24.26 incomestatement ===================== -incomestatement, is -This command displays an income statement, showing revenues and expenses -during one or more periods. Amounts are shown with normal positive -sign, as in conventional financial statements. +(is) + + This command displays an income statement, showing revenues and +expenses during one or more periods. Amounts are shown with normal +positive sign, as in conventional financial statements. This report shows accounts declared with the ‘Revenue’ or ‘Expense’ type (see account types). Or if no such accounts are declared, it shows @@ -9115,10 +9168,9 @@ options The output formats supported are ‘txt’, ‘csv’, ‘html’, and  File: hledger.info, Node: notes, Next: payees, Prev: incomestatement, Up: PART 4 COMMANDS -24.19 notes +24.27 notes =========== -notes List the unique notes that appear in transactions. This command lists the unique notes that appear in transactions, in @@ -9135,10 +9187,9 @@ Snacks  File: hledger.info, Node: payees, Next: prices, Prev: notes, Up: PART 4 COMMANDS -24.20 payees +24.28 payees ============ -payees List the unique payee/payer names that appear in transactions. This command lists unique payee/payer names which have been declared @@ -9161,10 +9212,9 @@ Person A  File: hledger.info, Node: prices, Next: print, Prev: payees, Up: PART 4 COMMANDS -24.21 prices +24.29 prices ============ -prices Print market price directives from the journal. With –infer-market-prices, generate additional market prices from costs. With –infer-reverse-prices, also generate market prices by inverting @@ -9174,10 +9224,9 @@ displayed with their full precision.  File: hledger.info, Node: print, Next: register, Prev: prices, Up: PART 4 COMMANDS -24.22 print +24.30 print =========== -print Show transaction journal entries, sorted by date. The print command displays full journal entries (transactions) from @@ -9299,11 +9348,12 @@ $ hledger print -Ocsv  File: hledger.info, Node: register, Next: rewrite, Prev: print, Up: PART 4 COMMANDS -24.23 register +24.31 register ============== -register, reg -Show postings and their running total. +(reg) + + 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. @@ -9408,7 +9458,7 @@ no posting will be shown and the program exit code will be non-zero.  File: hledger.info, Node: Custom register output, Up: register -24.23.1 Custom register output +24.31.1 Custom register output ------------------------------ register uses the full terminal width by default, except on windows. @@ -9440,10 +9490,9 @@ options The output formats supported are ‘txt’, ‘csv’, and  File: hledger.info, Node: rewrite, Next: roi, Prev: register, Up: PART 4 COMMANDS -24.24 rewrite +24.32 rewrite ============= -rewrite Print all transactions, rewriting the postings of matched transactions. For now the only rewrite available is adding new postings, like print –auto. @@ -9494,7 +9543,7 @@ commodity.  File: hledger.info, Node: Re-write rules in a file, Next: Diff output format, Up: rewrite -24.24.1 Re-write rules in a file +24.32.1 Re-write rules in a file -------------------------------- During the run this tool will execute so called "Automated Transactions" @@ -9532,7 +9581,7 @@ postings.  File: hledger.info, Node: Diff output format, Next: rewrite vs print --auto, Prev: Re-write rules in a file, Up: rewrite -24.24.2 Diff output format +24.32.2 Diff output format -------------------------- To use this tool for batch modification of your journal files you may @@ -9573,7 +9622,7 @@ output from ‘hledger print’.  File: hledger.info, Node: rewrite vs print --auto, Prev: Diff output format, Up: rewrite -24.24.3 rewrite vs. print –auto +24.32.3 rewrite vs. print –auto ------------------------------- This command predates print –auto, and currently does much the same @@ -9593,10 +9642,9 @@ thing, but with these differences:  File: hledger.info, Node: roi, Next: stats, Prev: rewrite, Up: PART 4 COMMANDS -24.25 roi +24.33 roi ========= -roi Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on your investments. @@ -9642,7 +9690,7 @@ display, regardless of the length of reporting interval.  File: hledger.info, Node: Spaces and special characters in --inv and --pnl, Next: Semantics of --inv and --pnl, Up: roi -24.25.1 Spaces and special characters in ‘--inv’ and +24.33.1 Spaces and special characters in ‘--inv’ and ---------------------------------------------------- ‘--pnl’ Note that ‘--inv’ and ‘--pnl’’s argument is a query, and queries @@ -9661,7 +9709,7 @@ $ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'  File: hledger.info, Node: Semantics of --inv and --pnl, Next: IRR and TWR explained, Prev: Spaces and special characters in --inv and --pnl, Up: roi -24.25.2 Semantics of ‘--inv’ and ‘--pnl’ +24.33.2 Semantics of ‘--inv’ and ‘--pnl’ ---------------------------------------- Query supplied to ‘--inv’ has to match all transactions that are related @@ -9715,7 +9763,7 @@ postings in the example below would be classifed as:  File: hledger.info, Node: IRR and TWR explained, Prev: Semantics of --inv and --pnl, Up: roi -24.25.3 IRR and TWR explained +24.33.3 IRR and TWR explained ----------------------------- "ROI" stands for "return on investment". Traditionally this was @@ -9782,10 +9830,9 @@ your investment.  File: hledger.info, Node: stats, Next: tags, Prev: roi, Up: PART 4 COMMANDS -24.26 stats +24.34 stats =========== -stats Show journal and performance statistics. The stats command displays summary information for the whole journal, @@ -9823,10 +9870,9 @@ Throughput : 8342 txns/s  File: hledger.info, Node: tags, Next: test, Prev: stats, Up: PART 4 COMMANDS -24.27 tags +24.35 tags ========== -tags List the tags used in the journal, or their values. This command lists the tag names used in the journal, whether on @@ -9854,10 +9900,9 @@ transactions also acquire tags from their postings.  File: hledger.info, Node: test, Prev: tags, Up: PART 4 COMMANDS -24.28 test +24.36 test ========== -test Run built-in unit tests. This command runs the unit tests built in to hledger and hledger-lib, @@ -10331,570 +10376,584 @@ Node: Unicode characters14054 Ref: #unicode-characters14219 Node: Regular expressions15651 Ref: #regular-expressions15791 -Node: Environment17633 -Ref: #environment17744 -Node: Input19355 -Ref: #input19455 -Node: Data formats20018 -Ref: #data-formats20131 -Node: Multiple files21583 -Ref: #multiple-files21720 -Node: Strict mode22205 -Ref: #strict-mode22315 -Node: Commands23069 -Ref: #commands23170 -Node: Add-on commands23654 -Ref: #add-on-commands23756 -Node: Output24923 -Ref: #output25026 -Node: Output destination25142 -Ref: #output-destination25273 -Node: Output format25702 -Ref: #output-format25848 -Node: CSV output27420 -Ref: #csv-output27536 -Node: HTML output27641 -Ref: #html-output27779 -Node: JSON output27879 -Ref: #json-output28017 -Node: SQL output28949 -Ref: #sql-output29065 -Node: Commodity styles29588 -Ref: #commodity-styles29728 -Node: Colour30335 -Ref: #colour30453 -Node: Box-drawing30887 -Ref: #box-drawing31011 -Node: Debug output31325 -Ref: #debug-output31436 -Node: Limitations32111 -Ref: #limitations32231 -Node: Troubleshooting33006 -Ref: #troubleshooting33147 -Node: PART 2 DATA FORMATS35669 -Ref: #part-2-data-formats35816 -Node: Journal35816 -Ref: #journal35927 -Node: Journal cheatsheet36514 -Ref: #journal-cheatsheet36655 -Node: About journal format41104 -Ref: #about-journal-format41266 -Node: Comments42804 -Ref: #comments42936 -Node: Transactions43790 -Ref: #transactions43915 -Node: Dates44949 -Ref: #dates45058 -Node: Simple dates45103 -Ref: #simple-dates45221 -Node: Posting dates45758 -Ref: #posting-dates45878 -Node: Status46861 -Ref: #status46964 -Node: Code48716 -Ref: #code48821 -Node: Description49053 -Ref: #description49186 -Node: Payee and note49508 -Ref: #payee-and-note49616 -Node: Transaction comments49963 -Ref: #transaction-comments50118 -Node: Postings50489 -Ref: #postings50624 -Node: Account names51633 -Ref: #account-names51765 -Node: Amounts53467 -Ref: #amounts53584 -Node: Decimal marks digit group marks54573 -Ref: #decimal-marks-digit-group-marks54750 -Node: Commodity55774 -Ref: #commodity55963 -Node: Directives influencing number parsing and display56945 -Ref: #directives-influencing-number-parsing-and-display57206 -Node: Commodity display style57668 -Ref: #commodity-display-style57876 -Node: Rounding60087 -Ref: #rounding60207 -Node: Costs60508 -Ref: #costs60626 -Node: Other cost/lot notations62657 -Ref: #other-costlot-notations62791 -Node: Balance assertions65544 -Ref: #balance-assertions65697 -Node: Assertions and ordering66790 -Ref: #assertions-and-ordering66981 -Node: Assertions and multiple included files67683 -Ref: #assertions-and-multiple-included-files67945 -Node: Assertions and multiple -f files68453 -Ref: #assertions-and-multiple--f-files68706 -Node: Assertions and commodities69115 -Ref: #assertions-and-commodities69339 -Node: Assertions and prices70529 -Ref: #assertions-and-prices70737 -Node: Assertions and subaccounts71168 -Ref: #assertions-and-subaccounts71391 -Node: Assertions and virtual postings71733 -Ref: #assertions-and-virtual-postings71973 -Node: Assertions and auto postings72113 -Ref: #assertions-and-auto-postings72345 -Node: Assertions and precision73016 -Ref: #assertions-and-precision73200 -Node: Posting comments73467 -Ref: #posting-comments73615 -Node: Tags74000 -Ref: #tags74116 -Node: Tag values75321 -Ref: #tag-values75412 -Node: Directives76185 -Ref: #directives76305 -Node: Directive effects78173 -Ref: #directive-effects78329 -Node: Directives and multiple files81412 -Ref: #directives-and-multiple-files81592 -Node: Accounts82302 -Ref: #accounts82429 -Node: Account comments83849 -Ref: #account-comments83992 -Node: Account subdirectives84512 -Ref: #account-subdirectives84696 -Node: Account error checking84838 -Ref: #account-error-checking85029 -Node: Account display order86248 -Ref: #account-display-order86429 -Node: Account types87568 -Ref: #account-types87702 -Node: Account aliases91494 -Ref: #account-aliases91636 -Node: Basic aliases92686 -Ref: #basic-aliases92819 -Node: Regex aliases93573 -Ref: #regex-aliases93732 -Node: Combining aliases94626 -Ref: #combining-aliases94806 -Node: Aliases and multiple files96100 -Ref: #aliases-and-multiple-files96296 -Node: end aliases96881 -Ref: #end-aliases97076 -Node: Aliases can generate bad account names97225 -Ref: #aliases-can-generate-bad-account-names97465 -Node: Aliases and account types98062 -Ref: #aliases-and-account-types98256 -Node: Commodities98958 -Ref: #commodities99096 -Node: Commodity error checking101700 -Ref: #commodity-error-checking101840 -Node: Decimal mark102369 -Ref: #decimal-mark102507 -Node: Include files102908 -Ref: #include-files103050 -Node: Market prices103998 -Ref: #market-prices104134 -Node: Payees104913 -Ref: #payees105043 -Node: Periodic transactions105347 -Ref: #periodic-transactions105506 -Node: Periodic rule syntax107219 -Ref: #periodic-rule-syntax107399 -Node: Periodic rules and relative dates107874 -Ref: #periodic-rules-and-relative-dates108142 -Node: Two spaces between period expression and description!108681 -Ref: #two-spaces-between-period-expression-and-description108960 -Node: Other syntax109650 -Ref: #other-syntax109776 -Node: Auto postings110427 -Ref: #auto-postings110563 -Node: Auto postings and multiple files113059 -Ref: #auto-postings-and-multiple-files113261 -Node: Auto postings and dates113478 -Ref: #auto-postings-and-dates113750 -Node: Auto postings and transaction balancing / inferred amounts / balance assertions113925 -Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions114264 -Node: Auto posting tags114771 -Ref: #auto-posting-tags114984 -Node: Balance assignments115646 -Ref: #balance-assignments115826 -Node: Balance assignments and prices117160 -Ref: #balance-assignments-and-prices117330 -Node: Bracketed posting dates117541 -Ref: #bracketed-posting-dates117733 -Node: Default commodity118277 -Ref: #default-commodity118460 -Node: Default parent account120011 -Ref: #default-parent-account120193 -Node: Default year120902 -Ref: #default-year121062 -Node: Secondary dates121875 -Ref: #secondary-dates122032 -Node: Star comments122864 -Ref: #star-comments123026 -Node: Valuation expressions123566 -Ref: #valuation-expressions123745 -Node: Virtual postings123867 -Ref: #virtual-postings124048 -Node: Other Ledger directives125620 -Ref: #other-ledger-directives125785 -Node: CSV126355 -Ref: #csv126448 -Node: CSV rules cheatsheet128551 -Ref: #csv-rules-cheatsheet128683 -Node: separator130451 -Ref: #separator130582 -Node: skip131160 -Ref: #skip131272 -Node: date-format131855 -Ref: #date-format131980 -Node: timezone132726 -Ref: #timezone132853 -Node: newest-first133886 -Ref: #newest-first134028 -Node: intra-day-reversed134612 -Ref: #intra-day-reversed134770 -Node: decimal-mark135267 -Ref: #decimal-mark-1135412 -Node: fields list135751 -Ref: #fields-list135892 -Node: Field assignment137615 -Ref: #field-assignment137759 -Node: Field names138808 -Ref: #field-names138939 -Node: date field140160 -Ref: #date-field140278 -Node: date2 field140330 -Ref: #date2-field140471 -Node: status field140533 -Ref: #status-field140676 -Node: code field140731 -Ref: #code-field140876 -Node: description field140927 -Ref: #description-field141087 -Node: comment field141152 -Ref: #comment-field141307 -Node: account field141620 -Ref: #account-field141770 -Node: amount field142366 -Ref: #amount-field142515 -Node: currency field144620 -Ref: #currency-field144773 -Node: balance field145042 -Ref: #balance-field145174 -Node: if block145562 -Ref: #if-block145687 -Node: Matchers147111 -Ref: #matchers147225 -Node: if table148755 -Ref: #if-table148881 -Node: balance-type150317 -Ref: #balance-type150450 -Node: include151158 -Ref: #include151289 -Node: Working with CSV151739 -Ref: #working-with-csv151886 -Node: Rapid feedback152257 -Ref: #rapid-feedback152390 -Node: Valid CSV152846 -Ref: #valid-csv152992 -Node: File Extension153746 -Ref: #file-extension153919 -Node: Reading CSV from standard input154509 -Ref: #reading-csv-from-standard-input154733 -Node: Reading multiple CSV files154899 -Ref: #reading-multiple-csv-files155117 -Node: Valid transactions155366 -Ref: #valid-transactions155560 -Node: Deduplicating importing156188 -Ref: #deduplicating-importing156383 -Node: Setting amounts157429 -Ref: #setting-amounts157600 -Node: Amount signs160123 -Ref: #amount-signs160291 -Node: Setting currency/commodity161030 -Ref: #setting-currencycommodity161234 -Node: Amount decimal places162426 -Ref: #amount-decimal-places162632 -Node: Referencing other fields162950 -Ref: #referencing-other-fields163163 -Node: How CSV rules are evaluated164066 -Ref: #how-csv-rules-are-evaluated164283 -Node: Well factored rules165796 -Ref: #well-factored-rules165964 -Node: CSV rules examples166302 -Ref: #csv-rules-examples166437 -Node: Bank of Ireland166502 -Ref: #bank-of-ireland166639 -Node: Coinbase168107 -Ref: #coinbase168245 -Node: Amazon169298 -Ref: #amazon169423 -Node: Paypal171148 -Ref: #paypal171256 -Node: Timeclock178902 -Ref: #timeclock179007 -Node: Timedot181175 -Ref: #timedot181298 -Node: PART 3 REPORTING CONCEPTS186149 -Ref: #part-3-reporting-concepts186313 -Node: Time periods186313 -Ref: #time-periods186447 -Node: Report start & end date186545 -Ref: #report-start-end-date186697 -Node: Smart dates188446 -Ref: #smart-dates188599 -Node: Report intervals190521 -Ref: #report-intervals190679 -Node: Period expressions192500 -Ref: #period-expressions192642 -Node: Period expressions with a report interval194493 -Ref: #period-expressions-with-a-report-interval194727 -Node: More complex report intervals195882 -Ref: #more-complex-report-intervals196133 -Node: Intervals with custom start date196815 -Ref: #intervals-with-custom-start-date197049 -Node: Periods or dates ?198709 -Ref: #periods-or-dates198913 -Node: Events on multiple weekdays199369 -Ref: #events-on-multiple-weekdays199550 -Node: Depth200459 -Ref: #depth200561 -Node: Queries200881 -Ref: #queries200983 -Node: Query types201960 -Ref: #query-types202081 -Node: Combining query terms205421 -Ref: #combining-query-terms205598 -Node: Queries and command options206696 -Ref: #queries-and-command-options206901 -Node: Queries and account aliases207166 -Ref: #queries-and-account-aliases207371 -Node: Queries and valuation207503 -Ref: #queries-and-valuation207698 -Node: Querying with account aliases207937 -Ref: #querying-with-account-aliases208148 -Node: Querying with cost or value208290 -Ref: #querying-with-cost-or-value208467 -Node: Pivoting208776 -Ref: #pivoting208890 -Node: Generating data210378 -Ref: #generating-data210510 -Node: Forecasting211008 -Ref: #forecasting211133 -Node: Budgeting214020 -Ref: #budgeting214140 -Node: Cost reporting214411 -Ref: #cost-reporting214539 -Node: -B Convert to cost215654 -Ref: #b-convert-to-cost215810 -Node: Equity conversion postings217218 -Ref: #equity-conversion-postings217432 -Node: Inferring equity postings from cost218061 -Ref: #inferring-equity-postings-from-cost218310 -Node: Inferring cost from equity postings219284 -Ref: #inferring-cost-from-equity-postings219532 -Node: When to infer cost/equity221635 -Ref: #when-to-infer-costequity221853 -Node: How to record conversions222261 -Ref: #how-to-record-conversions222453 -Node: Conversion with implicit cost222744 -Ref: #conversion-with-implicit-cost222949 -Node: Conversion with explicit cost223854 -Ref: #conversion-with-explicit-cost224099 -Node: Conversion with equity postings224526 -Ref: #conversion-with-equity-postings224795 -Node: Conversion with equity postings and explicit cost225632 -Ref: #conversion-with-equity-postings-and-explicit-cost225899 -Node: Cost tips226522 -Ref: #cost-tips226648 -Node: Valuation227407 -Ref: #valuation227531 -Node: -V Value228317 -Ref: #v-value228443 -Node: -X Value in specified commodity228642 -Ref: #x-value-in-specified-commodity228837 -Node: Valuation date228994 -Ref: #valuation-date229165 -Node: Finding market price229604 -Ref: #finding-market-price229809 -Node: --infer-market-prices market prices from transactions230989 -Ref: #infer-market-prices-market-prices-from-transactions231267 -Node: Valuation commodity234113 -Ref: #valuation-commodity234326 -Node: Simple valuation examples235571 -Ref: #simple-valuation-examples235769 -Node: --value Flexible valuation236432 -Ref: #value-flexible-valuation236638 -Node: More valuation examples238324 -Ref: #more-valuation-examples238533 -Node: Interaction of valuation and queries240544 -Ref: #interaction-of-valuation-and-queries240785 -Node: Effect of valuation on reports241265 -Ref: #effect-of-valuation-on-reports241462 -Node: PART 4 COMMANDS249221 -Ref: #part-4-commands249364 -Node: accounts252096 -Ref: #accounts-1252203 -Node: activity254187 -Ref: #activity254306 -Node: add254689 -Ref: #add254799 -Node: aregister257664 -Ref: #aregister257785 -Node: aregister and custom posting dates260770 -Ref: #aregister-and-custom-posting-dates260936 -Node: balance261504 -Ref: #balance261630 -Node: balance features262638 -Ref: #balance-features262778 -Node: Simple balance report264908 -Ref: #simple-balance-report265093 -Node: Balance report line format266738 -Ref: #balance-report-line-format266940 -Node: Filtered balance report269190 -Ref: #filtered-balance-report269382 -Node: List or tree mode269709 -Ref: #list-or-tree-mode269877 -Node: Depth limiting271252 -Ref: #depth-limiting271418 -Node: Dropping top-level accounts272035 -Ref: #dropping-top-level-accounts272235 -Node: Showing declared accounts272549 -Ref: #showing-declared-accounts272748 -Node: Sorting by amount273289 -Ref: #sorting-by-amount273456 -Node: Percentages274146 -Ref: #percentages274305 -Node: Multi-period balance report274875 -Ref: #multi-period-balance-report275075 -Node: Balance change end balance277468 -Ref: #balance-change-end-balance277677 -Node: Balance report types279125 -Ref: #balance-report-types279306 -Node: Calculation type279822 -Ref: #calculation-type279977 -Node: Accumulation type280508 -Ref: #accumulation-type280688 -Node: Valuation type281616 -Ref: #valuation-type281804 -Node: Combining balance report types282871 -Ref: #combining-balance-report-types283065 -Node: Budget report284969 -Ref: #budget-report285121 -Node: Budget report start date290423 -Ref: #budget-report-start-date290601 -Node: Budgets and subaccounts291963 -Ref: #budgets-and-subaccounts292170 -Node: Selecting budget goals295656 -Ref: #selecting-budget-goals295828 -Node: Data layout296870 -Ref: #data-layout297020 -Node: Useful balance reports304961 -Ref: #useful-balance-reports305111 -Node: balancesheet306264 -Ref: #balancesheet306409 -Node: balancesheetequity307783 -Ref: #balancesheetequity307941 -Node: cashflow309398 -Ref: #cashflow309529 -Node: check311019 -Ref: #check311131 -Node: Basic checks311943 -Ref: #basic-checks312061 -Node: Strict checks312599 -Ref: #strict-checks312740 -Node: Other checks313181 -Ref: #other-checks313321 -Node: Custom checks313832 -Ref: #custom-checks313987 -Node: More about specific checks314408 -Ref: #more-about-specific-checks314568 -Node: close315300 -Ref: #close315411 -Node: close and costs317551 -Ref: #close-and-costs317677 -Node: close date318069 -Ref: #close-date318252 -Node: Example close asset/liability accounts for file transition319044 -Ref: #example-close-assetliability-accounts-for-file-transition319345 -Node: Hiding opening/closing transactions320204 -Ref: #hiding-openingclosing-transactions320475 -Node: close and balance assertions321862 -Ref: #close-and-balance-assertions322120 -Node: Example close revenue/expense accounts to retained earnings323496 -Ref: #example-close-revenueexpense-accounts-to-retained-earnings323774 -Node: codes324684 -Ref: #codes324801 -Node: commodities325683 -Ref: #commodities-1325819 -Node: descriptions325901 -Ref: #descriptions326038 -Node: diff326342 -Ref: #diff326457 -Node: files327508 -Ref: #files327617 -Node: help327764 -Ref: #help327873 -Node: import328868 -Ref: #import328991 -Node: Deduplication330106 -Ref: #deduplication330231 -Node: Import testing332153 -Ref: #import-testing332318 -Node: Importing balance assignments332810 -Ref: #importing-balance-assignments333016 -Node: Commodity display styles333673 -Ref: #commodity-display-styles333846 -Node: incomestatement333975 -Ref: #incomestatement334117 -Node: notes335495 -Ref: #notes335617 -Node: payees335985 -Ref: #payees-1336100 -Node: prices336632 -Ref: #prices336747 -Node: print337056 -Ref: #print337171 -Node: register342623 -Ref: #register342745 -Node: Custom register output347858 -Ref: #custom-register-output347989 -Node: rewrite349364 -Ref: #rewrite349482 -Node: Re-write rules in a file351402 -Ref: #re-write-rules-in-a-file351565 -Node: Diff output format352718 -Ref: #diff-output-format352901 -Node: rewrite vs print --auto354013 -Ref: #rewrite-vs.-print---auto354175 -Node: roi354749 -Ref: #roi354856 -Node: Spaces and special characters in --inv and --pnl356621 -Ref: #spaces-and-special-characters-in---inv-and---pnl356869 -Node: Semantics of --inv and --pnl357367 -Ref: #semantics-of---inv-and---pnl357614 -Node: IRR and TWR explained359492 -Ref: #irr-and-twr-explained359652 -Node: stats362764 -Ref: #stats362872 -Node: tags364275 -Ref: #tags-1364382 -Node: test365404 -Ref: #test365497 -Node: PART 5 COMMON TASKS366252 -Ref: #part-5-common-tasks366385 -Node: Getting help366659 -Ref: #getting-help366800 -Node: Constructing command lines367564 -Ref: #constructing-command-lines367765 -Node: Starting a journal file368446 -Ref: #starting-a-journal-file368653 -Node: Setting opening balances369851 -Ref: #setting-opening-balances370056 -Node: Recording transactions373209 -Ref: #recording-transactions373398 -Node: Reconciling373954 -Ref: #reconciling374106 -Node: Reporting376419 -Ref: #reporting376568 -Node: Migrating to a new file380557 -Ref: #migrating-to-a-new-file380714 +Node: Environment17645 +Ref: #environment17756 +Node: Input19367 +Ref: #input19467 +Node: Data formats20030 +Ref: #data-formats20143 +Node: Multiple files21595 +Ref: #multiple-files21732 +Node: Strict mode22217 +Ref: #strict-mode22327 +Node: Commands23081 +Ref: #commands23182 +Node: Add-on commands23666 +Ref: #add-on-commands23768 +Node: Output24935 +Ref: #output25038 +Node: Output destination25154 +Ref: #output-destination25285 +Node: Output format25714 +Ref: #output-format25860 +Node: CSV output27432 +Ref: #csv-output27548 +Node: HTML output27653 +Ref: #html-output27791 +Node: JSON output27891 +Ref: #json-output28029 +Node: SQL output28961 +Ref: #sql-output29077 +Node: Commodity styles29600 +Ref: #commodity-styles29740 +Node: Colour30347 +Ref: #colour30465 +Node: Box-drawing30899 +Ref: #box-drawing31023 +Node: Debug output31337 +Ref: #debug-output31448 +Node: Limitations32123 +Ref: #limitations32243 +Node: Troubleshooting33018 +Ref: #troubleshooting33159 +Node: PART 2 DATA FORMATS35681 +Ref: #part-2-data-formats35828 +Node: Journal35828 +Ref: #journal35939 +Node: Journal cheatsheet36582 +Ref: #journal-cheatsheet36723 +Node: About journal format40711 +Ref: #about-journal-format40873 +Node: Comments42411 +Ref: #comments42543 +Node: Transactions43397 +Ref: #transactions43522 +Node: Dates44556 +Ref: #dates44665 +Node: Simple dates44710 +Ref: #simple-dates44828 +Node: Posting dates45360 +Ref: #posting-dates45480 +Node: Status46463 +Ref: #status46566 +Node: Code48318 +Ref: #code48423 +Node: Description48655 +Ref: #description48788 +Node: Payee and note49110 +Ref: #payee-and-note49218 +Node: Transaction comments49565 +Ref: #transaction-comments49720 +Node: Postings50091 +Ref: #postings50226 +Node: Account names51235 +Ref: #account-names51367 +Node: Amounts53069 +Ref: #amounts53186 +Node: Decimal marks digit group marks54175 +Ref: #decimal-marks-digit-group-marks54352 +Node: Commodity55376 +Ref: #commodity55565 +Node: Directives influencing number parsing and display56547 +Ref: #directives-influencing-number-parsing-and-display56808 +Node: Commodity display style57270 +Ref: #commodity-display-style57478 +Node: Rounding59689 +Ref: #rounding59809 +Node: Costs60110 +Ref: #costs60228 +Node: Other cost/lot notations62259 +Ref: #other-costlot-notations62393 +Node: Balance assertions65146 +Ref: #balance-assertions65299 +Node: Assertions and ordering66392 +Ref: #assertions-and-ordering66583 +Node: Assertions and multiple included files67285 +Ref: #assertions-and-multiple-included-files67547 +Node: Assertions and multiple -f files68055 +Ref: #assertions-and-multiple--f-files68308 +Node: Assertions and commodities68717 +Ref: #assertions-and-commodities68941 +Node: Assertions and prices70131 +Ref: #assertions-and-prices70339 +Node: Assertions and subaccounts70770 +Ref: #assertions-and-subaccounts70993 +Node: Assertions and virtual postings71335 +Ref: #assertions-and-virtual-postings71575 +Node: Assertions and auto postings71715 +Ref: #assertions-and-auto-postings71947 +Node: Assertions and precision72618 +Ref: #assertions-and-precision72802 +Node: Posting comments73069 +Ref: #posting-comments73217 +Node: Tags73602 +Ref: #tags73718 +Node: Tag values74923 +Ref: #tag-values75014 +Node: Directives75787 +Ref: #directives75916 +Node: Directive effects77784 +Ref: #directive-effects77940 +Node: Directives and multiple files81023 +Ref: #directives-and-multiple-files81203 +Node: account directive81913 +Ref: #account-directive82075 +Node: Account comments83495 +Ref: #account-comments83647 +Node: Account subdirectives84167 +Ref: #account-subdirectives84360 +Node: Account error checking84502 +Ref: #account-error-checking84702 +Node: Account display order85921 +Ref: #account-display-order86111 +Node: Account types87250 +Ref: #account-types87393 +Node: alias directive91128 +Ref: #alias-directive91295 +Node: Basic aliases92355 +Ref: #basic-aliases92488 +Node: Regex aliases93242 +Ref: #regex-aliases93401 +Node: Combining aliases94295 +Ref: #combining-aliases94475 +Node: Aliases and multiple files95769 +Ref: #aliases-and-multiple-files95975 +Node: end aliases directive96560 +Ref: #end-aliases-directive96785 +Node: Aliases can generate bad account names96934 +Ref: #aliases-can-generate-bad-account-names97184 +Node: Aliases and account types97781 +Ref: #aliases-and-account-types97975 +Node: commodity directive98677 +Ref: #commodity-directive98857 +Node: Commodity error checking101461 +Ref: #commodity-error-checking101609 +Node: decimal-mark directive102138 +Ref: #decimal-mark-directive102326 +Node: include directive102727 +Ref: #include-directive102897 +Node: P directive103845 +Ref: #p-directive103996 +Node: payee directive104895 +Ref: #payee-directive105050 +Node: tag directive105370 +Ref: #tag-directive105531 +Node: Periodic transactions106003 +Ref: #periodic-transactions106169 +Node: Periodic rule syntax107907 +Ref: #periodic-rule-syntax108087 +Node: Periodic rules and relative dates108742 +Ref: #periodic-rules-and-relative-dates109010 +Node: Two spaces between period expression and description!109549 +Ref: #two-spaces-between-period-expression-and-description109828 +Node: Other syntax110518 +Ref: #other-syntax110644 +Node: Auto postings111289 +Ref: #auto-postings111425 +Node: Auto postings and multiple files113936 +Ref: #auto-postings-and-multiple-files114138 +Node: Auto postings and dates114355 +Ref: #auto-postings-and-dates114627 +Node: Auto postings and transaction balancing / inferred amounts / balance assertions114802 +Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions115141 +Node: Auto posting tags115648 +Ref: #auto-posting-tags115861 +Node: Balance assignments116523 +Ref: #balance-assignments116703 +Node: Balance assignments and prices118037 +Ref: #balance-assignments-and-prices118207 +Node: Bracketed posting dates118418 +Ref: #bracketed-posting-dates118604 +Node: D directive119148 +Ref: #d-directive119322 +Node: apply account directive120990 +Ref: #apply-account-directive121176 +Node: Y directive121875 +Ref: #y-directive122041 +Node: Secondary dates122885 +Ref: #secondary-dates123041 +Node: Star comments123873 +Ref: #star-comments124035 +Node: Valuation expressions124575 +Ref: #valuation-expressions124754 +Node: Virtual postings124876 +Ref: #virtual-postings125057 +Node: Other Ledger directives126629 +Ref: #other-ledger-directives126794 +Node: CSV127364 +Ref: #csv127457 +Node: CSV rules cheatsheet129560 +Ref: #csv-rules-cheatsheet129692 +Node: separator131460 +Ref: #separator131591 +Node: skip132169 +Ref: #skip132281 +Node: date-format132864 +Ref: #date-format132989 +Node: timezone133735 +Ref: #timezone133862 +Node: newest-first134895 +Ref: #newest-first135037 +Node: intra-day-reversed135621 +Ref: #intra-day-reversed135779 +Node: decimal-mark136276 +Ref: #decimal-mark136421 +Node: fields list136760 +Ref: #fields-list136901 +Node: Field assignment138624 +Ref: #field-assignment138768 +Node: Field names139817 +Ref: #field-names139948 +Node: date field141169 +Ref: #date-field141287 +Node: date2 field141339 +Ref: #date2-field141480 +Node: status field141542 +Ref: #status-field141685 +Node: code field141740 +Ref: #code-field141885 +Node: description field141936 +Ref: #description-field142096 +Node: comment field142161 +Ref: #comment-field142316 +Node: account field142629 +Ref: #account-field142779 +Node: amount field143375 +Ref: #amount-field143524 +Node: currency field145629 +Ref: #currency-field145782 +Node: balance field146051 +Ref: #balance-field146183 +Node: if block146571 +Ref: #if-block146696 +Node: Matchers148120 +Ref: #matchers148234 +Node: if table149764 +Ref: #if-table149890 +Node: balance-type151326 +Ref: #balance-type151459 +Node: include152167 +Ref: #include152298 +Node: Working with CSV152748 +Ref: #working-with-csv152895 +Node: Rapid feedback153266 +Ref: #rapid-feedback153399 +Node: Valid CSV153855 +Ref: #valid-csv154001 +Node: File Extension154755 +Ref: #file-extension154928 +Node: Reading CSV from standard input155518 +Ref: #reading-csv-from-standard-input155742 +Node: Reading multiple CSV files155908 +Ref: #reading-multiple-csv-files156126 +Node: Valid transactions156375 +Ref: #valid-transactions156569 +Node: Deduplicating importing157197 +Ref: #deduplicating-importing157392 +Node: Setting amounts158438 +Ref: #setting-amounts158609 +Node: Amount signs161132 +Ref: #amount-signs161300 +Node: Setting currency/commodity162039 +Ref: #setting-currencycommodity162243 +Node: Amount decimal places163435 +Ref: #amount-decimal-places163641 +Node: Referencing other fields163959 +Ref: #referencing-other-fields164172 +Node: How CSV rules are evaluated165075 +Ref: #how-csv-rules-are-evaluated165292 +Node: Well factored rules166805 +Ref: #well-factored-rules166973 +Node: CSV rules examples167311 +Ref: #csv-rules-examples167446 +Node: Bank of Ireland167511 +Ref: #bank-of-ireland167648 +Node: Coinbase169116 +Ref: #coinbase169254 +Node: Amazon170307 +Ref: #amazon170432 +Node: Paypal172157 +Ref: #paypal172265 +Node: Timeclock179911 +Ref: #timeclock180016 +Node: Timedot182184 +Ref: #timedot182307 +Node: PART 3 REPORTING CONCEPTS187158 +Ref: #part-3-reporting-concepts187322 +Node: Time periods187322 +Ref: #time-periods187456 +Node: Report start & end date187574 +Ref: #report-start-end-date187726 +Node: Smart dates189459 +Ref: #smart-dates189612 +Node: Report intervals191572 +Ref: #report-intervals191727 +Node: Date adjustment192179 +Ref: #date-adjustment192339 +Node: Period expressions193671 +Ref: #period-expressions193812 +Node: Period expressions with a report interval195648 +Ref: #period-expressions-with-a-report-interval195882 +Node: More complex report intervals196112 +Ref: #more-complex-report-intervals196357 +Node: Multiple weekday intervals198286 +Ref: #multiple-weekday-intervals198475 +Node: Depth199339 +Ref: #depth199441 +Node: Queries199761 +Ref: #queries199863 +Node: Query types200808 +Ref: #query-types200929 +Node: Combining query terms204269 +Ref: #combining-query-terms204446 +Node: Queries and command options205544 +Ref: #queries-and-command-options205743 +Node: Queries and valuation206008 +Ref: #queries-and-valuation206203 +Node: Querying with account aliases206442 +Ref: #querying-with-account-aliases206653 +Node: Querying with cost or value206795 +Ref: #querying-with-cost-or-value206972 +Node: Pivoting207281 +Ref: #pivoting207395 +Node: Generating data208883 +Ref: #generating-data209015 +Node: Forecasting209513 +Ref: #forecasting209638 +Node: Budgeting212525 +Ref: #budgeting212645 +Node: Cost reporting212916 +Ref: #cost-reporting213044 +Node: -B Convert to cost214159 +Ref: #b-convert-to-cost214315 +Node: Equity conversion postings215723 +Ref: #equity-conversion-postings215937 +Node: Inferring equity postings from cost216832 +Ref: #inferring-equity-postings-from-cost217081 +Node: Inferring cost from equity postings217900 +Ref: #inferring-cost-from-equity-postings218148 +Node: When to infer cost/equity219957 +Ref: #when-to-infer-costequity220175 +Node: How to record conversions220583 +Ref: #how-to-record-conversions220775 +Node: Conversion with implicit cost221066 +Ref: #conversion-with-implicit-cost221271 +Node: Conversion with explicit cost222176 +Ref: #conversion-with-explicit-cost222421 +Node: Conversion with equity postings222848 +Ref: #conversion-with-equity-postings223117 +Node: Conversion with equity postings and explicit cost223954 +Ref: #conversion-with-equity-postings-and-explicit-cost224221 +Node: Cost tips224695 +Ref: #cost-tips224821 +Node: Valuation225557 +Ref: #valuation225681 +Node: -V Value226467 +Ref: #v-value226593 +Node: -X Value in specified commodity226792 +Ref: #x-value-in-specified-commodity226987 +Node: Valuation date227144 +Ref: #valuation-date227315 +Node: Finding market price227754 +Ref: #finding-market-price227959 +Node: --infer-market-prices market prices from transactions229139 +Ref: #infer-market-prices-market-prices-from-transactions229417 +Node: Valuation commodity232263 +Ref: #valuation-commodity232476 +Node: Simple valuation examples233721 +Ref: #simple-valuation-examples233919 +Node: --value Flexible valuation234582 +Ref: #value-flexible-valuation234788 +Node: More valuation examples236474 +Ref: #more-valuation-examples236683 +Node: Interaction of valuation and queries238694 +Ref: #interaction-of-valuation-and-queries238935 +Node: Effect of valuation on reports239415 +Ref: #effect-of-valuation-on-reports239612 +Node: PART 4 COMMANDS247371 +Ref: #part-4-commands247514 +Node: DATA ENTRY248031 +Ref: #data-entry248149 +Node: DATA CREATION248349 +Ref: #data-creation248497 +Node: DATA MANAGEMENT248620 +Ref: #data-management248779 +Node: REPORTS FINANCIAL248904 +Ref: #reports-financial249073 +Node: REPORTS VERSATILE249388 +Ref: #reports-versatile249555 +Node: REPORTS BASIC249816 +Ref: #reports-basic249962 +Node: HELP250522 +Ref: #help250638 +Node: ADD-ONS250698 +Ref: #add-ons250815 +Node: accounts251430 +Ref: #accounts251553 +Node: activity253528 +Ref: #activity253649 +Node: add254023 +Ref: #add254135 +Node: aregister256996 +Ref: #aregister257119 +Node: aregister and custom posting dates260095 +Ref: #aregister-and-custom-posting-dates260263 +Node: balance260831 +Ref: #balance260959 +Node: balance features261964 +Ref: #balance-features262106 +Node: Simple balance report264236 +Ref: #simple-balance-report264423 +Node: Balance report line format266068 +Ref: #balance-report-line-format266272 +Node: Filtered balance report268522 +Ref: #filtered-balance-report268716 +Node: List or tree mode269043 +Ref: #list-or-tree-mode269213 +Node: Depth limiting270588 +Ref: #depth-limiting270756 +Node: Dropping top-level accounts271373 +Ref: #dropping-top-level-accounts271575 +Node: Showing declared accounts271889 +Ref: #showing-declared-accounts272090 +Node: Sorting by amount272631 +Ref: #sorting-by-amount272800 +Node: Percentages273490 +Ref: #percentages273651 +Node: Multi-period balance report274221 +Ref: #multi-period-balance-report274423 +Node: Balance change end balance276816 +Ref: #balance-change-end-balance277027 +Node: Balance report types278475 +Ref: #balance-report-types278658 +Node: Calculation type279174 +Ref: #calculation-type279331 +Node: Accumulation type279862 +Ref: #accumulation-type280044 +Node: Valuation type280972 +Ref: #valuation-type281162 +Node: Combining balance report types282229 +Ref: #combining-balance-report-types282425 +Node: Budget report284329 +Ref: #budget-report284483 +Node: Budget report start date290217 +Ref: #budget-report-start-date290397 +Node: Budgets and subaccounts291759 +Ref: #budgets-and-subaccounts291968 +Node: Selecting budget goals295454 +Ref: #selecting-budget-goals295655 +Node: Budget vs forecast296702 +Ref: #budget-vs-forecast296863 +Node: Data layout298563 +Ref: #data-layout298715 +Node: Useful balance reports306656 +Ref: #useful-balance-reports306808 +Node: balancesheet307961 +Ref: #balancesheet308108 +Node: balancesheetequity309474 +Ref: #balancesheetequity309634 +Node: cashflow311077 +Ref: #cashflow311210 +Node: check312696 +Ref: #check312810 +Node: Basic checks313616 +Ref: #basic-checks313736 +Node: Strict checks314274 +Ref: #strict-checks314417 +Node: Other checks314858 +Ref: #other-checks315000 +Node: Custom checks315577 +Ref: #custom-checks315734 +Node: More about specific checks316155 +Ref: #more-about-specific-checks316317 +Node: close317049 +Ref: #close317160 +Node: close and costs319798 +Ref: #close-and-costs319942 +Node: close and balance assertions320231 +Ref: #close-and-balance-assertions320433 +Node: Example retain earnings321604 +Ref: #example-retain-earnings321821 +Node: Example migrate balances to a new file322179 +Ref: #example-migrate-balances-to-a-new-file322444 +Node: Example excluding closing/opening transactions322997 +Ref: #example-excluding-closingopening-transactions323246 +Node: codes324424 +Ref: #codes324541 +Node: commodities325417 +Ref: #commodities325553 +Node: descriptions325623 +Ref: #descriptions325760 +Node: diff326051 +Ref: #diff326166 +Node: files327212 +Ref: #files327321 +Node: help327462 +Ref: #help-1327571 +Node: import328561 +Ref: #import328684 +Node: Deduplication329792 +Ref: #deduplication329917 +Node: Import testing331839 +Ref: #import-testing332004 +Node: Importing balance assignments332855 +Ref: #importing-balance-assignments333061 +Node: Commodity display styles333718 +Ref: #commodity-display-styles333891 +Node: incomestatement334020 +Ref: #incomestatement334162 +Node: notes335529 +Ref: #notes335651 +Node: payees336013 +Ref: #payees336128 +Node: prices336653 +Ref: #prices336768 +Node: print337070 +Ref: #print337185 +Node: register342631 +Ref: #register342753 +Node: Custom register output347862 +Ref: #custom-register-output347993 +Node: rewrite349368 +Ref: #rewrite349486 +Node: Re-write rules in a file351398 +Ref: #re-write-rules-in-a-file351561 +Node: Diff output format352714 +Ref: #diff-output-format352897 +Node: rewrite vs print --auto354009 +Ref: #rewrite-vs.-print---auto354171 +Node: roi354745 +Ref: #roi354852 +Node: Spaces and special characters in --inv and --pnl356613 +Ref: #spaces-and-special-characters-in---inv-and---pnl356861 +Node: Semantics of --inv and --pnl357359 +Ref: #semantics-of---inv-and---pnl357606 +Node: IRR and TWR explained359484 +Ref: #irr-and-twr-explained359644 +Node: stats362756 +Ref: #stats362864 +Node: tags364261 +Ref: #tags-1364368 +Node: test365385 +Ref: #test365478 +Node: PART 5 COMMON TASKS366228 +Ref: #part-5-common-tasks366361 +Node: Getting help366635 +Ref: #getting-help366776 +Node: Constructing command lines367540 +Ref: #constructing-command-lines367741 +Node: Starting a journal file368422 +Ref: #starting-a-journal-file368629 +Node: Setting opening balances369827 +Ref: #setting-opening-balances370032 +Node: Recording transactions373185 +Ref: #recording-transactions373374 +Node: Reconciling373930 +Ref: #reconciling374082 +Node: Reporting376395 +Ref: #reporting376544 +Node: Migrating to a new file380533 +Ref: #migrating-to-a-new-file380690  End Tag Table diff --git a/hledger/hledger.txt b/hledger/hledger.txt index 5a679e1e4..33e22bc26 100644 --- a/hledger/hledger.txt +++ b/hledger/hledger.txt @@ -387,8 +387,8 @@ Options o CSV rules conditional blocks: if REGEX ... - o account alias directives and options: alias /REGEX/ = REPLACEMENT, - --alias /REGEX/=REPLACEMENT + o account alias directive and --alias option: alias /REGEX/ = REPLACE- + MENT, --alias /REGEX/=REPLACEMENT hledger's regular expressions come from the regex-tdfa library. If they're not doing what you expect, it's important to know exactly what @@ -627,7 +627,7 @@ Output - txt csv html json sql -------------------------------------------------------------------------------------- - aregister Y Y Y + aregister Y Y Y Y balance Y 1 Y 1 Y 1,2 Y balancesheet Y 1 Y 1 Y 1 Y balancesheetequity Y 1 Y 1 Y 1 Y @@ -902,14 +902,7 @@ Journal expenses:tax:us:2021 $500 ; plus means added to this account (debit) ; revenue/expense categories are also "accounts" - 2022-01-01 Whole Foods | payee name and description can be separated by a pipe char - ; Transaction or posting comments can contain searchable tags, - ; written NAME: or NAME:VALUE (value ends at comma or end of line). - ; Here's tag1:with a value, and an empty tag2: - ; A few tags have special meaning. A "date:" tag on a posting adjusts its date. - assets:checking $-50 ; date:2022-01-03, checking cleared two days later - expenses:food - + Kv 2022-01-01 ; The description is optional. ; Any currency/commodity symbols are allowed, on either side. assets:cash:wallet GBP -10 @@ -1029,9 +1022,9 @@ Journal 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: - 2010-01-31, 2010/01/31, 2010.1.31, 1/31. + rent transaction, the default year set with a Y directive, or the cur- + rent 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 dates documented in the hledger manual.) @@ -1737,7 +1730,6 @@ Journal GENERATING DATA: Generate recurring transactions or budget ~ goals - Generate extra postings on transactions = CHECKING FOR ERRORS: Define valid entities to provide more error account, commodity, payee @@ -1752,6 +1744,8 @@ Journal entries (transactions) it affects: + + direc- what it does ends tive at file @@ -1817,7 +1811,7 @@ Journal It can be surprising though; for example, it means that alias direc- tives do not affect parent or sibling files (see below). - Accounts + account directive account directives can be used to declare accounts (ie, the places that amounts are transferred from and to). Though not required, these dec- larations can provide several benefits: @@ -1986,8 +1980,7 @@ Journal o The rules for inferring types from account names are as follows. These are just a convenience that sometimes help new users get going; if they don't work for you, just ignore them and declare your account - types. See also Regular expressions. Note the Cash regexp changed - in hledger 1.24.99.2. + types. See also Regular expressions. If account's name contains this (CI) regular expression: | its type is: --------------------------------------------------------------------|------------- @@ -1999,25 +1992,25 @@ Journal ^(income|revenue)s?(:|$) | Revenue ^expenses?(:|$) | Expense - o If you declare any account types, it's a good idea to declare an - account for all of the account types, because a mixture of declared + o If you declare any account types, it's a good idea to declare an + account for all of the account types, because a mixture of declared and name-inferred types can disrupt certain reports. - o Certain uses of account aliases can disrupt account types. See + o Certain uses of account aliases can disrupt account types. See Rewriting accounts > Aliases and account types. o As mentioned above, subaccounts will inherit a type from their parent - account. More precisely, an account's type is decided by the first + account. More precisely, an account's type is decided by the first of these that exists: 1. A type: declaration for this account. - 2. A type: declaration in the parent accounts above it, preferring + 2. A type: declaration in the parent accounts above it, preferring the nearest. 3. An account type inferred from this account's name. - 4. An account type inferred from a parent account's name, preferring + 4. An account type inferred from a parent account's name, preferring the nearest parent. 5. Otherwise, it will have no type. @@ -2026,7 +2019,7 @@ Journal $ hledger accounts --types [ACCTPAT] [-DEPTH] [type:TYPECODES] - Account aliases + alias directive You can define account alias rules which rewrite your account names, or parts of them, before generating reports. This can be useful for: @@ -2043,7 +2036,7 @@ Journal 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. Account aliases are very powerful. They are generally easy to use cor- @@ -2053,9 +2046,9 @@ Journal 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 - included files (but note: not sibling or parent files). The spaces + 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 (but note: not sibling or parent files). The spaces around the = are optional: alias OLD = NEW @@ -2063,17 +2056,17 @@ Journal 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 - replace any occurrence of the old account name with the new one. Sub- + OLD and NEW are case sensitive full account names. hledger will + replace any occurrence of the old account name with the new one. Sub- accounts 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, - indicated by wrapping the pattern in forward slashes. (This is the - only place where hledger requires forward slashes around a regular + There is also a more powerful variant that uses a regular expression, + indicated by wrapping the pattern in forward slashes. (This is the + only place where hledger requires forward slashes around a regular expression.) Eg: @@ -2084,13 +2077,13 @@ Journal $ hledger --alias '/REGEX/=REPLACEMENT' ... - Any part of an account name matched by REGEX will be replaced by + Any part of an account name matched by REGEX will be replaced by REPLACEMENT. REGEX is case-insensitive as usual. - If you need to match a forward slash, escape it with a backslash, eg + If you need to match a forward slash, escape it with a backslash, eg /\/=:. - If REGEX contains parenthesised match groups, these can be referenced + If REGEX contains parenthesised match groups, these can be referenced by the usual backslash and number in REPLACEMENT: alias /^(.+):bank:([^:]+):(.*)/ = \1:\2 \3 @@ -2100,21 +2093,21 @@ Journal option argument), so it can contain trailing whitespace. 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: @@ -2125,15 +2118,15 @@ Journal 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 @@ -2159,14 +2152,14 @@ Journal include c.journal ; also affected - end aliases + end aliases directive You can clear (forget) all currently defined aliases (seen in the jour- nal so far, or defined on the command line) with this directive: end aliases Aliases can generate bad account names - Be aware that account aliases can produce malformed account names, + Be aware that account aliases can produce malformed account names, which could cause confusing reports or invalid print output. For exam- ple, you could erase all account names: @@ -2178,8 +2171,8 @@ Journal 2021-01-01 1 - The above print output is not a valid journal. Or you could insert an - illegal double space, causing print output that would give a different + The above print output is not a valid journal. Or you could insert an + illegal double space, causing print output that would give a different journal when reparsed: 2021-01-01 @@ -2193,48 +2186,48 @@ Journal Aliases and account types If an account with a type declaration (see Declaring accounts > Account - types) is renamed by an alias, normally the account type remains in + types) is renamed by an alias, normally the account type remains in effect. - However, renaming in a way that reshapes the account tree (eg renaming - parent accounts but not their children, or vice versa) could prevent + However, renaming in a way that reshapes the account tree (eg renaming + parent accounts but not their children, or vice versa) could prevent child accounts from inheriting the account type of their parents. - Secondly, if an account's type is being inferred from its name, renam- + Secondly, if an account's type is being inferred from its name, renam- ing it by an alias could prevent or alter that. - If you are using account aliases and the type: query is not matching - accounts as you expect, try troubleshooting with the accounts command, + If you are using account aliases and the type: query is not matching + accounts as you expect, try troubleshooting with the accounts command, eg something like: $ hledger accounts --alias assets=bassetts type:a - Commodities - You can use commodity directives to declare your commodities. In fact + commodity directive + You can use commodity directives to declare your commodities. In fact the commodity directive performs several functions at once: - 1. It declares commodities which may be used in the journal. This can - optionally be enforced, providing useful error checking. (Cf Com- + 1. It declares commodities which may be used in the journal. This can + optionally be enforced, providing useful error checking. (Cf Com- modity error checking) - 2. It declares which 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 + 2. It declares which 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. (Cf Amounts) - 3. It declares how to render the commodity's amounts when displaying + 3. It declares how to render the commodity's amounts when displaying output - the decimal mark, any digit group marks, the number of dec- - imal places, symbol placement and so on. (Cf Commodity display + imal places, symbol placement and so on. (Cf Commodity display style) - You will run into one of the problems solved by commodity directives + You will run into one of the problems solved by commodity directives sooner or later, so we recommend using them, for robust and predictable parsing and display. - Generally you should put them at the top of your journal file (since + Generally you should put them at the top of your journal file (since for function 2, they affect only following amounts, cf #793). - A commodity directive is just the word commodity followed by a sample + A commodity directive is just the word commodity followed by a sample amount, like this: ;commodity SAMPLEAMOUNT @@ -2242,8 +2235,8 @@ Journal commodity $1000.00 commodity 1,000.0000 AAAA ; optional same-line comment - It may also be written on multiple lines, and use the format subdirec- - tive, as in Ledger. Note in this case the commodity symbol appears + It may also be written on multiple lines, and use the format subdirec- + tive, as in Ledger. Note in this case the commodity symbol appears twice; it must be the same in both places: ;commodity SYMBOL @@ -2257,11 +2250,11 @@ Journal Other indented subdirectives are currently ignored. - Remember that if the commodity symbol contains spaces, numbers, or + Remember that if the commodity symbol contains spaces, numbers, or punctuation, it must be enclosed in double quotes (cf Commodity). - The amount's quantity does not matter; only the format is significant. - It must include a decimal mark - either a period or a comma - followed + The amount's quantity does not matter; only the format is significant. + It must include a decimal mark - either a period or a comma - followed by 0 or more decimal digits. A few more examples: @@ -2272,24 +2265,24 @@ Journal commodity INR 9,99,99,999.0 commodity 1 000 000. - 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.) - Even in the presence of commodity directives, the commodity display + Even in the presence of commodity directives, the commodity display style can still be overridden by supplying a command line option. 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. - Note, this disallows amounts without a commodity symbol, because cur- + Note, this disallows amounts without a commodity symbol, because cur- rently it's not possible (?) to declare the "no-symbol" commodity with - a directive. This is one exception for convenience: zero amounts are + a directive. This is one exception for convenience: zero amounts are always allowed to have no commodity symbol. - Decimal mark + decimal-mark directive You can use a decimal-mark directive - usually one per file, at the top of the file - to declare which character represents a decimal mark when parsing amounts in this file. It can look like @@ -2300,20 +2293,20 @@ Journal decimal-mark , - This prevents any ambiguity when parsing numbers in the file, so we - recommend it, especially if the file contains digit group marks (eg + This prevents any ambiguity when parsing numbers in the file, so we + recommend it, especially if the file contains digit group marks (eg thousands separators). - Include files - You can pull in the content of additional files by writing an include + include directive + 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. @@ -2321,20 +2314,21 @@ Journal The path may contain glob patterns to match multiple files, eg: include *.journal. - There is limited support for recursive wildcards: **/ (the slash is - required) matches 0 or more subdirectories. It's not super convenient - since you have to avoid include cycles and including directories, but + There is limited support for recursive wildcards: **/ (the slash is + required) 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): + ing the file extension (as described in hledger.1 -> Input files): include timedot:~/notes/2020*.md. - Market prices - The P directive declares a market price, which is a conversion rate - between two commodities on a certain date. These are often obtained - from a stock exchange, cryptocurrency exchange, or the foreign exchange - market. + P directive + The P directive declares a market price, which is a conversion rate + between two commodities on a certain date. This allows value reports + to convert amounts of one commodity to their value in another, on or + after that date. These prices are often obtained from a stock + exchange, cryptocurrency exchange, the or foreign exchange market. The format is: @@ -2355,20 +2349,37 @@ Journal values in another commodity. See Valuation. - Payees - The payee directive can be used to declare a limited set of payees - which may appear in transaction descriptions. The "payees" check will - report an error if any transaction refers to a payee that has not been - declared. Eg: + payee directive + payee PAYEE NAME + + This directive can be used to declare a limited set of payees which may + appear in transaction descriptions. The "payees" check will report an + error if any transaction refers to a payee that has not been declared. + Eg: payee Whole Foods Any indented subdirectives are currently ignored. + tag directive + tag TAGNAME + + This directive can be used to declare a limited set of tag names + allowed in tags. TAGNAME should be a valid tag name (no spaces). Eg: + + tag item-id + + Any indented subdirectives are currently ignored. + + The "tags" check will report an error if any undeclared tag name is + used. It is quite easy to accidentally create a tag through normal use + of colons in comments(#comments]; if you want to prevent this, you can + declare and check your tags . + Periodic transactions - Periodic transaction rules describe transactions that recur. They - allow hledger to generate temporary future transactions (visible only - in reports) to help with forecasting or budgeting. + The ~ directive declares recurring transactions. Such directives allow + hledger to generate temporary future transactions (visible in reports, + not in the journal file) to help with forecasting or budgeting. Periodic transactions can be a little tricky, so before you use them, read this whole section, or at least these tips: @@ -2406,18 +2417,25 @@ Journal date replaced by a tilde (~) followed by a period expression (mnemonic: ~ looks like a recurring sine wave.): + # every first of month ~ monthly 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 - 2018/1/1 is valid, but monthly from 2018/1/15 is not. + # every 15th of month in 2023's first quarter: + ~ monthly from 2023-04-15 to 2023-06-16 + expenses:utilities $400 + assets:bank:checking + + The period expression is the same syntax used for specifying multi- + period reports, just interpreted differently; there, it specifies + report periods; here it specifies recurrence dates (the periods' start + dates). Periodic rules and relative dates - Partial or relative dates (like 12/31, 25, tomorrow, last week, next - quarter) are usually not recommended in periodic rules, since the - results will change as time passes. If used, they will be interpreted + Partial or relative dates (like 12/31, 25, tomorrow, last week, next + quarter) are usually not recommended in periodic rules, since the + results will change as time passes. If used, they will be interpreted relative to, in order of preference: 1. the first day of the default year specified by a recent Y directive @@ -2426,11 +2444,11 @@ Journal 3. or the date on which you are running the report. - They will not be affected at all by report period or forecast period + They will not be affected at all by report period or forecast period dates. 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: @@ -2444,24 +2462,24 @@ Journal 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 + o Don't accidentally write two spaces in the middle of your period expression. Other syntax - hledger journal format supports quite a few other features, mainly to - make interoperating with or converting from Ledger easier. Note some - of the features below are powerful and can be useful in special cases, - but in general, features in this section are considered less important - or even not recommended for most users. Downsides are mentioned to + hledger journal format supports quite a few other features, mainly to + make interoperating with or converting from Ledger easier. Note some + of the features below are powerful and can be useful in special cases, + but in general, features in this section are considered less important + or even not recommended for most users. Downsides are mentioned to help you decide if you want to use them. Auto postings - "Automated postings" or "auto postings" are extra postings which get - added automatically to transactions which match certain queries, - defined by "auto posting rules", when you use the --auto flag. + The = directive declares a rule for automatically adding temporary + extra postings (visible in reports, not in the journal file) to all + transactions matched by a certain query, when you use the --auto flag. Downsides: depending on generated data for your reports makes your financial data less portable, less future-proof, and less trustworthy @@ -2632,18 +2650,19 @@ Journal Downsides: another syntax to learn, redundant with hledger's date:/date2: tags, and confusingly similar to Ledger's lot date syntax. - Default commodity - The D directive sets a default commodity, to be used for any subsequent + D directive + D AMOUNT + + This directive sets a default commodity, to be used for any subsequent commodityless amounts (ie, plain numbers) seen while parsing the jour- nal. This effect lasts until the next D directive, or the end of the journal. For compatibility/historical reasons, D also acts like a commodity directive (setting the commodity's decimal mark for parsing and display - style for output). - - The syntax is D AMOUNT. As with commodity, the amount must include a - decimal mark (either period or comma). Eg: + style for output). So its argument is not just a commodity symbol, but + a full amount demonstrating the style. The amount must include a deci- + mal mark (either period or comma). Eg: ; commodity-less amounts should be treated as dollars ; (and displayed with the dollar sign on the left, thousands separators and two decimal places) @@ -2653,23 +2672,27 @@ Journal a 5 ; <- commodity-less amount, parsed as $5 and displayed as $5.00 b - If both commodity and D directives are found for a commodity, commodity - takes precedence for setting decimal mark and display style. + Interactions with other directives: - If you are using D and also checking commodities, you will need to add - a commodity directive similar to the D. (The hledger check commodities - command expects commodity directives, and ignores D). + For setting a commodity's display style, a commodity directive has + highest priority, then a D directive. + + For detecting a commodity's decimal mark during parsing, decimal-mark + has highest priority, then commodity, then D. + + For checking commodity symbols with the check command, a commodity + directive is required (hledger check commodities ignores D directives). Downsides: omitting commodity symbols makes your financial data less explicit, less portable, and less trustworthy in an audit. It is usu- ally an unsustainable shortcut; sooner or later you will want to track multiple commodities. D is overloaded with functions redundant with - commodity and decimal mark. And it works differently from Ledger's D. + commodity and decimal-mark. And it works differently from Ledger's D. - Default parent account - The apply account directive sets a parent account which will be - prepended to all accounts in following entries, until an end apply - account directive or end of current file. Eg: + apply account directive + This directive sets a default parent account, which will be prepended + to all accounts in following entries, until an end apply account direc- + tive or end of current file. Eg: apply account home @@ -2695,10 +2718,15 @@ Journal Downsides: this can make your financial data less explicit, less porta- ble, and less trustworthy in an audit. - 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 (or year or apply - year) followed by the year. Eg: + Y directive + Y YEAR + + or (deprecated backward-compatible forms): + + year YEAR apply year YEAR + + The space is optional. This sets a default year to be used for subse- + quent dates which don't specify a year. Eg: Y2009 ; set default year to 2009 @@ -2718,60 +2746,60 @@ Journal Downsides: omitting the year (from primary transaction dates, at least) makes your financial data less explicit, less portable, and less trust- - worthy in an audit. Such dates can get separated from their corre- - sponding Y directive, eg when evaluating a region of the journal in - your editor. A missing Y directive makes reports dependent on today's + worthy in an audit. Such dates can get separated from their corre- + sponding Y directive, eg when evaluating a region of the journal in + your editor. A missing Y directive makes reports dependent on today's date. Secondary dates 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". - Downsides: makes your financial data more complicated, less portable, + Downsides: makes your financial data more complicated, less portable, and less trustworthy in an audit. Keeping the meaning of the two dates - consistent requires discipline, and you have to remember which report- - ing mode is appropriate for a given report. Posting dates are simpler + consistent requires discipline, and you have to remember which report- + ing mode is appropriate for a given report. Posting dates are simpler and better. Star comments - Lines beginning with * (star/asterisk) are also comment lines. This - feature allows Emacs users to insert org headings in their journal, - allowing them to fold/unfold/navigate it like an outline when viewed + Lines beginning with * (star/asterisk) are also comment lines. This + feature allows Emacs users to insert org headings in their journal, + allowing them to fold/unfold/navigate it like an outline when viewed with org mode. - Downsides: another, unconventional comment syntax to learn. Decreases - your journal's portability. And switching to Emacs org mode just for - folding/unfolding meant losing the benefits of ledger mode; nowadays - you can add outshine mode to ledger mode to get folding without losing + Downsides: another, unconventional comment syntax to learn. Decreases + your journal's portability. And switching to Emacs org mode just for + folding/unfolding meant losing the benefits of ledger mode; nowadays + you can add outshine mode to ledger mode to get folding without losing ledger mode's features. Valuation expressions - Ledger allows a valuation function or value to be written in double + Ledger allows a valuation function or value to be written in double parentheses after an amount. hledger ignores these. Virtual postings - A posting with parentheses around the account name is called a virtual - posting or unbalanced posting, which means it is exempt from the usual + A posting with parentheses around the account name is called a virtual + posting 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 bookkeeping, 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 bookkeeping, 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: 2022-01-01 opening balances (assets:checking) $1000 (assets:savings) $2000 - A posting with brackets around the account name is called a balanced - virtual posting. The balanced virtual postings in a transaction must + A posting with brackets around the 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: 2022-01-01 buy food with cash, update budget envelope subaccounts, & something else @@ -2782,17 +2810,17 @@ Journal [assets:checking:available] $10 ; <- (something:else) $5 ; <- this is not required to balance - Postings whose account names are neither parenthesised nor bracketed - are called real postings. You can exclude virtual postings from + Postings whose account names are neither parenthesised nor bracketed + are called real postings. You can exclude virtual postings from reports with the -R/--real flag or a real:1 query. Downsides: violates double entry bookkeeping, can be used to avoid fig- - uring out correct entries, makes your financial data less portable and + uring out correct entries, makes your financial data less portable and less trustworthy in an audit. Other Ledger directives These other Ledger directives are currently accepted but ignored. This - allows hledger to read more Ledger files, but be aware that hledger's + allows hledger to read more Ledger files, but be aware that hledger's reports may differ from Ledger's if you use these. apply fixed COMM AMT @@ -2813,36 +2841,36 @@ Journal value EXPR --command-line-flags - See also https://hledger.org/ledger.html for a detailed hledger/Ledger + See also https://hledger.org/ledger.html for a detailed hledger/Ledger syntax comparison. CSV - hledger can read CSV files (Character Separated Value - usually comma, - semicolon, or tab) containing dated records, automatically converting + hledger can read CSV files (Character Separated Value - usually comma, + semicolon, or tab) containing dated records, automatically converting each record into a transaction. (To learn about writing CSV, see CSV output.) - For best error messages when reading CSV/TSV/SSV files, make sure they + For best error messages when reading CSV/TSV/SSV files, make sure they have a corresponding .csv, .tsv or .ssv file extension or use a hledger file prefix (see File Extension below). Each CSV file must be described by a corresponding rules file. - This contains rules describing the CSV data (header line, fields lay- - out, date format etc.), how to construct hledger transactions from it, - and how to categorise transactions based on description or other + This contains rules describing the CSV data (header line, fields lay- + out, date format etc.), how to construct hledger transactions from it, + and how to categorise transactions based on description or other attributes. - By default hledger looks for a rules file named like the CSV file with - an extra .rules extension, in the same directory. Eg when asked to + By default hledger looks for a rules file named like the CSV file with + an extra .rules extension, in the same directory. Eg when asked to read foo/FILE.csv, hledger looks for foo/FILE.csv.rules. You can spec- - ify a different rules file with the --rules-file option. If no rules - file is found, hledger will create a sample rules file, which you'll + ify a different rules file with the --rules-file option. If no rules + file is found, hledger will create a sample rules file, which you'll need to adjust. - 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 @@ -2859,7 +2887,7 @@ CSV income:unknown -10.23 There's an introductory Importing CSV data tutorial on hledger.org, and - more CSV rules examples below, and a larger collection at + more CSV rules examples below, and a larger collection at https://github.com/simonmichael/hledger/tree/master/examples/csv. CSV rules cheatsheet @@ -2867,38 +2895,39 @@ CSV (Blank lines and lines beginning with # or ; or * are ignored.) - separator declare the field separator, instead of rely- + separator declare the field separator, instead of rely- ing on file extension skip skip one or more header lines at start of file date-format declare how to parse CSV dates/date-times - timezone declare the time zone of ambiguous CSV date- + timezone declare the time zone of ambiguous CSV date- times - newest-first improve txn order when: there are multiple + newest-first improve txn order when: there are multiple records, newest first, all with the same date - intra-day-reversed improve txn order when: same-day txns are in + intra-day-reversed improve txn order when: same-day txns are in opposite order to the overall file - decimal-mark declare the decimal mark used in CSV amounts, + decimal-mark declare the decimal mark used in CSV amounts, when ambiguous - fields list name CSV fields for easy reference, and + fields list name CSV fields for easy reference, and optionally assign their values to hledger fields - Field assignment assign a CSV value or interpolated text value + Field assignment assign a CSV value or interpolated text value to a hledger field + if block conditionally assign values to hledger fields, or skip a record or end (skip rest of file) if table conditionally assign values to hledger fields, using compact syntax - balance-type select which type of balance asser- + balance-type select which type of balance asser- tions/assignments to generate include inline another CSV rules file - Working with CSV tips can be found below, including How CSV rules are + Working with CSV tips can be found below, including How CSV rules are evaluated. 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 , @@ -2911,32 +2940,32 @@ CSV 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. skip skip N - The word skip followed by a number (or no number, meaning 1) tells - hledger to ignore this many non-empty lines at the start of the input - data. (Empty/blank lines are skipped automatically, so you don't need - to count those.) You'll need this whenever your CSV data contains - header lines. Header lines skipped in this way are ignored, and not + The word skip followed by a number (or no number, meaning 1) tells + hledger to ignore this many non-empty lines at the start of the input + data. (Empty/blank lines are skipped automatically, so you don't need + to count those.) You'll need this whenever your CSV data contains + header lines. Header lines skipped in this way are ignored, and not parsed as CSV. skip can also be used inside if blocks (described below), to skip indi- - vidual data records. Note records skipped in this way are still + vidual data records. Note records skipped in this way are still required to be valid CSV, even though otherwise ignored. 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-style - date parsing pattern - see https://hackage.haskell.org/pack- - age/time/docs/Data-Time-Format.html#v:formatTime. The pattern must + 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-style + date parsing pattern - see https://hackage.haskell.org/pack- + age/time/docs/Data-Time-Format.html#v:formatTime. The pattern must parse the CSV date value completely. Some examples: # MM/DD/YY @@ -2956,33 +2985,33 @@ CSV timezone timezone TIMEZONE - When CSV contains date-times that are implicitly in some time zone + When CSV contains date-times that are implicitly in some time zone other than yours, but containing no explicit time zone information, you - can use this rule to declare the CSV's native time zone, which helps + can use this rule to declare the CSV's native time zone, which helps prevent off-by-one dates. - When the CSV date-times do contain time zone information, you don't - need this rule; instead, use %Z in date-format (or %z, %EZ, %Ez; see + When the CSV date-times do contain time zone information, you don't + need this rule; instead, use %Z in date-format (or %z, %EZ, %Ez; see the formatTime link above). In either of these cases, hledger will do a time-zone-aware conversion, localising the CSV date-times to your current system time zone. If you prefer to localise to some other time zone, eg for reproducibility, you - can (on unix at least) set the output timezone with the TZ environment + can (on unix at least) set the output timezone with the TZ environment variable, eg: $ TZ=-1000 hledger print -f foo.csv # or TZ=-1000 hledger import foo.csv - timezone currently does not understand timezone names, except "UTC", - "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", or "PDT". For + timezone currently does not understand timezone names, except "UTC", + "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", or "PDT". For others, use numeric format: +HHMM or -HHMM. newest-first hledger tries to ensure that the generated transactions will be ordered - chronologically, including intra-day transactions. Usually it can - auto-detect how the CSV records are ordered. But if it encounters CSV + chronologically, including intra-day transactions. Usually it can + auto-detect how the CSV records are ordered. But if it encounters CSV where all records are on the same date, it assumes that the records are - oldest first. If in fact the CSV's records are normally newest first, + oldest first. If in fact the CSV's records are normally newest first, like: 2022-10-01, txn 3... @@ -2996,8 +3025,8 @@ CSV newest-first intra-day-reversed - CSV records for each day are sometimes ordered in reverse compared to - the overall date order. Eg, here dates are newest first, but the + CSV records for each day are sometimes ordered in reverse compared to + the overall date order. Eg, here dates are newest first, but the transactions on each date are oldest first: 2022-10-02, txn 3... @@ -3005,7 +3034,7 @@ CSV 2022-10-01, txn 1... 2022-10-01, txn 2... - In this situation, add the intra-day-reversed rule, and hledger will + In this situation, add the intra-day-reversed rule, and hledger will compensate, improving the order of transactions. # transactions within each day are reversed with respect to the overall date order @@ -3018,10 +3047,10 @@ CSV 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. fields list @@ -3030,17 +3059,17 @@ CSV A fields list (the word fields followed by comma-separated field names) is optional, but convenient. It does two things: - 1. It names the CSV field in each column. This can be convenient if - you are referencing them in other rules, so you can say %SomeField + 1. It names the CSV field in each column. This can be convenient if + you are referencing them in other rules, so you can say %SomeField instead of remembering %13. - 2. Whenever you use one of the special hledger field names (described - below), it assigns the CSV value in this position to that hledger - field. This is the quickest way to populate hledger's fields and + 2. Whenever you use one of the special hledger field names (described + below), it assigns the CSV value in this position to that hledger + field. This is the quickest way to populate hledger's fields and build a 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 @@ -3050,35 +3079,35 @@ CSV o There must be least two items in the list (at least one comma). - o Field names may not contain spaces. Spaces before/after field names + o Field names may not contain spaces. Spaces before/after field names are optional. o Field names may contain _ (underscore) or - (hyphen). - o Fields you don't care about can be given a dummy name or an empty + o Fields you don't care about can be given a dummy name or an empty name. - If the CSV contains column headings, it's convenient to use these for + If the CSV contains column headings, it's convenient to use these for your field names, suitably modified (eg lower-cased with spaces replaced by underscores). - Sometimes you may want to alter a CSV field name to avoid assigning to - a hledger field with the same name. Eg you could call the CSV's "bal- - ance" field balance_ to avoid directly setting hledger's balance field + Sometimes you may want to alter a CSV field name to avoid assigning to + a hledger field with the same name. Eg you could call the CSV's "bal- + ance" field balance_ to avoid directly setting hledger's balance field (and generating a balance assertion). Field assignment HLEDGERFIELD FIELDVALUE - Field assignments are the more flexible way to assign CSV values to + Field assignments are the more flexible way to assign CSV values to hledger fields. They can be used instead of or in addition to a fields list (see above). - To assign a value to a hledger field, write the field name (any of the - standard hledger field/pseudo-field names, defined below), a space, - followed by a text value on the same line. This text value may inter- - polate CSV fields, referenced by their 1-based position in the CSV - record (%N), or by the name they were given in the fields list (%CSV- + To assign a value to a hledger field, write the field name (any of the + standard hledger field/pseudo-field names, defined below), a space, + followed by a text value on the same line. This text value may inter- + polate CSV fields, referenced by their 1-based position in the CSV + record (%N), or by the name they were given in the fields list (%CSV- FIELD). Some examples: @@ -3091,26 +3120,26 @@ CSV Tips: - o Interpolation strips outer whitespace (so a CSV value like " 1 " + o Interpolation strips outer whitespace (so a CSV value like " 1 " becomes 1 when interpolated) (#1051). - o Interpolations always refer to a CSV field - you can't interpolate a + o Interpolations always refer to a CSV field - you can't interpolate a hledger field. (See Referencing other fields below). Field names - Note the two kinds of field names mentioned here, and used only in + Note the two kinds of field names mentioned here, and used only in hledger CSV rules files: - 1. CSV field names (CSVFIELD in these docs): you can optionally name - the CSV columns for easy reference (since hledger doesn't yet auto- + 1. CSV field names (CSVFIELD in these docs): you can optionally name + the CSV columns for easy reference (since hledger doesn't yet auto- matically recognise column headings in a CSV file), by writing arbi- trary names in a fields list, eg: fields When, What, Some_Id, Net, Total, Foo, Bar - 2. Special hledger field names (HLEDGERFIELD in these docs): you must - set at least some of these to generate the hledger transaction from - a CSV record, by writing them as the left hand side of a field + 2. Special hledger field names (HLEDGERFIELD in these docs): you must + set at least some of these to generate the hledger transaction from + a CSV record, by writing them as the left hand side of a field assignment, eg: date %When @@ -3125,7 +3154,7 @@ CSV currency $ comment %Foo %Bar - Here are all the special hledger field names available, and what hap- + Here are all the special hledger field names available, and what hap- pens when you assign values to them: date field @@ -3148,7 +3177,7 @@ CSV commentN, where N is a number, sets the Nth posting's comment. - You can assign multi-line comments by writing literal \n in the code. + You can assign multi-line comments by writing literal \n in the code. A comment starting with \n will begin on a new line. Comments can contain tags, as usual. @@ -3157,88 +3186,88 @@ CSV Assigning to accountN, where N is 1 to 99, sets the account name of the Nth posting, and causes that posting to be generated. - 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, in conditional rules. - 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 field - There are several "amount" field name variants, useful for different + There are several "amount" field name variants, useful for different situations: - o amountN sets the amount of the Nth posting, and causes that posting - to be generated. By assigning to amount1, amount2, ... etc. you - can generate up to 99 postings. Posting numbers don't have to be + o amountN sets the amount of the Nth posting, and causes that posting + to be generated. By assigning to amount1, amount2, ... etc. you + can generate up to 99 postings. Posting numbers don't have to be consecutive; in certain situations using a high number might be help- ful to influence the layout of postings. - o amountN-in and amountN-out should be used instead, as a pair, when - and only when the amount must be obtained from two CSV fields. Eg + o amountN-in and amountN-out should be used instead, as a pair, when + and only when the amount must be obtained from two CSV fields. Eg when the CSV has separate Debit and Credit fields instead of a single Amount field. Note: - o Don't think "-in is for the first posting and -out is for the sec- + o Don't think "-in is for the first posting and -out is for the sec- ond posting" - that's not correct. Think: "amountN-in and amountN- out together detect the amount for posting N, by inspecting two CSV fields at once." - o hledger assumes both CSV fields are unsigned, and will automati- + o hledger assumes both CSV fields are unsigned, and will automati- cally negate the -out value. - o It also expects that at least one of the values is empty or zero, - so it knows which one to ignore. If that's not the case you'll + o It also expects that at least one of the values is empty or zero, + so it knows which one to ignore. If that's not the case you'll need an if rule (see Setting amounts below). - o amount, with no posting number (and similarly, amount-in and amount- - out with no number) are an older syntax. We keep them for backwards - compatibility, and because they have special behaviour that is some- + o amount, with no posting number (and similarly, amount-in and amount- + out with no number) are an older syntax. We keep them for backwards + compatibility, and because they have special behaviour that is some- times convenient: - o They set the amount of posting 1 and (negated) the amount of post- + o They set the amount of posting 1 and (negated) the amount of post- ing 2. - o Posting 2's amount will be converted to cost if it has a cost + o Posting 2's amount will be converted to cost if it has a cost price. - o Any of the newer rules for posting 1 or 2 (like amount1, or - amount2-in and amount2-out) will take precedence. This allows + o Any of the newer rules for posting 1 or 2 (like amount1, or + amount2-in and amount2-out) will take precedence. This allows incrementally migrating old rules files to the new syntax. - There's more to say about amount-setting that doesn't fit here; please + There's more to say about amount-setting that doesn't fit here; please see also "Setting amounts" below. currency field - currency sets a currency symbol, to be prepended to all postings' - amounts. You can use this if the CSV amounts do not have a currency + currency sets a currency symbol, to be prepended to all postings' + amounts. You can use this if the CSV amounts do not have a currency symbol, eg if it is in a separate column. - currencyN prepends a currency symbol to just the Nth posting's amount. + currencyN prepends a currency symbol to just the Nth posting's amount. balance field - 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. balance is a compatibility spelling for hledger <1.17; it 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). See Tips below for more about setting amounts and currency. if block - Rules can be applied conditionally, depending on patterns in the CSV - data. This allows flexibility; in particular, it is how you can cate- - gorise transactions, selecting an appropriate account name based on - their description (for example). There are two ways to write condi- - tional rules: "if blocks", described here, and "if tables", described + Rules can be applied conditionally, depending on patterns in the CSV + data. This allows flexibility; in particular, it is how you can cate- + gorise transactions, selecting an appropriate account name based on + their description (for example). There are two ways to write condi- + tional rules: "if blocks", described here, and "if tables", described below. - An if block is the word if and one or more "matcher" expressions (can + An if block is the word if and one or more "matcher" expressions (can be a word or phrase), one per line, starting either on the same or next line; followed by one or more indented rules. Eg, @@ -3254,11 +3283,11 @@ CSV RULE RULE - If any of the matchers succeeds, all of the indented rules will be + If any of the matchers succeeds, all of the indented rules will be applied. They are usually field assignments, but the following special rules may also be used within an if block: - o skip - skips the matched CSV record (generating no transaction from + o skip - skips the matched CSV record (generating no transaction from it) o end - skips the rest of the current CSV file. @@ -3284,26 +3313,26 @@ CSV Matchers There are two kinds: - 1. A record matcher is a word or single-line text fragment or regular - expression (REGEX), which hledger will try to match case-insensi- + 1. A record matcher is a word or single-line text fragment or regular + expression (REGEX), which hledger will try to match case-insensi- tively anywhere within the CSV record. Eg: whole foods - 2. A field matcher is preceded with a percent sign and CSV field name - (%CSVFIELD REGEX). hledger will try to match these just within the + 2. A field matcher is preceded with a percent sign and CSV field name + (%CSVFIELD REGEX). hledger will try to match these just within the named CSV field. Eg: %date 2023 - The regular expression is (as usual in hledger) a POSIX extended regu- - lar expression, that also supports GNU word boundaries (\b, \B, \<, - \>), and nothing else. If you have trouble, see "Regular expressions" + The regular expression is (as usual in hledger) a POSIX extended regu- + lar expression, that also supports GNU word boundaries (\b, \B, \<, + \>), and nothing else. If you have trouble, see "Regular expressions" in the hledger manual (https://hledger.org/hledger.html#regular-expres- sions). With record matchers, it's important to know that the record matched is - not the original CSV record, but a modified one: separators will be - converted to commas, and enclosing double quotes (but not enclosing - whitespace) are removed. So for example, when reading an SSV file, if + not the original CSV record, but a modified one: separators will be + converted to commas, and enclosing double quotes (but not enclosing + whitespace) are removed. So for example, when reading an SSV file, if the original record was: 2020-01-01; "Acme, Inc."; 1,000 @@ -3316,14 +3345,14 @@ CSV o By default they are OR'd (any one of them can match) - o When a matcher is preceded by ampersand (&) it will be AND'ed with + o When a matcher is preceded by ampersand (&) it will be AND'ed with the previous matcher (both of them must match). There's not yet an easy syntax to negate a matcher. if table - "if tables" are an alternative to if blocks; they can express many - matchers and field assignments in a more compact tabular format, like + "if tables" are an alternative to if blocks; they can express many + matchers and field assignments in a more compact tabular format, like this: if,HLEDGERFIELD1,HLEDGERFIELD2,... @@ -3332,17 +3361,17 @@ CSV MATCHERC,VALUE1,VALUE2,... - The first character after if is taken to be the separator for the rest - of the table. It should be a non-alphanumeric character like , or | - that does not appear anywhere else in the table. (Note: it is unre- - lated to the CSV file's separator.) Whitespace can be used in the - matcher lines for readability, but not in the if line currently. The - table must be terminated by an empty line (or end of file). Each line + The first character after if is taken to be the separator for the rest + of the table. It should be a non-alphanumeric character like , or | + that does not appear anywhere else in the table. (Note: it is unre- + lated to the CSV file's separator.) Whitespace can be used in the + matcher lines for readability, but not in the if line currently. The + table must be terminated by an empty line (or end of file). Each line must contain the same number of separators; empty values are allowed. - The above means: try all of the matchers; whenever a matcher succeeds, - assign all of the values on that line to the corresponding hledger - fields; later lines can overrider earlier ones. It is equivalent to + The above means: try all of the matchers; whenever a matcher succeeds, + assign all of the values on that line to the corresponding hledger + fields; later lines can overrider earlier ones. It is equivalent to this sequence of if blocks: if MATCHERA @@ -3369,10 +3398,10 @@ CSV 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 @@ -3388,9 +3417,9 @@ CSV 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 @@ -3407,42 +3436,42 @@ CSV Some 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 eradman.com/entrproject: $ 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 - Note that hledger will only accept valid CSV conforming to RFC 4180, + Note that hledger will only accept valid CSV conforming to RFC 4180, and equivalent SSV and TSV formats (like RFC 4180 but with semicolon or tab as separators). This means, eg: o Values may be enclosed in double quotes, or not. Enclosing in single quotes is not allowed. (Eg 'A','B' is rejected.) - o When values are enclosed in double quotes, spaces outside the quotes + o When values are enclosed in double quotes, spaces outside the quotes are not allowed. (Eg "A", "B" is rejected.) - o When values are not enclosed in quotes, they may not contain double + o When values are not enclosed in quotes, they may not contain double quotes. (Eg A"A, B is rejected.) - If your CSV/SSV/TSV is not valid in this sense, you'll need to trans- - form it before reading with hledger. Try using sed, or a more permis- + If your CSV/SSV/TSV is not valid in this sense, you'll need to trans- + form it before reading with hledger. Try using sed, or a more permis- sive CSV parser like python's csv lib. File Extension - To help hledger choose the CSV file reader and show the right error - messages (and choose the right field separator character by default), - it's best if CSV/SSV/TSV files are named with a .csv, .ssv or .tsv + To help hledger choose the CSV file reader and show the right error + messages (and choose the right field separator character by default), + it's best if CSV/SSV/TSV files are named with a .csv, .ssv or .tsv filename extension. (More about this at Data formats.) - When reading files with the "wrong" extension, you can ensure the CSV - reader (and the default field separator) by prefixing the file path + When reading files with the "wrong" extension, you can ensure the CSV + reader (and the default field separator) by prefixing the file path with csv:, ssv: or tsv:: Eg: $ hledger -f ssv:foo.dat print @@ -3451,50 +3480,50 @@ CSV if needed. Reading CSV from standard input - You'll need the file format prefix when reading CSV from stdin also, + You'll need the file format prefix when reading CSV from stdin also, since hledger assumes journal format by default. Eg: $ cat foo.dat | hledger -f ssv:- print 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 + 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 assertions 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: @@ -3509,11 +3538,11 @@ CSV 1. If the amount is in a single CSV field: a. If its sign indicates direction of flow: - Assign it to amountN, to set the Nth posting's amount. N is usu- + Assign it to amountN, to set the Nth posting's amount. N is usu- ally 1 or 2 but can go up to 99. b. If another field indicates direction of flow: - Use one or more conditional rules to set the appropriate amount + Use one or more conditional rules to set the appropriate amount sign. Eg: # assume a withdrawal unless Type contains "deposit": @@ -3530,7 +3559,7 @@ CSV b. If either field is signed: Use a conditional rule to flip the sign when needed. Eg below, the - -out value already has a minus sign so we undo hledger's automatic + -out value already has a minus sign so we undo hledger's automatic negating by negating once more (but only if the field is non-empty, so that we don't leave a minus sign by itself): @@ -3538,12 +3567,12 @@ CSV if %amount1-out [1-9] amount1-out -%amount1-out - c. If both fields can contain a non-zero value (or both can be + c. If both fields can contain a non-zero value (or both can be empty): The -in/-out rules normally choose the value which is non-zero/non- empty. Some value pairs can be ambiguous, such as 1 and none. For - such cases, use conditional rules to help select the amount. Eg, - to handle the above you could select the value containing non-zero + such cases, use conditional rules to help select the amount. Eg, + to handle the above you could select the value containing non-zero digits: fields date, description, in, out @@ -3556,14 +3585,14 @@ CSV Use the unnumbered amount (or amount-in and amount-out) syntax. 4. If the CSV has only balance amounts, not transaction amounts: - Assign to balanceN, to set a balance assignment on the Nth posting, - causing the posting's amount to be calculated automatically. balance + Assign to balanceN, to set a balance assignment on the Nth posting, + causing the posting's amount to be calculated automatically. balance with no number is equivalent to balance1. In this situation hledger is more likely to guess the wrong default account name, so you may need to set that explicitly. Amount signs - There is some special handling for amount signs, to simplify parsing + There is some special handling for amount signs, to simplify parsing and sign-flipping: o If an amount value begins with a plus sign: @@ -3572,17 +3601,17 @@ CSV o If an amount value is parenthesised: it will be de-parenthesised and sign-flipped: (AMT) becomes -AMT - o If an amount value has two minus signs (or two sets of parentheses, + o If an amount value has two minus signs (or two sets of parentheses, or a minus sign and parentheses): they cancel out and will be removed: --AMT or -(AMT) becomes AMT - o If an amount value contains just a sign (or just a set of parenthe- + o If an amount value contains just a sign (or just a set of parenthe- ses): - that is removed, making it an empty value. "+" or "-" or "()" becomes + that is removed, making it an empty value. "+" or "-" or "()" becomes "". Setting currency/commodity - If the currency/commodity symbol is included in the CSV's amount + If the currency/commodity symbol is included in the CSV's amount field(s): 2020-01-01,foo,$123.00 @@ -3601,7 +3630,7 @@ CSV 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 @@ -3610,7 +3639,7 @@ CSV 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: @@ -3621,7 +3650,7 @@ CSV 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. Amount decimal places @@ -3629,13 +3658,13 @@ CSV amount1 influence commodity display styles, such as the number of deci- mal places displayed in reports. - The original amounts as written in the CSV file do not affect display + The original amounts as written in the CSV file do not affect display style (because we don't yet reliably know their commodity). 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" @@ -3647,7 +3676,7 @@ CSV # 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 @@ -3655,7 +3684,7 @@ CSV # 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: @@ -3665,14 +3694,14 @@ CSV 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 + Then "global" rules are evaluated, top to bottom. If a rule is repeated, the last one wins: o skip (at top level) @@ -3686,41 +3715,41 @@ CSV Then for each CSV record in turn: - o test all if blocks. If any of them contain a end rule, skip all + o test all if blocks. If any of them contain a end rule, skip all remaining CSV records. Otherwise if any of them contain a skip rule, - skip that many CSV records. If there are multiple matched skip + 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 - assigned to it (and interpolate the %CSVFIELD references), or a + o compute a value for each hledger field - either the one that was + assigned to it (and interpolate the %CSVFIELD references), or a default o generate a hledger transaction (journal entry) 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. Well factored rules - Some things than can help reduce duplication and complexity in rules + Some things than can help reduce duplication and complexity in rules files: - o Extracting common rules usable with multiple CSV files into a com- - mon.rules, and adding include common.rules to each CSV's rules file. + o Extracting common rules usable with multiple CSV files into a com- + mon.rules, and adding include common.rules to each CSV's rules file. o Splitting if blocks into smaller if blocks, extracting the frequently used parts. CSV rules examples 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 @@ -3762,13 +3791,13 @@ CSV 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. Coinbase - A simple example with some CSV from Coinbase. The spot price is - recorded using cost notation. The legacy amount field name conve- + A simple example with some CSV from Coinbase. The spot price is + recorded using cost notation. The legacy amount field name conve- niently sets amount 2 (posting 2's amount) to the total cost. # Timestamp,Transaction Type,Asset,Quantity Transacted,Spot Price Currency,Spot Price at Transaction,Subtotal,Total (inclusive of fees and/or spread),Fees and/or Spread,Notes @@ -3790,7 +3819,7 @@ CSV 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" @@ -3842,7 +3871,7 @@ CSV 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" @@ -3993,12 +4022,12 @@ CSV Timeclock 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). Lines beginning with + the time is always interpreted as a local time). Lines beginning with # or ; or *, and blank lines, are ignored. i 2015/03/30 09:00:00 some:account name optional description after two spaces @@ -4006,9 +4035,9 @@ Timeclock 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 @@ -4029,27 +4058,27 @@ Timeclock 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 - timedot format is hledger's human-friendly time logging format. Com- + timedot format is hledger's human-friendly time logging format. Com- pared to timeclock format, it is o convenient for quick, approximate, and retroactive time logging o readable: you can see at a glance where time was spent. - A timedot file contains a series of day entries, which might look like + A timedot file contains a series of day entries, which might look like this: 2021-08-04 @@ -4057,7 +4086,7 @@ Timedot fos:hledger:timedot .. ; docs per:admin:finance - hledger reads this as three time transactions on this day, with each + hledger reads this as three time transactions on this day, with each dot representing a quarter-hour spent: $ hledger -f a.timedot print # .timedot file extension activates the timedot reader @@ -4080,47 +4109,47 @@ Timedot o a common transaction comment for this day, after a semicolon (;). - After the date line are zero or more optionally-indented time transac- + After the date line are zero or more optionally-indented time transac- tion lines, consisting of: o an account name - any word or phrase, usually a hledger-style account name. - o two or more spaces - a field separator, required if there is an + o two or more spaces - a field separator, required if there is an amount (as in journal format). - o a timedot amount - dots representing quarter hours, or a number rep- + o a timedot amount - dots representing quarter hours, or a number rep- resenting hours. o an optional comment beginning with semicolon. This is ignored. In more detail, timedot amounts can be: - o dots: zero or more period characters, each representing one quarter- - hour. Spaces are ignored and can be used for grouping. Eg: .... .. + o dots: zero or more period characters, each representing one quarter- + hour. Spaces are ignored and can be used for grouping. Eg: .... .. o a number, representing hours. Eg: 1.5 - o a number immediately followed by a unit symbol s, m, h, d, w, mo, or + o a number immediately followed by a unit symbol s, m, h, d, w, mo, or y, representing seconds, minutes, hours, days weeks, months or years. Eg 1.5h or 90m. The following equivalencies are assumed: - 60s = 1m, 60m = 1h, 24h = 1d, 7d = 1w, 30d = 1mo, 365d = 1y. (This - unit will not be visible in the generated transaction amount, which is + 60s = 1m, 60m = 1h, 24h = 1d, 7d = 1w, 30d = 1mo, 365d = 1y. (This + unit will not be visible in the generated transaction amount, which is always in hours.) - There is some added flexibility to help with keeping time log data in + There is some added flexibility to help with keeping time log data in the same file as your notes, todo lists, etc.: o Blank lines and lines beginning with # or ; are ignored. o Before the first date line, lines beginning with * are ignored. From - the first date line onward, a sequence of *'s followed by a space at - beginning of lines (ie, the headline prefix used by Emacs Org mode) - is ignored. This means the time log can be kept under an Org head- - line, and date lines or time transaction lines can be Org headlines. + the first date line onward, a sequence of *'s followed by a space at + beginning of lines (ie, the headline prefix used by Emacs Org mode) + is ignored. This means the time log can be kept under an Org head- + line, and date lines or time transaction lines can be Org headlines. - o Lines not ending with a double-space and amount are parsed as trans- - actions with zero amount. (Most hledger reports hide these by + o Lines not ending with a double-space and amount are parsed as trans- + actions with zero amount. (Most hledger reports hide these by default; add -E to see them.) More examples: @@ -4204,51 +4233,50 @@ PART 3: REPORTING CONCEPTS Time periods Report start & end date By default, most hledger reports will show the full span of time repre- - sented by the journal data. The report start date will be the earliest + sented by the journal. The report start date will be the earliest transaction or posting date, and the report end date will be the latest transaction, posting, or market price date. - Often you will want to see a shorter time span, such as the current - month. You can specify a start and/or end date using -b/--begin, + Often you will want to see a shorter time span, such as the current + month. You can specify a start and/or end date using -b/--begin, -e/--end, -p/--period or a date: query (described below). All of these accept the smart date syntax (below). Some notes: - o End dates are exclusive, as in Ledger, so you should write the date + o End dates are exclusive, as in Ledger, so you should write the date after the last day you want to see in the report. - o As noted in reporting options: among start/end dates specified with + o As noted in reporting options: among start/end dates specified with options, the last (i.e. right-most) option takes precedence. - o The effective report start and end dates are the intersection of the - start/end dates from options and that from date: queries. That is, - date:2019-01 date:2019 -p'2000 to 2030' yields January 2019, the + o The effective report start and end dates are the intersection of the + start/end dates from options and that from date: queries. That is, + date:2019-01 date:2019 -p'2000 to 2030' yields January 2019, the smallest common time span. - o A report interval (see below) will adjust start/end dates, when - needed, so that they fall on subperiod boundaries. + o In some cases a report interval will adjust start/end dates to fall + on interval boundaries (see below). Examples: -b 2016/3/17 begin on St. Patrick's day 2016 - -e 12/1 end at the start of december 1st of the current year + -e 12/1 end at the start of december 1st of the current year (11/30 will be the last date included) -b thismonth all transactions on or after the 1st of the current month -p thismonth all transactions in the current month - date:2016/3/17.. the above written as queries instead (.. can also be + date:2016/3/17.. the above written as queries instead (.. can also be replaced with -) date:..12/1 date:thismonth.. date:thismonth Smart dates - hledger's user interfaces accept a flexible "smart date" syntax. Smart - dates allow some english words, can be relative to today's date, and - can have less-significant date parts omitted (defaulting to 1). - - Examples: + hledger's user interfaces accept a "smart date" syntax for added conve- + nience. Smart dates optionally can be relative to today's date, be + written with english words, and have less-significant parts omitted + (missing parts are inferred as 1). Some examples: 2004/10/1, 2004-01-01, exact date, several separators allowed. Year @@ -4272,11 +4300,10 @@ Time periods n -n periods from the current period days/weeks/months/quar- ters/years ago - 20181201 8 digit YYYYMMDD with valid year month and day 201812 6 digit YYYYMM with valid year and month - Counterexamples - malformed digit sequences might give surprising + Some counterexamples - malformed digit sequences might give surprising results: @@ -4287,17 +4314,17 @@ Time periods 20181232 8 digits with an invalid day gives an error 201801012 9+ digits beginning with a valid YYYYMMDD gives an error - Note "today's date" can be overridden with the --today option, in case - it's needed for testing or for recreating old reports. (Except for - periodic transaction rules; those are not affected by --today.) + "Today's date" can be overridden with the --today option, in case it's + needed for testing or for recreating old reports. (Except for periodic + transaction rules, which are not affected by --today.) Report intervals - A report interval can be specified so that commands like register, bal- - ance and activity become multi-period, showing each subperiod as a sep- - arate row or column. + A report interval can be specified so that reports like register, bal- + ance or activity become multi-period, showing each subperiod as a sepa- + rate row or column. - The following "standard" report intervals can be enabled by using their - corresponding flag: + The following standard intervals can be enabled with command-line + flags: o -D/--daily @@ -4309,69 +4336,71 @@ Time periods o -Y/--yearly - These standard intervals always start on natural interval boundaries: - eg --weekly starts on mondays, --monthly starts on the first of the - month, --yearly always starts on January 1st, etc. + More complex intervals can be specified using -p/--period, described + below. - Certain more complex intervals, and more flexible boundary dates, can - be specified by -p/--period. These are described in period expres- - sions, below. + Date adjustment + With a report interval (other than daily), report start / end dates + which have not been specified explicitly and in full (eg not -b + 2023-01-01, but -b 2023-01 or -b 2023 or unspecified) are considered + flexible: - Report intervals can only be specified by the flags above, and not by - query arguments, currently. + o A flexible start date will be automatically adjusted earlier if + needed to fall on a natural interval boundary. - Report intervals have another effect: multi-period reports are always - expanded to fill a whole number of subperiods. So if you use a report - interval (other than --daily), and you have specified a start or end - date, you may notice those dates being overridden (ie, the report - starts earlier than your requested start date, or ends later than your - requested end date). This is done to ensure "full" first and last sub- - periods, so that all subperiods' numbers are comparable. + o Similarly, a flexible end date will be adjusted later if needed to + make the last period a whole interval (the same length as the oth- + ers). - To summarise: + This is convenient for producing clean periodic reports (this is tradi- + tional hledger behaviour). By contrast, fully-specified exact dates + will not be adjusted (this is new in hledger 1.29). - o In multiperiod reports, all subperiods are forced to be the same - length, to simplify reporting. + An example: with a journal whose first date is 2023-01-10 and last date + is 2023-03-20: - o Reports with the standard --weekly/--monthly/--quarterly/--yearly - intervals are required to start on the first day of a - week/month/quarter/year. We'd like more flexibility here but it - isn't supported yet. + o hledger bal -M -b 2023/1/15 -e 2023/3/10 + The report periods will begin on the 15th day of each month, starting + from 2023-01-15, and the last period's last day will be 2023-03-09. + (Exact start and end dates, neither is adjusted.) - o --period (below) can specify more complex intervals, starting on any - date. + o hledger bal -M -b 2023-01 -e 2023-04 or hledger bal -M + The report periods will begin on the 1st of each month, starting from + 2023-01-01, and the last period's last day will be 2023-03-31. (Flexi- + ble start and end dates, both are adjusted.) Period expressions - The -p/--period option accepts period expressions, a shorthand way of - expressing a start date, end date, and/or report interval all at once. - - Here's a basic period expression specifying the first quarter of 2009. - Note, hledger always treats start dates as inclusive and end dates as - exclusive: + The -p/--period option specifies a period expression, which is a com- + pact way of expressing a start date, end date, and/or report interval. + Here's a period expression with a start and end date (specifying the + first quarter of 2009): -p "from 2009/1/1 to 2009/4/1" - Keywords like "from" and "to" are optional, and so are the spaces, as - long as you don't run two dates together. "to" can also be written as - ".." or "-". These are equivalent to the above: + Several keywords like "from" and "to" are supported for readability; + these are optional. "to" can also be written as ".." or "-". The spa- + ces are also optional, as long as you don't run two dates together. So + the following are equivalent to the above: -p "2009/1/1 2009/4/1" -p2009/1/1to2009/4/1 -p2009/1/1..2009/4/1 - Dates are smart dates, so if the current year is 2009, the above can - also be written as: + Dates are smart dates, so if the current year is 2009, these are also + equivalent to the above: -p "1/1 4/1" - -p "january-apr" + -p "jan-apr" -p "this year to 4/1" If you specify only one date, the missing start or end date will be the - earliest or latest transaction in your journal: + earliest or latest transaction date in the journal: + + -p "from 2009/1/1" everything after january @@ -4382,15 +4411,16 @@ Time periods -p "to 2009" everything before january 1, 2009 - A single date with no "from" or "to" defines both the start and end - date like so: + You can also specify a period by writing a single partial or full date: - -p "2009" the year 2009; equivalent to "2009/1/1 to 2010/1/1" - -p "2009/1" the month of jan; equivalent to "2009/1/1 to 2009/2/1" - -p "2009/1/1" just that day; equivalent to "2009/1/1 to 2009/1/2" + -p "2009" the year 2009; equivalent to "2009/1/1 to 2010/1/1" + -p "2009/1" the month of january 2009; equivalent to "2009/1/1 to + 2009/2/1" + -p "2009/1/1" the first day of 2009; equivalent to "2009/1/1 to + 2009/1/2" - Or you can specify a single quarter like so: + or by using the "Q" quarter-year syntax (case insensitive): -p "2009Q1" first quarter of 2009, equivalent to "2009/1/1 to @@ -4398,81 +4428,47 @@ Time periods -p "q4" fourth quarter of the current year Period expressions with a report interval - -p/--period's argument can also begin with, or entirely consist of, a - report interval. This should be separated from the start/end dates (if - any) by a space, or the word in. The basic intervals (which can also - be written as command line flags) are daily, weekly, monthly, quar- - terly, and yearly. Some examples: + A period expression can also begin with a report interval, separated + from the start/end dates (if any) by a space or the word in: -p "weekly from 2009/1/1 to 2009/4/1" -p "monthly in 2008" -p "quarterly" - As mentioned above, the weekly, monthly, quarterly and yearly intervals - require a report start date that is the first day of a week, month, - quarter or year. And, report start/end dates will be expanded if - needed to span a whole number of intervals. - - For example: - - - -p "weekly from 2009/1/1 starts on 2008/12/29, closest preceding Mon- - to 2009/4/1" day - -p "monthly in starts on 2018/11/01 - 2008/11/25" - -p "quarterly from starts on 2009/04/01, ends on 2009/06/30, - 2009-05-05 to 2009-06-01" which are first and last days of Q2 2009 - -p "yearly from starts on 2009/01/01, first day of 2009 - 2009-12-29" - More complex report intervals - Some more complex kinds of interval are also supported in period - expressions: + Some more complex intervals can be specified within period expressions, + such as: - o biweekly + o biweekly (every two weeks) o fortnightly - o bimonthly + o bimonthly (every two months) o every day|week|month|quarter|year o every N days|weeks|months|quarters|years - These too will cause report start/end dates to be expanded, if needed, - to span a whole number of intervals. Examples: + Weekly on a custom day: - - -p "bimonthly from 2008" periods will have boundaries on 2008/01/01, - 2008/03/01, ... - -p "every 2 weeks" starts on closest preceding Monday - -p "every 5 months from periods will have boundaries on 2009/03/01, - 2009/03" 2009/08/01, ... - - Intervals with custom start date - All intervals mentioned above are required to start on their natural - calendar boundaries, but the following intervals can start on any date: - - Weekly on custom day: - - o every Nth day of week (th, nd, rd, or st are all accepted after the + o every Nth day of week (th, nd, rd, or st are all accepted after the number) - o every WEEKDAYNAME (full or three-letter english weekday name, case + o every WEEKDAYNAME (full or three-letter english weekday name, case insensitive) - Monthly on custom day: + Monthly on a custom day: o every Nth day [of month] o every Nth WEEKDAYNAME [of month] - Yearly on custom day: + Yearly on a custom day: o every MM/DD [of year] (month number and day of month number) - o every MONTHNAME DDth [of year] (full or three-letter english month + o every MONTHNAME DDth [of year] (full or three-letter english month name, case insensitive, and day of month number) o every DDth MONTHNAME [of year] (equivalent to the above) @@ -4480,65 +4476,60 @@ Time periods Examples: - -p "every 2nd day of periods will go from Tue to Tue - week" - -p "every Tue" same - -p "every 15th day" period boundaries will be on 15th of each - month - -p "every 2nd Monday" period boundaries will be on second Monday of - each month - -p "every 11/05" yearly periods with boundaries on 5th of - November - -p "every 5th November" same - -p "every Nov 5th" same + -p "bimonthly from 2008" - Show historical balances at end of the 15th day of each month (N is an + -p "every 2 weeks" + -p "every 5 months from + 2009/03" + -p "every 2nd day of week" periods will go from Tue to Tue + -p "every Tue" same + -p "every 15th day" period boundaries will be on 15th of each + month + -p "every 2nd Monday" period boundaries will be on second Monday + of each month + -p "every 11/05" yearly periods with boundaries on 5th of + November + -p "every 5th November" same + -p "every Nov 5th" same + + Show historical balances at end of the 15th day of each month (N is an end date, exclusive as always): $ hledger balance -H -p "every 16th day" - Group postings from the start of wednesday to end of the following + Group postings from the start of wednesday to end of the following tuesday (N is both (inclusive) start date and (exclusive) end date): $ hledger register checking -p "every 3rd day of week" - Periods or dates ? - Report intervals like the above are most often used with -p|--period, - to divide reports into multiple subperiods - each generated date marks - a subperiod boundary. Here, the periods between the dates are what's - important. + Multiple weekday intervals + This special form is also supported: - But report intervals can also be used with --forecast to generate - future transactions, or with balance --budget to generate budget goal- - setting transactions. For these, the dates themselves are what mat- - ters. + o every WEEKDAYNAME,WEEKDAYNAME,... (full or three-letter english week- + day names, case insensitive) - Events on multiple weekdays - The every WEEKDAYNAME form has a special variant with multiple day - names, comma-separated. Eg: every mon,thu,sat. Also, weekday and - weekendday are shorthand for mon,tue,wed,thu,fri and sat,sun respec- - tively. + Also, weekday and weekendday are shorthand for mon,tue,wed,thu,fri and + sat,sun. - This form is mainly intended for use with --forecast, to generate peri- - odic transactions on arbitrary days of the week. It may be less useful - with -p, since it divides each week into subperiods of unequal length. - (Because gaps between periods are not allowed; if you'd like to change - this, see #1632.) + This is mainly intended for use with --forecast, to generate periodic + transactions on arbitrary days of the week. It may be less useful with + -p, since it divides each week into subperiods of unequal length, which + is unusual. (Related: #1632) Examples: - -p "every dates will be Mon, Wed, Fri; periods will be Mon- + -p "every dates will be Mon, Wed, Fri; periods will be Mon- mon,wed,fri" Tue, Wed-Thu, Fri-Sun - -p "every weekday" dates will be Mon, Tue, Wed, Thu, Fri; periods will + -p "every weekday" dates will be Mon, Tue, Wed, Thu, Fri; periods will be Mon, Tue, Wed, Thu, Fri-Sun -p "every weekend- dates will be Sat, Sun; periods will be Sat, Sun-Fri day" Depth - With the --depth NUM option (short form: -NUM), reports will show - accounts only to the specified depth, hiding deeper subaccounts. Use - this when you want a summary with less detail. This flag has the same + With the --depth NUM option (short form: -NUM), reports will show + accounts only to the specified depth, hiding deeper subaccounts. Use + this when you want a summary with less detail. This flag has the same effect as a depth: query argument: depth:2, --depth=2 or -2 are equiva- lent. @@ -4547,12 +4538,12 @@ Queries subset of your data. Most hledger commands accept optional query argu- ments to restrict their scope. The syntax is as follows: - o Zero or more space-separated query terms. These are most often + o Zero or more space-separated query terms. These are most often account name substrings: utilities food:groceries - o Terms with spaces or other special characters should be enclosed in + o Terms with spaces or other special characters should be enclosed in quotes: "personal care" @@ -4574,16 +4565,16 @@ Queries prefixed with not: to convert them into a negative match. acct:REGEX, REGEX - Match account names containing this (case insensitive) regular expres- + Match account names containing this (case insensitive) regular expres- sion. This is the default query type when there is no prefix, and reg- - ular expression syntax is typically not needed, so usually we just + ular expression syntax is typically not needed, so usually we just write an account name substring, like expenses or food. amt:N, amt:N, amt:>=N - Match postings with a single-commodity amount equal to, less than, or - greater than N. (Postings with multi-commodity amounts are not tested + Match postings with a single-commodity amount equal to, less than, or + greater than N. (Postings with multi-commodity amounts are not tested and will always match.) The comparison has two modes: if N is preceded - by a + or - sign (or is 0), the two signed numbers are compared. Oth- + by a + or - sign (or is 0), the two signed numbers are compared. Oth- erwise, the absolute magnitudes are compared, ignoring sign. code:REGEX @@ -4591,10 +4582,10 @@ Queries cur:REGEX Match postings or transactions including any amounts whose cur- - rency/commodity symbol is fully matched by REGEX. (For a partial - match, use .*REGEX.*). Note, to match special characters which are - regex-significant, you need to escape them with \. And for characters - which are significant to your shell you may need one more level of + rency/commodity symbol is fully matched by REGEX. (For a partial + match, use .*REGEX.*). Note, to match special characters which are + regex-significant, you need to escape them with \. And for characters + which are significant to your shell you may need one more level of escaping. So eg to match the dollar sign: hledger print cur:\\$. @@ -4602,17 +4593,17 @@ Queries Match transaction descriptions. date:PERIODEXPR - Match dates (or with the --date2 flag, secondary dates) within the - specified period. PERIODEXPR is a period expression with no report + Match dates (or with the --date2 flag, secondary dates) within the + specified period. PERIODEXPR is a period expression with no report interval. Examples: date:2016, date:thismonth, date:2/1-2/15, date:2021-07-27..nextquarter. date2:PERIODEXPR - Match secondary dates within the specified period (independent of the + Match secondary dates within the specified period (independent of the --date2 flag). depth:N - Match (or display, depending on command) accounts at or above this + Match (or display, depending on command) accounts at or above this depth. note:REGEX @@ -4620,7 +4611,7 @@ Queries whole description if there's no |). payee:REGEX - Match transaction payee/payer names (the part of the description left + Match transaction payee/payer names (the part of the description left of |, or the whole description if there's no |). real:, real:0 @@ -4630,11 +4621,11 @@ Queries Match unmarked, pending, or cleared transactions respectively. type:TYPECODES - Match by account type (see Declaring accounts > Account types). TYPE- - CODES is one or more of the single-letter account type codes ALERXCV, + Match by account type (see Declaring accounts > Account types). TYPE- + CODES is one or more of the single-letter account type codes ALERXCV, case insensitive. Note type:A and type:E will also match their respec- - tive subtypes C (Cash) and V (Conversion). Certain kinds of account - alias can disrupt account types, see Rewriting accounts > Aliases and + tive subtypes C (Cash) and V (Conversion). Certain kinds of account + alias can disrupt account types, see Rewriting accounts > Aliases and account types. tag:REGEX[=REGEX] @@ -4650,11 +4641,11 @@ Queries o Transactions also acquire the tags of their postings. (inacct:ACCTNAME - A special query term used automatically in hledger-web only: tells + A special query term used automatically in hledger-web only: tells hledger-web to show the transaction register for an account.) Combining query terms - When given multiple query terms, most commands select things which + When given multiple query terms, most commands select things which match: o any of the description terms AND @@ -4677,7 +4668,7 @@ Queries Although these fixed rules are enough for many needs, we do not support full boolean expressions (#203), (and you should not write AND or OR in - your queries). This makes certain queries hard to express, but here + your queries). This makes certain queries hard to express, but here are some tricks that can help: 1. Use a doubled not: prefix. Eg, to print only the food expenses paid @@ -4685,21 +4676,17 @@ Queries $ hledger print food not:not:cash - 2. Or pre-filter the transactions with print, piping the result into a + 2. Or pre-filter the transactions with print, piping the result into a second hledger command (with balance assertions disabled): $ hledger print cash | hledger -f- -I balance food Queries and command options - Some queries can also be expressed as command-line options: depth:2 is + Some queries can also be expressed as command-line options: depth:2 is equivalent to --depth 2, date:2020 is equivalent to -p 2020, etc. When - you mix command options and query arguments, generally the resulting + you mix command options and query arguments, generally the resulting query is their intersection. - Queries and account aliases - When account names are rewritten with --alias or alias, acct: will - match either the old or the new account name. - Queries and valuation When amounts are converted to other commodities in cost or value reports, cur: and amt: match the old commodity symbol and the old @@ -4928,11 +4915,14 @@ Cost reporting Happily, current hledger can read either notation, or convert one to the other when needed, so you can use the one you prefer. + You can even use cost notation and equivalent conversion postings at + the same time, for clarity. hledger will ignore the redundancy. But + be sure the cost and conversion posting amounts match, or you'll see a + not-so-clear transaction balancing error message. + Inferring equity postings from cost With --infer-equity, hledger detects transactions written with PTA cost - notation and adds equity conversion postings to them (and temporarily - permits the coexistence of equity conversion postings and cost nota- - tion, which normally would cause an unbalanced transaction error). Eg: + notation and adds equity conversion postings to them: 2022-01-01 assets:dollars -$135 @@ -4955,9 +4945,8 @@ Cost reporting Inferring cost from equity postings The reverse operation is possible using --infer-costs, which detects - transactions written with equity conversion postings and adds PTA cost - notation to them (and temporarily permits the coexistence of equity - conversion postings and cost notation). Eg: + transactions written with equity conversion postings and adds cost + notation to them: 2022-01-01 assets:dollars $-135 @@ -4972,8 +4961,8 @@ Cost reporting equity:conversion EUR-100 assets:euros EUR100 - --infer-costs is useful when combined with -B/--cost, allowing cost - reporting even when transactions have been recorded using equity post- + --infer-costs is useful when combined with -B/--cost, allowing cost + reporting even when transactions have been recorded using equity post- ings: $ hledger print --infer-costs -B @@ -4990,24 +4979,19 @@ Cost reporting 2. two equity postings, next to one another 3. the equity accounts must be declared, with account type V/Conversion - (or if they are not declared, they must be named equity:conversion, + (or if they are not declared, they must be named equity:conversion, equity:trade, equity:trading or subaccounts of these) 4. the equity postings' amounts must exactly match the non-equity post- - ings' amounts + ings' amounts. - 5. all of the amounts must be explicit, with none missing - - Multiple such exchanges can coexist within a single transaction, should - you need that. + Multiple such exchanges can coexist within a single transaction. When inferring cost, the order of postings matters: the cost is added to the first of the non-equity postings involved in the exchange, in the commodity of the last non-equity posting involved in the exchange. - If you don't want to write your postings in the required order, the - alternative is not to infer cost; instead, use explicit cost notation, - omitting the equity postings, inferring them later with --infer-equity - if needed. + If you don't want to write your postings in the required order, you can + use explicit cost notation instead. --infer-equity and --infer-costs can be used together, if you have a mixture of both notations in your journal. @@ -5115,9 +5099,7 @@ Cost reporting o Cost reporting requires adding the --infer-costs flag Conversion with equity postings and explicit cost - Here both equity postings and @ notation are used together. hledger - will usually complain about this redundancy, but when using the - --infer-costs flag it is accepted. + Here both equity postings and @ notation are used together. 2021-01-01 assets:cash -100 EUR @ 1.20 USD @@ -5139,26 +5121,26 @@ Cost reporting o Most verbose - o Requires the --infer-costs flag - o Not compatible with ledger Cost tips - o Recording the conversion rate explicitly is good because it makes - that clear and helps detect errors. + o Recording the cost/conversion rate explicitly is good because it + makes that clear and helps detect errors. o Recording equity postings is good because it is correct bookkeeping and preserves the accounting equation. - o Combining these is possible by using the --infer-costs flag (which - requires well-ordered postings). + o Combining these is possible. - o When you want to see the cost (or sale proceeds) of things, use -B - (or --cost). If you use equity conversion postings notation, use -B - --infer-costs. + o When you want to see the cost (or sale proceeds) of things, use -B + (short form of --cost). - o If you use PTA cost notation, and you want to see a balanced balance - sheet or print correct journal entries, use --infer-equity. + o If you use conversion postings without cost notation, add --infer- + costs also. + + o If you use cost notation without conversion postings, and you want to + see a balanced balance sheet or print correct journal entries, use + --infer-equity. o Conversion to cost is performed before valuation (described next). @@ -5597,6 +5579,10 @@ Valuation is, bs postings in period at respec- each period, sums of post- --change, cf period tive posting valued at ings --change) dates period ends + + + + end balances sums of same as sums of values of period end value at (bal -H, is costs of --value=end postings from balances, DATE/today of --H, bs, cf) postings before period valued at sums of post- @@ -5604,7 +5590,6 @@ Valuation report start end at respective to period posting dates end - budget like balance like balance like balance like bal- like balance amounts changes/end changes/end changes/end bal- ances changes/end (--budget) balances balances ances balances @@ -5654,10 +5639,9 @@ Valuation ods). PART 4: COMMANDS - Here are the built-in commands, with the most often-used in bold: - - Data entry: + Here are the built-in commands: + DATA ENTRY These data entry commands are the only ones which can modify your jour- nal file. @@ -5665,18 +5649,17 @@ PART 4: COMMANDS o import - add any new transactions from other files (eg csv) - Data management: - - o check - check for various kinds of issue in the data - - o close (equity) - generate balance-resetting transactions - - o diff - compare account transactions in two journal files + DATA CREATION + o close - generate balance-resetting transactions o rewrite - generate extra postings, similar to print --auto - Financial statements: + DATA MANAGEMENT + o check - check for various kinds of issue in the data + o diff - compare account transactions in two journal files + + REPORTS, FINANCIAL o aregister (areg) - show transactions in a particular account o balancesheet (bs) - show assets, liabilities and net worth @@ -5687,17 +5670,22 @@ PART 4: COMMANDS o incomestatement (is) - show revenues and expenses + REPORTS, VERSATILE + o balance (bal) - show balance changes/end balances/budgets in any + accounts + + o print - show transactions (journal entries) + + o register (reg) - show postings in one or more accounts & running + total + o roi - show return on investments - Miscellaneous reports: - + REPORTS, BASIC o accounts - show account names o activity - show postings-per-interval bar charts - o balance (bal) - show balance changes/end balances/budgets in any - accounts - o codes - show transaction codes o commodities - show commodity/currency symbols @@ -5706,79 +5694,78 @@ PART 4: COMMANDS o files - show input file paths - o help - show hledger user manuals in several formats - o notes - show unique note segments of transaction descriptions o payees - show unique payee segments of transaction descriptions o prices - show market price records - o print - show transactions (journal entries) - - o register (reg) - show postings in one or more accounts & running - total - o stats - show journal statistics o tags - show tag names o test - run self tests + HELP + o help - show hledger user manuals in several formats - And here are some typical add-on commands installed by the hledger- - install script. If installed, these will also appear in hledger's com- - mands list, with a + mark: - o ui - hledger's official curses-style TUI + ADD-ONS + And here are some typical add-on commands. Some of these are installed + by the hledger-install script. If installed, they will appear in + hledger's commands list: + + o ui - hledger's official terminal UI o web - hledger's official web UI - o iadd - a popular alternative to hledger's add command. + o iadd - an alternative to hledger's add command (currently hard to + build) o interest - generates interest transactions - o stockquotes - downloads market prices. (Alpha quality, needs your - help.) + o stockquotes - downloads market prices + + o Scripts and add-ons - check-fancyassertions, edit, fifo, git, move, + pijul, plot, and more.. Next, each command is described in detail, in alphabetical order. accounts - accounts Show account names. - This command lists account names. By default it shows all known - accounts, either used in transactions or declared with account direc- + This command lists account names. By default it shows all known + accounts, either used in transactions or declared with account direc- tives. With query arguments, only matched account names and account names ref- erenced by matched postings are shown. - Or it can show just the used accounts (--used/-u), the declared - accounts (--declared/-d), the accounts declared but not used - (--unused), the accounts used but not declared (--undeclared), or the + Or it can show just the used accounts (--used/-u), the declared + accounts (--declared/-d), the accounts declared but not used + (--unused), the accounts used but not declared (--undeclared), or the first account matched by an account name pattern, if any (--find). - It shows a flat list by default. With --tree, it uses indentation to - show the account hierarchy. In flat mode you can add --drop N to omit - the first few account name components. Account names can be depth- + It shows a flat list by default. With --tree, it uses indentation to + show the account hierarchy. In flat mode you can add --drop N to omit + the first few account name components. Account names can be depth- clipped with depth:N or --depth N or -N. - With --types, it also shows each account's type, if it's known. (See + With --types, it also shows each account's type, if it's known. (See Declaring accounts > Account types.) - With --positions, it also shows the file and line number of each - account's declaration, if any, and the account's overall declaration - order; these may be useful when troubleshooting account display order. + With --positions, it also shows the file and line number of each + account's declaration, if any, and the account's overall declaration + order; these may be useful when troubleshooting account display order. - With --directives, it adds the account keyword, showing valid account - directives which can be pasted into a journal file. This is useful - together with --undeclared when updating your account declarations to + With --directives, it adds the account keyword, showing valid account + directives which can be pasted into a journal file. This is useful + together with --undeclared when updating your account declarations to satisfy hledger check accounts. - The --find flag can be used to look up a single account name, in the - same way that the aregister command does. It returns the alphanumeri- - cally-first matched account name, or if none can be found, it fails + The --find flag can be used to look up a single account name, in the + same way that the aregister command does. It returns the alphanumeri- + cally-first matched account name, or if none can be found, it fails with a non-zero exit code. Examples: @@ -5797,11 +5784,10 @@ PART 4: COMMANDS $ hledger check accounts activity - activity Show an ascii barchart of posting counts per interval. - The activity command displays an ascii histogram showing transaction - counts by day, week, month or other reporting interval (by day is the + The activity command displays an ascii histogram showing transaction + counts by day, week, month or other reporting interval (by day is the default). With query arguments, it counts only matched transactions. Examples: @@ -5813,37 +5799,36 @@ PART 4: COMMANDS 2008-10-01 ** add - add - Prompt for transactions and add them to the journal. Any arguments + Prompt for transactions and add them to the journal. Any arguments will be used as default inputs for the first N prompts. - Many hledger users edit their journals directly with a text editor, or - generate them from CSV. For more interactive data entry, there is the - add command, which prompts interactively on the console for new trans- - actions, and appends them to the main journal file (which should be in - journal format). Existing transactions are not changed. This is one - of the few hledger commands that writes to the journal file (see also + Many hledger users edit their journals directly with a text editor, or + generate them from CSV. For more interactive data entry, there is the + add command, which prompts interactively on the console for new trans- + actions, and appends them to the main journal file (which should be in + journal format). Existing transactions are not changed. This is one + of the few hledger commands that writes to the journal file (see also import). To use it, just run hledger add and follow the prompts. You can add as - many transactions as you like; when you are finished, enter . or press + many transactions as you like; when you are finished, enter . or press control-d or control-c to exit. Features: - o add tries to provide useful defaults, using the most similar (by - description) recent transaction (filtered by the query, if any) as a + o add tries to provide useful defaults, using the most similar (by + description) recent transaction (filtered by the query, if any) as a template. o You can also set the initial defaults with command line arguments. o Readline-style edit keys can be used during data entry. - o The tab key will auto-complete whenever possible - accounts, pay- - ees/descriptions, dates (yesterday, today, tomorrow). If the input + o The tab key will auto-complete whenever possible - accounts, pay- + ees/descriptions, dates (yesterday, today, tomorrow). If the input area is empty, it will insert the default value. - o If the journal defines a default commodity, it will be added to any + o If the journal defines a default commodity, it will be added to any bare numbers entered. o A parenthesised transaction code may be entered following a date. @@ -5852,7 +5837,7 @@ PART 4: COMMANDS o If you make a mistake, enter < at any prompt to go one step backward. - o Input prompts are displayed in a different colour when the terminal + o Input prompts are displayed in a different colour when the terminal supports it. Example (see https://hledger.org/add.html for a detailed tutorial): @@ -5882,101 +5867,102 @@ PART 4: COMMANDS Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2015/05/22]: $ - On Microsoft Windows, the add command makes sure that no part of the + On Microsoft Windows, the add command makes sure that no part of the file path ends with a period, as that would cause problems (#1056). aregister - aregister, areg + (areg) - Show the transactions and running historical balance of a single + Show the transactions and running historical balance of a single account, with each transaction displayed as one line. aregister shows the overall transactions affecting a particular account - (and any subaccounts). Each report line represents one transaction in - this account. Transactions before the report start date are always + (and any subaccounts). Each report line represents one transaction in + this account. Transactions before the report start date are always included in the running balance (--historical mode is always on). - This is a more "real world", bank-like view than the register command - (which shows individual postings, possibly from multiple accounts, not + This is a more "real world", bank-like view than the register command + (which shows individual postings, possibly from multiple accounts, not necessarily in historical mode). As a quick rule of thumb: - use areg- ister for reviewing and reconciling real-world asset/liability accounts - use register for reviewing detailed revenues/expenses. - aregister requires one argument: the account to report on. You can - write either the full account name, or a case-insensitive regular - expression which will select the alphabetically first matched account. + aregister requires one argument: the account to report on. You can + write either the full account name, or a case-insensitive regular + expression which will select the alphabetically first matched account. When there are multiple matches, the alphabetically-first choice can be - surprising; eg if you have assets:per:checking 1 and assets:biz:check- - ing 2 accounts, hledger areg checking would select assets:biz:checking - 2. It's just a convenience to save typing, so if in doubt, write the + surprising; eg if you have assets:per:checking 1 and assets:biz:check- + ing 2 accounts, hledger areg checking would select assets:biz:checking + 2. It's just a convenience to save typing, so if in doubt, write the full account name, or a distinctive substring that matches uniquely. - Transactions involving subaccounts of this account will also be shown. - aregister ignores depth limits, so its final total will always match a + Transactions involving subaccounts of this account will also be shown. + aregister ignores depth limits, so its final total will always match a balance report with similar arguments. - Any additional arguments form a query which will filter the transac- + Any additional arguments form a query which will filter the transac- tions shown. Note some queries will disturb the running balance, caus- ing it to be different from the account's real-world running balance. - An example: this shows the transactions and historical running balance + An example: this shows the transactions and historical running balance during july, in the first account whose name contains "checking": $ hledger areg checking date:jul Each aregister line item shows: - o the transaction's date (or the relevant posting's date if different, + o the transaction's date (or the relevant posting's date if different, see below) - o the names of all the other account(s) involved in this transaction + o the names of all the other account(s) involved in this transaction (probably abbreviated) o the total change to this account's balance from this transaction o the account's historical running balance after this transaction. - Transactions making a net change of zero are not shown by default; add + Transactions making a net change of zero are not shown by default; add the -E/--empty flag to show them. - For performance reasons, column widths are chosen based on the first - 1000 lines; this means unusually wide values in later lines can cause - visual discontinuities as column widths are adjusted. If you want to - ensure perfect alignment, at the cost of more time and memory, use the + For performance reasons, column widths are chosen based on the first + 1000 lines; this means unusually wide values in later lines can cause + visual discontinuities as column widths are adjusted. If you want to + ensure perfect alignment, at the cost of more time and memory, use the --align-all flag. - This command also supports the output destination and output format + This command also supports the output destination and output format options. The output formats supported are txt, csv, and json. aregister and custom posting dates - Transactions whose date is outside the report period can still be - shown, if they have a posting to this account dated inside the report - period. (And in this case it's the posting date that is shown.) This + Transactions whose date is outside the report period can still be + shown, if they have a posting to this account dated inside the report + period. (And in this case it's the posting date that is shown.) This ensures that aregister can show an accurate historical running balance, matching the one shown by register -H with the same arguments. - To filter strictly by transaction date instead, add the --txn-dates - flag. If you use this flag and some of your postings have custom + To filter strictly by transaction date instead, add the --txn-dates + flag. If you use this flag and some of your postings have custom dates, it's probably best to assume the running balance is wrong. balance - balance, bal + (bal) + Show accounts and their balances. - balance is one of hledger's oldest and most versatile commands, for - listing account balances, balance changes, values, value changes and + balance is one of hledger's oldest and most versatile commands, for + listing account balances, balance changes, values, value changes and more, during one time period or many. Generally it shows a table, with rows representing accounts, and columns representing periods. - Note there are some higher-level variants of the balance command with - convenient defaults, which can be simpler to use: balancesheet, bal- + Note there are some higher-level variants of the balance command with + convenient defaults, which can be simpler to use: balancesheet, bal- ancesheetequity, cashflow and incomestatement. When you need more con- trol, then use balance. balance features - Here's a quick overview of the balance command's features, followed by - more detailed descriptions and examples. Many of these work with the + Here's a quick overview of the balance command's features, followed by + more detailed descriptions and examples. Many of these work with the higher-level commands as well. balance can show.. @@ -6027,7 +6013,7 @@ PART 4: COMMANDS ..with.. - o totals (-T), averages (-A), percentages (-%), inverted sign + o totals (-T), averages (-A), percentages (-%), inverted sign (--invert) o rows and columns swapped (--transpose) @@ -6039,24 +6025,24 @@ PART 4: COMMANDS o commodities displayed on the same line or multiple lines (--layout) This command supports the output destination and output format options, - with output formats txt, csv, json, and (multi-period reports only:) - html. In txt output in a colour-supporting terminal, negative amounts + with output formats txt, csv, json, and (multi-period reports only:) + html. In txt output in a colour-supporting terminal, negative amounts are shown in red. - The --related/-r flag shows the balance of the other postings in the + The --related/-r flag shows the balance of the other postings in the transactions of the postings which would normally be shown. Simple balance report - With no arguments, balance shows a list of all accounts and their - change of balance - ie, the sum of posting amounts, both inflows and - outflows - during the entire period of the journal. ("Simple" here - means just one column of numbers, covering a single period. You can + With no arguments, balance shows a list of all accounts and their + change of balance - ie, the sum of posting amounts, both inflows and + outflows - during the entire period of the journal. ("Simple" here + means just one column of numbers, covering a single period. You can also have multi-period reports, described later.) - For real-world accounts, these numbers will normally be their end bal- + For real-world accounts, these numbers will normally be their end bal- ance at the end of the journal period; more on this below. - Accounts are sorted by declaration order if any, and then alphabeti- + Accounts are sorted by declaration order if any, and then alphabeti- cally by account name. For instance (using examples/sample.journal): $ hledger -f examples/sample.journal bal @@ -6071,7 +6057,7 @@ PART 4: COMMANDS 0 Accounts with a zero balance (and no non-zero subaccounts, in tree mode - - see below) are hidden by default. Use -E/--empty to show them + - see below) are hidden by default. Use -E/--empty to show them (revealing assets:bank:checking here): $ hledger -f examples/sample.journal bal -E @@ -6086,12 +6072,12 @@ PART 4: COMMANDS -------------------- 0 - The total of the amounts displayed is shown as the last line, unless + The total of the amounts displayed is shown as the last line, unless -N/--no-total is used. Balance report line format For single-period balance reports displayed in the terminal (only), you - can use --format FMT to customise the format and content of each line. + can use --format FMT to customise the format and content of each line. Eg: $ hledger -f examples/sample.journal balance --format "%20(account) %12(total)" @@ -6109,7 +6095,7 @@ PART 4: COMMANDS 0 The FMT format string specifies the formatting applied to each - account/balance pair. It may contain any suitable text, with data + account/balance pair. It may contain any suitable text, with data fields interpolated like so: %[MIN][.MAX](FIELDNAME) @@ -6120,14 +6106,14 @@ PART 4: COMMANDS o FIELDNAME must be enclosed in parentheses, and can be one of: - o depth_spacer - a number of spaces equal to the account's depth, or + o depth_spacer - a number of spaces equal to the account's depth, or if MIN is specified, MIN * depth spaces. o account - the account's name o total - the account's balance/posted total, right justified - Also, FMT can begin with an optional prefix to control how multi-com- + Also, FMT can begin with an optional prefix to control how multi-com- modity amounts are rendered: o %_ - render on multiple lines, bottom-aligned (the default) @@ -6136,26 +6122,26 @@ PART 4: COMMANDS o %, - render on one line, comma-separated - There are some quirks. Eg in one-line mode, %(depth_spacer) has no - effect, instead %(account) has indentation built in. Experimentation + There are some quirks. Eg in one-line mode, %(depth_spacer) has no + effect, instead %(account) has indentation built in. Experimentation may be needed to get pleasing results. Some example formats: o %(total) - the account's total - o %-20.20(account) - the account's name, left justified, padded to 20 + o %-20.20(account) - the account's name, left justified, padded to 20 characters and clipped at 20 characters - o %,%-50(account) %25(total) - account name padded to 50 characters, - total padded to 20 characters, with multiple commodities rendered on + o %,%-50(account) %25(total) - account name padded to 50 characters, + total padded to 20 characters, with multiple commodities rendered on one line - o %20(total) %2(depth_spacer)%-(account) - the default format for the + o %20(total) %2(depth_spacer)%-(account) - the default format for the single-column balance report Filtered balance report - You can show fewer accounts, a different time period, totals from + You can show fewer accounts, a different time period, totals from cleared transactions only, etc. by using query arguments or options to limit the postings being matched. Eg: @@ -6165,10 +6151,10 @@ PART 4: COMMANDS $-2 List or tree mode - By default, or with -l/--flat, accounts are shown as a flat list with + By default, or with -l/--flat, accounts are shown as a flat list with their full names visible, as in the examples above. - With -t/--tree, the account hierarchy is shown, with subaccounts' + With -t/--tree, the account hierarchy is shown, with subaccounts' "leaf" names indented below their parent: $ hledger -f examples/sample.journal balance @@ -6188,26 +6174,26 @@ PART 4: COMMANDS Notes: o "Boring" accounts are combined with their subaccount for more compact - output, unless --no-elide is used. Boring accounts have no balance - of their own and just one subaccount (eg assets:bank and liabilities + output, unless --no-elide is used. Boring accounts have no balance + of their own and just one subaccount (eg assets:bank and liabilities above). - o All balances shown are "inclusive", ie including the balances from - all subaccounts. Note this means some repetition in the output, + o All balances shown are "inclusive", ie including the balances from + all subaccounts. Note this means some repetition in the output, which requires explanation when sharing reports with non-plaintextac- - counting-users. A tree mode report's final total is the sum of the + counting-users. A tree mode report's final total is the sum of the top-level balances shown, not of all the balances shown. - o Each group of sibling accounts (ie, under a common parent) is sorted + o Each group of sibling accounts (ie, under a common parent) is sorted separately. Depth limiting - With a depth:NUM query, or --depth NUM option, or just -NUM (eg: -3) - balance reports will show accounts only to the specified depth, hiding - the deeper subaccounts. This can be useful for getting an overview + With a depth:NUM query, or --depth NUM option, or just -NUM (eg: -3) + balance reports will show accounts only to the specified depth, hiding + the deeper subaccounts. This can be useful for getting an overview without too much detail. - Account balances at the depth limit always include the balances from + Account balances at the depth limit always include the balances from any deeper subaccounts (even in list mode). Eg, limiting to depth 1: $ hledger -f examples/sample.journal balance -1 @@ -6219,7 +6205,7 @@ PART 4: COMMANDS 0 Dropping top-level accounts - You can also hide one or more top-level account name parts, using + You can also hide one or more top-level account name parts, using --drop NUM. This can be useful for hiding repetitive top-level account names: @@ -6231,54 +6217,54 @@ PART 4: COMMANDS Showing declared accounts - With --declared, accounts which have been declared with an account - directive will be included in the balance report, even if they have no + With --declared, accounts which have been declared with an account + directive will be included in the balance report, even if they have no transactions. (Since they will have a zero balance, you will also need -E/--empty to see them.) - More precisely, leaf declared accounts (with no subaccounts) will be + More precisely, leaf declared accounts (with no subaccounts) will be included, since those are usually the more useful in reports. - The idea of this is to be able to see a useful "complete" balance - report, even when you don't have transactions in all of your declared + The idea of this is to be able to see a useful "complete" balance + report, even when you don't have transactions in all of your declared accounts yet. Sorting by amount - With -S/--sort-amount, accounts with the largest (most positive) bal- - ances are shown first. Eg: hledger bal expenses -MAS shows your big- - gest averaged monthly expenses first. When more than one commodity is - present, they will be sorted by the alphabetically earliest commodity - first, and then by subsequent commodities (if an amount is missing a + With -S/--sort-amount, accounts with the largest (most positive) bal- + ances are shown first. Eg: hledger bal expenses -MAS shows your big- + gest averaged monthly expenses first. When more than one commodity is + present, they will be sorted by the alphabetically earliest commodity + first, and then by subsequent commodities (if an amount is missing a commodity, it is treated as 0). - Revenues and liability balances are typically negative, however, so -S - shows these in reverse order. To work around this, you can add - --invert to flip the signs. (Or, use one of the higher-level reports, - which flip the sign automatically. Eg: hledger incomestatement -MAS). + Revenues and liability balances are typically negative, however, so -S + shows these in reverse order. To work around this, you can add + --invert to flip the signs. (Or, use one of the higher-level reports, + which flip the sign automatically. Eg: hledger incomestatement -MAS). Percentages - With -%/--percent, balance reports show each account's value expressed + With -%/--percent, balance reports show each account's value expressed as a percentage of the (column) total. Note it is not useful to calculate percentages if the amounts in a col- - umn have mixed signs. In this case, make a separate report for each + umn have mixed signs. In this case, make a separate report for each sign, eg: $ hledger bal -% amt:`>0` $ hledger bal -% amt:`<0` - Similarly, if the amounts in a column have mixed commodities, convert - them to one commodity with -B, -V, -X or --value, or make a separate + Similarly, if the amounts in a column have mixed commodities, convert + them to one commodity with -B, -V, -X or --value, or make a separate report for each commodity: $ hledger bal -% cur:\\$ $ hledger bal -% cur:EUR Multi-period balance report - With a report interval (set by the -D/--daily, -W/--weekly, - -M/--monthly, -Q/--quarterly, -Y/--yearly, or -p/--period flag), bal- - ance shows a tabular report, with columns representing successive time + With a report interval (set by the -D/--daily, -W/--weekly, + -M/--monthly, -Q/--quarterly, -Y/--yearly, or -p/--period flag), bal- + ance shows a tabular report, with columns representing successive time periods (and a title): $ hledger -f examples/sample.journal bal --quarterly income expenses -E @@ -6299,21 +6285,21 @@ PART 4: COMMANDS encompass the displayed subperiods (so that the first and last subpe- riods have the same duration as the others). - o Leading and trailing periods (columns) containing all zeroes are not + o Leading and trailing periods (columns) containing all zeroes are not shown, unless -E/--empty is used. - o Accounts (rows) containing all zeroes are not shown, unless + o Accounts (rows) containing all zeroes are not shown, unless -E/--empty is used. - o Amounts with many commodities are shown in abbreviated form, unless + o Amounts with many commodities are shown in abbreviated form, unless --no-elide is used. (experimental) - o Average and/or total columns can be added with the -A/--average and + o Average and/or total columns can be added with the -A/--average and -T/--row-total flags. o The --transpose flag can be used to exchange rows and columns. - o The --pivot FIELD option causes a different transaction field to be + o The --pivot FIELD option causes a different transaction field to be used as "account name". See PIVOTING. Multi-period reports with many periods can be too wide for easy viewing @@ -6327,57 +6313,57 @@ PART 4: COMMANDS o Reduce the terminal's font size - o View with a pager like less, eg: hledger bal -D --color=yes | less + o View with a pager like less, eg: hledger bal -D --color=yes | less -RS - o Output as CSV and use a CSV viewer like visidata (hledger bal -D -O - csv | vd -f csv), Emacs' csv-mode (M-x csv-mode, C-c C-a), or a + o Output as CSV and use a CSV viewer like visidata (hledger bal -D -O + csv | vd -f csv), Emacs' csv-mode (M-x csv-mode, C-c C-a), or a spreadsheet (hledger bal -D -o a.csv && open a.csv) - o Output as HTML and view with a browser: hledger bal -D -o a.html && + o Output as HTML and view with a browser: hledger bal -D -o a.html && open a.html Balance change, end balance - It's important to be clear on the meaning of the numbers shown in bal- + It's important to be clear on the meaning of the numbers shown in bal- ance reports. Here is some terminology we use: - A balance change is the net amount added to, or removed from, an + A balance change is the net amount added to, or removed from, an account during some period. - An end balance is the amount accumulated in an account as of some date - (and some time, but hledger doesn't store that; assume end of day in + An end balance is the amount accumulated in an account as of some date + (and some time, but hledger doesn't store that; assume end of day in your timezone). It is the sum of previous balance changes. - We call it a historical end balance if it includes all balance changes + We call it a historical end balance if it includes all balance changes since the account was created. For a real world account, this means it - will match the "historical record", eg the balances reported in your + will match the "historical record", eg the balances reported in your bank statements or bank web UI. (If they are correct!) - In general, balance changes are what you want to see when reviewing + In general, balance changes are what you want to see when reviewing revenues and expenses, and historical end balances are what you want to see when reviewing or reconciling asset, liability and equity accounts. - balance shows balance changes by default. To see accurate historical + balance shows balance changes by default. To see accurate historical end balances: - 1. Initialise account starting balances with an "opening balances" - transaction (a transfer from equity to the account), unless the + 1. Initialise account starting balances with an "opening balances" + transaction (a transfer from equity to the account), unless the journal covers the account's full lifetime. 2. Include all of of the account's prior postings in the report, by not - specifying a report start date, or by using the -H/--historical + specifying a report start date, or by using the -H/--historical flag. (-H causes report start date to be ignored when summing post- ings.) Balance report types - The balance command is quite flexible; here is the full detail on how - to control what it reports. If the following seems complicated, don't + The balance command is quite flexible; here is the full detail on how + to control what it reports. If the following seems complicated, don't worry - this is for advanced reporting, and it does typically take some time and experimentation to get clear on all these report modes. There are three important option groups: - hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] + hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] ... Calculation type @@ -6389,44 +6375,44 @@ PART 4: COMMANDS each account/period) o --valuechange : show the change in period-end historical balance val- - ues (caused by deposits, withdrawals, and/or market price fluctua- + ues (caused by deposits, withdrawals, and/or market price fluctua- tions) - o --gain : show the unrealised capital gain/loss, (the current valued + o --gain : show the unrealised capital gain/loss, (the current valued balance minus each amount's original cost) Accumulation type - How amounts should accumulate across report periods. Another way to - say it: which time period's postings should contribute to each cell's + How amounts should accumulate across report periods. Another way to + say it: which time period's postings should contribute to each cell's calculation. It is one of: - o --change : calculate with postings from column start to column end, - ie "just this column". Typically used to see revenues/expenses. + o --change : calculate with postings from column start to column end, + ie "just this column". Typically used to see revenues/expenses. (default for balance, incomestatement) - o --cumulative : calculate with postings from report start to column - end, ie "previous columns plus this column". Typically used to show + o --cumulative : calculate with postings from report start to column + end, ie "previous columns plus this column". Typically used to show changes accumulated since the report's start date. Not often used. - o --historical/-H : calculate with postings from journal start to col- - umn end, ie "all postings from before report start date until this - column's end". Typically used to see historical end balances of + o --historical/-H : calculate with postings from journal start to col- + umn end, ie "all postings from before report start date until this + column's end". Typically used to see historical end balances of assets/liabilities/equity. (default for balancesheet, balancesheete- quity, cashflow) Valuation type - Which kind of value or cost conversion should be applied, if any, + Which kind of value or cost conversion should be applied, if any, before displaying the report. It is one of: o no valuation type : don't convert to cost or value (default) - o --value=cost[,COMM] : convert amounts to cost (then optionally to + o --value=cost[,COMM] : convert amounts to cost (then optionally to some other commodity) - o --value=then[,COMM] : convert amounts to market value on transaction + o --value=then[,COMM] : convert amounts to market value on transaction dates - o --value=end[,COMM] : convert amounts to market value on period end + o --value=end[,COMM] : convert amounts to market value on period end date(s) (default with --valuechange, --gain) @@ -6437,7 +6423,7 @@ PART 4: COMMANDS or one of the equivalent simpler flags: - o -B/--cost : like --value=cost (though, note --cost and --value are + o -B/--cost : like --value=cost (though, note --cost and --value are independent options which can both be used at once) o -V/--market : like --value=end @@ -6447,13 +6433,13 @@ PART 4: COMMANDS See Cost reporting and Valuation for more about these. Combining balance report types - Most combinations of these options should produce reasonable reports, - but if you find any that seem wrong or misleading, let us know. The + Most combinations of these options should produce reasonable reports, + but if you find any that seem wrong or misleading, let us know. The following restrictions are applied: o --valuechange implies --value=end - o --valuechange makes --change the default when used with the bal- + o --valuechange makes --change the default when used with the bal- ancesheet/balancesheetequity commands o --cumulative or --historical disables --row-total/-T @@ -6468,26 +6454,26 @@ PART 4: COMMANDS lation:v ----------------------------------------------------------------------------------- --change change in period sum of posting- period-end DATE-value of - date market val- value of change change in + date market val- value of change change in ues in period in period period --cumu- change from sum of posting- period-end DATE-value of - lative report start to date market val- value of change change from + lative report start to date market val- value of change change from period end ues from report from report report start start to period start to period to period end end end --his- change from sum of posting- period-end DATE-value of - torical journal start to date market val- value of change change from - /-H period end (his- ues from journal from journal journal start + torical journal start to date market val- value of change change from + /-H period end (his- ues from journal from journal journal start torical end bal- start to period start to period to period end ance) end end Budget report - The --budget report type activates extra columns showing any budget - goals for each account and period. The budget goals are defined by + The --budget report type activates extra columns showing any budget + goals for each account and period. The budget goals are defined by periodic transactions. This is useful for comparing planned and actual income, expenses, time usage, etc. - For example, you can take average monthly expenses in the common + For example, you can take average monthly expenses in the common expense categories to construct a minimal monthly budget: ;; Budget @@ -6534,26 +6520,26 @@ PART 4: COMMANDS This is different from a normal balance report in several ways: - o Only accounts with budget goals during the report period are shown, + o Only accounts with budget goals during the report period are shown, by default. - o In each column, in square brackets after the actual amount, budget - goal amounts are shown, and the actual/goal percentage. (Note: bud- + o In each column, in square brackets after the actual amount, budget + goal amounts are shown, and the actual/goal percentage. (Note: bud- get goals should be in the same commodity as the actual amount.) - o All parent accounts are always shown, even in list mode. Eg assets, + o All parent accounts are always shown, even in list mode. Eg assets, assets:bank, and expenses above. - o Amounts always include all subaccounts, budgeted or unbudgeted, even + o Amounts always include all subaccounts, budgeted or unbudgeted, even in list mode. - This means that the numbers displayed will not always add up! Eg - above, the expenses actual amount includes the gifts and supplies + This means that the numbers displayed will not always add up! Eg + above, the expenses actual amount includes the gifts and supplies transactions, but the expenses:gifts and expenses:supplies accounts are not shown, as they have no budget amounts declared. - This can be confusing. When you need to make things clearer, use the - -E/--empty flag, which will reveal all accounts including unbudgeted + This can be confusing. When you need to make things clearer, use the + -E/--empty flag, which will reveal all accounts including unbudgeted ones, giving the full picture. Eg: $ hledger balance -M --budget --empty @@ -6592,15 +6578,27 @@ PART 4: COMMANDS ----------------------++---------------------------------------------------- || 0 [ 0] 0 [ 0] + It's common to limit budgets/budget reports to just expenses + + hledger bal -M --budget expenses + + or just revenues and expenses (eg, using account types): + + hledger bal -M --budget type:rx + + It's also common to limit or convert them to a single currency + (cur:COMM or -X COMM [--infer-market-prices]). If showing multiple + currencies, --layout bare or --layout tall can help. + For more examples and notes, see Budgeting. Budget report start date - This might be a bug, but for now: when making budget reports, it's a + This might be a bug, but for now: when making budget reports, it's a good idea to explicitly set the report's start date to the first day of - a reporting period, because a periodic rule like ~ monthly generates - its transactions on the 1st of each month, and if your journal has no - regular transactions on the 1st, the default report start date could - exclude that budget goal, which can be a little surprising. Eg here + a reporting period, because a periodic rule like ~ monthly generates + its transactions on the 1st of each month, and if your journal has no + regular transactions on the 1st, the default report start date could + exclude that budget goal, which can be a little surprising. Eg here the default report period is just the day of 2020-01-15: ~ monthly in 2020 @@ -6619,9 +6617,9 @@ PART 4: COMMANDS --------------++------------ || $400 - To avoid this, specify the budget report's period, or at least the - start date, with -b/-e/-p/date:, to ensure it includes the budget goal - transactions (periodic transactions) that you want. Eg, adding -b + To avoid this, specify the budget report's period, or at least the + start date, with -b/-e/-p/date:, to ensure it includes the budget goal + transactions (periodic transactions) that you want. Eg, adding -b 2020/1/1 to the above: $ hledger bal expenses --budget -b 2020/1/1 @@ -6634,12 +6632,12 @@ PART 4: COMMANDS || $400 [80% of $500] Budgets and subaccounts - You can add budgets to any account in your account hierarchy. If you + You can add budgets to any account in your account hierarchy. If you have budgets on both parent account and some of its children, then bud- - get(s) of the child account(s) would be added to the budget of their + get(s) of the child account(s) would be added to the budget of their parent, much like account balances behave. - In the most simple case this means that once you add a budget to any + In the most simple case this means that once you add a budget to any account, all its parents would have budget as well. To illustrate this, consider the following budget: @@ -6649,13 +6647,13 @@ PART 4: COMMANDS expenses:personal:electronics $100.00 liabilities - With this, monthly budget for electronics is defined to be $100 and - budget for personal expenses is an additional $1000, which implicitly + With this, monthly budget for electronics is defined to be $100 and + budget for personal expenses is an additional $1000, which implicitly means that budget for both expenses:personal and expenses is $1100. - Transactions in expenses:personal:electronics will be counted both - towards its $100 budget and $1100 of expenses:personal , and transac- - tions in any other subaccount of expenses:personal would be counted + Transactions in expenses:personal:electronics will be counted both + towards its $100 budget and $1100 of expenses:personal , and transac- + tions in any other subaccount of expenses:personal would be counted towards only towards the budget of expenses:personal. For example, let's consider these transactions: @@ -6681,9 +6679,9 @@ PART 4: COMMANDS expenses:personal $30.00 liabilities - As you can see, we have transactions in expenses:personal:electron- - ics:upgrades and expenses:personal:train tickets, and since both of - these accounts are without explicitly defined budget, these transac- + As you can see, we have transactions in expenses:personal:electron- + ics:upgrades and expenses:personal:train tickets, and since both of + these accounts are without explicitly defined budget, these transac- tions would be counted towards budgets of expenses:personal:electronics and expenses:personal accordingly: @@ -6699,7 +6697,7 @@ PART 4: COMMANDS -------------------------------++------------------------------- || 0 [ 0] - And with --empty, we can get a better picture of budget allocation and + And with --empty, we can get a better picture of budget allocation and consumption: $ hledger balance --budget -M --empty @@ -6718,25 +6716,76 @@ PART 4: COMMANDS Selecting budget goals The budget report evaluates periodic transaction rules to generate spe- - cial "goal transactions", which generate the goal amounts for each - account in each report subperiod. When troubleshooting, you can use - the print command to show these as forecasted transactions: + cial "goal transactions", which generate the goal amounts for each + account in each report subperiod. When troubleshooting, you can use + print --forecast to show these as forecasted transactions: $ hledger print --forecast=BUDGETREPORTPERIOD tag:generated - By default, the budget report uses all available periodic transaction - rules to generate goals. This includes rules with a different report - interval from your report. Eg if you have daily, weekly and monthly - periodic rules, all of these will contribute to the goals in a monthly + By default, the budget report uses all available periodic transaction + rules to generate goals. This includes rules with a different report + interval from your report. Eg if you have daily, weekly and monthly + periodic rules, all of these will contribute to the goals in a monthly budget report. - You can select a subset of periodic rules by providing an argument to - the --budget flag. --budget=DESCPAT will match all periodic rules + You can select a subset of periodic rules by providing an argument to + the --budget flag. --budget=DESCPAT will match all periodic rules whose description contains DESCPAT, a case-insensitive substring (not a - regular expression or query). This means you can give your periodic - rules descriptions (remember that two spaces are needed), and then + regular expression or query). This means you can give your periodic + rules descriptions (remember that two spaces are needed), and then select from multiple budgets defined in your journal. + Budget vs forecast + hledger --forecast ... and hledger balance --budget ... are separate + features, though both of them use the periodic transaction rules + defined in the journal, and both of them generate temporary transac- + tions for reporting purposes ("forecast transactions" and "budget goal + transactions", respectively). You can use both features at the same + time if you want. Here are some differences between them, as of + hledger 1.29: + + CLI: + + o --forecast is a general hledger option, usable with any command + + o --budget is a balance command option, usable only with that command. + + Visibility of generated transactions: + + o forecast transactions are visible in any report, like ordinary trans- + actions + + o budget goal transactions are invisible except for the goal amounts + they produce in --budget reports. + + Periodic transaction rules: + + o --forecast uses all available periodic transaction rules + + o --budget uses all periodic rules (--budget) or a selected subset + (--budget=DESCPAT) + + Period of generated transactions: + + o --forecast generates forecast transactions + + o from after the last regular transaction to the end of the report + period (--forecast) + + o or, during a specified period (--forecast=PERIODEXPR) + + o possibly further restricted by a period specified in the periodic + transaction rule + + o and always restricted within the bounds of the report period + + o --budget generates budget goal transactions + + o throughout the report period + + o possibly restricted by a period specified in the periodic transac- + tion rule. + Data layout The --layout option affects how balance reports show multi-commodity amounts and commodity symbols, which can improve readability. It can @@ -6906,7 +6955,8 @@ PART 4: COMMANDS Show top gainers [or losers] last week balancesheet - balancesheet, bs + (bs) + This command displays a balance sheet, showing historical ending bal- ances of asset and liability accounts. (To see equity as well, use the balancesheetequity command.) Amounts are shown with normal positive @@ -6949,7 +6999,8 @@ PART 4: COMMANDS mental) json. balancesheetequity - balancesheetequity, bse + (bse) + This command displays a balance sheet, showing historical ending bal- ances of asset, liability and equity accounts. Amounts are shown with normal positive sign, as in conventional financial statements. @@ -6996,7 +7047,8 @@ PART 4: COMMANDS mental) json. cashflow - cashflow, cf + (cf) + This command displays a cashflow statement, showing the inflows and outflows affecting "cash" (ie, liquid, easily convertible) assets. Amounts are shown with normal positive sign, as in conventional finan- @@ -7043,7 +7095,6 @@ PART 4: COMMANDS mental) json. check - check Check for various kinds of errors in your data. hledger provides a number of built-in error checks to help prevent @@ -7100,6 +7151,8 @@ PART 4: COMMANDS o recentassertions - all accounts with balance assertions have a bal- ance assertion no more than 7 days before their latest posting + o tags - all tags used by transactions have been declared + o uniqueleafnames - all account leaf names are unique Custom checks @@ -7129,210 +7182,175 @@ PART 4: COMMANDS assertions against real-world balances. close - close, equity - Prints a sample "closing" transaction bringing specified account bal- - ances to zero, and an inverse "opening" transaction restoring the same - account balances. + close [--retain | --migrate | --open] [QUERY] - If like most people you split your journal files by time, eg by year: - at the end of the year you can use this command to "close out" your - asset and liability (and perhaps equity) balances in the old file, and - reinitialise them in the new file. This helps ensure that report bal- - ances remain correct whether you are including old files or not. - (Because all closing/opening transactions except the very first will - cancel out - see example below.) + By default: prints a transaction that zeroes out ("closes") all + accounts, transferring their balances to an equity account. Query + arguments can be added to override the accounts selection. Three other + modes are supported: - Some people also use this command to close out revenue and expense bal- - ances at the end of an accounting period. This properly records the - period's profit/loss as "retained earnings" (part of equity), and - allows the accounting equation (A-L=E) to balance, which you could then - check by the bse report's zero total. + --retain: prints a transaction closing revenue and expense balances. + This is traditionally done by businesses at the end of each accounting + period; it is less necessary in personal and computer-based accounting, + but it can help balance the accounting equation A=L+E. - You can print just the closing transaction by using the --close flag, - or just the opening transaction with the --open flag. + --migrate: prints a transaction to close asset, liability and most + equity balances, and another transaction to re-open them. This can be + useful when starting a new file (for performance or data protection). + Adding the closing transaction to the old file allows old and new files + to be combined. - Their descriptions are closing balances and opening balances by - default; you can customise these with the --close-desc and --open-desc - options. + --open: as above, but prints just the opening transaction. This can be + useful for starting a new file, leaving the old file unchanged. Simi- + lar to Ledger's equity command. - Just one balancing equity posting is used by default, with the amount - left implicit. The default account name is equity:opening/closing bal- - ances. You can customise the account name(s) with --close-acct and - --open-acct. (If you specify only one of these, it will be used for - both.) + You can change the equity account name with --close-acct ACCT. It + defaults to equity:retained earnings with --retain, or equity:open- + ing/closing balances otherwise. - With --x/--explicit, the equity posting's amount will be shown explic- - itly, and if it involves multiple commodities, there will be a separate - equity posting for each commodity (as in the print command). + You can change the transaction description(s) with --close-desc 'DESC' + and --open-desc 'DESC'. It defaults to retain earnings with --retain, + or closing balances and opening balances otherwise. - With --interleaved, each equity posting is shown next to the posting it - balances (good for troubleshooting). + Just one posting to the equity account will be used by default, with an + implicit amount. + + With --x/--explicit the amount will be shown explicitly, and if it + involves multiple commodities, a separate posting will be generated for + each commodity. + + With --interleaved, each equity posting is shown next to the corre- + sponding source/destination posting. + + The default closing date is yesterday or the journal's end date, which- + ever is later. You can change this by specifying a report end date; + the last day of the report period will be the closing date. Eg -e 2022 + means "close on 2022-12-31". + + The default closing date is yesterday, or the journal's end date, + whichever is later. You can change this by specifying a report end + date; (The report start date does not matter.) The last day of the + report period will be the closing date; eg -e 2022 means "close on + 2022-12-31". The opening date is always the day after the closing + date. close and costs - Costs are ignored (and discarded) by closing/opening transactions, by - default. With --show-costs, they are preserved; there will be a sepa- - rate equity posting for each cost in each commodity. This means bal- - ance -B reports will look the same after the transition. Note if you - have many foreign currency or investment transactions, this will gener- - ate very large journal entries. - - close date - The default closing date is yesterday, or the journal's end date, - whichever is later. - - Unless you are running close on exactly the first day of the new - period, you'll want to override the closing date. This is done by - specifying a report end date, where "last day of the report period" - will be the closing date. The opening date is always the following - day. So to close on (end of) 2020-12-31 and open on (start of) - 2021-01-01, any of these will work: - - - end date argu- explanation - ment - -------------------------------------------------------------------------- - -e 2021-01-01 end dates are exclusive - -e 2021 equivalent, per smart dates - -p 2020 equivalent, the period's begin date is ignored - date:2020 equivalent query - - Example: close asset/liability accounts for file transition - Carrying asset/liability balances from 2020.journal into a new file for - 2021: - - $ hledger close -f 2020.journal -p 2020 assets liabilities - # copy/paste the closing transaction to the end of 2020.journal - # copy/paste the opening transaction to the start of 2021.journal - - Or: - - $ hledger close -f 2020.journal -p 2020 assets liabilities --open >> 2021.journal # add 2021's first transaction - $ hledger close -f 2020.journal -p 2020 assets liabilities --close >> 2020.journal # add 2020's last transaction - - Now, - - $ hledger bs -f 2021.journal # just new file - balances correct - $ hledger bs -f 2020.journal -f 2021.journal # old and new files - balances correct - $ hledger bs -f 2020.journal # just old files - balances are zero ? - # (exclude final closing txn, see below) - - Hiding opening/closing transactions - Although the closing/opening transactions cancel out, they will be vis- - ible in reports like print and register, creating some visual clutter. - You can exclude them all with a query, like: - - $ hledger print not:desc:'opening|closing' # less typing - $ hledger print not:'equity:opening/closing balances' # more precise - - But when reporting on multiple files, this can get a bit tricky; you - may need to keep the earliest opening balances, for a historical regis- - ter report; or you may need to suppress a closing transaction, to see - year-end balances. If you find yourself needing more precise queries, - here's one solution: add more easily-matched tags to opening/closing - transactions, like this: - - ; 2019.journal - 2019-01-01 opening balances ; earliest opening txn, no tag here - ... - 2019-12-31 closing balances ; clopen:2020 - ... - - ; 2020.journal - 2020-01-01 opening balances ; clopen:2020 - ... - 2020-12-31 closing balances ; clopen:2021 - ... - - ; 2021.journal - 2021-01-01 opening balances ; clopen:2021 - ... - - Now with - - ; all.journal - include 2019.journal - include 2020.journal - include 2021.journal - - you could do eg: - - $ hledger -f all.journal reg -H checking not:tag:clopen - # all years checking register, hiding non-essential opening/closing txns - - $ hledger -f all.journal bs -p 2020 not:tag:clopen=2020 - # 2020 year end balances, suppressing 2020 closing txn + With --show-costs, any amount costs are shown, with separate postings + for each cost. (This currently the best way to view investment assets, + showing lots and cost bases.) If you have many currency conversion or + investment transactions, it can generate very large journal entries. close and balance assertions - The closing and opening transactions will include balance assertions, - verifying that the accounts have first been reset to zero and then - restored to their previous balance. These provide valuable error - checking, alerting you when things get out of line, but you can ignore - them temporarily with -I or just remove them if you prefer. + Balance assertions will be generated, verifying that the accounts have + been reset to zero (and then restored to their previous balances, if + there is an opening transaction). - You probably shouldn't use status or realness filters (like -C or -R or - status:) with close, or the generated balance assertions will depend on - these flags. Likewise, if you run this command with --auto, the bal- - ance assertions would probably always require --auto. + These provide useful error checking, but you can ignore them temporar- + ily with -I, or remove them if you prefer. - Multi-day transactions (where some postings have a different date) - break the balance assertions, because the money is temporarily "invisi- - ble" while in transit: + You probably should avoid filtering transactions by status or realness + (-C, -R, status:), or generating postings (--auto), with this command, + since the balance assertions would depend on these. - 2020/12/30 a purchase made in december, cleared in the next year + Note custom posting dates spanning the file boundary will disrupt the + balance assertions: + + 2023-12-30 a purchase made in december, cleared in january expenses:food 5 - assets:bank:checking -5 ; date: 2021/1/2 + assets:bank:checking -5 ; date: 2023-01-02 - To fix the assertions, you can add a temporary account to track such - in-transit money (splitting the multi-day transaction into two single- - day transactions): + To solve that you can transfer the money to and from a temporary + account, in effect splitting the multi-day transaction into two single- + day transactions: - ; in 2020.journal: - 2020/12/30 a purchase made in december, cleared in the next year + ; in 2022.journal: + 2022-12-30 a purchase made in december, cleared in january expenses:food 5 - liabilities:pending + equity:pending -5 - ; in 2021.journal: - 2021/1/2 clearance of last year's pending transactions - liabilities:pending 5 = 0 - assets:bank:checking + ; in 2023.journal: + 2023-01-02 last year's transaction cleared + equity:pending 5 = 0 + assets:bank:checking -5 - Example: close revenue/expense accounts to retained earnings - For this, use --close to suppress the opening transaction, as it's not - needed. Also you'll want to change the equity account name to your - equivalent of "equity:retained earnings". + Example: retain earnings + Record 2022's revenues/expenses as retained earnings on 2022-12-31, + appending the generated transaction to the journal: - Closing 2021's first quarter revenues/expenses: + $ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal - $ hledger close -f 2021.journal --close revenues expenses -p 2021Q1 \ - --close-acct='equity:retained earnings' >> 2021.journal + Now 2022's income statement will show only zeroes. To see it again, + exclude the retain transaction. Eg: - The same, using the default journal and current year: + $ hledger -f 2022.journal is not:desc:'retain earnings' - $ hledger close --close revenues expenses -p Q1 \ - --close-acct='equity:retained earnings' >> $LEDGER_FILE + Example: migrate balances to a new file + Close assets/liabilities/equity on 2022-12-31 and re-open them on + 2023-01-01: - Now, the first quarter's balance sheet should show a zero (unless you - are using @/@@ notation without equity postings): + $ hledger close --migrate -f 2022.journal -p 2022 + # copy/paste the closing transaction to the end of 2022.journal + # copy/paste the opening transaction to the start of 2023.journal - $ hledger bse -p Q1 + Now 2022's balance sheet will show only zeroes, indicating a balanced + accounting equation. (Unless you are using @/@@ notation - in that + case, try adding --infer-equity.) To see it again, exclude the closing + transaction. Eg: - And we must suppress the closing transaction to see the first quarter's - income statement (using the description; not:'retained earnings' won't - work here): + $ hledger -f 2022.journal bs not:desc:'closing balances' - $ hledger is -p Q1 not:desc:'closing balances' + Example: excluding closing/opening transactions + When combining many files for multi-year reports, the closing/opening + transactions cause some noise in reports like print and register. You + can exclude them as shown above, but not:desc:... could be fragile, and + also you will need to avoid excluding the very first opening transac- + tion, which can be awkward. Here is a way to do it, using tags: add + clopen: tags to all opening/closing balances transactions except the + first, like this: + + ; 2021.journal + 2021-06-01 first opening balances + ... + 2021-12-31 closing balances ; clopen:2022 + ... + + ; 2022.journal + 2022-01-01 opening balances ; clopen:2022 + ... + 2022-12-31 closing balances ; clopen:2023 + ... + + ; 2023.journal + 2023-01-01 opening balances ; clopen:2023 + ... + + Now, assuming a combined journal like: + + ; all.journal + include 2021.journal + include 2022.journal + include 2023.journal + + The clopen: tag can exclude all but the first opening transaction. To + show a clean multi-year checking register: + + $ hledger -f all.journal areg checking not:tag:clopen + + And the year values allow more precision. To show 2022's year-end bal- + ance sheet: + + $ hledger -f all.journal bs -e2023 not:tag:clopen=2023 codes - codes List the codes seen in transactions, in the order parsed. - This command prints the value of each transaction's code field, in the - order transactions were parsed. The transaction code is an optional - value written in parentheses between the date and description, often + This command prints the value of each transaction's code field, in the + order transactions were parsed. The transaction code is an optional + value written in parentheses between the date and description, often used to store a cheque number, order number or similar. Transactions aren't required to have a code, and missing or empty codes - will not be shown by default. With the -E/--empty flag, they will be + will not be shown by default. With the -E/--empty flag, they will be printed as blank lines. You can add a query to select a subset of transactions. @@ -7367,15 +7385,13 @@ PART 4: COMMANDS 126 commodities - commodities List all commodity/currency symbols used or declared in the journal. descriptions - descriptions List the unique descriptions that appear in transactions. This command lists the unique descriptions that appear in transactions, - in alphabetic order. You can add a query to select a subset of trans- + in alphabetic order. You can add a query to select a subset of trans- actions. Example: @@ -7386,19 +7402,18 @@ PART 4: COMMANDS Person A diff - diff - Compares a particular account's transactions in two input files. It + Compares a particular account's transactions in two input files. It shows any transactions to this account which are in one file but not in the other. More precisely, for each posting affecting this account in either file, - it looks for a corresponding posting in the other file which posts the - same amount to the same account (ignoring date, description, etc.) + it looks for a corresponding posting in the other file which posts the + same amount to the same account (ignoring date, description, etc.) Since postings not transactions are compared, this also works when mul- tiple bank transactions have been combined into a single journal entry. This is useful eg if you have downloaded an account's transactions from - your bank (eg as CSV data). When hledger and your bank disagree about + your bank (eg as CSV data). When hledger and your bank disagree about the account balance, you can compare the bank data with your journal to find out the cause. @@ -7415,24 +7430,22 @@ PART 4: COMMANDS These transactions are in the second file only: files - files - List all files included in the journal. With a REGEX argument, only - file names matching the regular expression (case sensitive) are shown. + List all files included in the journal. With a REGEX argument, only + file names matching the regular expression (case sensitive) are shown. help - help - Show the hledger user manual in the terminal, with info, man, or a - pager. With a TOPIC argument, open it at that topic if possible. - TOPIC can be any heading in the manual, or a heading prefix, case - insensitive. Eg: commands, print, forecast, journal, amount, "auto + Show the hledger user manual in the terminal, with info, man, or a + pager. With a TOPIC argument, open it at that topic if possible. + TOPIC can be any heading in the manual, or a heading prefix, case + insensitive. Eg: commands, print, forecast, journal, amount, "auto postings". This command shows the hledger manual built in to your hledger version. It can be useful when offline, or when you prefer the terminal to a web - browser, or when the appropriate hledger manual or viewing tools are + browser, or when the appropriate hledger manual or viewing tools are not installed on your system. - By default it chooses the best viewer found in $PATH (preferring info + By default it chooses the best viewer found in $PATH (preferring info since the hledger manual is large). You can select a particular viewer with the -i, -m, or -p flags. @@ -7443,72 +7456,71 @@ PART 4: COMMANDS $ hledger help journal # show the journal topic in the hledger manual import - import - Read new transactions added to each FILE since last run, and add them - to the journal. Or with --dry-run, just print the transactions that - would be added. Or with --catchup, just mark all of the FILEs' trans- + Read new transactions added to each FILE since last run, and add them + to the journal. Or with --dry-run, just print the transactions that + would be added. Or with --catchup, just mark all of the FILEs' trans- actions as imported, without actually importing any. - This command may append new transactions to the main journal file - (which should be in journal format). Existing transactions are not - changed. This is one of the few hledger commands that writes to the + This command may append new transactions to the main journal file + (which should be in journal format). Existing transactions are not + changed. This is one of the few hledger commands that writes to the journal file (see also add). - Unlike other hledger commands, with import the journal file is an out- + Unlike other hledger commands, with import the journal file is an out- put file, and will be modified, though only by appending (existing data - will not be changed). The input files are specified as arguments, so - to import one or more CSV files to your main journal, you will run + will not be changed). The input files are specified as arguments, so + to import one or more CSV files to your main journal, you will run hledger import bank.csv or perhaps hledger import *.csv. Note you can import from any file format, though CSV files are the most common import source, and these docs focus on that case. Deduplication - As a convenience import does deduplication while reading transactions. + As a convenience import does deduplication while reading transactions. This does not mean "ignore transactions that look the same", but rather "ignore transactions that have been seen before". This is intended for - when you are periodically importing foreign data which may contain - already-imported transactions. So eg, if every day you download bank - CSV files containing redundant data, you can safely run hledger import - bank.csv and only new transactions will be imported. (import is idem- + when you are periodically importing foreign data which may contain + already-imported transactions. So eg, if every day you download bank + CSV files containing redundant data, you can safely run hledger import + bank.csv and only new transactions will be imported. (import is idem- potent.) - Since the items being read (CSV records, eg) often do not come with - unique identifiers, hledger detects new transactions by date, assuming + Since the items being read (CSV records, eg) often do not come with + unique identifiers, hledger detects new transactions by date, assuming that: 1. new items always have the newest dates 2. item dates do not change across reads - 3. and items with the same date remain in the same relative order + 3. and items with the same date remain in the same relative order across reads. - These are often true of CSV files representing transactions, or true - enough so that it works pretty well in practice. 1 is important, but + These are often true of CSV files representing transactions, or true + enough so that it works pretty well in practice. 1 is important, but violations of 2 and 3 amongst the old transactions won't matter (and if - you import often, the new transactions will be few, so less likely to + you import often, the new transactions will be few, so less likely to be the ones affected). - hledger remembers the latest date processed in each input file by sav- + hledger remembers the latest date processed in each input file by sav- ing a hidden ".latest" state file in the same directory. Eg when read- - ing finance/bank.csv, it will look for and update the finance/.lat- - est.bank.csv state file. The format is simple: one or more lines con- - taining the same ISO-format date (YYYY-MM-DD), meaning "I have pro- - cessed transactions up to this date, and this many of them on that + ing finance/bank.csv, it will look for and update the finance/.lat- + est.bank.csv state file. The format is simple: one or more lines con- + taining the same ISO-format date (YYYY-MM-DD), meaning "I have pro- + cessed transactions up to this date, and this many of them on that date." Normally you won't see or manipulate these state files yourself. - But if needed, you can delete them to reset the state (making all - transactions "new"), or you can construct them to "catch up" to a cer- + But if needed, you can delete them to reset the state (making all + transactions "new"), or you can construct them to "catch up" to a cer- tain date. - Note deduplication (and updating of state files) can also be done by + Note deduplication (and updating of state files) can also be done by print --new, but this is less often used. Import testing - With --dry-run, the transactions that will be imported are printed to + With --dry-run, the transactions that will be imported are printed to the terminal, without updating your journal or state files. The output - is valid journal format, like the print command, so you can re-parse - it. Eg, to see any importable transactions which CSV rules have not + is valid journal format, like the print command, so you can re-parse + it. Eg, to see any importable transactions which CSV rules have not categorised: $ hledger import --dry bank.csv | hledger -f- -I print unknown @@ -7517,18 +7529,24 @@ PART 4: COMMANDS $ ls bank.csv* | entr bash -c 'echo ====; hledger import --dry bank.csv | hledger -f- -I print unknown' + Note: when importing from multiple files at once, it's currently possi- + ble for some .latest files to be updated successfully, while the actual + import fails because of a problem in one of the files, leaving them out + of sync (and causing some transactions to be missed). To prevent this, + do a --dry-run first and fix any problems before the real import. + Importing balance assignments - Entries added by import will have their posting amounts made explicit - (like hledger print -x). This means that any balance assignments in - imported files must be evaluated; but, imported files don't get to see - the main file's account balances. As a result, importing entries with + Entries added by import will have their posting amounts made explicit + (like hledger print -x). This means that any balance assignments in + imported files must be evaluated; but, imported files don't get to see + the main file's account balances. As a result, importing entries with balance assignments (eg from an institution that provides only balances - and not posting amounts) will probably generate incorrect posting + and not posting amounts) will probably generate incorrect posting amounts. To avoid this problem, use print instead of import: $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE - (If you think import should leave amounts implicit like print does, + (If you think import should leave amounts implicit like print does, please test it and send a pull request.) Commodity display styles @@ -7536,14 +7554,15 @@ PART 4: COMMANDS styles (declared or inferred) in the main journal file. incomestatement - incomestatement, is + (is) + This command displays an income statement, showing revenues and - expenses during one or more periods. Amounts are shown with normal + expenses during one or more periods. Amounts are shown with normal positive sign, as in conventional financial statements. - This report shows accounts declared with the Revenue or Expense type - (see account types). Or if no such accounts are declared, it shows - top-level accounts named revenue or income or expense (case insensi- + This report shows accounts declared with the Revenue or Expense type + (see account types). Or if no such accounts are declared, it shows + top-level accounts named revenue or income or expense (case insensi- tive, plurals allowed) and their subaccounts. Example: @@ -7570,22 +7589,21 @@ PART 4: COMMANDS 0 This command is a higher-level variant of the balance command, and sup- - ports many of that command's features, such as multi-period reports. + ports many of that command's features, such as multi-period reports. It is similar to hledger balance '(revenues|income)' expenses, but with - smarter account detection, and revenues/income displayed with their + smarter account detection, and revenues/income displayed with their sign flipped. - This command also supports the output destination and output format - options The output formats supported are txt, csv, html, and (experi- + This command also supports the output destination and output format + options The output formats supported are txt, csv, html, and (experi- mental) json. notes - notes List the unique notes that appear in transactions. - This command lists the unique notes that appear in transactions, in - alphabetic order. You can add a query to select a subset of transac- - tions. The note is the part of the transaction description after a | + This command lists the unique notes that appear in transactions, in + alphabetic order. You can add a query to select a subset of transac- + tions. The note is the part of the transaction description after a | character (or if there is no |, the whole description). Example: @@ -7595,17 +7613,16 @@ PART 4: COMMANDS Snacks payees - payees List the unique payee/payer names that appear in transactions. - This command lists unique payee/payer names which have been declared - with payee directives (--declared), used in transaction descriptions + This command lists unique payee/payer names which have been declared + with payee directives (--declared), used in transaction descriptions (--used), or both (the default). - The payee/payer is the part of the transaction description before a | + The payee/payer is the part of the transaction description before a | character (or if there is no |, the whole description). - You can add query arguments to select a subset of transactions. This + You can add query arguments to select a subset of transactions. This implies --used. Example: @@ -7616,31 +7633,29 @@ PART 4: COMMANDS Person A prices - prices - Print market price directives from the journal. With --infer-market- - prices, generate additional market prices from costs. With --infer- - reverse-prices, also generate market prices by inverting known prices. - Prices can be filtered by a query. Price amounts are displayed with + Print market price directives from the journal. With --infer-market- + prices, generate additional market prices from costs. With --infer- + reverse-prices, also generate market prices by inverting known prices. + Prices can be filtered by a query. Price amounts are displayed with their full precision. print - print Show transaction journal entries, sorted by date. The print command displays full journal entries (transactions) from the journal file, sorted by date (or with --date2, by secondary date). - Amounts are shown mostly normalised to commodity display style, eg the - placement of commodity symbols will be consistent. All of their deci- + Amounts are shown mostly normalised to commodity display style, eg the + placement of commodity symbols will be consistent. All of their deci- mal places are shown, as in the original journal entry (with one alter- ation: in some cases trailing zeroes are added.) Amounts are shown right-aligned within each transaction (but not across all transactions). - Directives and inter-transaction comments are not shown, currently. + Directives and inter-transaction comments are not shown, currently. This means the print command is somewhat lossy, and if you are using it - to reformat your journal you should take care to also copy over the + to reformat your journal you should take care to also copy over the directives and file-level comments. Eg: @@ -7667,7 +7682,7 @@ PART 4: COMMANDS liabilities:debts $1 assets:bank:checking $-1 - print's output is usually a valid hledger journal, and you can process + print's output is usually a valid hledger journal, and you can process it again with a second hledger command. This can be useful for certain kinds of search, eg: @@ -7677,7 +7692,7 @@ PART 4: COMMANDS There are some situations where print's output can become unparseable: - o Valuation affects posting amounts but not balance assertion or bal- + o Valuation affects posting amounts but not balance assertion or bal- ance assignment amounts, potentially causing those to fail. o Auto postings can generate postings with too many missing amounts. @@ -7686,33 +7701,33 @@ PART 4: COMMANDS Normally, the journal entry's explicit or implicit amount style is pre- served. For example, when an amount is omitted in the journal, it will - not appear in the output. Similarly, when a cost is implied but not - written, it will not appear in the output. You can use the + not appear in the output. Similarly, when a cost is implied but not + written, it will not appear in the output. You can use the -x/--explicit flag to make all amounts and costs explicit, 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 + 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 costs are converted to cost using that + With -B/--cost, amounts with costs are converted to cost using that price. This can be used for troubleshooting. - With -m DESC/--match=DESC, print does a fuzzy search for one recent - transaction whose description is most similar to DESC. DESC should - contain at least two characters. If there is no similar-enough match, - no transaction will be shown and the program exit code will be non- + With -m DESC/--match=DESC, print does a fuzzy search for one recent + transaction whose description is most similar to DESC. DESC should + contain at least two characters. If there is no similar-enough match, + no transaction will be shown and the program exit code will be non- zero. - With --new, hledger prints only transactions it has not seen on a pre- - vious run. This uses the same deduplication system as the import com- + With --new, hledger prints only transactions it has not seen on a pre- + vious run. This uses the same deduplication system as the import com- mand. (See import's docs for details.) - This command also supports the output destination and output format - options The output formats supported are txt, csv, and (experimental) + This command also supports the output destination and output format + options The output formats supported are txt, csv, and (experimental) json and sql. Here's an example of print's CSV output: @@ -7731,35 +7746,36 @@ PART 4: 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.) register - register, reg + (reg) + 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 @@ -7770,14 +7786,14 @@ PART 4: COMMANDS With --date2, it shows and sorts by secondary date instead. - For performance reasons, column widths are chosen based on the first - 1000 lines; this means unusually wide values in later lines can cause - visual discontinuities as column widths are adjusted. If you want to - ensure perfect alignment, at the cost of more time and memory, use the + For performance reasons, column widths are chosen based on the first + 1000 lines; this means unusually wide values in later lines can cause + visual discontinuities as column widths are adjusted. If you want to + ensure perfect alignment, at the cost of more time and memory, use the --align-all flag. - The --historical/-H flag adds the balance from any undisplayed prior - postings to the running total. This is useful when you want to see + The --historical/-H flag adds the balance from any undisplayed prior + postings to the running total. This is useful when you want to see only recent activity, with a historically accurate running balance: $ hledger register checking -b 2008/6 --historical @@ -7787,30 +7803,30 @@ PART 4: 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 + the whole report period). This flag implies --empty (see below). It + is affected by --historical. It works best when showing just one account 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 + bers. It's also useful to show postings on the checking account together with the related account: $ hledger register --related --invert assets:checking - With a reporting interval, register shows summary postings, one per + With a reporting interval, register shows summary postings, one per interval, aggregating the postings to each account: $ hledger register --monthly income 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 @@ -7827,7 +7843,7 @@ PART 4: COMMANDS 2008/11 0 $-2 2008/12 0 $-2 - Often, you'll want to see just one line per interval. The --depth + Often, you'll want to see just one line per interval. The --depth option helps with this, causing subaccounts to be aggregated: $ hledger register --monthly assets --depth 1h @@ -7835,24 +7851,24 @@ PART 4: 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 - intervals. 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 + intervals. This ensures that the first and last intervals are full length and comparable to the others in the report. - With -m DESC/--match=DESC, register does a fuzzy search for one recent + With -m DESC/--match=DESC, register does a fuzzy search for one recent posting whose description is most similar to DESC. DESC should contain at least two characters. If there is no similar-enough match, no post- ing will be shown and the program exit code will be non-zero. Custom register output - register 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 - (about half of (width - 40) each). You can adjust this by adding a - description width as part of --width's argument, comma-separated: + The description and account columns normally share the space equally + (about half of (width - 40) each). You can adjust this by adding a + description width as part of --width's argument, comma-separated: --width W,D . Here's a diagram (won't display correctly in --help): <--------------------------------- width (W) ----------------------------------> @@ -7868,20 +7884,19 @@ PART 4: COMMANDS $ hledger reg -w 100,40 # set overall width 100, description width 40 $ hledger reg -w $COLUMNS,40 # use terminal width, & description width 40 - This command also supports the output destination and output format - options The output formats supported are txt, csv, and (experimental) + This command also supports the output destination and output format + options The output formats supported are txt, csv, and (experimental) json. 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: @@ -7897,7 +7912,7 @@ PART 4: 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: @@ -7907,16 +7922,16 @@ PART 4: 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 - includes a commodity name, the new posting amount will be in the new - commodity; otherwise, it will be in the matched posting amount's com- + factor for an amount of original matched posting. If the amount + includes a commodity name, the new posting amount will be in the new + commodity; otherwise, it will be in the matched posting amount's com- modity. 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. @@ -7931,7 +7946,7 @@ PART 4: 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. @@ -7944,12 +7959,12 @@ PART 4: 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' @@ -7973,10 +7988,10 @@ PART 4: 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: @@ -7984,54 +7999,53 @@ PART 4: 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. - At a minimum, you need to supply a query (which could be just an - account name) to select your investment(s) with --inv, and another + At a minimum, you need to supply a query (which could be just an + account name) to select your investment(s) with --inv, and another query to identify your profit and loss transactions with --pnl. - If you do not record changes in the value of your investment manually, - or do not require computation of time-weighted return (TWR), --pnl + If you do not record changes in the value of your investment manually, + or do not require computation of time-weighted return (TWR), --pnl could be an empty query (--pnl "" or --pnl STR where STR does not match any of your accounts). - This command will compute and display the internalized rate of return - (IRR) 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. - Price directives will be taken into account if you supply appropriate + Price directives will be taken into account if you supply appropriate --cost or --value flags (see VALUATION). Note, in some cases this report can fail, for these reasons: - o Error (NotBracketed): No solution for Internal Rate of Return (IRR). - Possible causes: IRR is huge (>1000000%), balance of investment + o Error (NotBracketed): No solution for Internal Rate of Return (IRR). + Possible causes: IRR is huge (>1000000%), balance of investment becomes negative at some point in time. - o Error (SearchFailed): Failed to find solution for Internal Rate of + o Error (SearchFailed): Failed to find solution for Internal Rate of Return (IRR). Either search does not converge to a solution, or con- verges too slowly. Examples: - o Using roi to compute total return of investment in stocks: + o Using roi to compute total return of investment in stocks: https://github.com/simonmichael/hledger/blob/master/examples/invest- ing/roi-unrealised.ledger @@ -8041,27 +8055,27 @@ PART 4: COMMANDS Note that --inv and --pnl's argument is a query, and queries could have several space-separated terms (see QUERIES). - To indicate that all search terms form single command-line argument, + To indicate that all search terms form single command-line argument, you will need to put them in quotes (see Special characters): $ hledger roi --inv 'term1 term2 term3 ...' - If any query terms contain spaces themselves, you will need an extra + If any query terms contain spaces themselves, you will need an extra level of nested quoting, eg: $ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'" Semantics of --inv and --pnl - Query supplied to --inv has to match all transactions that are related + Query supplied to --inv has to match all transactions that are related to your investment. Transactions not matching --inv will be ignored. In these transactions, ROI will conside postings that match --inv to be - "investment postings" and other postings (not matching --inv) will be - sorted into two categories: "cash flow" and "profit and loss", as ROI - needs to know which part of the investment value is your contributions + "investment postings" and other postings (not matching --inv) will be + sorted into two categories: "cash flow" and "profit and loss", as ROI + needs to know which part of the investment value is your contributions and which is due to the return on investment. - o "Cash flow" is depositing or withdrawing money, buying or selling + o "Cash flow" is depositing or withdrawing money, buying or selling assets, or otherwise converting between your investment commodity and any other commodity. Example: @@ -8079,12 +8093,12 @@ PART 4: COMMANDS investment:snake oil = $57 equity:unrealized profit or loss - All non-investment postings are assumed to be "cash flow", unless they - match --pnl query. Changes in value of your investment due to "profit - and loss" postings will be considered as part of your investment + All non-investment postings are assumed to be "cash flow", unless they + match --pnl query. Changes in value of your investment due to "profit + and loss" postings will be considered as part of your investment return. - Example: if you use --inv snake --pnl equity:unrealized, then postings + Example: if you use --inv snake --pnl equity:unrealized, then postings in the example below would be classifed as: 2019-01-01 Snake Oil #1 @@ -8101,57 +8115,57 @@ PART 4: COMMANDS snake oil $50 ; investment posting IRR and TWR explained - "ROI" stands for "return on investment". Traditionally this was com- - puted as a difference between current value of investment and its ini- + "ROI" stands for "return on investment". Traditionally this was com- + puted as a difference between current value of investment and its ini- tial value, expressed in percentage of the initial value. However, this approach is only practical in simple cases, where invest- - ments receives no in-flows or out-flows of money, and where rate of + ments receives no in-flows or out-flows of money, and where rate of growth is fixed over time. For more complex scenarios you need differ- - ent ways to compute rate of return, and this command implements two of + ent ways to compute rate of return, and this command implements two of them: IRR and TWR. - Internal rate of return, or "IRR" (also called "money-weighted rate of - return") takes into account effects of in-flows and out-flows. + 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 + 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 period between in-flow or out-flow of money, and then combine them in a - way that gives you a compound annual rate of return that investment is + way that gives you a compound annual rate of return that investment is expected to generate. - As mentioned before, in-flows and out-flows would be any cash that you + As mentioned before, in-flows and out-flows would be any cash that you personally put in or withdraw, and for the "roi" command, these are the - postings that match the query in the--inv argument and NOT match the + postings that match the query in the--inv argument and NOT match the query in the--pnl argument. - If you manually record changes in the value of your investment as - transactions that balance them against "profit and loss" (or "unreal- - ized gains") account or use price directives, then in order for IRR to - compute the precise effect of your in-flows and out-flows on the rate - of return, you will need to record the value of your investement on or + If you manually record changes in the value of your investment as + transactions that balance them against "profit and loss" (or "unreal- + ized gains") account or use price directives, then in order for IRR to + compute the precise effect of your in-flows and out-flows on the rate + of return, you will need to record the value of your investement on or close to the days when in- or out-flows occur. - In technical terms, IRR uses the same approach as computation of net + In technical terms, IRR uses the same approach as computation of net present value, and tries to find a discount rate that makes net present value of all the cash flows of your investment to add up to zero. This - could be hard to wrap your head around, especially if you haven't done + could be hard to wrap your head around, especially if you haven't done discounted cash flow analysis before. Implementation of IRR in hledger should produce results that match the XIRR formula in Excel. - Second way to compute rate of return that roi command implements is + 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, - out-flows and value changes, to compute rate of return per each period - and then a compound rate of return. However, internal workings of TWR + break the history of your investment into periods between in-flows, + out-flows and value changes, to compute rate of return per each period + and then a compound rate of return. However, internal workings of TWR are quite different. - 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: @@ -8162,22 +8176,21 @@ PART 4: COMMANDS o Explanation of TWR - o Examples of computing IRR and TWR and discussion of the limitations + o Examples of computing IRR and TWR and discussion of the limitations of both metrics stats - stats Show journal and performance 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. - At the end, it shows (in the terminal) the overall run time and number - of transactions processed per second. Note these are approximate and - will vary based on machine, current load, data size, hledger version, - haskell lib versions, GHC version.. but they may be of interest. The - stats command's run time is similar to that of a single-column balance + At the end, it shows (in the terminal) the overall run time and number + of transactions processed per second. Note these are approximate and + will vary based on machine, current load, data size, hledger version, + haskell lib versions, GHC version.. but they may be of interest. The + stats command's run time is similar to that of a single-column balance report. Example: @@ -8202,42 +8215,40 @@ PART 4: COMMANDS format selection). tags - tags List the tags used in the journal, or their values. This command lists the tag names used in the journal, whether on trans- actions, postings, or account declarations. - With a TAGREGEX argument, only tag names matching this regular expres- + With a TAGREGEX argument, only tag names matching this regular expres- sion (case insensitive, infix matched) are shown. - With QUERY arguments, only transactions and accounts matching this + With QUERY arguments, only transactions and accounts matching this query are considered. If the query involves transaction fields (date:, desc:, amt:, ...), the search is restricted to the matched transactions and their accounts. - With the --values flag, the tags' unique non-empty values are listed + With the --values flag, the tags' unique non-empty values are listed instead. With -E/--empty, blank/empty values are also shown. - With --parsed, tags or values are shown in the order they were parsed, - with duplicates included. (Except, tags from account declarations are + With --parsed, tags or values are shown in the order they were parsed, + with duplicates included. (Except, tags from account declarations are always shown first.) - Tip: remember, accounts also acquire tags from their parents, postings + Tip: remember, accounts also acquire tags from their parents, postings also acquire tags from their account and transaction, transactions also acquire tags from their postings. 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 -- @@ -8246,12 +8257,12 @@ PART 4: 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). PART 5: COMMON TASKS - Here are some quick examples of how to do some basic tasks with + Here are some quick examples of how to do some basic tasks with hledger. Getting help @@ -8261,37 +8272,37 @@ PART 5: COMMON TASKS $ hledger --help # show common options $ hledger CMD --help # show CMD's options, common options and CMD's documentation - You can also view your hledger version's manual in several formats by + You can also view your hledger version's manual in several formats by using the help command. Eg: $ hledger help # show the hledger manual with info, man or $PAGER (best available) $ hledger help journal # show the journal topic in the hledger manual $ hledger help --help # find out more about the help command - To view manuals and introductory docs on the web, visit - https://hledger.org. Chat and mail list support and discussion ar- + To view manuals and introductory docs on the web, visit + https://hledger.org. Chat and mail list support and discussion ar- chives can be found at https://hledger.org/support. Constructing command lines - hledger has a flexible command line interface. We strive to keep it - simple and ergonomic, but if you run into one of the sharp edges + hledger has a flexible command line interface. We strive to keep it + simple and ergonomic, but if you run into one of the sharp edges described in OPTIONS, here are some tips that might help: - o command-specific options must go after the command (it's fine to put + o command-specific options must go after the command (it's fine to put common options there too: hledger CMD OPTS ARGS) - o running add-on executables directly simplifies command line parsing + o running add-on executables directly simplifies command line parsing (hledger-ui OPTS ARGS) o enclose "problematic" args in single quotes - o if needed, also add a backslash to hide regular expression metachar- + o if needed, also add a backslash to hide regular expression metachar- acters from the shell o to see how a misbehaving command line is being parsed, add --debug=2. Starting a journal file - hledger looks for your accounting data in a journal file, + hledger looks for your accounting data in a journal file, $HOME/.hledger.journal by default: $ hledger stats @@ -8299,9 +8310,9 @@ PART 5: 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 @@ -8325,20 +8336,20 @@ PART 5: 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 - two accounts, like your checking account or cash wallet; and pick a - recent starting date, like today or the start of the week. You can + 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 + recent starting date, like today or the start of the week. You can always 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 @@ -8348,19 +8359,19 @@ PART 5: 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 @@ -8397,18 +8408,18 @@ PART 5: 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 @@ -8424,22 +8435,22 @@ PART 5: 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 - already-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 + already-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: @@ -8449,26 +8460,26 @@ PART 5: 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 - reported by hledger reg checking -C. This will be easier if you - generally record transaction dates quite similar to your bank's + action history and running balance from your bank with the one + reported by hledger reg checking -C. This will be easier if you + generally record transaction dates quite similar to your bank's clearing dates. 3. Repeat for other asset/liability accounts. - Tip: instead of the register command, use hledger-ui to see a live- + Tip: instead of the register command, use hledger-ui to see a live- updating register while you edit the journal: hledger-ui --watch --reg- ister 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 @@ -8540,7 +8551,7 @@ PART 5: 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 -2 @@ -8550,7 +8561,7 @@ PART 5: 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 -2 @@ -8617,9 +8628,9 @@ PART 5: 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. @@ -8627,7 +8638,7 @@ PART 5: COMMON TASKS REPORTING BUGS - Report bugs at http://bugs.hledger.org (or on the #hledger chat or + Report bugs at http://bugs.hledger.org (or on the #hledger chat or hledger mail list) @@ -8649,4 +8660,4 @@ SEE ALSO -hledger-1.28.99 January 2023 HLEDGER(1) +hledger-1.28.99 February 2023 HLEDGER(1)