fix: transactions table

This commit is contained in:
hackerESQ
2025-10-06 20:01:29 -05:00
parent c6032c5b66
commit 04f1d8cbcd
@@ -24,13 +24,13 @@ class TransactionsTable extends DataTableComponent
return Transaction::query() return Transaction::query()
->with(['portfolio', 'market_data']) ->with(['portfolio', 'market_data'])
->myTransactions() ->myTransactions()
->addSelect(['portfolio_id', 'transaction_type', 'split']) ->addSelect(['portfolio_id', 'transaction_type', 'split', 'cost_basis'])
->selectRaw(' ->selectRaw('
CASE (CASE
WHEN transaction_type = \'SELL\' WHEN transaction_type = \'SELL\'
THEN COALESCE(transactions.sale_price - transactions.cost_basis, 0) THEN COALESCE(transactions.sale_price, 0)
ELSE COALESCE(market_data.market_value - transactions.cost_basis, 0) ELSE COALESCE(market_data.market_value, 0)
END AS gain_dollars'); END) - COALESCE(transactions.cost_basis, 0) AS gain_dollars');
} }
public function configure(): void public function configure(): void