;update manuals
This commit is contained in:
parent
701768765a
commit
0b15d5771a
@ -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 ?
|
||||
(Commodity error checking)
|
||||
.PP
|
||||
See also: https://hledger.org/checking-for-errors.html
|
||||
.PP
|
||||
\f[I]experimental.\f[R]
|
||||
You can also use the check command to run these and some additional
|
||||
checks.
|
||||
.SH TIME PERIODS
|
||||
.SS Smart dates
|
||||
.PP
|
||||
@ -830,12 +829,35 @@ T}
|
||||
.SS Report intervals
|
||||
.PP
|
||||
A report interval can be specified so that commands like register,
|
||||
balance and activity will divide their reports into multiple subperiods.
|
||||
The basic intervals can be selected with one of \f[C]-D/--daily\f[R],
|
||||
\f[C]-W/--weekly\f[R], \f[C]-M/--monthly\f[R], \f[C]-Q/--quarterly\f[R],
|
||||
or \f[C]-Y/--yearly\f[R].
|
||||
More complex intervals may be specified with a period expression.
|
||||
Report intervals can not be specified with a query.
|
||||
balance and 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:
|
||||
.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
|
||||
.PP
|
||||
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)
|
||||
\f[R]
|
||||
.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
|
||||
.PP
|
||||
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
|
||||
optional:
|
||||
.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
|
||||
\f[B]payees\f[R] - all payees used by transactions have been declared
|
||||
.IP \[bu] 2
|
||||
@ -5440,23 +5469,15 @@ Amounts have a number (the \[dq]quantity\[dq]):
|
||||
\f[R]
|
||||
.fi
|
||||
.PP
|
||||
\&..and usually a currency or commodity name (the \[dq]commodity\[dq]).
|
||||
This is a symbol, word, or phrase, to the left or right of the quantity,
|
||||
with or without a separating space:
|
||||
\&..and usually a currency symbol or commodity name (more on this
|
||||
below), to the left or right of the quantity, with or without a
|
||||
separating space:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
$1
|
||||
4000 AAPL
|
||||
\f[R]
|
||||
.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]
|
||||
3 \[dq]green apples\[dq]
|
||||
\f[R]
|
||||
.fi
|
||||
.PP
|
||||
@ -5526,14 +5547,49 @@ Are these digit group marks or decimal marks ?
|
||||
.PP
|
||||
If you don\[aq]t tell it otherwise, hledger will assume both of the
|
||||
above are decimal marks, parsing both numbers as 1.
|
||||
To prevent confusion and undetected typos, especially if your data
|
||||
contains digit group marks, we recommend you explicitly declare the
|
||||
decimal mark (and optionally a digit group mark), for each commodity,
|
||||
using \f[C]commodity\f[R] directives (described below):
|
||||
To prevent confusion and undetected typos, we recommend adding
|
||||
\f[C]commodity\f[R] directives at the top of your journal file to
|
||||
explicitly declare the decimal mark (and optionally a digit group mark)
|
||||
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
|
||||
.nf
|
||||
\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 EUR 1.000,00
|
||||
commodity INR 9,99,99,999.00
|
||||
@ -5541,19 +5597,15 @@ commodity 1 000 000.9455
|
||||
\f[R]
|
||||
.fi
|
||||
.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
|
||||
.PP
|
||||
For the amounts in each commodity, hledger chooses a consistent display
|
||||
style to use in most reports.
|
||||
(Except for price amounts, which are always displayed as written).
|
||||
The display style is inferred as follows.
|
||||
(Exceptions: price amounts, and all amounts displayed by the
|
||||
\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
|
||||
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
|
||||
@ -6206,47 +6258,54 @@ payee Whole Foods
|
||||
.fi
|
||||
.SS Declaring commodities
|
||||
.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
|
||||
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
|
||||
It declares what decimal mark character (period or comma) to expect when
|
||||
parsing input - useful to disambiguate international number formats in
|
||||
your data.
|
||||
(Without this, hledger will parse both \f[C]1,000\f[R] and
|
||||
\f[C]1.000\f[R] as 1).
|
||||
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 \f[C]1,000\f[R] and
|
||||
\f[C]1.000\f[R] as 1.
|
||||
(Cf Amounts)
|
||||
.IP "3." 3
|
||||
It declares a commodity\[aq]s display style in output - decimal and
|
||||
digit group marks, number of decimal places, symbol placement etc.
|
||||
It declares how to render the commodity\[aq]s amounts when displaying
|
||||
output - the decimal mark, any digit group marks, the number of decimal
|
||||
places, symbol placement and so on.
|
||||
(Cf Commodity display style)
|
||||
.PP
|
||||
You are likely to run into one of the problems solved by commodity
|
||||
directives, sooner or later, so it\[aq]s a good idea to just always use
|
||||
them to declare your commodities.
|
||||
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.
|
||||
.PP
|
||||
A commodity directive is just the word \f[C]commodity\f[R] followed by
|
||||
an amount.
|
||||
It may be written on a single line, like this:
|
||||
Generally you should put them at the top of your journal file (since for
|
||||
function 2, they affect only following amounts, cf #793).
|
||||
.PP
|
||||
A commodity directive is just the word \f[C]commodity\f[R] followed by a
|
||||
sample amount, like this:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
; commodity EXAMPLEAMOUNT
|
||||
;commodity SAMPLEAMOUNT
|
||||
|
||||
; display AAAA amounts with the symbol on the right, space-separated,
|
||||
; using period as decimal point, with four decimal places, and
|
||||
; separating thousands with comma.
|
||||
commodity 1,000.0000 AAAA
|
||||
commodity $1000.00
|
||||
commodity 1,000.0000 AAAA ; optional same-line comment
|
||||
\f[R]
|
||||
.fi
|
||||
.PP
|
||||
or on multiple lines, using the \[dq]format\[dq] subdirective.
|
||||
(In this case the commodity symbol appears twice and should be the same
|
||||
in both places.):
|
||||
It may also be written on multiple lines, and use the \f[C]format\f[R]
|
||||
subdirective, as in Ledger.
|
||||
Note in this case the commodity symbol appears twice; it must be the
|
||||
same in both places:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
; commodity SYMBOL
|
||||
; format EXAMPLEAMOUNT
|
||||
;commodity SYMBOL
|
||||
; format SAMPLEAMOUNT
|
||||
|
||||
; display indian rupees with currency name on the left,
|
||||
; thousands, lakhs and crores comma-separated,
|
||||
@ -6256,10 +6315,25 @@ commodity INR
|
||||
\f[R]
|
||||
.fi
|
||||
.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.
|
||||
The number must include a decimal mark: either a period or a comma,
|
||||
followed by 0 or more decimal digits.
|
||||
It must include a decimal mark - either a period or a comma - followed
|
||||
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
|
||||
Note hledger normally uses banker\[aq]s rounding, so 0.5 displayed with
|
||||
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.
|
||||
.SS Default commodity
|
||||
.PP
|
||||
The \f[C]D\f[R] directive sets a default commodity, to be used for
|
||||
amounts without a commodity symbol (ie, plain numbers).
|
||||
This commodity will be applied to all subsequent commodity-less amounts,
|
||||
or until the next \f[C]D\f[R] directive.
|
||||
(Note, this is different from Ledger\[aq]s \f[C]D\f[R].)
|
||||
The \f[C]D\f[R] 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[C]D\f[R] directive, or the end of
|
||||
the journal.
|
||||
.PP
|
||||
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
|
||||
(for output) and decimal mark (for parsing input).
|
||||
As with \f[C]commodity\f[R], the amount must always be written with a
|
||||
decimal mark (period or comma).
|
||||
If both directives are used, \f[C]commodity\f[R]\[aq]s style takes
|
||||
precedence.
|
||||
\f[C]commodity\f[R] directive (setting the commodity\[aq]s decimal mark
|
||||
for parsing and display style for output).
|
||||
.PP
|
||||
As with \f[C]commodity\f[R], the amount must include a decimal mark
|
||||
(either period or comma).
|
||||
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
|
||||
The syntax is \f[C]D AMOUNT\f[R].
|
||||
Eg:
|
||||
@ -6494,7 +6569,7 @@ using the following rules:
|
||||
tab(@);
|
||||
l l.
|
||||
T{
|
||||
If name matches regular expression:
|
||||
If name matches this regular expression:
|
||||
T}@T{
|
||||
account type is:
|
||||
T}
|
||||
@ -6528,10 +6603,10 @@ T}
|
||||
.PP
|
||||
.TS
|
||||
tab(@);
|
||||
lw(56.9n) lw(13.1n).
|
||||
lw(57.6n) lw(12.4n).
|
||||
T{
|
||||
If account type is \f[C]Asset\f[R] and name does not contain regular
|
||||
expression:
|
||||
If account type is \f[C]Asset\f[R] and name does not contain this
|
||||
regular expression:
|
||||
T}@T{
|
||||
account type is:
|
||||
T}
|
||||
@ -7789,13 +7864,13 @@ REGEX
|
||||
\f[R]
|
||||
.fi
|
||||
.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.
|
||||
It is a POSIX ERE (extended regular expression) that also supports GNU
|
||||
word boundaries (\f[C]\[rs]b\f[R], \f[C]\[rs]B\f[R], \f[C]\[rs]<\f[R],
|
||||
\f[C]\[rs]>\f[R]), and nothing else.
|
||||
If you have trouble, be sure to check our
|
||||
https://hledger.org/hledger.html#regular-expressions doc.
|
||||
If you have trouble, be sure to check our doc:
|
||||
https://hledger.org/hledger.html#regular-expressions
|
||||
.PP
|
||||
Important note: the record that is matched is not the original record,
|
||||
but a synthetic one, with any enclosing double quotes (but not enclosing
|
||||
|
||||
1053
hledger/hledger.info
1053
hledger/hledger.info
File diff suppressed because it is too large
Load Diff
@ -497,9 +497,8 @@ DATA FILES
|
||||
o Are all commodities declared with a commodity directive ? (Commodity
|
||||
error checking)
|
||||
|
||||
See also: https://hledger.org/checking-for-errors.html
|
||||
|
||||
experimental.
|
||||
You can also use the check command to run these and some additional
|
||||
checks.
|
||||
|
||||
TIME PERIODS
|
||||
Smart dates
|
||||
@ -576,11 +575,32 @@ TIME PERIODS
|
||||
|
||||
Report intervals
|
||||
A report interval can be specified so that commands like register, bal-
|
||||
ance and activity will divide their reports into multiple subperiods.
|
||||
The basic intervals can be selected with one of -D/--daily,
|
||||
-W/--weekly, -M/--monthly, -Q/--quarterly, or -Y/--yearly. More com-
|
||||
plex intervals may be specified with a period expression. Report
|
||||
intervals can not be specified with a query.
|
||||
ance and activity become multi-period, showing each subperiod as a sep-
|
||||
arate row or column.
|
||||
|
||||
The following "standard" report intervals can be enabled by using their
|
||||
corresponding flag:
|
||||
|
||||
-D/--daily, -W/--weekly, -M/--monthly, -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 expres-
|
||||
sions, 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 sub-
|
||||
periods, so that all subperiods' numbers are comparable.
|
||||
|
||||
Period expressions
|
||||
The -p/--period option accepts period expressions, a shorthand way of
|
||||
@ -606,7 +626,6 @@ TIME PERIODS
|
||||
|
||||
|
||||
-p "1/1 4/1"
|
||||
|
||||
-p "january-apr"
|
||||
-p "this year to 4/1"
|
||||
|
||||
@ -1162,8 +1181,6 @@ VALUATION
|
||||
posting cost value at value at posting value at value at
|
||||
amounts report end date report or DATE/today
|
||||
or today journal end
|
||||
|
||||
|
||||
summary post- summarised value at sum of postings value at value at
|
||||
ing amounts cost period ends in interval, val- period ends DATE/today
|
||||
with report ued at interval
|
||||
@ -1201,6 +1218,12 @@ 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-
|
||||
@ -1322,6 +1345,11 @@ OUTPUT
|
||||
$ hledger print -o foo.txt
|
||||
$ hledger print -o - # write to stdout (the default)
|
||||
|
||||
hledger can optionally produce debug output (if enabled with
|
||||
--debug=N); this goes to stderr, and is not affected by -o/--output-
|
||||
file. If you need to capture it, use shell redirects, eg: hledger bal
|
||||
--debug=3 >file 2>&1.
|
||||
|
||||
Output format
|
||||
Some commands (print, register, the balance commands) offer a choice of
|
||||
output format. In addition to the usual plain text format (txt), there
|
||||
@ -2588,7 +2616,7 @@ COMMANDS
|
||||
check. They are more specialised and not desirable for everyone,
|
||||
therefore optional:
|
||||
|
||||
o ordereddates - transactions are ordered by date in each file
|
||||
o ordereddates - transactions are ordered by date within each file
|
||||
|
||||
o payees - all payees used by transactions have been declared
|
||||
|
||||
@ -3964,17 +3992,13 @@ JOURNAL FORMAT
|
||||
|
||||
1
|
||||
|
||||
..and usually a currency or commodity name (the "commodity"). This is
|
||||
a symbol, word, or phrase, to the left or right of the quantity, with
|
||||
or without a separating space:
|
||||
..and usually a currency symbol or commodity name (more on this below),
|
||||
to the left or right of the quantity, with or without a separating
|
||||
space:
|
||||
|
||||
$1
|
||||
4000 AAPL
|
||||
|
||||
If the commodity name contains spaces, numbers, or punctuation, it must
|
||||
be enclosed in double quotes:
|
||||
|
||||
3 "no. 42 green apples"
|
||||
3 "green apples"
|
||||
|
||||
Amounts can be preceded by a minus sign (or a plus sign, though plus is
|
||||
the default), The sign can be written before or after a left-side com-
|
||||
@ -4017,29 +4041,53 @@ JOURNAL FORMAT
|
||||
|
||||
If you don't tell it otherwise, hledger will assume both of the above
|
||||
are decimal marks, parsing both numbers as 1. To prevent confusion and
|
||||
undetected typos, especially if your data contains digit group marks,
|
||||
we recommend you explicitly declare the decimal mark (and optionally a
|
||||
digit group mark), for each commodity, using commodity directives
|
||||
(described below):
|
||||
undetected typos, we recommend adding commodity directives at the top
|
||||
of your journal file to explicitly declare the decimal mark (and
|
||||
optionally a digit group mark) for each commodity. Read on for more
|
||||
about this.
|
||||
|
||||
# number formats for $, EUR, INR and the no-symbol commodity:
|
||||
Commodity
|
||||
Amounts in hledger have both a "quantity", which is a signed decimal
|
||||
number, and a "commodity", which is a currency symbol, stock ticker, or
|
||||
any word or phrase describing something you are tracking.
|
||||
|
||||
If the commodity name contains non-letters (spaces, numbers, or punctu-
|
||||
ation), you must always write it inside double quotes ("green apples",
|
||||
"ABC123").
|
||||
|
||||
If you write just a bare number, that too will have a commodity, with
|
||||
name ""; we call that the "no-symbol commodity".
|
||||
|
||||
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: 1 USD, 2 EUR, 3.456
|
||||
TSLA. In practice, you will only see multi-commodity amounts in
|
||||
hledger's output; you can't write them directly in the journal file.
|
||||
|
||||
(If you are writing scripts or working with hledger's internals, these
|
||||
are the Amount and MixedAmount types.)
|
||||
|
||||
Commodity directives
|
||||
You can add commodity 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 commodi-
|
||||
ties. Here's a quick example:
|
||||
|
||||
# number format and display style for $, EUR, INR and the no-symbol commodity:
|
||||
commodity $1,000.00
|
||||
commodity EUR 1.000,00
|
||||
commodity INR 9,99,99,999.00
|
||||
commodity 1 000 000.9455
|
||||
|
||||
Note, commodity 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 dis-
|
||||
cussed more on #793.
|
||||
|
||||
|
||||
Commodity display style
|
||||
For the amounts in each commodity, hledger chooses a consistent display
|
||||
style to use in most reports. (Except for price amounts, which are
|
||||
always displayed as written). The display style is inferred as fol-
|
||||
lows.
|
||||
style to use in most reports. (Exceptions: price amounts, and all
|
||||
amounts displayed by the print command, are displayed with all of their
|
||||
decimal digits visible.)
|
||||
|
||||
A commodity's display style is inferred as follows.
|
||||
|
||||
First, if a default commodity is declared with D, this commodity and
|
||||
its style is applied to any no-symbol amounts in the journal.
|
||||
@ -4342,9 +4390,6 @@ JOURNAL FORMAT
|
||||
tive directive rec- 2018/06)
|
||||
tives
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
account any document account names, all entries in all
|
||||
text declare account types & dis- files, before or
|
||||
play order after
|
||||
@ -4360,6 +4405,11 @@ JOURNAL FORMAT
|
||||
ment until end of cur-
|
||||
rent file or end
|
||||
directive
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
commod- format declare a commodity and its number notation:
|
||||
ity number notation & display following entries
|
||||
style in that commodity
|
||||
@ -4494,39 +4544,44 @@ JOURNAL FORMAT
|
||||
payee Whole Foods
|
||||
|
||||
Declaring commodities
|
||||
The commodity directive has several functions:
|
||||
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 is
|
||||
currently not enforced, but can serve as documentation.
|
||||
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 what decimal mark character (period or comma) to expect
|
||||
when parsing input - useful to disambiguate international number
|
||||
formats in your data. (Without this, hledger will parse both 1,000
|
||||
and 1.000 as 1).
|
||||
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 a commodity's display style in output - decimal and
|
||||
digit group marks, number of decimal places, symbol placement etc.
|
||||
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
|
||||
style)
|
||||
|
||||
You are likely to run into one of the problems solved by commodity
|
||||
directives, sooner or later, so it's a good idea to just always use
|
||||
them to declare your commodities.
|
||||
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.
|
||||
|
||||
A commodity directive is just the word commodity followed by an amount.
|
||||
It may be written on a single line, like this:
|
||||
Generally you should put them at the top of your journal file (since
|
||||
for function 2, they affect only following amounts, cf #793).
|
||||
|
||||
; commodity EXAMPLEAMOUNT
|
||||
A commodity directive is just the word commodity followed by a sample
|
||||
amount, like this:
|
||||
|
||||
; display AAAA amounts with the symbol on the right, space-separated,
|
||||
; using period as decimal point, with four decimal places, and
|
||||
; separating thousands with comma.
|
||||
commodity 1,000.0000 AAAA
|
||||
;commodity SAMPLEAMOUNT
|
||||
|
||||
or on multiple lines, using the "format" subdirective. (In this case
|
||||
the commodity symbol appears twice and should be the same in both
|
||||
places.):
|
||||
commodity $1000.00
|
||||
commodity 1,000.0000 AAAA ; optional same-line comment
|
||||
|
||||
; commodity SYMBOL
|
||||
; format EXAMPLEAMOUNT
|
||||
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
|
||||
; format SAMPLEAMOUNT
|
||||
|
||||
; display indian rupees with currency name on the left,
|
||||
; thousands, lakhs and crores comma-separated,
|
||||
@ -4534,9 +4589,20 @@ JOURNAL FORMAT
|
||||
commodity INR
|
||||
format INR 1,00,00,000.00
|
||||
|
||||
The quantity of the amount does not matter; only the format is signifi-
|
||||
cant. The number must include a decimal mark: either a period or a
|
||||
comma, followed by 0 or more decimal digits.
|
||||
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
|
||||
by 0 or more decimal digits.
|
||||
|
||||
A few more examples:
|
||||
|
||||
# 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.
|
||||
|
||||
Note hledger normally uses banker's rounding, so 0.5 displayed with
|
||||
zero decimal digits is "0". (More at Commodity display style.)
|
||||
@ -4548,16 +4614,18 @@ JOURNAL FORMAT
|
||||
see the notes there for more details.
|
||||
|
||||
Default commodity
|
||||
The D directive sets a default commodity, to be used for amounts with-
|
||||
out a commodity symbol (ie, plain numbers). This commodity will be
|
||||
applied to all subsequent commodity-less amounts, or until the next D
|
||||
directive. (Note, this is different from Ledger's D.)
|
||||
The D 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 display style (for output) and deci-
|
||||
mal mark (for parsing input). As with commodity, the amount must
|
||||
always be written with a decimal mark (period or comma). If both
|
||||
directives are used, commodity's style takes precedence.
|
||||
directive (setting the commodity's decimal mark for parsing and display
|
||||
style for output).
|
||||
|
||||
As with commodity, the amount must include a decimal mark (either
|
||||
period or comma). If both commodity and D directives are used for the
|
||||
same commodity, the commodity style takes precedence.
|
||||
|
||||
The syntax is D AMOUNT. Eg:
|
||||
|
||||
@ -4718,8 +4786,8 @@ JOURNAL FORMAT
|
||||
cally using the following rules:
|
||||
|
||||
|
||||
If name matches regular account type is:
|
||||
expression:
|
||||
If name matches this regu- account type is:
|
||||
lar expression:
|
||||
----------------------------------------------
|
||||
^assets?(:|$) Asset
|
||||
^(debts?|lia- Liability
|
||||
@ -4729,10 +4797,9 @@ JOURNAL FORMAT
|
||||
^expenses?(:|$) Expense
|
||||
|
||||
|
||||
If account type is Asset and name does not contain regu- account type
|
||||
lar expression: is:
|
||||
If account type is Asset and name does not contain this account type
|
||||
regular expression: is:
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
(investment|receivable|:A/R|:fixed) Cash
|
||||
|
||||
Even so, explicit declarations may be a good idea, for clarity and pre-
|
||||
@ -5695,11 +5762,11 @@ CSV FORMAT
|
||||
|
||||
REGEX
|
||||
|
||||
REGEX is a case-insensitive regular expression which tries to match
|
||||
anywhere within the CSV record. It is a POSIX ERE (extended regular
|
||||
REGEX is a case-insensitive regular expression that tries to match any-
|
||||
where within the CSV record. It is a POSIX ERE (extended regular
|
||||
expression) that also supports GNU word boundaries (\b, \B, \<, \>),
|
||||
and nothing else. If you have trouble, be sure to check our
|
||||
https://hledger.org/hledger.html#regular-expressions doc.
|
||||
and nothing else. If you have trouble, be sure to check our doc:
|
||||
https://hledger.org/hledger.html#regular-expressions
|
||||
|
||||
Important note: the record that is matched is not the original record,
|
||||
but a synthetic one, with any enclosing double quotes (but not enclos-
|
||||
|
||||
Loading…
Reference in New Issue
Block a user