From 222a56bc92f6340d2a4452d4722519c704994b88 Mon Sep 17 00:00:00 2001 From: "hermes@bounty.hunter" Date: Tue, 19 May 2026 04:05:03 +0700 Subject: [PATCH] fix: resolve bounty issue #1950 - posting tags now override inherited txn tags --- hledger-lib/Hledger/Data/Posting.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hledger-lib/Hledger/Data/Posting.hs b/hledger-lib/Hledger/Data/Posting.hs index f86b9b0d316..866d4032bc9 100644 --- a/hledger-lib/Hledger/Data/Posting.hs +++ b/hledger-lib/Hledger/Data/Posting.hs @@ -760,8 +760,14 @@ postingCommodities = map acommodity . filter (not . isMissingAmount) . amountsRa where isMissingAmount a = acommodity a == "AUTO" -- | Tags for this posting including any inherited from its parent transaction. +-- Explicitly-set posting tags override inherited transaction tags with the same name. postingAllTags :: Posting -> [Tag] -postingAllTags p = ptags p ++ maybe [] ttags (ptransaction p) +postingAllTags p = postingTags ++ filteredTxnTags + where + postingTags = ptags p + txnTags = maybe [] ttags (ptransaction p) + postingTagNames = map fst postingTags + filteredTxnTags = filter ((`notElem` postingTagNames) . fst) txnTags -- | Tags for this transaction including any from its postings (which includes any from the postings' accounts). transactionAllTags :: Transaction -> [Tag]