@extends('pdf.layout') @section('content') @php $m = fn ($v) => number_format((float) $v, 2); $methods = collect($summary['payment_methods'] ?? [])->filter(fn ($d) => ($d['count'] ?? 0) > 0); $total = $sales->sum('total_amount'); $count = $sales->count(); $unpaid = $sales->where('payment_status', '!=', 'paid'); $label = fn ($method) => $methodNames[$method] ?? ucwords(str_replace('_', ' ', (string) $method)); @endphp
Total sales MWK {{ $m($total) }} {{ $count }} {{ \Illuminate\Support\Str::plural('transaction', $count) }} |
Average sale MWK {{ $m($count ? $total / $count : 0) }} {{ rtrim(rtrim(number_format((float) $sales->sum('total_items'), 2), '0'), '.') }} items sold |
Top payment method {{ $methods->count() ? $label($methods->sortByDesc('total')->keys()->first()) : '-' }} {{ $methods->count() ? 'MWK ' . $m($methods->max('total')) : 'no sales' }} |
Not fully paid {{ $unpaid->count() }} MWK {{ $m($unpaid->sum('total_amount')) }} |
| Method | Sales | Amount (MWK) | Share |
|---|---|---|---|
| {{ $label($method) }} | {{ $d['count'] }} | {{ $m($d['total']) }} | {{ $methods->sum('total') > 0 ? number_format($d['total'] / $methods->sum('total') * 100, 1) . '%' : '-' }} |
| Total | {{ $methods->sum('count') }} | {{ $m($methods->sum('total')) }} |
A split sale is counted under each method it was paid with.
@endif| Invoice | Date | Customer | Products | Items | Payment | Status | Cashier | Total (MWK) |
|---|---|---|---|---|---|---|---|---|
| {{ $s->invoice_no ?? 'INV-' . str_pad($s->id, 5, '0', STR_PAD_LEFT) }} | {{ $s->created_at->format('d M y H:i') }} | {{ $s->customer_name ?: 'Walk-in' }} | {{ $s->items->take(4)->map(fn ($i) => (optional($i->product)->name ?? 'Deleted product') . ' x' . rtrim(rtrim(number_format((float) $i->quantity, 2), '0'), '.'))->implode(', ') }}@if($s->items->count() > 4), +{{ $s->items->count() - 4 }} more@endif | {{ rtrim(rtrim(number_format((float) $s->total_items, 2), '0'), '.') }} | @if($s->payment_method === 'split' && $s->payments->count()) {{ $s->payments->map(fn ($p) => $label($p->method) . ' ' . $m($p->amount))->implode(' + ') }} @else {{ $label($s->payment_method) }} @endif | {{ ucfirst($s->payment_status) }} | {{ $s->register->user->name ?? '-' }} | {{ $m($s->total_amount) }} |
| Total ({{ $count }} {{ \Illuminate\Support\Str::plural('sale', $count) }}) | {{ rtrim(rtrim(number_format((float) $sales->sum('total_items'), 2), '0'), '.') }} | {{ $m($total) }} | ||||||