1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-09 15:35:22 +02:00

Fix today's cash balance

This commit is contained in:
Zach Gollwitzer 2025-05-08 11:24:40 -04:00
parent 89cfac4d95
commit 9c7bd588cd
3 changed files with 7 additions and 7 deletions

View file

@ -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

View file

@ -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

View file

@ -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" %>
</div>
<% end %>
</div>