Centralize investment_contributions_category logic and update references for streamlined handling.

This commit is contained in:
luckyPipewrench
2026-01-20 17:51:36 -05:00
parent 480e53710a
commit a75cb816c7
3 changed files with 8 additions and 2 deletions

View File

@@ -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.investment_contributions_name)
auto_category = account.family.investment_contributions_category
end
# Set investment activity label, kind, and category if detected

View File

@@ -79,6 +79,12 @@ class Family < ApplicationRecord
@income_statement ||= IncomeStatement.new(self)
end
# Returns the Investment Contributions category for this family, or nil if not found.
# This is a bootstrapped category used for auto-categorizing transfers to investment accounts.
def investment_contributions_category
categories.find_by(name: Category.investment_contributions_name)
end
def investment_statement
@investment_statement ||= InvestmentStatement.new(self)
end

View File

@@ -43,7 +43,7 @@ class Transfer::Creator
end
def investment_contributions_category
source_account.family.categories.find_by(name: Category.investment_contributions_name)
source_account.family.investment_contributions_category
end
def inflow_transaction