Remove unused SimpleFin account type mapping logic

- Remove map_simplefin_type_to_accountable_type method (no longer needed)
- Remove create_from_simplefin_account method (manual setup only)
- Simplify account type selection UI to not pre-select defaults
- Update processor to log error if account missing (safety check)
- All account creation now goes through manual user selection flow
This commit is contained in:
Sholom Ber
2025-08-07 15:38:26 -04:00
parent 0c14cca029
commit 00cb130ef0
3 changed files with 4 additions and 52 deletions

View File

@@ -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

View File

@@ -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