-
-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imp:print:beancount output: more robust account/commodity encoding
Unsupported chars are now hex-encoded, not just converted to dashes. This helps keep account and commodity names unique, especially with the equity conversion account names generated by --infer-equity when using currency symbols. (Those could also be converted to ISO 4217 codes, in theory, but for now we just hex encode them, which is easier to make robust.) Also, Beancount commodity symbols are no longer enclosed in hledger-style double quotes.
- Loading branch information
1 parent
cbdbe0a
commit f57cd63
Showing
3 changed files
with
81 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# * print command's beancount output format | ||
|
||
# ** 1. Unrecognised top level account names are rejected. | ||
< | ||
2000-01-01 | ||
other 0 ABC | ||
|
||
$ hledger -f- print -O beancount | ||
>2 /bad top-level account/ | ||
>=1 | ||
|
||
# ** 2. Otherwise, accounts are encoded to suit beancount, and open directives are added. | ||
< | ||
2000-01-01 | ||
assets:a 0 ABC | ||
equity:$-€:$ 0 USD | ||
|
||
$ hledger -f- print -O beancount | ||
2000-01-01 open Assets:A | ||
2000-01-01 open Equity:C24-C20ac:C24 | ||
|
||
2000-01-01 * | ||
Assets:A 0 ABC | ||
Equity:C24-C20ac:C24 0 USD | ||
|
||
>= | ||
|
||
# ** 3. Commodity symbols are converted to ISO 4217 codes, or encoded, to suit beancount. | ||
< | ||
2000-01-01 | ||
assets $0 | ||
assets 0 | ||
assets 0! | ||
assets 0 "size 2 pencils" | ||
|
||
$ hledger -f- print -O beancount | ||
2000-01-01 open Assets | ||
|
||
2000-01-01 * | ||
Assets 0 USD | ||
Assets 0 C | ||
Assets 0 C21 | ||
Assets 0 SIZE-2-PENCILS | ||
|
||
>= | ||
|