refactor: rename Savings Goals feature to Goals

User-facing rename + structural rename. Feature is now called just
"Goals" everywhere — page title, sidebar nav, modal headings, flash
messages, AI assistant tool. Code identifiers follow:

- Models: SavingsGoal → Goal, SavingsContribution → GoalContribution,
  SavingsGoalAccount → GoalAccount.
- Tables: savings_goals → goals, savings_contributions → goal_contributions,
  savings_goal_accounts → goal_accounts. FK columns savings_goal_id →
  goal_id. New migration db/migrate/20260511100003_rename_savings_to_goals.rb
  uses rename_table + rename_column; PG handles index renaming and FK
  redirection automatically.
- Controllers: SavingsGoalsController → GoalsController,
  SavingsContributionsController → GoalContributionsController.
- Routes: /savings_goals → /goals, nested /goals/:id/contributions
  (resource name shifts; old route name aliases dropped).
- ViewComponent namespace: Savings::* → Goals::*. Component class
  names drop their redundant "Goal" prefix where the namespace already
  carries it: Savings::GoalCardComponent → Goals::CardComponent,
  Savings::GoalAvatarComponent → Goals::AvatarComponent. Others keep
  their names (Goals::ProgressRingComponent, Goals::StatusPillComponent,
  Goals::AccountStackComponent, Goals::FundingAccountsBreakdownComponent).
- Stimulus controllers: savings_goal_* → goal_*, savings_goals_filter
  → goals_filter. Stimulus identifiers in data-controller / data-*
  attributes follow.
- Locale keys: savings_goals: → goals: (top level), savings_contributions:
  → goal_contributions: (top level). All t() callers updated.
- AI assistant tool: Assistant::Function::CreateSavingsGoal →
  Assistant::Function::CreateGoal, tool name "create_savings_goal" →
  "create_goal", description / response text updated.
- Sidebar nav label "Savings" → "Goals". Goals/show + index page title
  "Savings" → "Goals". Empty goals_section heading/subtitle dropped
  (duplicated the page title post-rename).

Original migrations create_savings_goals / create_savings_goal_accounts /
create_savings_contributions remain untouched so historical replay
still works; the rename migration runs on top.
This commit is contained in:
Guillem Arias
2026-05-11 20:08:32 +02:00
parent 560bff87d2
commit 9b61e4a41b
56 changed files with 810 additions and 804 deletions

View File

@@ -1,12 +1,12 @@
class Assistant::Function::CreateSavingsGoal < Assistant::Function
class Assistant::Function::CreateGoal < Assistant::Function
class << self
def name
"create_savings_goal"
"create_goal"
end
def description
<<~INSTRUCTIONS
Creates a savings goal for the user's family.
Creates a goal for the user's family.
Use when the user describes a target they want to save toward e.g.
"vacation in 4 months for $5000", "downpayment for a car next year",
@@ -111,16 +111,16 @@ class Assistant::Function::CreateSavingsGoal < Assistant::Function
end
goal = nil
SavingsGoal.transaction do
goal = family.savings_goals.new(
Goal.transaction do
goal = family.goals.new(
name: name,
target_amount: target_amount,
target_date: target_date,
currency: currencies.first,
notes: notes.presence,
color: SavingsGoal::COLORS.sample
color: Goal::COLORS.sample
)
matched.each { |a| goal.savings_goal_accounts.build(account: a) }
matched.each { |a| goal.goal_accounts.build(account: a) }
goal.save!
create_initial_contribution!(goal, matched, initial)
@@ -133,9 +133,9 @@ class Assistant::Function::CreateSavingsGoal < Assistant::Function
target_amount_formatted: goal.target_amount_money.format,
currency: goal.currency,
target_date: goal.target_date&.iso8601,
url: Rails.application.routes.url_helpers.savings_goal_path(goal),
url: Rails.application.routes.url_helpers.goal_path(goal),
linked_account_names: matched.map(&:name),
message: "Created savings goal '#{goal.name}' (target #{goal.target_amount_money.format}). View it at #{Rails.application.routes.url_helpers.savings_goal_path(goal)}."
message: "Created goal '#{goal.name}' (target #{goal.target_amount_money.format}). View it at #{Rails.application.routes.url_helpers.goal_path(goal)}."
}
rescue ActiveRecord::RecordInvalid => e
error("validation_failed", e.record.errors.full_messages.join("; "))
@@ -151,7 +151,7 @@ class Assistant::Function::CreateSavingsGoal < Assistant::Function
source = matched_accounts.find { |a| a.name == initial["source_account_name"].to_s }
raise ActiveRecord::RecordInvalid.new(goal) unless source
goal.savings_contributions.create!(
goal.goal_contributions.create!(
account: source,
amount: amount,
currency: goal.currency,