hledger
hledger copied to clipboard
Support alias subdirective for commodity
It would be nice if hledger supports the subdirectives of ledger-cli for the commodity directive
commodity $
note American Dollars
format $1,000.00
nomarket
alias USD
default
Currently only format is recognized. And adding any other subdirective fails when using hledger. It would be nice if hledger allows these at least. In a first version, hledger could just ignore them and only later on implement them (Especially the alias one can be usefuly to be able to use $ and USD interchangeably).
Thanks. I agree we should ignore Ledger subdirectives we don't support, probably in all directives, I think only account does that right now.
Could you analyse the commodity alias feature and try to list its use cases and interactions with other features ?
As far as I can tell, whenever a commodity is used (either as argument on the CLI or in the ledger) it gets translated from the alias to the original commodity.
You cannot create an alias for a commodity that is used already. In the output, it always uses the "main" name. The main use case is to allow for e.g. € and EUR. € is not always as easy to type but a bit more clean in the ledger file. So having € in the ledger file is nice since it can be auto-generated etc. But when passing CLI arguments, it can be much faster to type EUR instead of €
Thanks, that is clear so far. I think reasonably often people want to customise commodity symbols to something else for display. They might expect this directive to help with that; but I think it's a separate task and the two are independent.
Actually, this would also help, you can use the following: (Imagining you want USD in the output and $ in your ledger)
commodity USD
alias $
This might also be of interest for those using --infer-equity.
For instance, I can imagine that people would want Equity:Conversion:EUR-USD:USD in account names, rather than Equity:Conversion:EUR-$:$. This might help achieve that.
having an alias for EUR (and others) would have been lovely 🙄