1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-25 08:09:38 +02:00
Maybe/app/models/investment.rb
Zach Gollwitzer 49c353e10c
Plaid portfolio sync algorithm and calculation improvements (#1526)
* Start tests rework

* Cash balance on schema

* Add reverse syncer

* Reverse balance sync with holdings

* Reverse holdings sync

* Reverse holdings sync should work with only trade entries

* Consolidate brokerage cash

* Add forward sync option

* Update new balance info after syncs

* Intraday balance calculator and sync fixes

* Show only balance for trade entries

* Tests passing

* Update Gemfile.lock

* Cleanup, performance improvements

* Remove account reloads for reliable sync outputs

* Simplify valuation view logic

* Special handling for Plaid cash holding
2024-12-10 17:41:20 -05:00

35 lines
830 B
Ruby

class Investment < ApplicationRecord
include Accountable
SUBTYPES = [
[ "Brokerage", "brokerage" ],
[ "Pension", "pension" ],
[ "Retirement", "retirement" ],
[ "401(k)", "401k" ],
[ "Traditional 401(k)", "traditional_401k" ],
[ "Roth 401(k)", "roth_401k" ],
[ "529 Plan", "529_plan" ],
[ "Health Savings Account", "hsa" ],
[ "Mutual Fund", "mutual_fund" ],
[ "Traditional IRA", "traditional_ira" ],
[ "Roth IRA", "roth_ira" ],
[ "Angel", "angel" ]
].freeze
def color
"#1570EF"
end
def icon
"line-chart"
end
def post_sync
broadcast_replace_to(
account,
target: "chart_account_#{account.id}",
partial: account.plaid_account_id.present? ? "investments/chart" : "accounts/show/chart",
locals: { account: account }
)
end
end