;doc: document how aliases can break account types (#1820)

This commit is contained in:
Simon Michael 2022-02-01 14:47:30 -10:00
parent cb040dbe29
commit 0f8ede3038

View File

@ -848,10 +848,12 @@ Match real or virtual postings respectively.
Match unmarked, pending, or cleared transactions respectively. Match unmarked, pending, or cleared transactions respectively.
**`type:ACCTTYPES`**\ **`type:ACCTTYPES`**\
Match by account type (see [Declaring accounts > Account types](#account-types)). Match by account type (see ).
`ACCTTYPES` is one or more of the single-letter account type codes `ACCTTYPES` is one or more of the single-letter account type codes
`ALERXCV`, case insensitive. `ALERXCV`, case insensitive.
Eg: `hledger bal type:AL` shows asset and liability balances. Eg: `hledger bal type:AL` shows asset and liability balances.
Note: certain kinds of account alias can disrupt this, see
[Rewriting accounts > Aliases and account types](#aliases-and-account-types).
**`tag:REGEX[=REGEX]`**\ **`tag:REGEX[=REGEX]`**\
Match by tag name, and optionally also by tag value. Match by tag name, and optionally also by tag value.
@ -3337,6 +3339,34 @@ $ hledger print --alias old="new USD" | hledger -f- print
other other
``` ```
### Aliases and account types
If an account with a type declaration is renamed by an alias,
normally the account type remains in effect.
However, renaming in a way that reshapes the account tree
(eg renaming parent accounts but not their children, or vice versa)
could prevent child accounts from inheriting the account type of their parents.
<!--
Eg: with `account expenses ; type:X` and `hledger acc --alias /expenses$/=expenses:uncategorised`,
"expenses:uncategorised" is declared to be type X and "expenses" has no type declared,
nor do its children (because of the $, they do not get aliased and remain under "expenses").
-->
Secondly, if an account's type is being inferred from its name,
renaming it by an alias could prevent or alter that.
<!--
With `hledger -f examples/sample.journal acc --alias expenses=foo` and no account declarations,
it tries and fails to infer a type for "foo".
-->
If you are using account aliases and the [`type:` query](#queries) is not matching accounts as you expect,
try troubleshooting with the accounts command, eg something like:
```journal
$ hledger accounts --alias assets=bassetts type:a
```
## Default parent account ## Default parent account
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