mirror of
https://github.com/we-promise/sure.git
synced 2026-04-14 17:44:07 +00:00
* Add tests and update logic for processing SimpleFIN investment transactions - Added `SimplefinAccount::Transactions::ProcessorInvestmentTest` to validate dividend transaction processing, transaction linking, and stale linkage repairs. - Enhanced `SimplefinItem#process_accounts` with stale linkage repair logic and detailed logging for unlinked accounts with transactions. - Updated `SimplefinAccount::Transactions::Processor` for improved logging and error handling during transaction processing. - Adjusted `SimplefinItem::Importer` to log detailed account and transaction information and use extended sync windows for investment accounts. * Refactor `SimplefinItem#process_accounts` to use direct queries for fresh data and streamline stale linkage repair logic; update tests for improved coverage and clarity. * Improve stale linkage repair logic in `SimplefinItem#repair_stale_linkages` - Updated to handle multiple linked accounts matching the same unlinked account by selecting the first match. - Added detailed logging to warn about multiple matches for easier debugging. * Include `:linked_account` in `SimplefinItem#process_accounts` queries for more comprehensive account data processing. * Expand `merge_transactions` logic with composite key fallback for deduplication; document edge cases. --------- Co-authored-by: Josh Waldrep <joshua.waldrep5+github@gmail.com>
34 lines
1.5 KiB
Ruby
34 lines
1.5 KiB
Ruby
# SimpleFin Investment transactions processor
|
|
#
|
|
# NOTE: SimpleFIN transactions (dividends, contributions, etc.) for investment accounts
|
|
# are already processed by SimplefinAccount::Transactions::Processor, which handles ALL
|
|
# account types including investments. That processor uses SimplefinEntry::Processor
|
|
# which captures full metadata (merchant, notes, extra data).
|
|
#
|
|
# This processor is intentionally a no-op for transactions to avoid:
|
|
# 1. Duplicate processing of the same transactions
|
|
# 2. Overwriting richer data with less complete data
|
|
#
|
|
# Unlike Plaid (which has a separate investment_transactions endpoint), SimpleFIN returns
|
|
# all transactions in a single `transactions` array regardless of account type.
|
|
#
|
|
# Holdings are processed separately by SimplefinAccount::Investments::HoldingsProcessor.
|
|
class SimplefinAccount::Investments::TransactionsProcessor
|
|
def initialize(simplefin_account)
|
|
@simplefin_account = simplefin_account
|
|
end
|
|
|
|
def process
|
|
# Intentionally a no-op for transactions.
|
|
# SimpleFIN investment transactions are already processed by the regular
|
|
# SimplefinAccount::Transactions::Processor which handles all account types.
|
|
#
|
|
# This avoids duplicate processing and ensures the richer metadata from
|
|
# SimplefinEntry::Processor (merchant, notes, extra) is preserved.
|
|
Rails.logger.debug "SimplefinAccount::Investments::TransactionsProcessor - Skipping (transactions handled by SimplefinAccount::Transactions::Processor)"
|
|
end
|
|
|
|
private
|
|
attr_reader :simplefin_account
|
|
end
|