From 43a403e43121eda370a18dd05fb3e4e8dcc03a3a Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Sat, 24 May 2025 19:16:55 -0400 Subject: [PATCH] Increase specificity of filter when fetching Plaid liabilities --- app/models/plaid_item/accounts_snapshot.rb | 5 ++++- test/models/plaid_item/accounts_snapshot_test.rb | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/plaid_item/accounts_snapshot.rb b/app/models/plaid_item/accounts_snapshot.rb index dcf5957a..dc62d8ff 100644 --- a/app/models/plaid_item/accounts_snapshot.rb +++ b/app/models/plaid_item/accounts_snapshot.rb @@ -92,7 +92,10 @@ class PlaidItem::AccountsSnapshot def can_fetch_liabilities? plaid_item.supports_product?("liabilities") && - accounts.any? { |a| [ "credit", "loan" ].include?(a.type) } + accounts.any? do |a| + a.type == "credit" && a.subtype == "credit card" || + a.type == "loan" && (a.subtype == "mortgage" || a.subtype == "student") + end end def liabilities_data diff --git a/test/models/plaid_item/accounts_snapshot_test.rb b/test/models/plaid_item/accounts_snapshot_test.rb index 467497f7..433b3fe3 100644 --- a/test/models/plaid_item/accounts_snapshot_test.rb +++ b/test/models/plaid_item/accounts_snapshot_test.rb @@ -112,7 +112,8 @@ class PlaidItem::AccountsSnapshotTest < ActiveSupport::TestCase @snapshot.expects(:accounts).returns([ OpenStruct.new( account_id: "123", - type: "credit" + type: "loan", + subtype: "student" ) ]).at_least_once