mirror of
https://github.com/we-promise/sure.git
synced 2026-07-19 16:25:24 +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
30 lines
776 B
Ruby
30 lines
776 B
Ruby
class Rule::ActionExecutor::SetTransactionMerchant < Rule::ActionExecutor
|
|
def type
|
|
"select"
|
|
end
|
|
|
|
def options
|
|
family.merchants.alphabetically.pluck(:name, :id)
|
|
end
|
|
|
|
def execute(transaction_scope, value: nil, ignore_attribute_locks: false, rule_run: nil)
|
|
merchant = family.merchants.find_by_id(value)
|
|
return 0 unless merchant
|
|
|
|
scope = transaction_scope
|
|
unless ignore_attribute_locks
|
|
scope = scope.enrichable(:merchant_id)
|
|
end
|
|
|
|
count_modified_resources(scope) do |txn|
|
|
# enrich_attribute returns true if the transaction was actually modified, false otherwise
|
|
txn.enrich_attribute(
|
|
:merchant_id,
|
|
merchant.id,
|
|
source: "rule",
|
|
ignore_locks: ignore_attribute_locks
|
|
)
|
|
end
|
|
end
|
|
end
|