diff --git a/hledger-lib/Hledger/Data/Posting.hs b/hledger-lib/Hledger/Data/Posting.hs index c89ba88d6..986b0fccd 100644 --- a/hledger-lib/Hledger/Data/Posting.hs +++ b/hledger-lib/Hledger/Data/Posting.hs @@ -147,9 +147,9 @@ postingCleared p = if pstatus p postingAllTags :: Posting -> [Tag] postingAllTags p = ptags p ++ maybe [] transactionAllTags (ptransaction p) --- | Tags for this transaction including any inherited from above, when that is implemented. +-- | Tags for this transaction including any from its postings. transactionAllTags :: Transaction -> [Tag] -transactionAllTags t = ttags t +transactionAllTags t = ttags t ++ concatMap ptags (tpostings t) -- Get the other postings from this posting's transaction. relatedPostings :: Posting -> [Posting] diff --git a/hledger-lib/Hledger/Query.hs b/hledger-lib/Hledger/Query.hs index 8ed2d0551..2f72ddf06 100644 --- a/hledger-lib/Hledger/Query.hs +++ b/hledger-lib/Hledger/Query.hs @@ -631,8 +631,8 @@ tests_matchesTransaction = [ assertBool "" $ (Desc "x x") `matchesTransaction` nulltransaction{tdescription="x x"} -- see posting for more tag tests assertBool "" $ (Tag "foo" (Just "a")) `matchesTransaction` nulltransaction{ttags=[("foo","bar")]} - -- a tag match on a transaction usually ignores posting tags - assertBool "" $ not $ (Tag "postingtag" Nothing) `matchesTransaction` nulltransaction{tpostings=[nullposting{ptags=[("postingtag","")]}]} + -- a tag match on a transaction also matches posting tags + assertBool "" $ (Tag "postingtag" Nothing) `matchesTransaction` nulltransaction{tpostings=[nullposting{ptags=[("postingtag","")]}]} ] lookupTagByName :: String -> [Tag] -> Maybe Tag