mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-19 10:17:35 +03:00
docs: clarify dotted account name example (#331)
This commit is contained in:
parent
99444388af
commit
8b2ddbc38b
@ -1,22 +1,24 @@
|
||||
# see also http://hledger.org/docs -> How To Use Another Account Separator Character
|
||||
|
||||
2/1
|
||||
fos.haskell ....
|
||||
biz.research .
|
||||
inc.client1 .... .... .... .... .... ....
|
||||
fos:haskell ....
|
||||
biz:research .
|
||||
inc:client1 .... .... .... .... .... ....
|
||||
|
||||
2/2
|
||||
biz.research .
|
||||
inc.client1 .... .... ..
|
||||
biz:research .
|
||||
inc:client1 .... .... ..
|
||||
|
||||
2/3
|
||||
biz.research .
|
||||
fos.hledger .... .... ...
|
||||
biz.it .... ..
|
||||
inc.client1 .... .... .... .... ....
|
||||
biz:research .
|
||||
fos:hledger .... .... ...
|
||||
biz:it .... ..
|
||||
inc:client1 .... .... .... .... ....
|
||||
|
||||
2/4
|
||||
biz.research .... ..
|
||||
fos.hledger .... .... ....
|
||||
fos.ledger .
|
||||
fos.haskell ..
|
||||
inc.client1 .... ....
|
||||
biz:research .... ..
|
||||
fos:hledger .... .... ....
|
||||
fos:ledger 0.25
|
||||
fos:haskell .5
|
||||
inc:client1 2
|
||||
|
||||
|
@ -32,6 +32,10 @@ An example of converting bank data.
|
||||
#### [How to use account aliases](how-to-use-account-aliases.html)
|
||||
Aliases for account name rewriting.
|
||||
|
||||
#### [How to use another account separator character](how-to-use-another-account-separator-character.html)
|
||||
Writing `some.sub.account` instead of `some:sub:account`.
|
||||
|
||||
|
||||
## General info
|
||||
|
||||
#### [More docs](more-docs.html)
|
||||
|
48
site/how-to-use-another-account-separator-character.md
Normal file
48
site/how-to-use-another-account-separator-character.md
Normal file
@ -0,0 +1,48 @@
|
||||
# How to use another account separator character
|
||||
|
||||
[Timedot format](manual.html#timedot) makes me want to use dots (`.`) for separating account components, instead of colon (`:`).
|
||||
For example, instead of `fos:hledger:timedot` I'd like to write `fos.hledger.timedot`.
|
||||
We can use the powerful [account aliases](manual.html#account-aliases) feature
|
||||
to rewrite account names before hledger's account name parser sees them.
|
||||
|
||||
In journal files, we can use an alias directive.
|
||||
Note the backslash which tells the regular expression engine it's a literal `.` not a wildcard:
|
||||
|
||||
```journal
|
||||
# alias /REGEX/=REPLACEMENT
|
||||
alias /\./=:
|
||||
|
||||
2008/01/01 income
|
||||
assets.bank.checking $1
|
||||
income.salary
|
||||
```
|
||||
Check that subaccounts are recognised:
|
||||
```shell
|
||||
$ hledger -f t.journal bal --no-elide
|
||||
$1 assets
|
||||
$1 bank
|
||||
$1 checking
|
||||
$-1 income
|
||||
$-1 salary
|
||||
--------------------
|
||||
0
|
||||
```
|
||||
|
||||
Alias directives aren't supported in the timedot format,
|
||||
|
||||
```timedot
|
||||
2016/2/4
|
||||
fos.hledger.timedot 2
|
||||
fos.ledger 1
|
||||
```
|
||||
so we would use the `--alias` command line option instead.
|
||||
The second backslash tells the shell that's a literal backslash, not a shell escape sequence:
|
||||
```shell
|
||||
$ hledger --alias /\\./=: -f t.timedot bal --no-elide
|
||||
3.00 fos
|
||||
2.00 hledger
|
||||
2.00 timedot
|
||||
1.00 ledger
|
||||
--------------------
|
||||
3.00
|
||||
```
|
@ -927,28 +927,13 @@ Balance changes in 2016/02/01-2016/02/03:
|
||||
|| 7.75 2.25 8.00
|
||||
```
|
||||
|
||||
I prefer to use period for separating account components.
|
||||
We can make this work with an [account alias](#account-aliases):
|
||||
|
||||
```timedot
|
||||
2016/2/4
|
||||
fos.hledger.timedot 4
|
||||
fos.ledger ..
|
||||
```
|
||||
```shell
|
||||
$ hledger -f t.timedot --alias /\\./=: bal date:2016/2/4
|
||||
4.50 fos
|
||||
4.00 hledger:timedot
|
||||
0.50 ledger
|
||||
--------------------
|
||||
4.50
|
||||
```
|
||||
|
||||
[default year directives](#default-year) may be used.
|
||||
|
||||
Here is a
|
||||
[sample.timedot](https://raw.github.com/simonmichael/hledger/master/data/sample.timedot).
|
||||
|
||||
If you'd like to use dot in account names as well, see
|
||||
[how to use another account separator character](how-to-use-another-account-separator-character.html).
|
||||
|
||||
|
||||
### CSV
|
||||
|
Loading…
Reference in New Issue
Block a user