diff --git a/app/models/account/provider_import_adapter.rb b/app/models/account/provider_import_adapter.rb index 28bf61cf9..8232e2a1e 100644 --- a/app/models/account/provider_import_adapter.rb +++ b/app/models/account/provider_import_adapter.rb @@ -155,7 +155,7 @@ class Account::ProviderImportAdapter auto_kind = "funds_movement" elsif detected_label == "Contribution" auto_kind = "investment_contribution" - auto_category = account.family.categories.find_by(name: Category::DEFAULT_INVESTMENT_CONTRIBUTIONS_NAME) + auto_category = account.family.categories.find_by(name: Category.investment_contributions_name) end # Set investment activity label, kind, and category if detected diff --git a/app/models/category.rb b/app/models/category.rb index 3dfb8a809..9a83488fc 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -35,13 +35,10 @@ class Category < ApplicationRecord PAYMENT_COLOR = "#db5a54" TRADE_COLOR = "#e99537" - # Synthetic category name keys for i18n + # Category name keys for i18n UNCATEGORIZED_NAME_KEY = "models.category.uncategorized" OTHER_INVESTMENTS_NAME_KEY = "models.category.other_investments" - - # Default category name for investment contributions (bootstrapped category) - # This is the canonical English name used when seeding categories via bootstrap! - DEFAULT_INVESTMENT_CONTRIBUTIONS_NAME = "Investment Contributions" + INVESTMENT_CONTRIBUTIONS_NAME_KEY = "models.category.investment_contributions" class Group attr_reader :category, :subcategories @@ -117,6 +114,11 @@ class Category < ApplicationRecord I18n.t(OTHER_INVESTMENTS_NAME_KEY) end + # Helper to get the localized name for investment contributions + def investment_contributions_name + I18n.t(INVESTMENT_CONTRIBUTIONS_NAME_KEY) + end + private def default_categories [ @@ -141,7 +143,7 @@ class Category < ApplicationRecord [ "Services", "#7c3aed", "briefcase", "expense" ], [ "Fees", "#6b7280", "receipt", "expense" ], [ "Savings & Investments", "#059669", "piggy-bank", "expense" ], - [ "Investment Contributions", "#0d9488", "trending-up", "expense" ] + [ investment_contributions_name, "#0d9488", "trending-up", "expense" ] ] end end diff --git a/app/models/transfer/creator.rb b/app/models/transfer/creator.rb index 70b143b24..0ac93d8f3 100644 --- a/app/models/transfer/creator.rb +++ b/app/models/transfer/creator.rb @@ -43,7 +43,7 @@ class Transfer::Creator end def investment_contributions_category - source_account.family.categories.find_by(name: Category::DEFAULT_INVESTMENT_CONTRIBUTIONS_NAME) + source_account.family.categories.find_by(name: Category.investment_contributions_name) end def inflow_transaction diff --git a/config/locales/models/category/ca.yml b/config/locales/models/category/ca.yml index 6d1980a6c..310293577 100644 --- a/config/locales/models/category/ca.yml +++ b/config/locales/models/category/ca.yml @@ -4,3 +4,4 @@ ca: category: other_investments: Altres inversions uncategorized: Sense categoria + investment_contributions: Contribucions d'inversió diff --git a/config/locales/models/category/en.yml b/config/locales/models/category/en.yml index dc86eba56..749f80860 100644 --- a/config/locales/models/category/en.yml +++ b/config/locales/models/category/en.yml @@ -4,3 +4,4 @@ en: category: uncategorized: Uncategorized other_investments: Other Investments + investment_contributions: Investment Contributions diff --git a/config/locales/models/category/fr.yml b/config/locales/models/category/fr.yml index 2c9a907a2..eef81bda0 100644 --- a/config/locales/models/category/fr.yml +++ b/config/locales/models/category/fr.yml @@ -4,3 +4,4 @@ fr: category: uncategorized: Non catégorisé other_investments: Autres investissements + investment_contributions: Contributions aux investissements diff --git a/config/locales/models/category/nl.yml b/config/locales/models/category/nl.yml index 9428ab9cf..63edada65 100644 --- a/config/locales/models/category/nl.yml +++ b/config/locales/models/category/nl.yml @@ -4,3 +4,4 @@ nl: category: uncategorized: Ongecategoriseerd other_investments: Overige beleggingen + investment_contributions: Investeringsbijdragen diff --git a/test/test_helper.rb b/test/test_helper.rb index b44fcdeb3..867f19833 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -82,7 +82,7 @@ module ActiveSupport # Ensures the Investment Contributions category exists for a family # Used in transfer tests where this bootstrapped category is required def ensure_investment_contributions_category(family) - family.categories.find_or_create_by!(name: Category::DEFAULT_INVESTMENT_CONTRIBUTIONS_NAME) do |c| + family.categories.find_or_create_by!(name: Category.investment_contributions_name) do |c| c.color = "#0d9488" c.lucide_icon = "trending-up" c.classification = "expense"