Skip to content

Commit

Permalink
Attempt to sync transactions regardless of main item type
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgoll committed Nov 25, 2024
1 parent c1034e6 commit 03e92e6
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions app/models/plaid_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ def destroy_later
DestroyJob.perform_later(self)
end

def has_investment_accounts?
available_products.include?("investments") || billed_products.include?("investments")
end

def has_liability_accounts?
available_products.include?("liabilities") || billed_products.include?("liabilities")
end

private
def fetch_and_load_plaid_data
item = plaid_provider.get_item(access_token).item
Expand All @@ -72,7 +64,7 @@ def fetch_and_load_plaid_data
internal_plaid_account
end

fetched_transactions = safe_fetch_plaid_data(:get_item_transactions) unless has_investment_accounts?
fetched_transactions = safe_fetch_plaid_data(:get_item_transactions)

if fetched_transactions
transaction do
Expand All @@ -88,7 +80,7 @@ def fetch_and_load_plaid_data
end
end

fetched_investments = safe_fetch_plaid_data(:get_item_investments) if has_investment_accounts?
fetched_investments = safe_fetch_plaid_data(:get_item_investments)

if fetched_investments
transaction do
Expand All @@ -102,7 +94,7 @@ def fetch_and_load_plaid_data
end
end

fetched_liabilities = safe_fetch_plaid_data(:get_item_liabilities) if has_liability_accounts?
fetched_liabilities = safe_fetch_plaid_data(:get_item_liabilities)

if fetched_liabilities
transaction do
Expand Down

0 comments on commit 03e92e6

Please sign in to comment.