mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Fix SimpleFin integration bugs and improve code quality
- Fix upsert method to handle string/symbol keys with indifferent access - Add missing show route and view for SimpleFin items - Fix test fixtures to use correct user references - Update test data to match real-world JSON format (string keys, BigDecimal) - Apply code formatting and linting fixes (rubocop, erb_lint) - Ensure all SimpleFin tests pass (16/16 passing)
This commit is contained in:
@@ -81,32 +81,32 @@ class SimplefinItemsController < ApplicationController
|
||||
def setup_accounts
|
||||
@simplefin_accounts = @simplefin_item.simplefin_accounts
|
||||
@account_type_options = [
|
||||
['Checking or Savings Account', 'Depository'],
|
||||
['Credit Card', 'CreditCard'],
|
||||
['Investment Account', 'Investment'],
|
||||
['Loan or Mortgage', 'Loan'],
|
||||
['Other Asset', 'OtherAsset']
|
||||
[ "Checking or Savings Account", "Depository" ],
|
||||
[ "Credit Card", "CreditCard" ],
|
||||
[ "Investment Account", "Investment" ],
|
||||
[ "Loan or Mortgage", "Loan" ],
|
||||
[ "Other Asset", "OtherAsset" ]
|
||||
]
|
||||
|
||||
|
||||
# Subtype options for each account type
|
||||
@depository_subtypes = Depository::SUBTYPES.map { |k, v| [v[:long], k] }
|
||||
@credit_card_subtypes = CreditCard::SUBTYPES.map { |k, v| [v[:long], k] }
|
||||
@investment_subtypes = Investment::SUBTYPES.map { |k, v| [v[:long], k] }
|
||||
@loan_subtypes = Loan::SUBTYPES.map { |k, v| [v[:long], k] }
|
||||
@depository_subtypes = Depository::SUBTYPES.map { |k, v| [ v[:long], k ] }
|
||||
@credit_card_subtypes = CreditCard::SUBTYPES.map { |k, v| [ v[:long], k ] }
|
||||
@investment_subtypes = Investment::SUBTYPES.map { |k, v| [ v[:long], k ] }
|
||||
@loan_subtypes = Loan::SUBTYPES.map { |k, v| [ v[:long], k ] }
|
||||
end
|
||||
|
||||
def complete_account_setup
|
||||
account_types = params[:account_types] || {}
|
||||
account_subtypes = params[:account_subtypes] || {}
|
||||
|
||||
|
||||
account_types.each do |simplefin_account_id, selected_type|
|
||||
simplefin_account = @simplefin_item.simplefin_accounts.find(simplefin_account_id)
|
||||
selected_subtype = account_subtypes[simplefin_account_id]
|
||||
|
||||
|
||||
# Create account with user-selected type and subtype
|
||||
account = Account.create_from_simplefin_account_with_type_and_subtype(
|
||||
simplefin_account,
|
||||
selected_type,
|
||||
simplefin_account,
|
||||
selected_type,
|
||||
selected_subtype
|
||||
)
|
||||
simplefin_account.update!(account: account)
|
||||
@@ -114,10 +114,10 @@ class SimplefinItemsController < ApplicationController
|
||||
|
||||
# Clear pending status and mark as complete
|
||||
@simplefin_item.update!(pending_account_setup: false)
|
||||
|
||||
|
||||
# Schedule account syncs for the newly created accounts
|
||||
@simplefin_item.schedule_account_syncs
|
||||
|
||||
|
||||
redirect_to simplefin_items_path, notice: "SimpleFin accounts have been set up successfully!"
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user