Files
sure/app/models/rule/action_executor/exclude_transaction.rb
Augusto Xavier 09dc428136 fix(rules): make explicit re-apply override locked attributes (#2273)
When a rule is re-applied from the UI, RulesController passes
ignore_attribute_locks: true, but Enrichable#enrich_attributes still
rejected locked attributes unconditionally, so locked (manually edited
or import-locked) transactions were silently skipped and reported as
blocked.

Thread the flag through enrich_attribute/enrich_attributes as a new
ignore_locks keyword (default false, so provider syncs and AI
enrichment keep respecting locks) and pass it from the six synchronous
rule action executors.

Fixes #2051
2026-06-15 22:12:24 +02:00

28 lines
860 B
Ruby

class Rule::ActionExecutor::ExcludeTransaction < Rule::ActionExecutor
def label
"Exclude from budgeting and reports"
end
def execute(transaction_scope, value: nil, ignore_attribute_locks: false, rule_run: nil)
scope = transaction_scope.with_entry
unless ignore_attribute_locks
# Filter by entry's locked_attributes, not transaction's
# Since excluded is on Entry, not Transaction, we need to check entries.locked_attributes
scope = scope.where.not(
Arel.sql("entries.locked_attributes ? 'excluded'")
)
end
count_modified_resources(scope) do |txn|
# enrich_attribute returns true if the entry was actually modified, false otherwise
txn.entry.enrich_attribute(
:excluded,
true,
source: "rule",
ignore_locks: ignore_attribute_locks
)
end
end
end