add empty data help text

This commit is contained in:
hackerESQ
2024-09-06 23:15:43 -05:00
parent d911d05e9a
commit 96a408b32d
7 changed files with 76 additions and 10 deletions
+7 -3
View File
@@ -177,9 +177,13 @@ class Holding extends Model
->first();
$total_quantity = $query->qty_purchases - $query->qty_sales;
$average_cost_basis = $query->qty_purchases > 0
? $query->cost_basis / $query->qty_purchases
: 0;
$average_cost_basis = (
$query->qty_purchases > 0
&& $total_quantity > 0
)
? $query->cost_basis / $query->qty_purchases
: 0;
// pull dividend data joined with holdings/transactions
$dividends = Dividend::select('holdings.portfolio_id', 'dividends.date', 'dividends.symbol', 'dividends.dividend_amount')
+15
View File
@@ -110,6 +110,21 @@ class Transaction extends Model
return $query->where('symbol', $symbol);
}
public function scopeBuy($query)
{
return $query->where('transaction_type', 'BUY');
}
public function scopeSell($query)
{
return $query->where('transaction_type', 'SELL');
}
public function scopeBeforeDate($query, $date)
{
return $query->whereDate('date', '<', $date);
}
public function scopeMyTransactions()
{
return $this->whereHas('portfolio', function ($query) {