mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-23 07:09:39 +02:00
* Add change name rule for transaction * Use HTML template in the ERB, clone and inject those templates from the stimulus controller * Put back the ai_enabled check * Update docs * Example of what no case statement would look like * Remove action_type and needs_value now that controller is injecting templates/hiding action target * add "to" to template, improve no-option selection, ensure text box is cleared
29 lines
598 B
Ruby
29 lines
598 B
Ruby
class Rule::ActionExecutor::SetTransactionName < Rule::ActionExecutor
|
|
def type
|
|
"text"
|
|
end
|
|
|
|
def options
|
|
nil
|
|
end
|
|
|
|
def execute(transaction_scope, value: nil, ignore_attribute_locks: false)
|
|
return if value.blank?
|
|
|
|
scope = transaction_scope
|
|
unless ignore_attribute_locks
|
|
scope = scope.enrichable(:name)
|
|
end
|
|
|
|
scope.each do |txn|
|
|
Rule.transaction do
|
|
txn.entry.log_enrichment!(
|
|
attribute_name: "name",
|
|
attribute_value: value,
|
|
source: "rule"
|
|
)
|
|
txn.entry.update!(name: value)
|
|
end
|
|
end
|
|
end
|
|
end
|