From d78dada5ec4340ca2d3b791c03cdeb20a3ad66ea Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 9 Mar 2025 23:40:27 +0800 Subject: [PATCH] fix cannot filter transfer in transaction with transaction tags (#82) --- pkg/services/transactions.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/services/transactions.go b/pkg/services/transactions.go index c88a249b..d70790df 100644 --- a/pkg/services/transactions.go +++ b/pkg/services/transactions.go @@ -1983,7 +1983,7 @@ func (s *TransactionService) appendFilterTagIdsConditionToQuery(sess *xorm.Sessi if noTags { subQuery := builder.Select("transaction_id").From("transaction_tag_index").Where(subQueryCondition) - sess.NotIn("transaction_id", subQuery) + sess.NotIn("transaction_id", subQuery).NotIn("related_id", subQuery) return sess } @@ -1999,9 +1999,9 @@ func (s *TransactionService) appendFilterTagIdsConditionToQuery(sess *xorm.Sessi } if tagFilterType == models.TRANSACTION_TAG_FILTER_HAS_ANY || tagFilterType == models.TRANSACTION_TAG_FILTER_HAS_ALL { - sess.In("transaction_id", subQuery) + sess.And(builder.Or(builder.In("transaction_id", subQuery), builder.In("related_id", subQuery))) } else if tagFilterType == models.TRANSACTION_TAG_FILTER_NOT_HAS_ANY || tagFilterType == models.TRANSACTION_TAG_FILTER_NOT_HAS_ALL { - sess.NotIn("transaction_id", subQuery) + sess.NotIn("transaction_id", subQuery).NotIn("related_id", subQuery) } return sess