doc: journal: expand transactions/postings/status sections (#553)
This commit is contained in:
parent
2f5d950f0e
commit
34af40024a
@ -61,34 +61,49 @@ Here\[aq]s an example:
|
|||||||
.SH FILE FORMAT
|
.SH FILE FORMAT
|
||||||
.SS Transactions
|
.SS Transactions
|
||||||
.PP
|
.PP
|
||||||
Transactions are represented by journal entries.
|
Transactions are movements of some quantity of commodities between named
|
||||||
Each begins with a simple date in column 0, followed by three optional
|
accounts.
|
||||||
fields with spaces between them:
|
Each transaction is represented by a journal entry beginning with a
|
||||||
|
simple date in column 0.
|
||||||
|
This can be followed by any of the following, separated by spaces:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
a status flag, which can be empty or \f[C]!\f[] or \f[C]*\f[] (meaning
|
(optional) a status character (empty, \f[C]!\f[], or \f[C]*\f[])
|
||||||
"uncleared", "pending" and "cleared", or whatever you want)
|
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
a transaction code (eg a check number),
|
(optional) a transaction code (any short number or text, eg a check
|
||||||
|
number)
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
and/or a description
|
(optional) a transaction description (any remaining text until end of
|
||||||
|
line)
|
||||||
.PP
|
.PP
|
||||||
then some number of postings, of some amount to some account.
|
Then comes zero or more (but usually at least 2) indented lines
|
||||||
Each posting is on its own line, consisting of:
|
representing...
|
||||||
.IP \[bu] 2
|
.SS Postings
|
||||||
indentation of one or more spaces (or tabs)
|
|
||||||
.IP \[bu] 2
|
|
||||||
optionally, a \f[C]!\f[] or \f[C]*\f[] status flag followed by a space
|
|
||||||
.IP \[bu] 2
|
|
||||||
an account name, optionally containing single spaces
|
|
||||||
.IP \[bu] 2
|
|
||||||
optionally, two or more spaces or tabs followed by an amount
|
|
||||||
.PP
|
.PP
|
||||||
Usually there are two or more postings, though one or none is also
|
A posting is an addition of some amount to, or removal of some amount
|
||||||
possible.
|
from, an account.
|
||||||
The posting amounts within a transaction must always balance, ie add up
|
Each posting line begins with at least one space or tab (2 or 4 spaces
|
||||||
to 0.
|
is common), followed by:
|
||||||
Optionally one amount can be left blank, in which case it will be
|
.IP \[bu] 2
|
||||||
inferred.
|
(optional) a status character (empty, \f[C]!\f[], or \f[C]*\f[]),
|
||||||
|
followed by a space
|
||||||
|
.IP \[bu] 2
|
||||||
|
(required) an account name (any text, optionally containing \f[B]single
|
||||||
|
spaces\f[], until end of line or a double space)
|
||||||
|
.IP \[bu] 2
|
||||||
|
(optional) \f[B]two or more spaces\f[] or tabs followed by an amount.
|
||||||
|
.PP
|
||||||
|
Positive amounts are being added to the account, negative amounts are
|
||||||
|
being removed.
|
||||||
|
.PP
|
||||||
|
The amounts within a transaction must always sum up to zero.
|
||||||
|
As a convenience, one amount may be left blank; it will be inferred so
|
||||||
|
as to balance the transaction.
|
||||||
|
.PP
|
||||||
|
Be sure to note the unusual two\-space delimiter between account name
|
||||||
|
and amount.
|
||||||
|
This makes it easy to write account names containing spaces.
|
||||||
|
But if you accidentally leave only one space (or tab) before the amount,
|
||||||
|
the amount will be considered part of the account name.
|
||||||
.SS Dates
|
.SS Dates
|
||||||
.SS Simple dates
|
.SS Simple dates
|
||||||
.PP
|
.PP
|
||||||
@ -195,6 +210,49 @@ hledger will attempt to parse any square\-bracketed sequence of the
|
|||||||
\f[C]0123456789/\-.=\f[] characters in this way.
|
\f[C]0123456789/\-.=\f[] characters in this way.
|
||||||
With this syntax, DATE infers its year from the transaction and DATE2
|
With this syntax, DATE infers its year from the transaction and DATE2
|
||||||
infers its year from DATE.
|
infers its year from DATE.
|
||||||
|
.SS Status
|
||||||
|
.PP
|
||||||
|
More about the status field: transactions, or individual postings within
|
||||||
|
a transaction, can be in one of three states, represented by a single
|
||||||
|
character:
|
||||||
|
.IP \[bu] 2
|
||||||
|
empty (no status character) = uncleared
|
||||||
|
.IP \[bu] 2
|
||||||
|
\f[C]!\f[] = pending (aka "tentatively cleared")
|
||||||
|
.IP \[bu] 2
|
||||||
|
\f[C]*\f[] = cleared
|
||||||
|
.PP
|
||||||
|
When reporting, you can filter by status using the
|
||||||
|
\f[C]\-C/\-\-cleared\f[] and \f[C]\-U/\-\-uncleared\f[] flags or the
|
||||||
|
\f[C]status:\f[] query.
|
||||||
|
.PP
|
||||||
|
This feature is optional, but can be helpful for reconciling with
|
||||||
|
real\-world accounts.
|
||||||
|
What "uncleared", "pending", and "cleared" actually mean is up to you.
|
||||||
|
My recommendation: use cleared (\f[C]*\f[]) to mark transactions that
|
||||||
|
are "complete", ie:
|
||||||
|
.IP \[bu] 2
|
||||||
|
they have cleared with the bank, or the cash has been handed over
|
||||||
|
.IP \[bu] 2
|
||||||
|
you are satisfied they are recorded accurately in the journal
|
||||||
|
.IP \[bu] 2
|
||||||
|
the resulting account balance reported by hledger agrees exactly with
|
||||||
|
the external source of truth, if any (eg the bank\[aq]s online register
|
||||||
|
or statement)
|
||||||
|
.PP
|
||||||
|
Then, with \-\-cleared you\[aq]ll see the current balance at your bank,
|
||||||
|
with \-\-uncleared you\[aq]ll see things which will probably hit your
|
||||||
|
bank soon (eg uncashed checks), and with neither flag (the default)
|
||||||
|
you\[aq]ll see the most up\-to\-date state of your finances.
|
||||||
|
.PP
|
||||||
|
I don\[aq]t use pending (\f[C]!\f[]), but perhaps it is useful in very
|
||||||
|
tricky reconciliations, as a temporary marker for transactions matched
|
||||||
|
so far, allowing you start over more easily.
|
||||||
|
.PP
|
||||||
|
Tip: some editor modes highlight entries differently based on their
|
||||||
|
status.
|
||||||
|
In Emacs ledger\-mode, you can toggle transaction status with
|
||||||
|
\f[C]C\-c\ C\-e\f[], or posting status with \f[C]C\-c\ C\-c\f[].
|
||||||
.SS Account names
|
.SS Account names
|
||||||
.PP
|
.PP
|
||||||
Account names typically have several parts separated by a full colon,
|
Account names typically have several parts separated by a full colon,
|
||||||
|
|||||||
@ -64,7 +64,9 @@ File: hledger_journal.5.info, Node: FILE FORMAT, Next: EDITOR SUPPORT, Prev:
|
|||||||
* Menu:
|
* Menu:
|
||||||
|
|
||||||
* Transactions::
|
* Transactions::
|
||||||
|
* Postings::
|
||||||
* Dates::
|
* Dates::
|
||||||
|
* Status::
|
||||||
* Account names::
|
* Account names::
|
||||||
* Amounts::
|
* Amounts::
|
||||||
* Virtual Postings::
|
* Virtual Postings::
|
||||||
@ -76,37 +78,57 @@ File: hledger_journal.5.info, Node: FILE FORMAT, Next: EDITOR SUPPORT, Prev:
|
|||||||
* Directives::
|
* Directives::
|
||||||
|
|
||||||
|
|
||||||
File: hledger_journal.5.info, Node: Transactions, Next: Dates, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Transactions, Next: Postings, Up: FILE FORMAT
|
||||||
|
|
||||||
1.1 Transactions
|
1.1 Transactions
|
||||||
================
|
================
|
||||||
|
|
||||||
Transactions are represented by journal entries. Each begins with a
|
Transactions are movements of some quantity of commodities between named
|
||||||
simple date in column 0, followed by three optional fields with spaces
|
accounts. Each transaction is represented by a journal entry beginning
|
||||||
between them:
|
with a simple date in column 0. This can be followed by any of the
|
||||||
|
following, separated by spaces:
|
||||||
|
|
||||||
* a status flag, which can be empty or '!' or '*' (meaning
|
* (optional) a status character (empty, '!', or '*')
|
||||||
"uncleared", "pending" and "cleared", or whatever you want)
|
* (optional) a transaction code (any short number or text, eg a check
|
||||||
* a transaction code (eg a check number),
|
number)
|
||||||
* and/or a description
|
* (optional) a transaction description (any remaining text until end
|
||||||
|
of line)
|
||||||
|
|
||||||
then some number of postings, of some amount to some account. Each
|
Then comes zero or more (but usually at least 2) indented lines
|
||||||
posting is on its own line, consisting of:
|
representing...
|
||||||
|
|
||||||
* indentation of one or more spaces (or tabs)
|
|
||||||
* optionally, a '!' or '*' status flag followed by a space
|
|
||||||
* an account name, optionally containing single spaces
|
|
||||||
* optionally, two or more spaces or tabs followed by an amount
|
|
||||||
|
|
||||||
Usually there are two or more postings, though one or none is also
|
|
||||||
possible. The posting amounts within a transaction must always balance,
|
|
||||||
ie add up to 0. Optionally one amount can be left blank, in which case
|
|
||||||
it will be inferred.
|
|
||||||
|
|
||||||
|
|
||||||
File: hledger_journal.5.info, Node: Dates, Next: Account names, Prev: Transactions, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Postings, Next: Dates, Prev: Transactions, Up: FILE FORMAT
|
||||||
|
|
||||||
1.2 Dates
|
1.2 Postings
|
||||||
|
============
|
||||||
|
|
||||||
|
A posting is an addition of some amount to, or removal of some amount
|
||||||
|
from, an account. Each posting line begins with at least one space or
|
||||||
|
tab (2 or 4 spaces is common), followed by:
|
||||||
|
|
||||||
|
* (optional) a status character (empty, '!', or '*'), followed by a
|
||||||
|
space
|
||||||
|
* (required) an account name (any text, optionally containing *single
|
||||||
|
spaces*, until end of line or a double space)
|
||||||
|
* (optional) *two or more spaces* or tabs followed by an amount.
|
||||||
|
|
||||||
|
Positive amounts are being added to the account, negative amounts are
|
||||||
|
being removed.
|
||||||
|
|
||||||
|
The amounts within a transaction must always sum up to zero. As a
|
||||||
|
convenience, one amount may be left blank; it will be inferred so as to
|
||||||
|
balance the transaction.
|
||||||
|
|
||||||
|
Be sure to note the unusual two-space delimiter between account name
|
||||||
|
and amount. This makes it easy to write account names containing
|
||||||
|
spaces. But if you accidentally leave only one space (or tab) before
|
||||||
|
the amount, the amount will be considered part of the account name.
|
||||||
|
|
||||||
|
|
||||||
|
File: hledger_journal.5.info, Node: Dates, Next: Status, Prev: Postings, Up: FILE FORMAT
|
||||||
|
|
||||||
|
1.3 Dates
|
||||||
=========
|
=========
|
||||||
|
|
||||||
* Menu:
|
* Menu:
|
||||||
@ -118,7 +140,7 @@ File: hledger_journal.5.info, Node: Dates, Next: Account names, Prev: Transac
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Simple dates, Next: Secondary dates, Up: Dates
|
File: hledger_journal.5.info, Node: Simple dates, Next: Secondary dates, Up: Dates
|
||||||
|
|
||||||
1.2.1 Simple dates
|
1.3.1 Simple dates
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Within a journal file, transaction dates use Y/M/D (or Y-M-D or Y.M.D)
|
Within a journal file, transaction dates use Y/M/D (or Y-M-D or Y.M.D)
|
||||||
@ -131,7 +153,7 @@ command is run. Some examples: '2010/01/31', '1/31', '2010-01-31',
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Secondary dates, Next: Posting dates, Prev: Simple dates, Up: Dates
|
File: hledger_journal.5.info, Node: Secondary dates, Next: Posting dates, Prev: Simple dates, Up: Dates
|
||||||
|
|
||||||
1.2.2 Secondary dates
|
1.3.2 Secondary dates
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
Real-life transactions sometimes involve more than one date - eg the
|
Real-life transactions sometimes involve more than one date - eg the
|
||||||
@ -172,7 +194,7 @@ confusing alternative.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Posting dates, Prev: Secondary dates, Up: Dates
|
File: hledger_journal.5.info, Node: Posting dates, Prev: Secondary dates, Up: Dates
|
||||||
|
|
||||||
1.2.3 Posting dates
|
1.3.3 Posting dates
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
You can give individual postings a different date from their parent
|
You can give individual postings a different date from their parent
|
||||||
@ -205,9 +227,50 @@ characters in this way. With this syntax, DATE infers its year from the
|
|||||||
transaction and DATE2 infers its year from DATE.
|
transaction and DATE2 infers its year from DATE.
|
||||||
|
|
||||||
|
|
||||||
File: hledger_journal.5.info, Node: Account names, Next: Amounts, Prev: Dates, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Status, Next: Account names, Prev: Dates, Up: FILE FORMAT
|
||||||
|
|
||||||
1.3 Account names
|
1.4 Status
|
||||||
|
==========
|
||||||
|
|
||||||
|
More about the status field: transactions, or individual postings within
|
||||||
|
a transaction, can be in one of three states, represented by a single
|
||||||
|
character:
|
||||||
|
|
||||||
|
* empty (no status character) = uncleared
|
||||||
|
* '!' = pending (aka "tentatively cleared")
|
||||||
|
* '*' = cleared
|
||||||
|
|
||||||
|
When reporting, you can filter by status using the '-C/--cleared' and
|
||||||
|
'-U/--uncleared' flags or the 'status:' query.
|
||||||
|
|
||||||
|
This feature is optional, but can be helpful for reconciling with
|
||||||
|
real-world accounts. What "uncleared", "pending", and "cleared"
|
||||||
|
actually mean is up to you. My recommendation: use cleared ('*') to
|
||||||
|
mark transactions that are "complete", ie:
|
||||||
|
|
||||||
|
* they have cleared with the bank, or the cash has been handed over
|
||||||
|
* you are satisfied they are recorded accurately in the journal
|
||||||
|
* the resulting account balance reported by hledger agrees exactly
|
||||||
|
with the external source of truth, if any (eg the bank's online
|
||||||
|
register or statement)
|
||||||
|
|
||||||
|
Then, with -cleared you'll see the current balance at your bank, with
|
||||||
|
-uncleared you'll see things which will probably hit your bank soon (eg
|
||||||
|
uncashed checks), and with neither flag (the default) you'll see the
|
||||||
|
most up-to-date state of your finances.
|
||||||
|
|
||||||
|
I don't use pending ('!'), but perhaps it is useful in very tricky
|
||||||
|
reconciliations, as a temporary marker for transactions matched so far,
|
||||||
|
allowing you start over more easily.
|
||||||
|
|
||||||
|
Tip: some editor modes highlight entries differently based on their
|
||||||
|
status. In Emacs ledger-mode, you can toggle transaction status with
|
||||||
|
'C-c C-e', or posting status with 'C-c C-c'.
|
||||||
|
|
||||||
|
|
||||||
|
File: hledger_journal.5.info, Node: Account names, Next: Amounts, Prev: Status, Up: FILE FORMAT
|
||||||
|
|
||||||
|
1.5 Account names
|
||||||
=================
|
=================
|
||||||
|
|
||||||
Account names typically have several parts separated by a full colon,
|
Account names typically have several parts separated by a full colon,
|
||||||
@ -225,7 +288,7 @@ more spaces* (or newline).
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Amounts, Next: Virtual Postings, Prev: Account names, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Amounts, Next: Virtual Postings, Prev: Account names, Up: FILE FORMAT
|
||||||
|
|
||||||
1.4 Amounts
|
1.6 Amounts
|
||||||
===========
|
===========
|
||||||
|
|
||||||
After the account name, there is usually an amount. Important: between
|
After the account name, there is usually an amount. Important: between
|
||||||
@ -280,7 +343,7 @@ format with a commodity directive.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Virtual Postings, Next: Balance Assertions, Prev: Amounts, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Virtual Postings, Next: Balance Assertions, Prev: Amounts, Up: FILE FORMAT
|
||||||
|
|
||||||
1.5 Virtual Postings
|
1.7 Virtual Postings
|
||||||
====================
|
====================
|
||||||
|
|
||||||
When you parenthesise the account name in a posting, we call that a
|
When you parenthesise the account name in a posting, we call that a
|
||||||
@ -315,7 +378,7 @@ is more correct and provides better error checking.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Balance Assertions, Next: Balance Assignments, Prev: Virtual Postings, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Balance Assertions, Next: Balance Assignments, Prev: Virtual Postings, Up: FILE FORMAT
|
||||||
|
|
||||||
1.6 Balance Assertions
|
1.8 Balance Assertions
|
||||||
======================
|
======================
|
||||||
|
|
||||||
hledger supports Ledger-style balance assertions in journal files.
|
hledger supports Ledger-style balance assertions in journal files.
|
||||||
@ -349,7 +412,7 @@ or for reading Ledger files.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Assertions and ordering, Next: Assertions and included files, Up: Balance Assertions
|
File: hledger_journal.5.info, Node: Assertions and ordering, Next: Assertions and included files, Up: Balance Assertions
|
||||||
|
|
||||||
1.6.1 Assertions and ordering
|
1.8.1 Assertions and ordering
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
hledger sorts an account's postings and assertions first by date and
|
hledger sorts an account's postings and assertions first by date and
|
||||||
@ -368,7 +431,7 @@ can assert intra-day balances.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Assertions and included files, Next: Assertions and multiple -f options, Prev: Assertions and ordering, Up: Balance Assertions
|
File: hledger_journal.5.info, Node: Assertions and included files, Next: Assertions and multiple -f options, Prev: Assertions and ordering, Up: Balance Assertions
|
||||||
|
|
||||||
1.6.2 Assertions and included files
|
1.8.2 Assertions and included files
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
With included files, things are a little more complicated. Including
|
With included files, things are a little more complicated. Including
|
||||||
@ -380,7 +443,7 @@ you'll have to put the assertion in the right file.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Assertions and multiple -f options, Next: Assertions and commodities, Prev: Assertions and included files, Up: Balance Assertions
|
File: hledger_journal.5.info, Node: Assertions and multiple -f options, Next: Assertions and commodities, Prev: Assertions and included files, Up: Balance Assertions
|
||||||
|
|
||||||
1.6.3 Assertions and multiple -f options
|
1.8.3 Assertions and multiple -f options
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
Balance assertions don't work well across files specified with multiple
|
Balance assertions don't work well across files specified with multiple
|
||||||
@ -389,7 +452,7 @@ Balance assertions don't work well across files specified with multiple
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Assertions and commodities, Next: Assertions and subaccounts, Prev: Assertions and multiple -f options, Up: Balance Assertions
|
File: hledger_journal.5.info, Node: Assertions and commodities, Next: Assertions and subaccounts, Prev: Assertions and multiple -f options, Up: Balance Assertions
|
||||||
|
|
||||||
1.6.4 Assertions and commodities
|
1.8.4 Assertions and commodities
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
The asserted balance must be a simple single-commodity amount, and in
|
The asserted balance must be a simple single-commodity amount, and in
|
||||||
@ -408,7 +471,7 @@ for this kind of total balance assertion if there's demand.)
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Assertions and subaccounts, Next: Assertions and virtual postings, Prev: Assertions and commodities, Up: Balance Assertions
|
File: hledger_journal.5.info, Node: Assertions and subaccounts, Next: Assertions and virtual postings, Prev: Assertions and commodities, Up: Balance Assertions
|
||||||
|
|
||||||
1.6.5 Assertions and subaccounts
|
1.8.5 Assertions and subaccounts
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
Balance assertions do not count the balance from subaccounts; they check
|
Balance assertions do not count the balance from subaccounts; they check
|
||||||
@ -431,7 +494,7 @@ $ hledger bal checking --flat
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Assertions and virtual postings, Prev: Assertions and subaccounts, Up: Balance Assertions
|
File: hledger_journal.5.info, Node: Assertions and virtual postings, Prev: Assertions and subaccounts, Up: Balance Assertions
|
||||||
|
|
||||||
1.6.6 Assertions and virtual postings
|
1.8.6 Assertions and virtual postings
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
Balance assertions are checked against all postings, both real and
|
Balance assertions are checked against all postings, both real and
|
||||||
@ -441,7 +504,7 @@ query.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Balance Assignments, Next: Prices, Prev: Balance Assertions, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Balance Assignments, Next: Prices, Prev: Balance Assertions, Up: FILE FORMAT
|
||||||
|
|
||||||
1.7 Balance Assignments
|
1.9 Balance Assignments
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
Ledger-style balance assignments are also supported. These are like
|
Ledger-style balance assignments are also supported. These are like
|
||||||
@ -474,8 +537,8 @@ hledger or do the calculations yourself, instead of just reading it.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Prices, Next: Comments, Prev: Balance Assignments, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Prices, Next: Comments, Prev: Balance Assignments, Up: FILE FORMAT
|
||||||
|
|
||||||
1.8 Prices
|
1.10 Prices
|
||||||
==========
|
===========
|
||||||
|
|
||||||
* Menu:
|
* Menu:
|
||||||
|
|
||||||
@ -485,8 +548,8 @@ File: hledger_journal.5.info, Node: Prices, Next: Comments, Prev: Balance Ass
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Transaction prices, Next: Market prices, Up: Prices
|
File: hledger_journal.5.info, Node: Transaction prices, Next: Market prices, Up: Prices
|
||||||
|
|
||||||
1.8.1 Transaction prices
|
1.10.1 Transaction prices
|
||||||
------------------------
|
-------------------------
|
||||||
|
|
||||||
Within a transaction, you can note an amount's price in another
|
Within a transaction, you can note an amount's price in another
|
||||||
commodity. This can be used to document the cost (in a purchase) or
|
commodity. This can be used to document the cost (in a purchase) or
|
||||||
@ -546,8 +609,8 @@ $ hledger bal -N --flat -B
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Market prices, Prev: Transaction prices, Up: Prices
|
File: hledger_journal.5.info, Node: Market prices, Prev: Transaction prices, Up: Prices
|
||||||
|
|
||||||
1.8.2 Market prices
|
1.10.2 Market prices
|
||||||
-------------------
|
--------------------
|
||||||
|
|
||||||
Market prices are not tied to a particular transaction; they represent
|
Market prices are not tied to a particular transaction; they represent
|
||||||
historical exchange rates between two commodities. (Ledger calls them
|
historical exchange rates between two commodities. (Ledger calls them
|
||||||
@ -575,8 +638,8 @@ P 2010/1/1 € $1.40
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Comments, Next: Tags, Prev: Prices, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Comments, Next: Tags, Prev: Prices, Up: FILE FORMAT
|
||||||
|
|
||||||
1.9 Comments
|
1.11 Comments
|
||||||
============
|
=============
|
||||||
|
|
||||||
Lines in the journal beginning with a semicolon (';') or hash ('#') or
|
Lines in the journal beginning with a semicolon (';') or hash ('#') or
|
||||||
asterisk ('*') are comments, and will be ignored. (Asterisk comments
|
asterisk ('*') are comments, and will be ignored. (Asterisk comments
|
||||||
@ -615,7 +678,7 @@ end comment
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Tags, Next: Directives, Prev: Comments, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Tags, Next: Directives, Prev: Comments, Up: FILE FORMAT
|
||||||
|
|
||||||
1.10 Tags
|
1.12 Tags
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Tags are a way to add extra labels or labelled data to postings and
|
Tags are a way to add extra labels or labelled data to postings and
|
||||||
@ -661,7 +724,7 @@ are simple strings.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Implicit tags, Up: Tags
|
File: hledger_journal.5.info, Node: Implicit tags, Up: Tags
|
||||||
|
|
||||||
1.10.1 Implicit tags
|
1.12.1 Implicit tags
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
Some predefined "implicit" tags are also provided:
|
Some predefined "implicit" tags are also provided:
|
||||||
@ -679,7 +742,7 @@ the same as 'description'.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Directives, Prev: Tags, Up: FILE FORMAT
|
File: hledger_journal.5.info, Node: Directives, Prev: Tags, Up: FILE FORMAT
|
||||||
|
|
||||||
1.11 Directives
|
1.13 Directives
|
||||||
===============
|
===============
|
||||||
|
|
||||||
* Menu:
|
* Menu:
|
||||||
@ -696,7 +759,7 @@ File: hledger_journal.5.info, Node: Directives, Prev: Tags, Up: FILE FORMAT
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Account aliases, Next: account directive, Up: Directives
|
File: hledger_journal.5.info, Node: Account aliases, Next: account directive, Up: Directives
|
||||||
|
|
||||||
1.11.1 Account aliases
|
1.13.1 Account aliases
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
You can define aliases which rewrite your account names (after reading
|
You can define aliases which rewrite your account names (after reading
|
||||||
@ -721,7 +784,7 @@ be useful for:
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Basic aliases, Next: Regex aliases, Up: Account aliases
|
File: hledger_journal.5.info, Node: Basic aliases, Next: Regex aliases, Up: Account aliases
|
||||||
|
|
||||||
1.11.1.1 Basic aliases
|
1.13.1.1 Basic aliases
|
||||||
......................
|
......................
|
||||||
|
|
||||||
To set an account alias, use the 'alias' directive in your journal file.
|
To set an account alias, use the 'alias' directive in your journal file.
|
||||||
@ -744,7 +807,7 @@ alias checking = assets:bank:wells fargo:checking
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Regex aliases, Next: Multiple aliases, Prev: Basic aliases, Up: Account aliases
|
File: hledger_journal.5.info, Node: Regex aliases, Next: Multiple aliases, Prev: Basic aliases, Up: Account aliases
|
||||||
|
|
||||||
1.11.1.2 Regex aliases
|
1.13.1.2 Regex aliases
|
||||||
......................
|
......................
|
||||||
|
|
||||||
There is also a more powerful variant that uses a regular expression,
|
There is also a more powerful variant that uses a regular expression,
|
||||||
@ -767,7 +830,7 @@ alias /^(.+):bank:([^:]+)(.*)/ = \1:\2 \3
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Multiple aliases, Next: end aliases, Prev: Regex aliases, Up: Account aliases
|
File: hledger_journal.5.info, Node: Multiple aliases, Next: end aliases, Prev: Regex aliases, Up: Account aliases
|
||||||
|
|
||||||
1.11.1.3 Multiple aliases
|
1.13.1.3 Multiple aliases
|
||||||
.........................
|
.........................
|
||||||
|
|
||||||
You can define as many aliases as you like using directives or
|
You can define as many aliases as you like using directives or
|
||||||
@ -783,7 +846,7 @@ following order:
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: end aliases, Prev: Multiple aliases, Up: Account aliases
|
File: hledger_journal.5.info, Node: end aliases, Prev: Multiple aliases, Up: Account aliases
|
||||||
|
|
||||||
1.11.1.4 end aliases
|
1.13.1.4 end aliases
|
||||||
....................
|
....................
|
||||||
|
|
||||||
You can clear (forget) all currently defined aliases with the 'end
|
You can clear (forget) all currently defined aliases with the 'end
|
||||||
@ -794,7 +857,7 @@ end aliases
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: account directive, Next: apply account directive, Prev: Account aliases, Up: Directives
|
File: hledger_journal.5.info, Node: account directive, Next: apply account directive, Prev: Account aliases, Up: Directives
|
||||||
|
|
||||||
1.11.2 account directive
|
1.13.2 account directive
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
The 'account' directive predefines account names, as in Ledger and
|
The 'account' directive predefines account names, as in Ledger and
|
||||||
@ -815,7 +878,7 @@ account expenses:food
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: apply account directive, Next: Multi-line comments, Prev: account directive, Up: Directives
|
File: hledger_journal.5.info, Node: apply account directive, Next: Multi-line comments, Prev: account directive, Up: Directives
|
||||||
|
|
||||||
1.11.3 apply account directive
|
1.13.3 apply account directive
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
You can specify a parent account which will be prepended to all accounts
|
You can specify a parent account which will be prepended to all accounts
|
||||||
@ -851,7 +914,7 @@ supported.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Multi-line comments, Next: commodity directive, Prev: apply account directive, Up: Directives
|
File: hledger_journal.5.info, Node: Multi-line comments, Next: commodity directive, Prev: apply account directive, Up: Directives
|
||||||
|
|
||||||
1.11.4 Multi-line comments
|
1.13.4 Multi-line comments
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
A line containing just 'comment' starts a multi-line comment, and a line
|
A line containing just 'comment' starts a multi-line comment, and a line
|
||||||
@ -860,7 +923,7 @@ containing just 'end comment' ends it. See comments.
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: commodity directive, Next: Default commodity, Prev: Multi-line comments, Up: Directives
|
File: hledger_journal.5.info, Node: commodity directive, Next: Default commodity, Prev: Multi-line comments, Up: Directives
|
||||||
|
|
||||||
1.11.5 commodity directive
|
1.13.5 commodity directive
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
The 'commodity' directive predefines commodities (currently this is just
|
The 'commodity' directive predefines commodities (currently this is just
|
||||||
@ -892,7 +955,7 @@ commodity INR
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Default commodity, Next: Default year, Prev: commodity directive, Up: Directives
|
File: hledger_journal.5.info, Node: Default commodity, Next: Default year, Prev: commodity directive, Up: Directives
|
||||||
|
|
||||||
1.11.6 Default commodity
|
1.13.6 Default commodity
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
The D directive sets a default commodity (and display format), to be
|
The D directive sets a default commodity (and display format), to be
|
||||||
@ -912,7 +975,7 @@ D $1,000.00
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Default year, Next: Including other files, Prev: Default commodity, Up: Directives
|
File: hledger_journal.5.info, Node: Default year, Next: Including other files, Prev: Default commodity, Up: Directives
|
||||||
|
|
||||||
1.11.7 Default year
|
1.13.7 Default year
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
You can set a default year to be used for subsequent dates which don't
|
You can set a default year to be used for subsequent dates which don't
|
||||||
@ -938,7 +1001,7 @@ Y2010 ; change default year to 2010
|
|||||||
|
|
||||||
File: hledger_journal.5.info, Node: Including other files, Prev: Default year, Up: Directives
|
File: hledger_journal.5.info, Node: Including other files, Prev: Default year, Up: Directives
|
||||||
|
|
||||||
1.11.8 Including other files
|
1.13.8 Including other files
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
You can pull in the content of additional journal files by writing an
|
You can pull in the content of additional journal files by writing an
|
||||||
@ -977,77 +1040,81 @@ Tag Table:
|
|||||||
Node: Top78
|
Node: Top78
|
||||||
Node: FILE FORMAT2292
|
Node: FILE FORMAT2292
|
||||||
Ref: #file-format2418
|
Ref: #file-format2418
|
||||||
Node: Transactions2601
|
Node: Transactions2625
|
||||||
Ref: #transactions2721
|
Ref: #transactions2748
|
||||||
Node: Dates3663
|
Node: Postings3307
|
||||||
Ref: #dates3791
|
Ref: #postings3436
|
||||||
Node: Simple dates3856
|
Node: Dates4431
|
||||||
Ref: #simple-dates3984
|
Ref: #dates4548
|
||||||
Node: Secondary dates4350
|
Node: Simple dates4613
|
||||||
Ref: #secondary-dates4506
|
Ref: #simple-dates4741
|
||||||
Node: Posting dates6069
|
Node: Secondary dates5107
|
||||||
Ref: #posting-dates6200
|
Ref: #secondary-dates5263
|
||||||
Node: Account names7574
|
Node: Posting dates6826
|
||||||
Ref: #account-names7713
|
Ref: #posting-dates6957
|
||||||
Node: Amounts8200
|
Node: Status8331
|
||||||
Ref: #amounts8338
|
Ref: #status8455
|
||||||
Node: Virtual Postings10439
|
Node: Account names10018
|
||||||
Ref: #virtual-postings10600
|
Ref: #account-names10158
|
||||||
Node: Balance Assertions11820
|
Node: Amounts10645
|
||||||
Ref: #balance-assertions11997
|
Ref: #amounts10783
|
||||||
Node: Assertions and ordering12893
|
Node: Virtual Postings12884
|
||||||
Ref: #assertions-and-ordering13081
|
Ref: #virtual-postings13045
|
||||||
Node: Assertions and included files13781
|
Node: Balance Assertions14265
|
||||||
Ref: #assertions-and-included-files14024
|
Ref: #balance-assertions14442
|
||||||
Node: Assertions and multiple -f options14357
|
Node: Assertions and ordering15338
|
||||||
Ref: #assertions-and-multiple--f-options14613
|
Ref: #assertions-and-ordering15526
|
||||||
Node: Assertions and commodities14745
|
Node: Assertions and included files16226
|
||||||
Ref: #assertions-and-commodities14982
|
Ref: #assertions-and-included-files16469
|
||||||
Node: Assertions and subaccounts15678
|
Node: Assertions and multiple -f options16802
|
||||||
Ref: #assertions-and-subaccounts15912
|
Ref: #assertions-and-multiple--f-options17058
|
||||||
Node: Assertions and virtual postings16433
|
Node: Assertions and commodities17190
|
||||||
Ref: #assertions-and-virtual-postings16642
|
Ref: #assertions-and-commodities17427
|
||||||
Node: Balance Assignments16784
|
Node: Assertions and subaccounts18123
|
||||||
Ref: #balance-assignments16953
|
Ref: #assertions-and-subaccounts18357
|
||||||
Node: Prices18072
|
Node: Assertions and virtual postings18878
|
||||||
Ref: #prices18205
|
Ref: #assertions-and-virtual-postings19087
|
||||||
Node: Transaction prices18256
|
Node: Balance Assignments19229
|
||||||
Ref: #transaction-prices18401
|
Ref: #balance-assignments19398
|
||||||
Node: Market prices20557
|
Node: Prices20517
|
||||||
Ref: #market-prices20692
|
Ref: #prices20652
|
||||||
Node: Comments21652
|
Node: Transaction prices20703
|
||||||
Ref: #comments21774
|
Ref: #transaction-prices20850
|
||||||
Node: Tags22887
|
Node: Market prices23006
|
||||||
Ref: #tags23007
|
Ref: #market-prices23143
|
||||||
Node: Implicit tags24436
|
Node: Comments24103
|
||||||
Ref: #implicit-tags24544
|
Ref: #comments24227
|
||||||
Node: Directives25061
|
Node: Tags25340
|
||||||
Ref: #directives25176
|
Ref: #tags25460
|
||||||
Node: Account aliases25369
|
Node: Implicit tags26889
|
||||||
Ref: #account-aliases25515
|
Ref: #implicit-tags26997
|
||||||
Node: Basic aliases26119
|
Node: Directives27514
|
||||||
Ref: #basic-aliases26264
|
Ref: #directives27629
|
||||||
Node: Regex aliases26954
|
Node: Account aliases27822
|
||||||
Ref: #regex-aliases27124
|
Ref: #account-aliases27968
|
||||||
Node: Multiple aliases27839
|
Node: Basic aliases28572
|
||||||
Ref: #multiple-aliases28013
|
Ref: #basic-aliases28717
|
||||||
Node: end aliases28511
|
Node: Regex aliases29407
|
||||||
Ref: #end-aliases28653
|
Ref: #regex-aliases29577
|
||||||
Node: account directive28754
|
Node: Multiple aliases30292
|
||||||
Ref: #account-directive28936
|
Ref: #multiple-aliases30466
|
||||||
Node: apply account directive29232
|
Node: end aliases30964
|
||||||
Ref: #apply-account-directive29430
|
Ref: #end-aliases31106
|
||||||
Node: Multi-line comments30089
|
Node: account directive31207
|
||||||
Ref: #multi-line-comments30281
|
Ref: #account-directive31389
|
||||||
Node: commodity directive30409
|
Node: apply account directive31685
|
||||||
Ref: #commodity-directive30595
|
Ref: #apply-account-directive31883
|
||||||
Node: Default commodity31467
|
Node: Multi-line comments32542
|
||||||
Ref: #default-commodity31642
|
Ref: #multi-line-comments32734
|
||||||
Node: Default year32179
|
Node: commodity directive32862
|
||||||
Ref: #default-year32346
|
Ref: #commodity-directive33048
|
||||||
Node: Including other files32769
|
Node: Default commodity33920
|
||||||
Ref: #including-other-files32928
|
Ref: #default-commodity34095
|
||||||
Node: EDITOR SUPPORT33325
|
Node: Default year34632
|
||||||
Ref: #editor-support33445
|
Ref: #default-year34799
|
||||||
|
Node: Including other files35222
|
||||||
|
Ref: #including-other-files35381
|
||||||
|
Node: EDITOR SUPPORT35778
|
||||||
|
Ref: #editor-support35898
|
||||||
|
|
||||||
End Tag Table
|
End Tag Table
|
||||||
|
|||||||
@ -65,27 +65,33 @@ Here's an example:
|
|||||||
|
|
||||||
## Transactions
|
## Transactions
|
||||||
|
|
||||||
Transactions are represented by journal entries. Each begins with a
|
Transactions are movements of some quantity of commodities between named accounts.
|
||||||
[simple date](#simple-dates) in column 0, followed by three optional
|
Each transaction is represented by a journal entry beginning with a [simple date](#simple-dates) in column 0.
|
||||||
fields with spaces between them:
|
This can be followed by any of the following, separated by spaces:
|
||||||
|
|
||||||
- a status flag, which can be empty or `!` or `*` (meaning "uncleared",
|
- (optional) a [status](#status) character (empty, `!`, or `*`)
|
||||||
"pending" and "cleared", or whatever you want)
|
- (optional) a transaction code (any short number or text, eg a check number)
|
||||||
- a transaction code (eg a check number),
|
- (optional) a transaction description (any remaining text until end of line)
|
||||||
- and/or a description
|
|
||||||
|
|
||||||
then some number of postings, of some amount to some account. Each
|
Then comes zero or more (but usually at least 2) indented lines representing...
|
||||||
posting is on its own line, consisting of:
|
|
||||||
|
|
||||||
- indentation of one or more spaces (or tabs)
|
## Postings
|
||||||
- optionally, a `!` or `*` status flag followed by a space
|
|
||||||
- an account name, optionally containing single spaces
|
|
||||||
- optionally, two or more spaces or tabs followed by an amount
|
|
||||||
|
|
||||||
Usually there are two or more postings, though one or none is also
|
A posting is an addition of some amount to, or removal of some amount from, an account.
|
||||||
possible. The posting amounts within a transaction must always balance,
|
Each posting line begins with at least one space or tab (2 or 4 spaces is common), followed by:
|
||||||
ie add up to 0. Optionally one amount can be left blank, in which case
|
|
||||||
it will be inferred.
|
- (optional) a [status](#status) character (empty, `!`, or `*`), followed by a space
|
||||||
|
- (required) an [account name](#account-names) (any text, optionally containing **single spaces**, until end of line or a double space)
|
||||||
|
- (optional) **two or more spaces** or tabs followed by an [amount](#amounts).
|
||||||
|
|
||||||
|
Positive amounts are being added to the account, negative amounts are being removed.
|
||||||
|
|
||||||
|
The amounts within a transaction must always sum up to zero.
|
||||||
|
As a convenience, one amount may be left blank; it will be inferred so as to balance the transaction.
|
||||||
|
|
||||||
|
Be sure to note the unusual two-space delimiter between account name and amount.
|
||||||
|
This makes it easy to write account names containing spaces.
|
||||||
|
But if you accidentally leave only one space (or tab) before the amount, the amount will be considered part of the account name.
|
||||||
|
|
||||||
## Dates
|
## Dates
|
||||||
|
|
||||||
@ -177,6 +183,36 @@ attempt to parse any square-bracketed sequence of the `0123456789/-.=`
|
|||||||
characters in this way. With this syntax, DATE infers its year from
|
characters in this way. With this syntax, DATE infers its year from
|
||||||
the transaction and DATE2 infers its year from DATE.
|
the transaction and DATE2 infers its year from DATE.
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
More about the status field: transactions, or individual postings within a transaction,
|
||||||
|
can be in one of three states, represented by a single character:
|
||||||
|
|
||||||
|
- empty (no status character) = uncleared
|
||||||
|
- `!` = pending (aka "tentatively cleared")
|
||||||
|
- `*` = cleared
|
||||||
|
|
||||||
|
When reporting, you can filter by status using the `-C/--cleared` and `-U/--uncleared` flags
|
||||||
|
or the `status:` query.
|
||||||
|
|
||||||
|
This feature is optional, but can be helpful for reconciling with real-world accounts.
|
||||||
|
What "uncleared", "pending", and "cleared" actually mean is up to you.
|
||||||
|
My recommendation: use cleared (`*`) to mark transactions that are "complete", ie:
|
||||||
|
|
||||||
|
- they have cleared with the bank, or the cash has been handed over
|
||||||
|
- you are satisfied they are recorded accurately in the journal
|
||||||
|
- the resulting account balance reported by hledger agrees exactly with the external source of truth, if any (eg the bank's online register or statement)
|
||||||
|
|
||||||
|
Then, with --cleared you'll see the current balance at your bank,
|
||||||
|
with --uncleared you'll see things which will probably hit your bank soon (eg uncashed checks),
|
||||||
|
and with neither flag (the default) you'll see the most up-to-date state of your finances.
|
||||||
|
|
||||||
|
I don't use pending (`!`), but perhaps it is useful in very tricky reconciliations,
|
||||||
|
as a temporary marker for transactions matched so far, allowing you start over more easily.
|
||||||
|
|
||||||
|
Tip: some [editor modes](#editor-support) highlight entries differently based on their status.
|
||||||
|
In Emacs ledger-mode, you can toggle transaction status with `C-c C-e`, or posting status with `C-c C-c`.
|
||||||
|
|
||||||
## Account names
|
## Account names
|
||||||
|
|
||||||
Account names typically have several parts separated by a full colon, from
|
Account names typically have several parts separated by a full colon, from
|
||||||
|
|||||||
@ -53,32 +53,45 @@ DESCRIPTION
|
|||||||
|
|
||||||
FILE FORMAT
|
FILE FORMAT
|
||||||
Transactions
|
Transactions
|
||||||
Transactions are represented by journal entries. Each begins with a
|
Transactions are movements of some quantity of commodities between
|
||||||
simple date in column 0, followed by three optional fields with spaces
|
named accounts. Each transaction is represented by a journal entry
|
||||||
between them:
|
beginning with a simple date in column 0. This can be followed by any
|
||||||
|
of the following, separated by spaces:
|
||||||
|
|
||||||
o a status flag, which can be empty or ! or * (meaning "uncleared",
|
o (optional) a status character (empty, !, or *)
|
||||||
"pending" and "cleared", or whatever you want)
|
|
||||||
|
|
||||||
o a transaction code (eg a check number),
|
o (optional) a transaction code (any short number or text, eg a check
|
||||||
|
number)
|
||||||
|
|
||||||
o and/or a description
|
o (optional) a transaction description (any remaining text until end of
|
||||||
|
line)
|
||||||
|
|
||||||
then some number of postings, of some amount to some account. Each
|
Then comes zero or more (but usually at least 2) indented lines repre-
|
||||||
posting is on its own line, consisting of:
|
senting...
|
||||||
|
|
||||||
o indentation of one or more spaces (or tabs)
|
Postings
|
||||||
|
A posting is an addition of some amount to, or removal of some amount
|
||||||
|
from, an account. Each posting line begins with at least one space or
|
||||||
|
tab (2 or 4 spaces is common), followed by:
|
||||||
|
|
||||||
o optionally, a ! or * status flag followed by a space
|
o (optional) a status character (empty, !, or *), followed by a space
|
||||||
|
|
||||||
o an account name, optionally containing single spaces
|
o (required) an account name (any text, optionally containing single
|
||||||
|
spaces, until end of line or a double space)
|
||||||
|
|
||||||
o optionally, two or more spaces or tabs followed by an amount
|
o (optional) two or more spaces or tabs followed by an amount.
|
||||||
|
|
||||||
Usually there are two or more postings, though one or none is also pos-
|
Positive amounts are being added to the account, negative amounts are
|
||||||
sible. The posting amounts within a transaction must always balance,
|
being removed.
|
||||||
ie add up to 0. Optionally one amount can be left blank, in which case
|
|
||||||
it will be inferred.
|
The amounts within a transaction must always sum up to zero. As a con-
|
||||||
|
venience, one amount may be left blank; it will be inferred so as to
|
||||||
|
balance the transaction.
|
||||||
|
|
||||||
|
Be sure to note the unusual two-space delimiter between account name
|
||||||
|
and amount. This makes it easy to write account names containing spa-
|
||||||
|
ces. But if you accidentally leave only one space (or tab) before the
|
||||||
|
amount, the amount will be considered part of the account name.
|
||||||
|
|
||||||
Dates
|
Dates
|
||||||
Simple dates
|
Simple dates
|
||||||
@ -155,14 +168,54 @@ FILE FORMAT
|
|||||||
With this syntax, DATE infers its year from the transaction and DATE2
|
With this syntax, DATE infers its year from the transaction and DATE2
|
||||||
infers its year from DATE.
|
infers its year from DATE.
|
||||||
|
|
||||||
Account names
|
Status
|
||||||
Account names typically have several parts separated by a full colon,
|
More about the status field: transactions, or individual postings
|
||||||
from which hledger derives a hierarchical chart of accounts. They can
|
within a transaction, can be in one of three states, represented by a
|
||||||
be anything you like, but in finance there are traditionally five
|
single character:
|
||||||
top-level accounts: assets, liabilities, income, expenses, and equity.
|
|
||||||
|
|
||||||
Account names may contain single spaces, eg: assets:accounts receiv-
|
o empty (no status character) = uncleared
|
||||||
able. Because of this, they must always be followed by two or more
|
|
||||||
|
o ! = pending (aka "tentatively cleared")
|
||||||
|
|
||||||
|
o * = cleared
|
||||||
|
|
||||||
|
When reporting, you can filter by status using the -C/--cleared and
|
||||||
|
-U/--uncleared flags or the status: query.
|
||||||
|
|
||||||
|
This feature is optional, but can be helpful for reconciling with
|
||||||
|
real-world accounts. What "uncleared", "pending", and "cleared" actu-
|
||||||
|
ally mean is up to you. My recommendation: use cleared (*) to mark
|
||||||
|
transactions that are "complete", ie:
|
||||||
|
|
||||||
|
o they have cleared with the bank, or the cash has been handed over
|
||||||
|
|
||||||
|
o you are satisfied they are recorded accurately in the journal
|
||||||
|
|
||||||
|
o the resulting account balance reported by hledger agrees exactly with
|
||||||
|
the external source of truth, if any (eg the bank's online register
|
||||||
|
or statement)
|
||||||
|
|
||||||
|
Then, with --cleared you'll see the current balance at your bank, with
|
||||||
|
--uncleared you'll see things which will probably hit your bank soon
|
||||||
|
(eg uncashed checks), and with neither flag (the default) you'll see
|
||||||
|
the most up-to-date state of your finances.
|
||||||
|
|
||||||
|
I don't use pending (!), but perhaps it is useful in very tricky recon-
|
||||||
|
ciliations, as a temporary marker for transactions matched so far,
|
||||||
|
allowing you start over more easily.
|
||||||
|
|
||||||
|
Tip: some editor modes highlight entries differently based on their
|
||||||
|
status. In Emacs ledger-mode, you can toggle transaction status with
|
||||||
|
C-c C-e, or posting status with C-c C-c.
|
||||||
|
|
||||||
|
Account names
|
||||||
|
Account names typically have several parts separated by a full colon,
|
||||||
|
from which hledger derives a hierarchical chart of accounts. They can
|
||||||
|
be anything you like, but in finance there are traditionally five
|
||||||
|
top-level accounts: assets, liabilities, income, expenses, and equity.
|
||||||
|
|
||||||
|
Account names may contain single spaces, eg: assets:accounts receiv-
|
||||||
|
able. Because of this, they must always be followed by two or more
|
||||||
spaces (or newline).
|
spaces (or newline).
|
||||||
|
|
||||||
Account names can be aliased.
|
Account names can be aliased.
|
||||||
@ -171,7 +224,7 @@ FILE FORMAT
|
|||||||
After the account name, there is usually an amount. Important: between
|
After the account name, there is usually an amount. Important: between
|
||||||
account name and amount, there must be two or more spaces.
|
account name and amount, there must be two or more spaces.
|
||||||
|
|
||||||
Amounts consist of a number and (usually) a currency symbol or commod-
|
Amounts consist of a number and (usually) a currency symbol or commod-
|
||||||
ity name. Some examples:
|
ity name. Some examples:
|
||||||
|
|
||||||
2.00001
|
2.00001
|
||||||
@ -184,53 +237,53 @@ FILE FORMAT
|
|||||||
|
|
||||||
As you can see, the amount format is somewhat flexible:
|
As you can see, the amount format is somewhat flexible:
|
||||||
|
|
||||||
o amounts are a number (the "quantity") and optionally a currency sym-
|
o amounts are a number (the "quantity") and optionally a currency sym-
|
||||||
bol/commodity name (the "commodity").
|
bol/commodity name (the "commodity").
|
||||||
|
|
||||||
o the commodity is a symbol, word, or phrase, on the left or right,
|
o the commodity is a symbol, word, or phrase, on the left or right,
|
||||||
with or without a separating space. If the commodity contains num-
|
with or without a separating space. If the commodity contains num-
|
||||||
bers, spaces or non-word punctuation it must be enclosed in double
|
bers, spaces or non-word punctuation it must be enclosed in double
|
||||||
quotes.
|
quotes.
|
||||||
|
|
||||||
o negative amounts with a commodity on the left can have the minus sign
|
o negative amounts with a commodity on the left can have the minus sign
|
||||||
before or after it
|
before or after it
|
||||||
|
|
||||||
o digit groups (thousands, or any other grouping) can be separated by
|
o digit groups (thousands, or any other grouping) can be separated by
|
||||||
commas (in which case period is used for decimal point) or periods
|
commas (in which case period is used for decimal point) or periods
|
||||||
(in which case comma is used for decimal point)
|
(in which case comma is used for decimal point)
|
||||||
|
|
||||||
You can use any of these variations when recording data, but when
|
You can use any of these variations when recording data, but when
|
||||||
hledger displays amounts, it will choose a consistent format for each
|
hledger displays amounts, it will choose a consistent format for each
|
||||||
commodity. (Except for price amounts, which are always formatted as
|
commodity. (Except for price amounts, which are always formatted as
|
||||||
written). The display format is chosen as follows:
|
written). The display format is chosen as follows:
|
||||||
|
|
||||||
o if there is a commodity directive specifying the format, that is used
|
o if there is a commodity directive specifying the format, that is used
|
||||||
|
|
||||||
o otherwise the format is inferred from the first posting amount in
|
o otherwise the format is inferred from the first posting amount in
|
||||||
that commodity in the journal, and the precision (number of decimal
|
that commodity in the journal, and the precision (number of decimal
|
||||||
places) will be the maximum from all posting amounts in that commmod-
|
places) will be the maximum from all posting amounts in that commmod-
|
||||||
ity
|
ity
|
||||||
|
|
||||||
o or if there are no such amounts in the journal, a default format is
|
o or if there are no such amounts in the journal, a default format is
|
||||||
used (like $1000.00).
|
used (like $1000.00).
|
||||||
|
|
||||||
Price amounts and amounts in D directives usually don't affect amount
|
Price amounts and amounts in D directives usually don't affect amount
|
||||||
format inference, but in some situations they can do so indirectly.
|
format inference, but in some situations they can do so indirectly.
|
||||||
(Eg when D's default commodity is applied to a commodity-less amount,
|
(Eg when D's default commodity is applied to a commodity-less amount,
|
||||||
or when an amountless posting is balanced using a price's commodity, or
|
or when an amountless posting is balanced using a price's commodity, or
|
||||||
when -V is used.) If you find this causing problems, set the desired
|
when -V is used.) If you find this causing problems, set the desired
|
||||||
format with a commodity directive.
|
format with a commodity directive.
|
||||||
|
|
||||||
Virtual Postings
|
Virtual Postings
|
||||||
When you parenthesise the account name in a posting, we call that a
|
When you parenthesise the account name in a posting, we call that a
|
||||||
virtual posting, which means:
|
virtual posting, which means:
|
||||||
|
|
||||||
o it is ignored when checking that the transaction is balanced
|
o it is ignored when checking that the transaction is balanced
|
||||||
|
|
||||||
o it is excluded from reports when the --real/-R flag is used, or the
|
o it is excluded from reports when the --real/-R flag is used, or the
|
||||||
real:1 query.
|
real:1 query.
|
||||||
|
|
||||||
You could use this, eg, to set an account's opening balance without
|
You could use this, eg, to set an account's opening balance without
|
||||||
needing to use the equity:opening balances account:
|
needing to use the equity:opening balances account:
|
||||||
|
|
||||||
1/1 special unbalanced posting to set initial balance
|
1/1 special unbalanced posting to set initial balance
|
||||||
@ -238,8 +291,8 @@ FILE FORMAT
|
|||||||
|
|
||||||
When the account name is bracketed, we call it a balanced virtual post-
|
When the account name is bracketed, we call it a balanced virtual post-
|
||||||
ing. This is like an ordinary virtual posting except the balanced vir-
|
ing. This is like an ordinary virtual posting except the balanced vir-
|
||||||
tual postings in a transaction must balance to 0, like the real post-
|
tual postings in a transaction must balance to 0, like the real post-
|
||||||
ings (but separately from them). Balanced virtual postings are also
|
ings (but separately from them). Balanced virtual postings are also
|
||||||
excluded by --real/-R or real:1.
|
excluded by --real/-R or real:1.
|
||||||
|
|
||||||
1/1 buy food with cash, and update some budget-tracking subaccounts elsewhere
|
1/1 buy food with cash, and update some budget-tracking subaccounts elsewhere
|
||||||
@ -249,13 +302,13 @@ FILE FORMAT
|
|||||||
[assets:checking:budget:food] $-10
|
[assets:checking:budget:food] $-10
|
||||||
|
|
||||||
Virtual postings have some legitimate uses, but those are few. You can
|
Virtual postings have some legitimate uses, but those are few. You can
|
||||||
usually find an equivalent journal entry using real postings, which is
|
usually find an equivalent journal entry using real postings, which is
|
||||||
more correct and provides better error checking.
|
more correct and provides better error checking.
|
||||||
|
|
||||||
Balance Assertions
|
Balance Assertions
|
||||||
hledger supports Ledger-style balance assertions in journal files.
|
hledger supports Ledger-style balance assertions in journal files.
|
||||||
These look like =EXPECTEDBALANCE following a posting's amount. Eg in
|
These look like =EXPECTEDBALANCE following a posting's amount. Eg in
|
||||||
this example we assert the expected dollar balance in accounts a and b
|
this example we assert the expected dollar balance in accounts a and b
|
||||||
after each posting:
|
after each posting:
|
||||||
|
|
||||||
2013/1/1
|
2013/1/1
|
||||||
@ -267,31 +320,31 @@ FILE FORMAT
|
|||||||
b $-1 =$-2
|
b $-1 =$-2
|
||||||
|
|
||||||
After reading a journal file, hledger will check all balance assertions
|
After reading a journal file, hledger will check all balance assertions
|
||||||
and report an error if any of them fail. Balance assertions can pro-
|
and report an error if any of them fail. Balance assertions can pro-
|
||||||
tect you from, eg, inadvertently disrupting reconciled balances while
|
tect you from, eg, inadvertently disrupting reconciled balances while
|
||||||
cleaning up old entries. You can disable them temporarily with the
|
cleaning up old entries. You can disable them temporarily with the
|
||||||
--ignore-assertions flag, which can be useful for troubleshooting or
|
--ignore-assertions flag, which can be useful for troubleshooting or
|
||||||
for reading Ledger files.
|
for reading Ledger files.
|
||||||
|
|
||||||
Assertions and ordering
|
Assertions and ordering
|
||||||
hledger sorts an account's postings and assertions first by date and
|
hledger sorts an account's postings and assertions first by date and
|
||||||
then (for postings on the same day) by parse order. Note this is dif-
|
then (for postings on the same day) by parse order. Note this is dif-
|
||||||
ferent from Ledger, which sorts assertions only by parse order. (Also,
|
ferent from Ledger, which sorts assertions only by parse order. (Also,
|
||||||
Ledger assertions do not see the accumulated effect of repeated post-
|
Ledger assertions do not see the accumulated effect of repeated post-
|
||||||
ings to the same account within a transaction.)
|
ings to the same account within a transaction.)
|
||||||
|
|
||||||
So, hledger balance assertions keep working if you reorder differ-
|
So, hledger balance assertions keep working if you reorder differ-
|
||||||
ently-dated transactions within the journal. But if you reorder
|
ently-dated transactions within the journal. But if you reorder
|
||||||
same-dated transactions or postings, assertions might break and require
|
same-dated transactions or postings, assertions might break and require
|
||||||
updating. This order dependence does bring an advantage: precise con-
|
updating. This order dependence does bring an advantage: precise con-
|
||||||
trol over the order of postings and assertions within a day, so you can
|
trol over the order of postings and assertions within a day, so you can
|
||||||
assert intra-day balances.
|
assert intra-day balances.
|
||||||
|
|
||||||
Assertions and included files
|
Assertions and included files
|
||||||
With included files, things are a little more complicated. Including
|
With included files, things are a little more complicated. Including
|
||||||
preserves the ordering of postings and assertions. If you have multi-
|
preserves the ordering of postings and assertions. If you have multi-
|
||||||
ple postings to an account on the same day, split across different
|
ple postings to an account on the same day, split across different
|
||||||
files, and you also want to assert the account's balance on the same
|
files, and you also want to assert the account's balance on the same
|
||||||
day, you'll have to put the assertion in the right file.
|
day, you'll have to put the assertion in the right file.
|
||||||
|
|
||||||
Assertions and multiple -f options
|
Assertions and multiple -f options
|
||||||
@ -299,21 +352,21 @@ FILE FORMAT
|
|||||||
-f options. Use include or concatenate the files instead.
|
-f options. Use include or concatenate the files instead.
|
||||||
|
|
||||||
Assertions and commodities
|
Assertions and commodities
|
||||||
The asserted balance must be a simple single-commodity amount, and in
|
The asserted balance must be a simple single-commodity amount, and in
|
||||||
fact the assertion checks only this commodity's balance within the
|
fact the assertion checks only this commodity's balance within the
|
||||||
(possibly multi-commodity) account balance. We could call this a par-
|
(possibly multi-commodity) account balance. We could call this a par-
|
||||||
tial balance assertion. This is compatible with Ledger, and makes it
|
tial balance assertion. This is compatible with Ledger, and makes it
|
||||||
possible to make assertions about accounts containing multiple commodi-
|
possible to make assertions about accounts containing multiple commodi-
|
||||||
ties.
|
ties.
|
||||||
|
|
||||||
To assert each commodity's balance in such a multi-commodity account,
|
To assert each commodity's balance in such a multi-commodity account,
|
||||||
you can add multiple postings (with amount 0 if necessary). But note
|
you can add multiple postings (with amount 0 if necessary). But note
|
||||||
that no matter how many assertions you add, you can't be sure the
|
that no matter how many assertions you add, you can't be sure the
|
||||||
account does not contain some unexpected commodity. (We'll add support
|
account does not contain some unexpected commodity. (We'll add support
|
||||||
for this kind of total balance assertion if there's demand.)
|
for this kind of total balance assertion if there's demand.)
|
||||||
|
|
||||||
Assertions and subaccounts
|
Assertions and subaccounts
|
||||||
Balance assertions do not count the balance from subaccounts; they
|
Balance assertions do not count the balance from subaccounts; they
|
||||||
check the posted account's exclusive balance. For example:
|
check the posted account's exclusive balance. For example:
|
||||||
|
|
||||||
1/1
|
1/1
|
||||||
@ -321,7 +374,7 @@ FILE FORMAT
|
|||||||
checking 1 = 1 ; post to the parent account, its exclusive balance is now 1
|
checking 1 = 1 ; post to the parent account, its exclusive balance is now 1
|
||||||
equity
|
equity
|
||||||
|
|
||||||
The balance report's flat mode shows these exclusive balances more
|
The balance report's flat mode shows these exclusive balances more
|
||||||
clearly:
|
clearly:
|
||||||
|
|
||||||
$ hledger bal checking --flat
|
$ hledger bal checking --flat
|
||||||
@ -335,10 +388,10 @@ FILE FORMAT
|
|||||||
tual. They are not affected by the --real/-R flag or real: query.
|
tual. They are not affected by the --real/-R flag or real: query.
|
||||||
|
|
||||||
Balance Assignments
|
Balance Assignments
|
||||||
Ledger-style balance assignments are also supported. These are like
|
Ledger-style balance assignments are also supported. These are like
|
||||||
balance assertions, but with no posting amount on the left side of the
|
balance assertions, but with no posting amount on the left side of the
|
||||||
equals sign; instead it is calculated automatically so as to satisfy
|
equals sign; instead it is calculated automatically so as to satisfy
|
||||||
the assertion. This can be a convenience during data entry, eg when
|
the assertion. This can be a convenience during data entry, eg when
|
||||||
setting opening balances:
|
setting opening balances:
|
||||||
|
|
||||||
; starting a new journal, set asset account balances
|
; starting a new journal, set asset account balances
|
||||||
@ -356,8 +409,8 @@ FILE FORMAT
|
|||||||
expenses:misc
|
expenses:misc
|
||||||
|
|
||||||
The calculated amount depends on the account's balance in the commodity
|
The calculated amount depends on the account's balance in the commodity
|
||||||
at that point (which depends on the previously-dated postings of the
|
at that point (which depends on the previously-dated postings of the
|
||||||
commodity to that account since the last balance assertion or assign-
|
commodity to that account since the last balance assertion or assign-
|
||||||
ment). Note that using balance assignments makes your journal a little
|
ment). Note that using balance assignments makes your journal a little
|
||||||
less explicit; to know the exact amount posted, you have to run hledger
|
less explicit; to know the exact amount posted, you have to run hledger
|
||||||
or do the calculations yourself, instead of just reading it.
|
or do the calculations yourself, instead of just reading it.
|
||||||
@ -365,12 +418,12 @@ FILE FORMAT
|
|||||||
Prices
|
Prices
|
||||||
Transaction prices
|
Transaction prices
|
||||||
Within a transaction, you can note an amount's price in another commod-
|
Within a transaction, you can note an amount's price in another commod-
|
||||||
ity. This can be used to document the cost (in a purchase) or selling
|
ity. This can be used to document the cost (in a purchase) or selling
|
||||||
price (in a sale). For example, transaction prices are useful to
|
price (in a sale). For example, transaction prices are useful to
|
||||||
record purchases of a foreign currency.
|
record purchases of a foreign currency.
|
||||||
|
|
||||||
Transaction prices are fixed, and do not change over time. (Ledger
|
Transaction prices are fixed, and do not change over time. (Ledger
|
||||||
users: Ledger uses a different syntax for fixed prices, {=UNITPRICE},
|
users: Ledger uses a different syntax for fixed prices, {=UNITPRICE},
|
||||||
which hledger currently ignores).
|
which hledger currently ignores).
|
||||||
|
|
||||||
There are several ways to record a transaction price:
|
There are several ways to record a transaction price:
|
||||||
@ -394,9 +447,9 @@ FILE FORMAT
|
|||||||
assets:euros 100 ; one hundred euros purchased
|
assets:euros 100 ; one hundred euros purchased
|
||||||
assets:dollars $-135 ; for $135
|
assets:dollars $-135 ; for $135
|
||||||
|
|
||||||
Amounts with transaction prices can be displayed in the transaction
|
Amounts with transaction prices can be displayed in the transaction
|
||||||
price's commodity by using the -B/--cost flag (except for #551) ("B" is
|
price's commodity by using the -B/--cost flag (except for #551) ("B" is
|
||||||
from "cost Basis"). Eg for the above, here is how -B affects the bal-
|
from "cost Basis"). Eg for the above, here is how -B affects the bal-
|
||||||
ance report:
|
ance report:
|
||||||
|
|
||||||
$ hledger bal -N --flat
|
$ hledger bal -N --flat
|
||||||
@ -406,8 +459,8 @@ FILE FORMAT
|
|||||||
$-135 assets:dollars
|
$-135 assets:dollars
|
||||||
$135 assets:euros # <- the euros' cost
|
$135 assets:euros # <- the euros' cost
|
||||||
|
|
||||||
Note -B is sensitive to the order of postings when a transaction price
|
Note -B is sensitive to the order of postings when a transaction price
|
||||||
is inferred: the inferred price will be in the commodity of the last
|
is inferred: the inferred price will be in the commodity of the last
|
||||||
amount. So if example 3's postings are reversed, while the transaction
|
amount. So if example 3's postings are reversed, while the transaction
|
||||||
is equivalent, -B shows something different:
|
is equivalent, -B shows something different:
|
||||||
|
|
||||||
@ -420,41 +473,41 @@ FILE FORMAT
|
|||||||
100 assets:euros
|
100 assets:euros
|
||||||
|
|
||||||
Market prices
|
Market prices
|
||||||
Market prices are not tied to a particular transaction; they represent
|
Market prices are not tied to a particular transaction; they represent
|
||||||
historical exchange rates between two commodities. (Ledger calls them
|
historical exchange rates between two commodities. (Ledger calls them
|
||||||
historical prices.) For example, the prices published by a stock
|
historical prices.) For example, the prices published by a stock
|
||||||
exchange or the foreign exchange market. hledger can use these prices
|
exchange or the foreign exchange market. hledger can use these prices
|
||||||
to show the market value of things at a given date, see market value.
|
to show the market value of things at a given date, see market value.
|
||||||
|
|
||||||
To record market prices, use P directives in the main journal or in an
|
To record market prices, use P directives in the main journal or in an
|
||||||
included file. Their format is:
|
included file. Their format is:
|
||||||
|
|
||||||
P DATE COMMODITYBEINGPRICED UNITPRICE
|
P DATE COMMODITYBEINGPRICED UNITPRICE
|
||||||
|
|
||||||
DATE is a simple date as usual. COMMODITYBEINGPRICED is the symbol of
|
DATE is a simple date as usual. COMMODITYBEINGPRICED is the symbol of
|
||||||
the commodity being priced. UNITPRICE is an ordinary amount (symbol
|
the commodity being priced. UNITPRICE is an ordinary amount (symbol
|
||||||
and quantity) in a second commodity, specifying the unit price or con-
|
and quantity) in a second commodity, specifying the unit price or con-
|
||||||
version rate for the first commodity in terms of the second, on the
|
version rate for the first commodity in terms of the second, on the
|
||||||
given date.
|
given date.
|
||||||
|
|
||||||
For example, the following directives say that one euro was worth 1.35
|
For example, the following directives say that one euro was worth 1.35
|
||||||
US dollars during 2009, and $1.40 from 2010 onward:
|
US dollars during 2009, and $1.40 from 2010 onward:
|
||||||
|
|
||||||
P 2009/1/1 $1.35
|
P 2009/1/1 $1.35
|
||||||
P 2010/1/1 $1.40
|
P 2010/1/1 $1.40
|
||||||
|
|
||||||
Comments
|
Comments
|
||||||
Lines in the journal beginning with a semicolon (;) or hash (#) or
|
Lines in the journal beginning with a semicolon (;) or hash (#) or
|
||||||
asterisk (*) are comments, and will be ignored. (Asterisk comments
|
asterisk (*) are comments, and will be ignored. (Asterisk comments
|
||||||
make it easy to treat your journal like an org-mode outline in emacs.)
|
make it easy to treat your journal like an org-mode outline in emacs.)
|
||||||
|
|
||||||
Also, anything between comment and end comment directives is a
|
Also, anything between comment and end comment directives is a
|
||||||
(multi-line) comment. If there is no end comment, the comment extends
|
(multi-line) comment. If there is no end comment, the comment extends
|
||||||
to the end of the file.
|
to the end of the file.
|
||||||
|
|
||||||
You can attach comments to a transaction by writing them after the
|
You can attach comments to a transaction by writing them after the
|
||||||
description and/or indented on the following lines (before the post-
|
description and/or indented on the following lines (before the post-
|
||||||
ings). Similarly, you can attach comments to an individual posting by
|
ings). Similarly, you can attach comments to an individual posting by
|
||||||
writing them after the amount and/or indented on the following lines.
|
writing them after the amount and/or indented on the following lines.
|
||||||
|
|
||||||
Some examples:
|
Some examples:
|
||||||
@ -479,20 +532,20 @@ FILE FORMAT
|
|||||||
; a journal comment (because not indented)
|
; a journal comment (because not indented)
|
||||||
|
|
||||||
Tags
|
Tags
|
||||||
Tags are a way to add extra labels or labelled data to postings and
|
Tags are a way to add extra labels or labelled data to postings and
|
||||||
transactions, which you can then search or pivot on.
|
transactions, which you can then search or pivot on.
|
||||||
|
|
||||||
A simple tag is a word (which may contain hyphens) followed by a full
|
A simple tag is a word (which may contain hyphens) followed by a full
|
||||||
colon, written inside a transaction or posting comment line:
|
colon, written inside a transaction or posting comment line:
|
||||||
|
|
||||||
2017/1/16 bought groceries ; sometag:
|
2017/1/16 bought groceries ; sometag:
|
||||||
|
|
||||||
Tags can have a value, which is the text after the colon, up to the
|
Tags can have a value, which is the text after the colon, up to the
|
||||||
next comma or end of line, with leading/trailing whitespace removed:
|
next comma or end of line, with leading/trailing whitespace removed:
|
||||||
|
|
||||||
expenses:food $10 ; a-posting-tag: the tag value
|
expenses:food $10 ; a-posting-tag: the tag value
|
||||||
|
|
||||||
Note this means hledger's tag values can not contain commas or new-
|
Note this means hledger's tag values can not contain commas or new-
|
||||||
lines. Ending at commas means you can write multiple short tags on one
|
lines. Ending at commas means you can write multiple short tags on one
|
||||||
line, comma separated:
|
line, comma separated:
|
||||||
|
|
||||||
@ -506,16 +559,16 @@ FILE FORMAT
|
|||||||
|
|
||||||
o "tag2" is another tag, whose value is "some value ..."
|
o "tag2" is another tag, whose value is "some value ..."
|
||||||
|
|
||||||
Tags in a transaction comment affect the transaction and all of its
|
Tags in a transaction comment affect the transaction and all of its
|
||||||
postings, while tags in a posting comment affect only that posting.
|
postings, while tags in a posting comment affect only that posting.
|
||||||
For example, the following transaction has three tags (A, TAG2,
|
For example, the following transaction has three tags (A, TAG2,
|
||||||
third-tag) and the posting has four (those plus posting-tag):
|
third-tag) and the posting has four (those plus posting-tag):
|
||||||
|
|
||||||
1/1 a transaction ; A:, TAG2:
|
1/1 a transaction ; A:, TAG2:
|
||||||
; third-tag: a third transaction tag, <- with a value
|
; third-tag: a third transaction tag, <- with a value
|
||||||
(a) $1 ; posting-tag:
|
(a) $1 ; posting-tag:
|
||||||
|
|
||||||
Tags are like Ledger's metadata feature, except hledger's tag values
|
Tags are like Ledger's metadata feature, except hledger's tag values
|
||||||
are simple strings.
|
are simple strings.
|
||||||
|
|
||||||
Implicit tags
|
Implicit tags
|
||||||
@ -529,14 +582,14 @@ FILE FORMAT
|
|||||||
|
|
||||||
o note - the part of description after |, or all of it
|
o note - the part of description after |, or all of it
|
||||||
|
|
||||||
payee and note support descriptions written in a special PAYEE | NOTE
|
payee and note support descriptions written in a special PAYEE | NOTE
|
||||||
format, accessing the parts before and after the pipe character respec-
|
format, accessing the parts before and after the pipe character respec-
|
||||||
tively. For descriptions not containing a pipe character they are the
|
tively. For descriptions not containing a pipe character they are the
|
||||||
same as description.
|
same as description.
|
||||||
|
|
||||||
Directives
|
Directives
|
||||||
Account aliases
|
Account aliases
|
||||||
You can define aliases which rewrite your account names (after reading
|
You can define aliases which rewrite your account names (after reading
|
||||||
the journal, before generating reports). hledger's account aliases can
|
the journal, before generating reports). hledger's account aliases can
|
||||||
be useful for:
|
be useful for:
|
||||||
|
|
||||||
@ -553,8 +606,8 @@ FILE FORMAT
|
|||||||
See also Cookbook: rewrite account names.
|
See also Cookbook: rewrite account names.
|
||||||
|
|
||||||
Basic aliases
|
Basic aliases
|
||||||
To set an account alias, use the alias directive in your journal file.
|
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
|
This affects all subsequent journal entries in the current file or its
|
||||||
included files. The spaces around the = are optional:
|
included files. The spaces around the = are optional:
|
||||||
|
|
||||||
alias OLD = NEW
|
alias OLD = NEW
|
||||||
@ -562,52 +615,52 @@ FILE FORMAT
|
|||||||
Or, you can use the --alias 'OLD=NEW' option on the command line. This
|
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.
|
affects all entries. It's useful for trying out aliases interactively.
|
||||||
|
|
||||||
OLD and NEW are full account names. hledger will replace any occur-
|
OLD and NEW are full account names. hledger will replace any occur-
|
||||||
rence of the old account name with the new one. Subaccounts are also
|
rence of the old account name with the new one. Subaccounts are also
|
||||||
affected. Eg:
|
affected. Eg:
|
||||||
|
|
||||||
alias checking = assets:bank:wells fargo:checking
|
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"
|
# rewrites "checking" to "assets:bank:wells fargo:checking", or "checking:a" to "assets:bank:wells fargo:checking:a"
|
||||||
|
|
||||||
Regex aliases
|
Regex aliases
|
||||||
There is also a more powerful variant that uses a regular expression,
|
There is also a more powerful variant that uses a regular expression,
|
||||||
indicated by the forward slashes:
|
indicated by the forward slashes:
|
||||||
|
|
||||||
alias /REGEX/ = REPLACEMENT
|
alias /REGEX/ = REPLACEMENT
|
||||||
|
|
||||||
or --alias '/REGEX/=REPLACEMENT'.
|
or --alias '/REGEX/=REPLACEMENT'.
|
||||||
|
|
||||||
REGEX is a case-insensitive regular expression. Anywhere it matches
|
REGEX is a case-insensitive regular expression. Anywhere it matches
|
||||||
inside an account name, the matched part will be replaced by REPLACE-
|
inside an account name, the matched part will be replaced by REPLACE-
|
||||||
MENT. If REGEX contains parenthesised match groups, these can be ref-
|
MENT. If REGEX contains parenthesised match groups, these can be ref-
|
||||||
erenced by the usual numeric backreferences in REPLACEMENT. Note, cur-
|
erenced by the usual numeric backreferences in REPLACEMENT. Note, cur-
|
||||||
rently regular expression aliases may cause noticeable slow-downs.
|
rently regular expression aliases may cause noticeable slow-downs.
|
||||||
(And if you use Ledger on your hledger file, they will be ignored.) Eg:
|
(And if you use Ledger on your hledger file, they will be ignored.) Eg:
|
||||||
|
|
||||||
alias /^(.+):bank:([^:]+)(.*)/ = \1:\2 \3
|
alias /^(.+):bank:([^:]+)(.*)/ = \1:\2 \3
|
||||||
# rewrites "assets:bank:wells fargo:checking" to "assets:wells fargo checking"
|
# rewrites "assets:bank:wells fargo:checking" to "assets:wells fargo checking"
|
||||||
|
|
||||||
Multiple aliases
|
Multiple aliases
|
||||||
You can define as many aliases as you like using directives or com-
|
You can define as many aliases as you like using directives or com-
|
||||||
mand-line options. Aliases are recursive - each alias sees the result
|
mand-line options. Aliases are recursive - each alias sees the result
|
||||||
of applying previous ones. (This is different from Ledger, where
|
of applying previous ones. (This is different from Ledger, where
|
||||||
aliases are non-recursive by default). Aliases are applied in the fol-
|
aliases are non-recursive by default). Aliases are applied in the fol-
|
||||||
lowing order:
|
lowing order:
|
||||||
|
|
||||||
1. alias directives, most recently seen first (recent directives take
|
1. alias directives, most recently seen first (recent directives take
|
||||||
precedence over earlier ones; directives not yet seen are ignored)
|
precedence over earlier ones; directives not yet seen are ignored)
|
||||||
|
|
||||||
2. alias options, in the order they appear on the command line
|
2. alias options, in the order they appear on the command line
|
||||||
|
|
||||||
end aliases
|
end aliases
|
||||||
You can clear (forget) all currently defined aliases with the
|
You can clear (forget) all currently defined aliases with the
|
||||||
end aliases directive:
|
end aliases directive:
|
||||||
|
|
||||||
end aliases
|
end aliases
|
||||||
|
|
||||||
account directive
|
account directive
|
||||||
The account directive predefines account names, as in Ledger and Bean-
|
The account directive predefines account names, as in Ledger and Bean-
|
||||||
count. This may be useful for your own documentation; hledger doesn't
|
count. This may be useful for your own documentation; hledger doesn't
|
||||||
make use of it yet.
|
make use of it yet.
|
||||||
|
|
||||||
; account ACCT
|
; account ACCT
|
||||||
@ -622,8 +675,8 @@ FILE FORMAT
|
|||||||
; etc.
|
; etc.
|
||||||
|
|
||||||
apply account directive
|
apply account directive
|
||||||
You can specify a parent account which will be prepended to all
|
You can specify a parent account which will be prepended to all
|
||||||
accounts within a section of the journal. Use the apply account and
|
accounts within a section of the journal. Use the apply account and
|
||||||
end apply account directives like so:
|
end apply account directives like so:
|
||||||
|
|
||||||
apply account home
|
apply account home
|
||||||
@ -640,7 +693,7 @@ FILE FORMAT
|
|||||||
home:food $10
|
home:food $10
|
||||||
home:cash $-10
|
home:cash $-10
|
||||||
|
|
||||||
If end apply account is omitted, the effect lasts to the end of the
|
If end apply account is omitted, the effect lasts to the end of the
|
||||||
file. Included files are also affected, eg:
|
file. Included files are also affected, eg:
|
||||||
|
|
||||||
apply account business
|
apply account business
|
||||||
@ -649,16 +702,16 @@ FILE FORMAT
|
|||||||
apply account personal
|
apply account personal
|
||||||
include personal.journal
|
include personal.journal
|
||||||
|
|
||||||
Prior to hledger 1.0, legacy account and end spellings were also sup-
|
Prior to hledger 1.0, legacy account and end spellings were also sup-
|
||||||
ported.
|
ported.
|
||||||
|
|
||||||
Multi-line comments
|
Multi-line comments
|
||||||
A line containing just comment starts a multi-line comment, and a line
|
A line containing just comment starts a multi-line comment, and a line
|
||||||
containing just end comment ends it. See comments.
|
containing just end comment ends it. See comments.
|
||||||
|
|
||||||
commodity directive
|
commodity directive
|
||||||
The commodity directive predefines commodities (currently this is just
|
The commodity directive predefines commodities (currently this is just
|
||||||
informational), and also it may define the display format for amounts
|
informational), and also it may define the display format for amounts
|
||||||
in this commodity (overriding the automatically inferred format).
|
in this commodity (overriding the automatically inferred format).
|
||||||
|
|
||||||
It may be written on a single line, like this:
|
It may be written on a single line, like this:
|
||||||
@ -670,8 +723,8 @@ FILE FORMAT
|
|||||||
; separating thousands with comma.
|
; separating thousands with comma.
|
||||||
commodity 1,000.0000 AAAA
|
commodity 1,000.0000 AAAA
|
||||||
|
|
||||||
or on multiple lines, using the "format" subdirective. In this case
|
or on multiple lines, using the "format" subdirective. In this case
|
||||||
the commodity symbol appears twice and should be the same in both
|
the commodity symbol appears twice and should be the same in both
|
||||||
places:
|
places:
|
||||||
|
|
||||||
; commodity SYMBOL
|
; commodity SYMBOL
|
||||||
@ -684,10 +737,10 @@ FILE FORMAT
|
|||||||
format INR 9,99,99,999.00
|
format INR 9,99,99,999.00
|
||||||
|
|
||||||
Default commodity
|
Default commodity
|
||||||
The D directive sets a default commodity (and display format), to be
|
The D directive sets a default commodity (and display format), to be
|
||||||
used for amounts without a commodity symbol (ie, plain numbers). (Note
|
used for amounts without a commodity symbol (ie, plain numbers). (Note
|
||||||
this differs from Ledger's default commodity directive.) The commodity
|
this differs from Ledger's default commodity directive.) The commodity
|
||||||
and display format will be applied to all subsequent commodity-less
|
and display format will be applied to all subsequent commodity-less
|
||||||
amounts, or until the next D directive.
|
amounts, or until the next D directive.
|
||||||
|
|
||||||
# commodity-less amounts should be treated as dollars
|
# commodity-less amounts should be treated as dollars
|
||||||
@ -699,8 +752,8 @@ FILE FORMAT
|
|||||||
b
|
b
|
||||||
|
|
||||||
Default year
|
Default year
|
||||||
You can set a default year to be used for subsequent dates which don't
|
You can set a default year to be used for subsequent dates which don't
|
||||||
specify a year. This is a line beginning with Y followed by the year.
|
specify a year. This is a line beginning with Y followed by the year.
|
||||||
Eg:
|
Eg:
|
||||||
|
|
||||||
Y2009 ; set default year to 2009
|
Y2009 ; set default year to 2009
|
||||||
@ -720,24 +773,24 @@ FILE FORMAT
|
|||||||
assets
|
assets
|
||||||
|
|
||||||
Including other files
|
Including other files
|
||||||
You can pull in the content of additional journal files by writing an
|
You can pull in the content of additional journal files by writing an
|
||||||
include directive, like this:
|
include directive, like this:
|
||||||
|
|
||||||
include path/to/file.journal
|
include path/to/file.journal
|
||||||
|
|
||||||
If the path does not begin with a slash, it is relative to the current
|
If the path does not begin with a slash, it is relative to the current
|
||||||
file. Glob patterns (*) are not currently supported.
|
file. Glob patterns (*) are not currently supported.
|
||||||
|
|
||||||
The include directive can only be used in journal files. It can
|
The include directive can only be used in journal files. It can
|
||||||
include journal, timeclock or timedot files, but not CSV files.
|
include journal, timeclock or timedot files, but not CSV files.
|
||||||
|
|
||||||
EDITOR SUPPORT
|
EDITOR SUPPORT
|
||||||
Add-on modes exist for various text editors, to make working with jour-
|
Add-on modes exist for various text editors, to make working with jour-
|
||||||
nal files easier. They add colour, navigation aids and helpful com-
|
nal files easier. They add colour, navigation aids and helpful com-
|
||||||
mands. For hledger users who edit the journal file directly (the
|
mands. For hledger users who edit the journal file directly (the
|
||||||
majority), using one of these modes is quite recommended.
|
majority), using one of these modes is quite recommended.
|
||||||
|
|
||||||
These were written with Ledger in mind, but also work with hledger
|
These were written with Ledger in mind, but also work with hledger
|
||||||
files:
|
files:
|
||||||
|
|
||||||
|
|
||||||
@ -746,16 +799,16 @@ EDITOR SUPPORT
|
|||||||
ting-started
|
ting-started
|
||||||
Sublime Text https://github.com/ledger/ledger/wiki/Using-Sub-
|
Sublime Text https://github.com/ledger/ledger/wiki/Using-Sub-
|
||||||
lime-Text
|
lime-Text
|
||||||
|
|
||||||
Textmate https://github.com/ledger/ledger/wiki/Using-Text-
|
Textmate https://github.com/ledger/ledger/wiki/Using-Text-
|
||||||
Mate-2
|
Mate-2
|
||||||
|
|
||||||
Text Wrangler https://github.com/ledger/ledger/wiki/Edit-
|
Text Wrangler https://github.com/ledger/ledger/wiki/Edit-
|
||||||
ing-Ledger-files-with-TextWrangler
|
ing-Ledger-files-with-TextWrangler
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
REPORTING BUGS
|
REPORTING BUGS
|
||||||
Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel
|
Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel
|
||||||
or hledger mail list)
|
or hledger mail list)
|
||||||
|
|
||||||
|
|
||||||
@ -769,7 +822,7 @@ COPYRIGHT
|
|||||||
|
|
||||||
|
|
||||||
SEE ALSO
|
SEE ALSO
|
||||||
hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1),
|
hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1),
|
||||||
hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
|
hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
|
||||||
dot(5), ledger(1)
|
dot(5), ledger(1)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user