hledger icon indicating copy to clipboard operation
hledger copied to clipboard

allow aliases to be defined within account declarations

Open simonmichael opened this issue 5 years ago • 5 comments

Ledger's account directive supports various subdirectives, which our account directive currently ignores.

I'd like to have support for the alias subdirective, to begin with. This is an alternative to the top-level alias directive. Eg:

account A
  alias B
  alias C

creates aliases like:

alias B = A
alias C = A

If you want to alias multiple accounts to a new name A, say for tax reporting, the advantage is that A's name can be written just once instead of in multiple places which must be kept in sync.

simonmichael avatar Jul 06 '20 19:07 simonmichael

Code: https://github.com/simonmichael/hledger/blob/1.18/hledger-lib/Hledger/Read/JournalReader.hs#L349

simonmichael avatar Jul 06 '20 19:07 simonmichael

On the downside, currently the only way to apply a bunch of aliases temporarily is to insert/uncomment them, and this new style would seem to make it harder to enable/disable them as a block.

simonmichael avatar Jul 06 '20 19:07 simonmichael

Well actually, in my tax reporting use case I'd be commenting the account directives too, so it's not a problem.

simonmichael avatar Jul 06 '20 19:07 simonmichael

Hello @mildred - in 2019 on #217 you were interested in adding this feature to hledger (declaring aliases with account declarations) - are you still ? We'd still like to add this feature.

simonmichael avatar Oct 13 '25 20:10 simonmichael

For the record I should note the complication also noted for #1389: multi-file setups sometimes want/need duplicated account declarations, so when we add more features to the account directive we need to consider what happens in that case. Eg perhaps if there's multiple declarations of an account, the subdirectives/tags from all of them are combined.

simonmichael avatar Oct 13 '25 21:10 simonmichael