diff --git a/app/models/account.rb b/app/models/account.rb index a59024ccd..ba1d3ea39 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -73,21 +73,6 @@ class Account < ApplicationRecord account end - def create_from_simplefin_account(simplefin_account) - account_type = map_simplefin_type_to_accountable_type(simplefin_account.account_type, account_name: simplefin_account.name) - - attributes = { - family: simplefin_account.simplefin_item.family, - name: simplefin_account.name, - balance: simplefin_account.current_balance || simplefin_account.available_balance || 0, - currency: simplefin_account.currency, - accountable_type: account_type, - accountable_attributes: build_accountable_attributes(simplefin_account, account_type), - simplefin_account_id: simplefin_account.id - } - - create_and_sync(attributes) - end def create_from_simplefin_account_with_type(simplefin_account, account_type) attributes = { @@ -117,39 +102,6 @@ class Account < ApplicationRecord create_and_sync(attributes) end - def map_simplefin_type_to_accountable_type(simplefin_type, account_name: nil) - # First try to map by explicit type if provided - case simplefin_type&.downcase - when "checking", "savings" - return "Depository" - when "credit", "credit card" - return "CreditCard" - when "investment", "brokerage" - return "Investment" - when "loan", "mortgage" - return "Loan" - end - - # If type is unknown, try to infer from account name - if account_name.present? - name_lower = account_name.downcase - case name_lower - when /checking|chk/ - return "Depository" - when /savings|save/ - return "Depository" - when /credit|card/ - return "CreditCard" - when /investment|invest|brokerage|401k|ira/ - return "Investment" - when /loan|mortgage|auto|personal/ - return "Loan" - end - end - - # Default to OtherAsset if we can't determine type - "OtherAsset" - end private diff --git a/app/models/simplefin_account/processor.rb b/app/models/simplefin_account/processor.rb index 39ec66110..9508d2344 100644 --- a/app/models/simplefin_account/processor.rb +++ b/app/models/simplefin_account/processor.rb @@ -15,8 +15,9 @@ class SimplefinAccount::Processor def ensure_account_exists return if simplefin_account.account.present? - account = Account.create_from_simplefin_account(simplefin_account) - simplefin_account.update!(account: account) + # This should not happen in normal flow since accounts are created manually + # during setup, but keeping as safety check + Rails.logger.error("SimpleFin account #{simplefin_account.id} has no associated Account - this should not happen after manual setup") end def process_transactions diff --git a/app/views/simplefin_items/setup_accounts.html.erb b/app/views/simplefin_items/setup_accounts.html.erb index 7ee45c377..cebceb861 100644 --- a/app/views/simplefin_items/setup_accounts.html.erb +++ b/app/views/simplefin_items/setup_accounts.html.erb @@ -50,8 +50,7 @@ <%= label_tag "account_types[#{simplefin_account.id}]", "Account Type:", class: "block text-sm font-medium text-primary mb-2" %> <%= select_tag "account_types[#{simplefin_account.id}]", - options_for_select(@account_type_options, - Account.map_simplefin_type_to_accountable_type(simplefin_account.account_type, account_name: simplefin_account.name)), + options_for_select(@account_type_options), { class: "w-full px-3 py-2 border border-primary rounded-lg focus:ring-2 focus:ring-blue-600 focus:border-blue-600", data: { action: "change->account-type-selector#updateSubtype"