@extends('admin.layout.interface') @section('content')

Shipment Report

Report Filter

@if (!empty($hasRange)) @endif
@if (!empty($hasRange))
Shipments

{{ number_format($totalShipments) }}

{{ $rangeLabel }}
Customers

{{ number_format($customerCount) }}

With shipments
Invoices

{{ number_format($totalInvoices) }}

Linked invoices
Total Charges

{{ number_format($totalCharges, 2) }}

{{ $rangeLabel }}
@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; @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 @endif
@endsection