Comments

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
...

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.

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.