This commit is contained in:
hackerESQ
2025-08-11 20:39:54 -05:00
parent 97b13063d9
commit 03089ed1b3
+3 -3
View File
@@ -119,12 +119,12 @@ class DailyChange extends Model
WHEN transactions.transaction_type = 'SELL'
THEN transactions.sale_price_base - transactions.cost_basis_base
END
) * transactions.quantity * COALESCE(cr.rate, 1) AS realized_gain_loss"),
) * transactions.quantity * COALESCE(cr.rate, 1) AS realized_gain_dollars"),
'cb')
->selectRaw('SUM(cb.realized_gain_loss)')
->selectRaw('SUM(cb.realized_gain_dollars)')
->whereColumn('cb.date', '<=', 'daily_change.date')
->whereColumn('cb.portfolio_id', '=', 'daily_change.portfolio_id');
}, 'realized_gain_loss')
}, 'realized_gain_dollars')
->selectSub(function ($query) use ($dividendSub) { // todo: maybe costbasis uses this model?
$query->fromSub($dividendSub, 'd')
->selectRaw('SUM(d.total_dividends_earned)')