mirror of
https://github.com/we-promise/sure.git
synced 2026-04-20 20:44:08 +00:00
Pre-fill rule suggestion with transaction name and category (#497)
Co-authored-by: Carlos Adames <cj@Carloss-MacBook-Air.local>
This commit is contained in:
@@ -29,6 +29,22 @@ class RulesController < ApplicationController
|
||||
@rule = Current.family.rules.build(
|
||||
resource_type: params[:resource_type] || "transaction",
|
||||
)
|
||||
|
||||
if params[:name].present?
|
||||
@rule.name = params[:name]
|
||||
@rule.conditions.build(
|
||||
condition_type: "transaction_name",
|
||||
operator: "like",
|
||||
value: params[:name]
|
||||
)
|
||||
end
|
||||
|
||||
if params[:action_type].present? && params[:action_value].present?
|
||||
@rule.actions.build(
|
||||
action_type: params[:action_type],
|
||||
value: params[:action_value]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -11,7 +11,8 @@ class TransactionCategoriesController < ApplicationController
|
||||
flash[:cta] = {
|
||||
type: "category_rule",
|
||||
category_id: transaction.category_id,
|
||||
category_name: transaction.category.name
|
||||
category_name: transaction.category.name,
|
||||
merchant_name: @entry.name
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user