print: tag queries will match transactions whose postings contain the tag

This commit is contained in:
Simon Michael 2014-03-01 17:42:13 -08:00
parent d89367d75e
commit 6f49263c9b
2 changed files with 4 additions and 4 deletions

View File

@ -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]

View File

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