hledger icon indicating copy to clipboard operation
hledger copied to clipboard

Inherited Tag Values are not Overwritten [💰$20]

Open nobodyinperson opened this issue 3 years ago • 23 comments

Thank you very much for hledger, it is awesome! 🎉

Apparently there is a misleading behaviour when inheriting values of tags.

The docs (https://hledger.org/1.27/hledger.html#tags-1) mention that tags are inherited, but only mention value-less tags.

Consider this book.hledger:

2022-11-17 Aldi
    ; concerns: me
    Assets               -30 €
    Costs:Food            20 €
    Loaned                10 €  ; concerns: you, note: 👈 This should OVERWRITE the concerns: me from above, shouldn't it?

For consistency, higher-level tag values should overwrite tags values lower down the chain, right? At least a transaction/account shouldn't have two values of the same tag at once, right? But:

❯ hledger --version
hledger 1.27.1, linux-x86_64

❯ hledger -f book.hledger balance  --pivot=concerns
               -10 €  me
                10 €  you
--------------------
                   0  
# ☝️ This is expected.


❯ hledger -f book.hledger register Loaned  --pivot=concerns
2022-11-17 Aldi    you              10 €          10 €
# ☝️ This is expected.

❯ hledger -f book.hledger register tag:concerns=me --pivot=concerns
2022-11-17 Aldi    me              -30 €         -30 €
                   me               20 €         -10 €
                   you              10 €             0 # 👈 why is this line here? I explicitly filtered for tag:concerns=me but a line with concerns=you appears?

❯ hledger -f book.hledger register Loaned tag:concerns=me
2022-11-17 Aldi          Loaned                 10 €          10 €
# ☝️ Why does this appear? 

❯ hledger -f book.hledger register Loaned tag:concerns=you
2022-11-17 Aldi          Loaned                 10 €          10 €
# ☝️ This is expected.

Conclusion

It seems that tag values are not overwritten down the chain but somehow still kept around. This can lead to confusion and inconsistencies in register for example.

Proposal

I propose that tag values down the line should overwrite higher-level tag values.

nobodyinperson avatar Nov 17 '22 22:11 nobodyinperson