Files
sure/test/models/rule
super 1a5d04d527 feat(rules): add a Transaction tag condition filter (#2558)
* feat(rules): add a Transaction tag condition filter

Rules could already set tags via the set_transaction_tags action but had
no way to match transactions by an existing tag. Add a select-type
transaction_tag condition filter (mirroring transaction_category) with the
standard "Equal to" and "Is empty" operators, registered on the
transaction rule resource so it surfaces in the rule builder automatically.

Also remap the tag UUID<->name in family data export/import for the new
condition, matching how the transaction_category/transaction_merchant
conditions and the set_transaction_tags action are already handled, so
tag-based rules survive an export/import round-trip.

Closes #2557

* fix(rules): match transaction_tag via EXISTS so compound tag conditions work

Addresses review feedback on #2558: the tag filter joined transactions.tags
and predicated on tags.id, which broke two compound cases:
- two ANDed tag conditions collapsed to `tags.id = a AND tags.id = b` on the
  same joined alias and could never match, even when the transaction had both
  tags;
- OR / multi-tag matches returned a transaction once per tagging row, inflating
  counts and making rule actions iterate duplicate transactions.

Use a correlated EXISTS subquery per condition instead. Each condition is
independent (fixes the AND case) and no join is added, so rows are never
multiplied (fixes the OR duplication) and prepare adds nothing, keeping
branches structurally compatible inside a compound OR. Add tests for both.
2026-08-22 07:38:09 +02:00
..