@php $grouped = $data->groupBy(fn($item) => $item->category->name ?? 'Uncategorized'); $itemsSubtotal = (float) ($summary['subtotal_without_tax'] ?? $data->sum('total_sales')); $totalQty = (int) ($summary['total_quantity'] ?? $data->sum('total_quantity')); $serviceCharges = (float) ($summary['service_charges'] ?? round($itemsSubtotal * 0.07)); $gstTax = (float) ($summary['gst_tax'] ?? 0); $praTax = (float) ($summary['pra_tax'] ?? 0); $grandTotal = (float) ($summary['grand_total'] ?? ($itemsSubtotal + $serviceCharges + $gstTax + $praTax)); $todayServiceCharges = (float) ($summary['today_service_charges'] ?? $serviceCharges); $todayPraTax = (float) ($summary['today_pra_tax'] ?? $praTax); $filterLabel = ucfirst(str_replace(['_', '-'], ' ', $activeFilter ?? 'Current Shift')); @endphp
@include('pdf.partials.pdf-branding')

Item Sales Report

Period: {{ $filterLabel }} @if(!empty($categoryType) && $categoryType !== 'all')  |  Station: {{ strtoupper($categoryType) }} @endif  |  Generated on: {{ now()->format('d M Y, h:i A') }}
{{-- 4 KPI Summary Tiles --}}
Subtotal (Excl. Tax & Service)
Rs {{ number_format($itemsSubtotal, 2) }}
Without Service & PRA Tax ({{ number_format($totalQty) }} Items)
Service (7%)
Rs {{ number_format($serviceCharges, 2) }}
Today's Service (7%): Rs {{ number_format($todayServiceCharges, 2) }}
PRA Tax (8%)
Rs {{ number_format($praTax, 2) }}
Today's PRA (8%) Tax: Rs {{ number_format($todayPraTax, 2) }}
Grand Total (Incl. Tax)
Rs {{ number_format($grandTotal, 2) }}
Including Service (7%) & PRA (8%)
@if($data->count() > 0) @foreach($grouped as $categoryName => $records) @php $catQty = $records->sum('total_quantity'); $catSales = $records->sum('total_sales'); @endphp

{{ $categoryName }}

@foreach($records as $index => $record) @php $unitPrice = $record->total_quantity > 0 ? ($record->total_sales / $record->total_quantity) : 0; @endphp @endforeach
# Order # Product Unit Price Qty Sold Subtotal (Rs)
{{ $index + 1 }} #{{ $record->order_id }} {{ $record->product->name ?? 'N/A' }} Rs {{ number_format($unitPrice, 2) }} {{ number_format($record->total_quantity) }} Rs {{ number_format($record->total_sales, 2) }}
{{ $categoryName }} Subtotal (Excl. Tax): {{ number_format($catQty) }} Rs {{ number_format($catSales, 2) }}
@endforeach
Financial Summary
Total Quantity Sold {{ number_format($totalQty) }} Items
Order Subtotal (Excl. Tax & Service) Rs {{ number_format($itemsSubtotal, 2) }}
Service Charges (7%) Rs {{ number_format($serviceCharges, 2) }}
PRA Tax (8%) Rs {{ number_format($praTax, 2) }}
Grand Total (Including Tax & Service) Rs {{ number_format($grandTotal, 2) }}
@else

No item sales found for the selected period.

@endif