mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 20:14:08 +00:00
Add investment activity detection, labels, and exclusions
- Introduced `InvestmentActivityDetector` to mark internal investment activity as excluded from cashflow and assign appropriate labels. - Added `exclude_from_cashflow` flag to `entries` and `investment_activity_label` to `transactions` with migrations. - Implemented rake tasks to backfill and clear investment activity labels. - Updated `PlaidAccount::Investments::TransactionsProcessor` to map Plaid transaction types to labels. - Included comprehensive test coverage for new functionality.
This commit is contained in:
13
db/migrate/20260110120000_add_investment_cashflow_support.rb
Normal file
13
db/migrate/20260110120000_add_investment_cashflow_support.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class AddInvestmentCashflowSupport < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
# Flag for excluding from cashflow (user-controllable)
|
||||
# Used for internal investment activity like fund swaps
|
||||
add_column :entries, :exclude_from_cashflow, :boolean, default: false, null: false
|
||||
add_index :entries, :exclude_from_cashflow
|
||||
|
||||
# Holdings snapshot for comparison (provider-agnostic)
|
||||
# Used to detect internal investment activity by comparing holdings between syncs
|
||||
add_column :accounts, :holdings_snapshot_data, :jsonb
|
||||
add_column :accounts, :holdings_snapshot_at, :datetime
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
class AddInvestmentActivityLabelToTransactions < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
# Label for investment activity type (Buy, Sell, Sweep In, Dividend, etc.)
|
||||
# Provides human-readable context for why a transaction is excluded from cashflow
|
||||
add_column :transactions, :investment_activity_label, :string
|
||||
add_index :transactions, :investment_activity_label
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user