;update manuals

This commit is contained in:
Simon Michael 2021-05-18 10:35:43 -10:00
parent 701768765a
commit 0b15d5771a
3 changed files with 1471 additions and 1248 deletions

View File

@ -656,9 +656,8 @@ Are all accounts posted to, declared with an \f[C]account\f[R] directive
Are all commodities declared with a \f[C]commodity\f[R] directive ? Are all commodities declared with a \f[C]commodity\f[R] directive ?
(Commodity error checking) (Commodity error checking)
.PP .PP
See also: https://hledger.org/checking-for-errors.html You can also use the check command to run these and some additional
.PP checks.
\f[I]experimental.\f[R]
.SH TIME PERIODS .SH TIME PERIODS
.SS Smart dates .SS Smart dates
.PP .PP
@ -830,12 +829,35 @@ T}
.SS Report intervals .SS Report intervals
.PP .PP
A report interval can be specified so that commands like register, A report interval can be specified so that commands like register,
balance and activity will divide their reports into multiple subperiods. balance and activity become multi-period, showing each subperiod as a
The basic intervals can be selected with one of \f[C]-D/--daily\f[R], separate row or column.
\f[C]-W/--weekly\f[R], \f[C]-M/--monthly\f[R], \f[C]-Q/--quarterly\f[R], .PP
or \f[C]-Y/--yearly\f[R]. The following \[dq]standard\[dq] report intervals can be enabled by
More complex intervals may be specified with a period expression. using their corresponding flag:
Report intervals can not be specified with a query. .PP
\f[C]-D/--daily\f[R], \f[C]-W/--weekly\f[R], \f[C]-M/--monthly\f[R],
\f[C]-Q/--quarterly\f[R], \f[C]-Y/--yearly\f[R].
.PP
These standard intervals always start on natural interval boundaries: eg
\f[C]--weekly\f[R] starts on mondays, \f[C]--monthly\f[R] starts on the
first of the month, \f[C]--yearly\f[R] always starts on January 1st,
etc.
.PP
Certain more complex intervals, and more flexible boundary dates, can be
specified by \f[C]-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[C]--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.
.SS Period expressions .SS Period expressions
.PP .PP
The \f[C]-p/--period\f[R] option accepts period expressions, a shorthand The \f[C]-p/--period\f[R] option accepts period expressions, a shorthand
@ -2031,6 +2053,12 @@ $ hledger print -o foo.txt
$ hledger print -o - # write to stdout (the default) $ hledger print -o - # write to stdout (the default)
\f[R] \f[R]
.fi .fi
.PP
hledger can optionally produce debug output (if enabled with
\f[C]--debug=N\f[R]); this goes to stderr, and is not affected by
\f[C]-o/--output-file\f[R].
If you need to capture it, use shell redirects, eg:
\f[C]hledger bal --debug=3 >file 2>&1\f[R].
.SS Output format .SS Output format
.PP .PP
Some commands (print, register, the balance commands) offer a choice of Some commands (print, register, the balance commands) offer a choice of
@ -3612,7 +3640,8 @@ These checks can be run only by giving their names as arguments to
They are more specialised and not desirable for everyone, therefore They are more specialised and not desirable for everyone, therefore
optional: optional:
.IP \[bu] 2 .IP \[bu] 2
\f[B]ordereddates\f[R] - transactions are ordered by date in each file \f[B]ordereddates\f[R] - transactions are ordered by date within each
file
.IP \[bu] 2 .IP \[bu] 2
\f[B]payees\f[R] - all payees used by transactions have been declared \f[B]payees\f[R] - all payees used by transactions have been declared
.IP \[bu] 2 .IP \[bu] 2
@ -5440,23 +5469,15 @@ Amounts have a number (the \[dq]quantity\[dq]):
\f[R] \f[R]
.fi .fi
.PP .PP
\&..and usually a currency or commodity name (the \[dq]commodity\[dq]). \&..and usually a currency symbol or commodity name (more on this
This is a symbol, word, or phrase, to the left or right of the quantity, below), to the left or right of the quantity, with or without a
with or without a separating space: separating space:
.IP .IP
.nf .nf
\f[C] \f[C]
$1 $1
4000 AAPL 4000 AAPL
\f[R] 3 \[dq]green apples\[dq]
.fi
.PP
If the commodity name contains spaces, numbers, or punctuation, it must
be enclosed in double quotes:
.IP
.nf
\f[C]
3 \[dq]no. 42 green apples\[dq]
\f[R] \f[R]
.fi .fi
.PP .PP
@ -5526,14 +5547,49 @@ Are these digit group marks or decimal marks ?
.PP .PP
If you don\[aq]t tell it otherwise, hledger will assume both of the If you don\[aq]t tell it otherwise, hledger will assume both of the
above are decimal marks, parsing both numbers as 1. above are decimal marks, parsing both numbers as 1.
To prevent confusion and undetected typos, especially if your data To prevent confusion and undetected typos, we recommend adding
contains digit group marks, we recommend you explicitly declare the \f[C]commodity\f[R] directives at the top of your journal file to
decimal mark (and optionally a digit group mark), for each commodity, explicitly declare the decimal mark (and optionally a digit group mark)
using \f[C]commodity\f[R] directives (described below): for each commodity.
Read on for more about this.
.SS Commodity
.PP
Amounts in hledger have both a \[dq]quantity\[dq], which is a signed
decimal number, and a \[dq]commodity\[dq], which is a currency symbol,
stock ticker, or any word or phrase describing something you are
tracking.
.PP
If the commodity name contains non-letters (spaces, numbers, or
punctuation), you must always write it inside double quotes
(\f[C]\[dq]green apples\[dq]\f[R], \f[C]\[dq]ABC123\[dq]\f[R]).
.PP
If you write just a bare number, that too will have a commodity, with
name \f[C]\[dq]\[dq]\f[R]; we call that the \[dq]no-symbol
commodity\[dq].
.PP
Actually, hledger combines these single-commodity amounts into more
powerful multi-commodity amounts, which are what it works with most of
the time.
A multi-commodity amount could be, eg:
\f[C]1 USD, 2 EUR, 3.456 TSLA\f[R].
In practice, you will only see multi-commodity amounts in hledger\[aq]s
output; you can\[aq]t write them directly in the journal file.
.PP
(If you are writing scripts or working with hledger\[aq]s internals,
these are the \f[C]Amount\f[R] and \f[C]MixedAmount\f[R] types.)
.SS Commodity directives
.PP
You can add \f[C]commodity\f[R] directives to the journal, preferably at
the top, to declare your commodities and help with number parsing (see
above) and display (see below).
These are optional, but recommended.
They are described in more detail in JOURNAL FORMAT -> Declaring
commodities.
Here\[aq]s a quick example:
.IP .IP
.nf .nf
\f[C] \f[C]
# number formats for $, EUR, INR and the no-symbol commodity: # number format and display style for $, EUR, INR and the no-symbol commodity:
commodity $1,000.00 commodity $1,000.00
commodity EUR 1.000,00 commodity EUR 1.000,00
commodity INR 9,99,99,999.00 commodity INR 9,99,99,999.00
@ -5541,19 +5597,15 @@ commodity 1 000 000.9455
\f[R] \f[R]
.fi .fi
.PP .PP
Note, \f[C]commodity\f[R] directives declare both the number format for
parsing input, and the display style for showing output.
For the former, they are position-sensitive, affecting only following
amounts, so commodity directives should be at the top of your journal
file.
This is discussed more on #793.
.PP
.SS Commodity display style .SS Commodity display style
.PP .PP
For the amounts in each commodity, hledger chooses a consistent display For the amounts in each commodity, hledger chooses a consistent display
style to use in most reports. style to use in most reports.
(Except for price amounts, which are always displayed as written). (Exceptions: price amounts, and all amounts displayed by the
The display style is inferred as follows. \f[C]print\f[R] command, are displayed with all of their decimal digits
visible.)
.PP
A commodity\[aq]s display style is inferred as follows.
.PP .PP
First, if a default commodity is declared with \f[C]D\f[R], this First, if a default commodity is declared with \f[C]D\f[R], this
commodity and its style is applied to any no-symbol amounts in the commodity and its style is applied to any no-symbol amounts in the
@ -6206,47 +6258,54 @@ payee Whole Foods
.fi .fi
.SS Declaring commodities .SS Declaring commodities
.PP .PP
The \f[C]commodity\f[R] directive has several functions: You can use \f[C]commodity\f[R] directives to declare your commodities.
In fact the \f[C]commodity\f[R] directive performs several functions at
once:
.IP "1." 3 .IP "1." 3
It declares commodities which may be used in the journal. It declares commodities which may be used in the journal.
This is currently not enforced, but can serve as documentation. This can optionally be enforced, providing useful error checking.
(Cf Commodity error checking)
.IP "2." 3 .IP "2." 3
It declares what decimal mark character (period or comma) to expect when It declares which decimal mark character (period or comma), to expect
parsing input - useful to disambiguate international number formats in when parsing input - useful to disambiguate international number formats
your data. in your data.
(Without this, hledger will parse both \f[C]1,000\f[R] and Without this, hledger will parse both \f[C]1,000\f[R] and
\f[C]1.000\f[R] as 1). \f[C]1.000\f[R] as 1.
(Cf Amounts)
.IP "3." 3 .IP "3." 3
It declares a commodity\[aq]s display style in output - decimal and It declares how to render the commodity\[aq]s amounts when displaying
digit group marks, number of decimal places, symbol placement etc. output - the decimal mark, any digit group marks, the number of decimal
places, symbol placement and so on.
(Cf Commodity display style)
.PP .PP
You are likely to run into one of the problems solved by commodity You will run into one of the problems solved by commodity directives
directives, sooner or later, so it\[aq]s a good idea to just always use sooner or later, so we recommend using them, for robust and predictable
them to declare your commodities. parsing and display.
.PP .PP
A commodity directive is just the word \f[C]commodity\f[R] followed by Generally you should put them at the top of your journal file (since for
an amount. function 2, they affect only following amounts, cf #793).
It may be written on a single line, like this: .PP
A commodity directive is just the word \f[C]commodity\f[R] followed by a
sample amount, like this:
.IP .IP
.nf .nf
\f[C] \f[C]
; commodity EXAMPLEAMOUNT ;commodity SAMPLEAMOUNT
; display AAAA amounts with the symbol on the right, space-separated, commodity $1000.00
; using period as decimal point, with four decimal places, and commodity 1,000.0000 AAAA ; optional same-line comment
; separating thousands with comma.
commodity 1,000.0000 AAAA
\f[R] \f[R]
.fi .fi
.PP .PP
or on multiple lines, using the \[dq]format\[dq] subdirective. It may also be written on multiple lines, and use the \f[C]format\f[R]
(In this case the commodity symbol appears twice and should be the same subdirective, as in Ledger.
in both places.): Note in this case the commodity symbol appears twice; it must be the
same in both places:
.IP .IP
.nf .nf
\f[C] \f[C]
; commodity SYMBOL ;commodity SYMBOL
; format EXAMPLEAMOUNT ; format SAMPLEAMOUNT
; display indian rupees with currency name on the left, ; display indian rupees with currency name on the left,
; thousands, lakhs and crores comma-separated, ; thousands, lakhs and crores comma-separated,
@ -6256,10 +6315,25 @@ commodity INR
\f[R] \f[R]
.fi .fi
.PP .PP
The quantity of the amount does not matter; only the format is Remember that if the commodity symbol contains spaces, numbers, or
punctuation, it must be enclosed in double quotes (cf Commodity).
.PP
The amount\[aq]s quantity does not matter; only the format is
significant. significant.
The number must include a decimal mark: either a period or a comma, It must include a decimal mark - either a period or a comma - followed
followed by 0 or more decimal digits. by 0 or more decimal digits.
.PP
A few more examples:
.IP
.nf
\f[C]
# number formats for $, EUR, INR and the no-symbol commodity:
commodity $1,000.00
commodity EUR 1.000,00
commodity INR 9,99,99,999.0
commodity 1 000 000.
\f[R]
.fi
.PP .PP
Note hledger normally uses banker\[aq]s rounding, so 0.5 displayed with Note hledger normally uses banker\[aq]s rounding, so 0.5 displayed with
zero decimal digits is \[dq]0\[dq]. zero decimal digits is \[dq]0\[dq].
@ -6273,19 +6347,20 @@ This works similarly to account error checking, see the notes there for
more details. more details.
.SS Default commodity .SS Default commodity
.PP .PP
The \f[C]D\f[R] directive sets a default commodity, to be used for The \f[C]D\f[R] directive sets a default commodity, to be used for any
amounts without a commodity symbol (ie, plain numbers). subsequent commodityless amounts (ie, plain numbers) seen while parsing
This commodity will be applied to all subsequent commodity-less amounts, the journal.
or until the next \f[C]D\f[R] directive. This effect lasts until the next \f[C]D\f[R] directive, or the end of
(Note, this is different from Ledger\[aq]s \f[C]D\f[R].) the journal.
.PP .PP
For compatibility/historical reasons, \f[C]D\f[R] also acts like a For compatibility/historical reasons, \f[C]D\f[R] also acts like a
\f[C]commodity\f[R] directive, setting the commodity\[aq]s display style \f[C]commodity\f[R] directive (setting the commodity\[aq]s decimal mark
(for output) and decimal mark (for parsing input). for parsing and display style for output).
As with \f[C]commodity\f[R], the amount must always be written with a .PP
decimal mark (period or comma). As with \f[C]commodity\f[R], the amount must include a decimal mark
If both directives are used, \f[C]commodity\f[R]\[aq]s style takes (either period or comma).
precedence. If both \f[C]commodity\f[R] and \f[C]D\f[R] directives are used for the
same commodity, the \f[C]commodity\f[R] style takes precedence.
.PP .PP
The syntax is \f[C]D AMOUNT\f[R]. The syntax is \f[C]D AMOUNT\f[R].
Eg: Eg:
@ -6494,7 +6569,7 @@ using the following rules:
tab(@); tab(@);
l l. l l.
T{ T{
If name matches regular expression: If name matches this regular expression:
T}@T{ T}@T{
account type is: account type is:
T} T}
@ -6528,10 +6603,10 @@ T}
.PP .PP
.TS .TS
tab(@); tab(@);
lw(56.9n) lw(13.1n). lw(57.6n) lw(12.4n).
T{ T{
If account type is \f[C]Asset\f[R] and name does not contain regular If account type is \f[C]Asset\f[R] and name does not contain this
expression: regular expression:
T}@T{ T}@T{
account type is: account type is:
T} T}
@ -7789,13 +7864,13 @@ REGEX
\f[R] \f[R]
.fi .fi
.PP .PP
REGEX is a case-insensitive regular expression which tries to match REGEX is a case-insensitive regular expression that tries to match
anywhere within the CSV record. anywhere within the CSV record.
It is a POSIX ERE (extended regular expression) that also supports GNU It is a POSIX ERE (extended regular expression) that also supports GNU
word boundaries (\f[C]\[rs]b\f[R], \f[C]\[rs]B\f[R], \f[C]\[rs]<\f[R], word boundaries (\f[C]\[rs]b\f[R], \f[C]\[rs]B\f[R], \f[C]\[rs]<\f[R],
\f[C]\[rs]>\f[R]), and nothing else. \f[C]\[rs]>\f[R]), and nothing else.
If you have trouble, be sure to check our If you have trouble, be sure to check our doc:
https://hledger.org/hledger.html#regular-expressions doc. https://hledger.org/hledger.html#regular-expressions
.PP .PP
Important note: the record that is matched is not the original record, Important note: the record that is matched is not the original record,
but a synthetic one, with any enclosing double quotes (but not enclosing but a synthetic one, with any enclosing double quotes (but not enclosing

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff