Merge branch 'master' into web_permissions
This commit is contained in:
commit
d4f9432d47
@ -459,7 +459,9 @@ secondarydatep primaryDate = char '=' *> datep' (Just primaryYear)
|
|||||||
|
|
||||||
--- ** account names
|
--- ** account names
|
||||||
|
|
||||||
-- | Parse an account name, then apply any parent account prefix and/or account aliases currently in effect.
|
-- | Parse an account name (plus one following space if present),
|
||||||
|
-- then apply any parent account prefix and/or account aliases currently in effect,
|
||||||
|
-- in that order. (Ie first add the parent account prefix, then rewrite with aliases).
|
||||||
modifiedaccountnamep :: JournalParser m AccountName
|
modifiedaccountnamep :: JournalParser m AccountName
|
||||||
modifiedaccountnamep = do
|
modifiedaccountnamep = do
|
||||||
parent <- getParentAccount
|
parent <- getParentAccount
|
||||||
|
|||||||
@ -248,7 +248,7 @@ accountdirectivep :: JournalParser m ()
|
|||||||
accountdirectivep = do
|
accountdirectivep = do
|
||||||
string "account"
|
string "account"
|
||||||
lift (skipSome spacenonewline)
|
lift (skipSome spacenonewline)
|
||||||
acct <- lift accountnamep -- eats single spaces
|
acct <- modifiedaccountnamep -- account directives can be modified by alias/apply account
|
||||||
macode' :: Maybe String <- (optional $ lift $ skipSome spacenonewline >> some digitChar)
|
macode' :: Maybe String <- (optional $ lift $ skipSome spacenonewline >> some digitChar)
|
||||||
let macode :: Maybe AccountCode = read <$> macode'
|
let macode :: Maybe AccountCode = read <$> macode'
|
||||||
newline
|
newline
|
||||||
|
|||||||
@ -826,10 +826,16 @@ account liabilities 2000
|
|||||||
account revenues 4000
|
account revenues 4000
|
||||||
account expenses 6000
|
account expenses 6000
|
||||||
```
|
```
|
||||||
This affects account display order in reports:
|
This affects how accounts are sorted in account and balance reports:
|
||||||
accounts with codes are listed before accounts without codes and in increasing code order,
|
accounts with codes are listed before accounts without codes, and in increasing code order
|
||||||
instead of listing all accounts alphabetically.
|
(instead of listing all accounts alphabetically).
|
||||||
(*Note: currently not supported in the `balance` command's single-column mode.*)
|
Warning, this feature is incomplete; account codes do not yet affect sort order in
|
||||||
|
|
||||||
|
- the `accounts` command
|
||||||
|
- the `balance` command's single-column mode
|
||||||
|
- flat mode balance reports
|
||||||
|
(to work around this, declare account codes on the subaccounts as well).
|
||||||
|
- hledger-web's sidebar
|
||||||
|
|
||||||
Account codes should be all numeric digits, unique, and separated from the account name by at least two spaces (since account names may contain single spaces).
|
Account codes should be all numeric digits, unique, and separated from the account name by at least two spaces (since account names may contain single spaces).
|
||||||
By convention, often the first digit indicates the type of account,
|
By convention, often the first digit indicates the type of account,
|
||||||
@ -850,14 +856,18 @@ account assets:bank:checking 1110
|
|||||||
|
|
||||||
### Rewriting accounts
|
### Rewriting accounts
|
||||||
|
|
||||||
You can define aliases which rewrite your account names (after reading the journal,
|
You can define account alias rules which rewrite your account names, or parts of them,
|
||||||
before generating reports). hledger's account aliases can be useful for:
|
before generating reports.
|
||||||
|
This can be useful for:
|
||||||
|
|
||||||
- expanding shorthand account names to their full form, allowing easier data entry and a less verbose journal
|
- expanding shorthand account names to their full form, allowing easier data entry and a less verbose journal
|
||||||
- adapting old journals to your current chart of accounts
|
- adapting old journals to your current chart of accounts
|
||||||
- experimenting with new account organisations, like a new hierarchy or combining two accounts into one
|
- experimenting with new account organisations, like a new hierarchy or combining two accounts into one
|
||||||
- customising reports
|
- customising reports
|
||||||
|
|
||||||
|
Account aliases also rewrite account names in [account directives](#declaring-accounts).
|
||||||
|
They do not affect account names being entered via hledger add or hledger-web.
|
||||||
|
|
||||||
See also [Cookbook: Rewrite account names](https://github.com/simonmichael/hledger/wiki/Rewrite-account-names).
|
See also [Cookbook: Rewrite account names](https://github.com/simonmichael/hledger/wiki/Rewrite-account-names).
|
||||||
|
|
||||||
#### Basic aliases
|
#### Basic aliases
|
||||||
@ -874,7 +884,7 @@ alias OLD = NEW
|
|||||||
Or, you can use the `--alias 'OLD=NEW'` option on the command line.
|
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.
|
This affects all entries. It's useful for trying out aliases interactively.
|
||||||
|
|
||||||
OLD and NEW are full account names.
|
OLD and NEW are case sensitive full account names.
|
||||||
hledger will replace any occurrence of the old account name with the
|
hledger will replace any occurrence of the old account name with the
|
||||||
new one. Subaccounts are also affected. Eg:
|
new one. Subaccounts are also affected. Eg:
|
||||||
|
|
||||||
@ -963,6 +973,10 @@ include personal.journal
|
|||||||
|
|
||||||
Prior to hledger 1.0, legacy `account` and `end` spellings were also supported.
|
Prior to hledger 1.0, legacy `account` and `end` spellings were also supported.
|
||||||
|
|
||||||
|
A default parent account also affects [account directives](#declaring-accounts).
|
||||||
|
It does not affect account names being entered via hledger add or hledger-web.
|
||||||
|
If account aliases are present, they are applied after the default parent account.
|
||||||
|
|
||||||
## Periodic transactions
|
## Periodic transactions
|
||||||
|
|
||||||
Periodic transaction rules describe transactions that recur.
|
Periodic transaction rules describe transactions that recur.
|
||||||
|
|||||||
19
tests/journal/accounts.test
Normal file
19
tests/journal/accounts.test
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# account names
|
||||||
|
|
||||||
|
# 1. account directives are affected by aliases and apply account.
|
||||||
|
<
|
||||||
|
apply account c
|
||||||
|
alias c:a=b
|
||||||
|
account a
|
||||||
|
$ hledger -f - accounts
|
||||||
|
b
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# a trailing : should give a clear error
|
||||||
|
# 2009/1/1
|
||||||
|
# a: 1
|
||||||
|
# $ hledger -f - print
|
||||||
|
# >2 /accountname seems ill-formed: a:/
|
||||||
|
# >= 1
|
||||||
Loading…
Reference in New Issue
Block a user