@php $grandInvoiceTotal = 0; $grandInvoiceCount = 0; $grandCharges = (float) $totalCharges; @endphp

Darzi Shop — Shipment Report

Period: {{ $rangeLabel }} | Generated: {{ now()->format('d M Y, h:i A') }}
@if(!empty($shipmentNumber))
Shipment Number {{ $shipmentNumber }}
@endif
Shipments {{ number_format($totalShipments) }}
Customers {{ number_format($customerCount) }}
Invoices {{ number_format($totalInvoices) }}
Total Charges {{ number_format($totalCharges, 2) }}
@forelse ($groupedByCustomer as $customerIndex => $group) @php $customer = optional($group->first())->customer; $invoices = $group->flatMap(fn ($s) => $s->sales)->unique('id')->values(); $customerInvoiceTotal = (float) $invoices->sum('net_total'); $customerCharges = (float) $group->sum('charges'); $customerCombined = $customerInvoiceTotal + $customerCharges; $grandInvoiceTotal += $customerInvoiceTotal; $grandInvoiceCount += $invoices->count(); @endphp
Sr No. {{ $customerIndex + 1 }}
{{ $customer->name ?? 'Unknown Customer' }}
@foreach ($group as $shipKey => $shipment)
Shipment {{ $shipKey + 1 }}: {{ $shipment->shipment_number }}  |  Date: {{ optional($shipment->shipment_date)->format('Y-m-d') }}  |  Charges: {{ $shipment->charges !== null ? number_format((float) $shipment->charges, 2) : '-' }} @if(!empty($shipment->description))  |  Notes: {{ $shipment->description }} @endif
@endforeach
@forelse ($invoices as $invKey => $sale) @empty @endforelse
Sr No. Name bill no Price
{{ $invKey + 1 }} {{ $invKey === 0 ? ($customer->name ?? '-') : '' }} {{ $sale->bill_no }} {{ number_format((float) $sale->net_total, 0) }}
1 {{ $customer->name ?? '-' }} No invoices
Total Bills Payment {{ number_format($customerInvoiceTotal, 0) }}
Total Shipment Charges {{ number_format($customerCharges, 2) }}
Bills + Shipment {{ number_format($customerCombined, 0) }}
@empty
No shipments found for {{ $rangeLabel }}.
@endforelse @if($groupedByCustomer->isNotEmpty())
Grand Total Bills Payment ({{ $grandInvoiceCount }} invoices) {{ number_format($grandInvoiceTotal, 0) }}
Grand Total Shipment Charges {{ number_format($grandCharges, 2) }}
Grand Total (Bills + Shipment) {{ number_format($grandInvoiceTotal + $grandCharges, 0) }}
@endif