@php $topTotal = $topItems->sum('total_amount'); $topPct = $grandTotal > 0 ? round($topTotal / $grandTotal * 100, 1) : 0; $maxAmt = $topItems->max('total_amount'); @endphp {{-- Stat cards --}}
Grand Total
{{ number_format($grandTotal, 2) }}
all categories
Top {{ $limit }} Spend
{{ number_format($topTotal, 2) }}
{{ $topPct }}% of total
#1 Item
{{ $topItems->first()?->expense_item_name ?? '—' }}
{{ number_format($topItems->first()?->total_amount ?? 0, 2) }}
Total Occurrences
{{ number_format($topItems->sum('occurrence_count')) }}
across top {{ $limit }}
Top {{ $limit }} Expense Items Ranked by total amount
@if($topItems->isEmpty())
No expense items found.
@else @foreach($topItems as $i => $row) @php $barPct = $maxAmt > 0 ? round($row->total_amount / $maxAmt * 100) : 0; @endphp @endforeach
Rank Expense Item Occurrences Total Amount % of Total Amount Bar
@if($i === 0) #1 @elseif($i === 1) #2 @elseif($i === 2) #3 @else #{{ $i + 1 }} @endif {{ $row->expense_item_name }} {{ number_format($row->occurrence_count) }} {{ number_format($row->total_amount, 2) }} {{ $row->percentage }}%
@endif