Skip to content

armgit / maybe

Public Imported from GitHub
0

The personal finance app for everyone

Safely call liability object when syncing

Zach Gollwitzerc309c8abf894
diff --git a/app/models/plaid_item.rb b/app/models/plaid_item.rb
index 5492edaf..5abcff8f 100644
--- a/app/models/plaid_item.rb
+++ b/app/models/plaid_item.rb
@@ -107,9 +107,9 @@ class PlaidItem < ApplicationRecord
if fetched_liabilities
transaction do
internal_plaid_accounts.each do |internal_plaid_account|
- credit = fetched_liabilities.credit.find { |l| l.account_id == internal_plaid_account.plaid_id }
- mortgage = fetched_liabilities.mortgage.find { |l| l.account_id == internal_plaid_account.plaid_id }
- student = fetched_liabilities.student.find { |l| l.account_id == internal_plaid_account.plaid_id }
+ credit = fetched_liabilities.credit&.find { |l| l.account_id == internal_plaid_account.plaid_id }
+ mortgage = fetched_liabilities.mortgage&.find { |l| l.account_id == internal_plaid_account.plaid_id }
+ student = fetched_liabilities.student&.find { |l| l.account_id == internal_plaid_account.plaid_id }
internal_plaid_account.sync_credit_data!(credit) if credit
internal_plaid_account.sync_mortgage_data!(mortgage) if mortgage