Expenses by Category
@php
$totalKategori = $byKategori->sum();
$categoryColors = ['#F43F5E', '#0EA5E9', '#10B981', '#F59E0B', '#8B5CF6']; // Rose, Sky, Emerald, Amber, Violet
@endphp
@forelse($byKategori as $kategori => $total)
@php
$percentage = $totalKategori > 0 ? ($total / $totalKategori) * 100 : 0;
$color = $categoryColors[$loop->index % count($categoryColors)];
@endphp
{{ $kategori ?: 'Uncategorized' }}
{{ number_format($percentage, 1) }}%
Rp {{ number_format($total, 0, ',', '.') }}
@empty
No expense data
@endforelse
Monthly Trend
@php
$sortedBulan = $byBulan->sortKeys();
$last3Months = $sortedBulan->take(-3);
$globalMax = $last3Months->reduce(function ($carry, $item) {
return max($carry, $item['pemasukkan'], $item['pengeluaran']);
}, 0);
@endphp
@if($last3Months->count() > 0)
@foreach($last3Months as $bulan => $data)
Rp {{ number_format($data['pemasukkan'], 0, ',', '.') }}
Rp {{ number_format($data['pengeluaran'], 0, ',', '.') }}
{{ \Carbon\Carbon::parse($bulan)->format('M') }}
@endforeach
@else
No monthly data
@endif