You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm playing with account hierarchy to learn accounting, and I noticed that aliases defined in a ledger file included in a global file are not applied to the global file. I'm using the following file structure:
global.ledger file:
#!/usr/bin/env hledger-exec
include accounts.ledger
# Following are the transactions
...
accounts.ledger file contains the account hierarchy with its aliases:
account financial accounts:banks:main bank account ; type:Asset no:512
alias bank=financial accounts:banks:main bank account
alias a512=financial accounts:banks:main bank account
...
account expenses:buying ; type:Expense no:60
alias a60=expenses:buying
...
account revenue:products sold ; type:Revenue no:70
alias a70=revenue:products sold
...
I'm using this hierarchy because when running hledger-web or hledger-ui from the main files, new transactions made from the UI are appended to the main file. However, I want the account hierarchy to be separate, simply because I might modify it while I'm using hledger-web or ui at the same time.
When I declare aliases in accounts.ledger, they are not used in the global file. I have to declare them in the global file for them to be understood.
The fact that aliases are not propagated to including files is not in the documentation.
Perhaps the documentation should be updated, and perhaps aliases should be allowed to span to including files. having them restricted to the files they are in is also understandable, but perhaps use case around this should be discussed more.
The text was updated successfully, but these errors were encountered:
I see how this can be surprising/unsatisfying. I often find it annoying myself. Why does it work this way? It's to preserve these properties, which I think are worthwhile:
reordering files does not change their meaning
adding a file does not change the meaning of the other files
As a practical matter for right now,
put aliases inline at the top of the main journal file (or an including file, like your global.ledger). This should cause no problems for hledger-web or hledger-ui --watch, they will detect your file edits.
Aliases actually propagated to included files. Since migration to hledger I changed my layout to something like:
# effective-hledger.dat
commodity $
; note American Dollars
format $1,000,000,000.00
alias tips=Expenses:Tips
include ledger-2009.dat
# ...
include ledger-2019.journal
Though it is only chain and I cannot have anymore currencies/accounts/aliases split in different files it works for me.
I guess this is come-back of #510 . Maybe it worth to consider export include accounts.ledger syntax or something similar.
I'm playing with account hierarchy to learn accounting, and I noticed that aliases defined in a ledger file included in a global file are not applied to the global file. I'm using the following file structure:
global.ledger
file:accounts.ledger
file contains the account hierarchy with its aliases:I'm using this hierarchy because when running hledger-web or hledger-ui from the main files, new transactions made from the UI are appended to the main file. However, I want the account hierarchy to be separate, simply because I might modify it while I'm using hledger-web or ui at the same time.
When I declare aliases in
accounts.ledger
, they are not used in the global file. I have to declare them in the global file for them to be understood.The fact that aliases are not propagated to including files is not in the documentation.
Perhaps the documentation should be updated, and perhaps aliases should be allowed to span to including files. having them restricted to the files they are in is also understandable, but perhaps use case around this should be discussed more.
The text was updated successfully, but these errors were encountered: