Sales History

{{-- ── PAGE HEADING ── --}}

Sales History

All recorded transactions

{{ $sales->total() }} total sales
{{-- ── FILTERS ── --}}
@if(request('start') || request('end')) Clear @endif
{{-- ── PAYMENT SUMMARY ── --}} @php $dailyTotals = []; $grandTotal = 0; foreach ($sales as $sale) { foreach ($sale->payments ?? [] as $payment) { $method = $payment['method'] ?? 'Unknown'; $amount = (float) ($payment['amount'] ?? 0); $dailyTotals[$method] = ($dailyTotals[$method] ?? 0) + $amount; $grandTotal += $amount; } } @endphp @if (!empty($dailyTotals))
Payment summary  ·  {{ $sales->total() }} sales
@foreach ($dailyTotals as $method => $amount)
{{ ucfirst($method) }}
KSh {{ number_format($amount, 2) }}
@endforeach
Grand Total
KSh {{ number_format($grandTotal, 2) }}
@endif {{-- ── TABLE ── --}}
@forelse ($sales as $sale) @empty @endforelse
Ref # Date Client Payment Trans. Code Total Status Ready Cashier Actions
{{ $sale->reference_no }} {{ $sale->sale_date->format('d M Y') }}
{{ $sale->sale_date->format('H:i') }}
@if ($sale->client) {{ $sale->client->name }} @if ($sale->vehicle)
{{ $sale->vehicle->plate_number }} @endif @else Walk-in @endif
@php $methods = collect($sale->payments ?? []) ->pluck('method')->unique() ->map(fn($m) => ucfirst($m)) ->join(', '); @endphp {{ $methods ?: '—' }} @php $transCode = collect($sale->payments ?? []) ->first(fn($p) => strtolower($p['method'] ?? '') === 'm-pesa')['transaction_no'] ?? collect($sale->payments ?? [])->first()['transaction_no'] ?? null; @endphp @if ($transCode) {{ $transCode }} @else @endif KSh {{ number_format($sale->total, 2) }} @php $badgeClass = match($sale->status) { 'completed' => 'badge-completed', 'partial' => 'badge-partial', 'pending' => 'badge-pending', default => 'badge-cancelled', }; @endphp {{ ucfirst($sale->status) }} @if ($sale->is_ready) Ready @else @endif {{ $sale->cashier->name ?? '—' }}
View Print @if (in_array($sale->status, ['pending', 'partial'])) Edit @endif

No sales found in this period.

{{-- ── PAGINATION ── --}}
{{ $sales->appends(request()->query())->links() }}