simonmichael / hledger

Robust, fast, intuitive plain text accounting tool with CLI, TUI and web interfaces.
https://hledger.org
GNU General Public License v3.0
2.91k stars 315 forks source link

semantics of directives needs clarification/improvement #751

Closed simonmichael closed 1 year ago

simonmichael commented 6 years ago

Here are some confusing issues about how directives work, that need better functionality and/or docs:

1. the scope of effect of directives

Some affect a region between begin end directives. Some affect to the end of the current file. Some affect the whole current file. Maybe some affect all files ? This should be made clear for each one.

2. how directives interact with multiple files

Some (most ?) directives affect the file they are in (or the part of it after the directive), and any files included from that region, but they don't affect other sibling files or including parent files. So currently in a command like:

hledger -f A -f B ...

market prices, commodity directives etc. in file A won't affect journal entries in file B. To get directives in one to affect the other, you have to inline or include A in B, or vice versa. This was a design choice for simplicity and more predictable results, on the basis that otherwise it's too easy to quietly alter reports, annoyingly break assertions etc. by reordering file arguments or moving include directives. But it's unintuitive.

~3. position of this commodity directive has a surprising effect~

seems fixed

The following three examples are all parsed differently. (Maybe specific to space digit group separators and #749.)

No commodity directive:

2018-01-01
  (a)   USD 1 000

output:

$ hledger bal -N
           USD 1 000  a

Commodity directive at top:

commodity 1 000.00 USD

2018-01-01
  (a)   USD 1 000

output:

$ hledger bal -N
    1 000.00 USD  a

Commodity directive at bottom:

2018-01-01
  (a)   USD 1 000

commodity 1 000.00 USD

output:

$ hledger bal -N
        1.00 USD  a
simonmichael commented 6 years ago

Some doc improvements

simonmichael commented 3 years ago

Some discussion/proposals for different scoping of account aliases: https://www.reddit.com/r/plaintextaccounting/comments/n53ehk/getting_hledger_to_apply_aliases_globally_not/

simonmichael commented 1 year ago

These issues were documented at https://hledger.org/hledger.html#directives.