diff --git a/app/models/balance/reverse_calculator.rb b/app/models/balance/reverse_calculator.rb index 78a372cf..6a2ba70b 100644 --- a/app/models/balance/reverse_calculator.rb +++ b/app/models/balance/reverse_calculator.rb @@ -24,7 +24,7 @@ class Balance::ReverseCalculator < Balance::BaseCalculator # If date is today, we don't distinguish cash vs. total since provider's are inconsistent with treatment # of the cash component. Instead, just set the balance equal to the "total value" reported by the provider if date == Date.current - @balances << build_balance(date, account.balance, 0) + @balances << build_balance(date, account.cash_balance, account.balance - account.cash_balance) else @balances << build_balance(date, current_cash_balance, holdings_value) end diff --git a/app/models/plaid_investment_sync.rb b/app/models/plaid_investment_sync.rb index 8a95d1e2..34f0d7e4 100644 --- a/app/models/plaid_investment_sync.rb +++ b/app/models/plaid_investment_sync.rb @@ -25,15 +25,15 @@ class PlaidInvestmentSync # Maybe clearly distinguishes between "brokerage cash" vs. "holdings (i.e. invested cash)" # For this reason, we must back out cash + cash equivalent holdings from the reported cash balance to avoid double counting def normalize_cash_balance! - non_cash_holdings = holdings.reject do |h| - _internal_security, plaid_security = get_security(h.security_id, securities) - plaid_security&.type == "cash" + excludable_cash_holdings = holdings.select do |h| + internal_security, plaid_security = get_security(h.security_id, securities) + internal_security.present? && (plaid_security&.is_cash_equivalent || plaid_security&.type == "cash") end - non_cash_holdings_value = non_cash_holdings.sum { |h| h.quantity * h.institution_price } + excludable_cash_holdings_value = excludable_cash_holdings.sum { |h| h.quantity * h.institution_price } plaid_account.account.update!( - cash_balance: plaid_account.account.cash_balance - non_cash_holdings_value + cash_balance: plaid_account.account.cash_balance - excludable_cash_holdings_value ) end diff --git a/app/views/accounts/show/_chart.html.erb b/app/views/accounts/show/_chart.html.erb index 1661554c..08e67e84 100644 --- a/app/views/accounts/show/_chart.html.erb +++ b/app/views/accounts/show/_chart.html.erb @@ -28,7 +28,7 @@ Period.as_options, { selected: period.key }, data: { "auto-submit-form-target": "auto" }, - class: "bg-container border border-secondary font-medium rounded-lg px-3 py-2 text-sm pr-7 cursor-pointer text-primary focus:outline-hidden focus:ring-0" %> + class: "bg-container border border-secondary rounded-lg px-3 py-2 text-sm pr-7 cursor-pointer text-primary focus:outline-hidden focus:ring-0" %> <% end %>