fix:math for % earnings
This commit is contained in:
@@ -141,7 +141,7 @@ class Holding extends Model
|
|||||||
{
|
{
|
||||||
return $query->selectRaw('COALESCE(market_data.market_value * holdings.quantity, 0) AS total_market_value')
|
return $query->selectRaw('COALESCE(market_data.market_value * holdings.quantity, 0) AS total_market_value')
|
||||||
->selectRaw('COALESCE((market_data.market_value - holdings.average_cost_basis) * holdings.quantity, 0) AS market_gain_dollars')
|
->selectRaw('COALESCE((market_data.market_value - holdings.average_cost_basis) * holdings.quantity, 0) AS market_gain_dollars')
|
||||||
->selectRaw('COALESCE(((market_data.market_value - holdings.average_cost_basis) / holdings.average_cost_basis), 0) AS market_gain_percent');
|
->selectRaw('COALESCE(((market_data.market_value - holdings.average_cost_basis) / holdings.average_cost_basis) * 100, 0) AS market_gain_percent');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopePortfolio($query, $portfolio)
|
public function scopePortfolio($query, $portfolio)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
$isUp = $costBasis <= $marketValue;
|
$isUp = $costBasis <= $marketValue;
|
||||||
$percent = $costBasis ? (($marketValue - $costBasis) / $costBasis) : 0;
|
$percent = $costBasis ? (($marketValue - $costBasis) / $costBasis) * 100 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@endphp
|
@endphp
|
||||||
|
|||||||
@@ -78,7 +78,10 @@ new class extends Component {
|
|||||||
{{ Number::currency($row->market_gain_dollars ?? 0) }}
|
{{ Number::currency($row->market_gain_dollars ?? 0) }}
|
||||||
@endscope
|
@endscope
|
||||||
@scope('cell_market_gain_percent', $row)
|
@scope('cell_market_gain_percent', $row)
|
||||||
<x-gain-loss-arrow-badge :percent="$row->market_gain_percent" />
|
<x-gain-loss-arrow-badge
|
||||||
|
:cost-basis="$row->average_cost_basis"
|
||||||
|
:market-value="$row->market_data->market_value"
|
||||||
|
/>
|
||||||
@endscope
|
@endscope
|
||||||
@scope('cell_market_data_market_value', $row)
|
@scope('cell_market_data_market_value', $row)
|
||||||
{{ Number::currency($row->market_data_market_value ?? 0) }}
|
{{ Number::currency($row->market_data_market_value ?? 0) }}
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ new class extends Component {
|
|||||||
|
|
||||||
{{ $holding->market_data?->name }} ({{ $holding->symbol }})
|
{{ $holding->market_data?->name }} ({{ $holding->symbol }})
|
||||||
|
|
||||||
<x-gain-loss-arrow-badge :percent="$holding->market_gain_percent" />
|
<x-gain-loss-arrow-badge
|
||||||
|
:cost-basis="$holding->average_cost_basis"
|
||||||
|
:market-value="$holding->market_data->market_value"
|
||||||
|
/>
|
||||||
|
|
||||||
</x-slot:value>
|
</x-slot:value>
|
||||||
<x-slot:sub-value>
|
<x-slot:sub-value>
|
||||||
|
|||||||
Reference in New Issue
Block a user