journal: tests/docs for aliases corrupting account names (#1788)
This commit is contained in:
parent
e9dd77e82b
commit
9c173bc18b
@ -58,6 +58,7 @@ There are some situations where print's output can become unparseable:
|
||||
|
||||
- [Valuation](#valuation) affects posting amounts but not [balance assertion](#balance-assertions) or [balance assignment](#balance-assignments) amounts, potentially causing those to [fail](https://github.com/simonmichael/hledger/issues/1429).
|
||||
- [Auto postings](#auto-postings) can generate postings with [too many missing amounts](https://github.com/simonmichael/hledger/issues/1276).
|
||||
- [Account aliases can generate invalid account names](#account-aliases-can-generate-invalid-account-names).
|
||||
|
||||
Normally, the journal entry's explicit or implicit amount style is preserved.
|
||||
For example, when an amount is omitted in the journal, it will not appear in the output.
|
||||
|
||||
@ -3153,12 +3153,17 @@ This can be useful for:
|
||||
|
||||
- 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
|
||||
- experimenting with new account organisations, like a new hierarchy or combining two accounts into one
|
||||
- experimenting with new account organisations, like a new hierarchy
|
||||
- combining two accounts into one, eg to see their sum or difference on one line
|
||||
- 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.
|
||||
|
||||
Account aliases are very powerful.
|
||||
They are generally easy to use correctly, but you can also generate
|
||||
invalid account names with them; more on this below.
|
||||
|
||||
See also [Rewrite account names](rewrite-account-names.html).
|
||||
|
||||
### Basic aliases
|
||||
@ -3276,6 +3281,39 @@ with this directive:
|
||||
end aliases
|
||||
```
|
||||
|
||||
### Aliases can generate invalid account names
|
||||
|
||||
Be aware that account aliases can produce malformed account names,
|
||||
which could cause confusing reports or and invalid [`print`](#print) output.
|
||||
Two examples: you can erase an account name:
|
||||
|
||||
```journal
|
||||
2021-01-01
|
||||
a:aa 1
|
||||
b
|
||||
```
|
||||
```shell
|
||||
$ hledger -f- print --alias '/a:.*/='
|
||||
2021-01-01
|
||||
1
|
||||
b
|
||||
```
|
||||
|
||||
or insert an illegal double space, causing part of the account name
|
||||
to be treated as part of the amount if reparsed:
|
||||
|
||||
```journal
|
||||
2021-01-01
|
||||
old 1
|
||||
other
|
||||
```
|
||||
```shell
|
||||
$ hledger -f- --alias old="new USD" print | hledger -f- print
|
||||
2021-01-01
|
||||
new USD 1
|
||||
other
|
||||
```
|
||||
|
||||
## Default parent account
|
||||
|
||||
You can specify a parent account which will be prepended to all accounts
|
||||
|
||||
@ -225,3 +225,30 @@ $ hledger -f- print
|
||||
|
||||
>=0
|
||||
|
||||
# Aliases can produce malformed account names and invalid print output (#1788).
|
||||
# 16. For example, you can erase an account name:
|
||||
<
|
||||
alias /a:.*/=
|
||||
2021-01-01
|
||||
a:aa 1
|
||||
b
|
||||
$ hledger -f- print
|
||||
2021-01-01
|
||||
1
|
||||
b
|
||||
|
||||
>=0
|
||||
|
||||
# 17. Another example: you can insert an illegal double space,
|
||||
# with the second part considered part of the amount if reparsed:
|
||||
<
|
||||
2021-01-01
|
||||
old 1
|
||||
other
|
||||
|
||||
$ hledger -f- --alias old="new USD" print | hledger -f- print
|
||||
2021-01-01
|
||||
new USD 1
|
||||
other
|
||||
|
||||
>=0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user