mirror of
https://github.com/we-promise/sure.git
synced 2026-07-12 21:05:20 +00:00
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
28 lines
860 B
Ruby
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
|