@extends('layouts.app') @section('title', 'Status Update Report') @section('content')

Status Update Report

View all shipment status updates

@if(session('success')) @endif @if(session('error')) @endif
Total Updates

{{ $statusUpdates->count() }}

Unique Shipments

{{ $uniqueTrackingNumbers }}

Status Types

{{ $statusCounts->count() }}

@if($statusCounts->count() > 0)
Status Breakdown
@foreach($statusCounts as $status => $count)
{{ ucfirst(str_replace('_', ' ', $status)) }} {{ $count }}
@endforeach
@endif
@if($statusUpdates->count() === 0)
No status updates found

No status updates found for the selected date range.

@else
@foreach($statusUpdates as $update) @php if ($update->status_updated_type == 'wuser') { $updatedBy = $update->wuser->name ?? 'Warehouse'; } elseif ($update->status_updated_type == 'partner') { $updatedBy = $update->partner->name ?? 'Partner'; } elseif ($update->status_updated_type == 'kuser') { $updatedBy = $update->kuser->name ?? 'Customer'; } elseif ($update->status_updated_type == 'mms') { $updatedBy = 'MMS Sync'; } else { $updatedBy = 'System'; } $reportPayment = $update->shipmentPayment; $paymentFigures = $reportPayment ? $reportPayment->shippingFigures() : ['notax' => null, 'gst' => null, 'shipping' => null]; $viewShippingRate = $reportPayment ? $reportPayment->shipping_rate : null; if ($reportPayment && $viewShippingRate === null && $paymentFigures['notax'] !== null) { $viewShippingRate = round((float) $paymentFigures['notax'] - (float) ($reportPayment->additional_charges ?? 0), 2); } $shipBits = []; $rateShipment = null; $linkedRows = $reportPayment ? $reportPayment->warehousePaymentShipments : collect(); foreach ($linkedRows as $paymentShipment) { $linkedShipment = $paymentShipment->shipment; if (!$linkedShipment) { continue; } if (!$rateShipment) { $rateShipment = $linkedShipment; } $lineCount = $linkedShipment->items->count(); if ($lineCount === 0 && $linkedShipment->item_name) { $lineCount = 1; } $shipBits[] = ($linkedShipment->tracking_number ?: 'N/A').' ('.$lineCount.' '.($lineCount === 1 ? 'item' : 'items').')'; } $declaredInr = $rateShipment ? (float) $rateShipment->declared_value_inr : 0; $declaredUsd = $rateShipment ? (float) $rateShipment->declared_value : 0; $usdRate = ($declaredInr > 0 && $declaredUsd > 0) ? ($declaredInr / $declaredUsd) : 0; $shippingInr = $paymentFigures['shipping']; if ($shippingInr === null && $reportPayment) { $shippingInr = (float) $reportPayment->amount; } $shippingUsd = ($shippingInr !== null && $usdRate > 0) ? ((float) $shippingInr / $usdRate) : null; $statusSearch = strtolower(implode(' ', array_filter([ $update->tracking_number, optional($update->kuser)->name, optional($update->kuser)->email, $update->status, $update->display_status, $update->location, $updatedBy, implode(' ', $shipBits), ]))); @endphp
{{ $update->kuser ? $update->kuser->name : 'N/A' }} {{ $update->tracking_number ?? 'N/A' }} Suite {{ $reportPayment->suite_number ?? 'N/A' }} {{ $update->display_status ?? 'N/A' }} {{ ucfirst(str_replace('_', ' ', (string) $update->status)) }} {{ count($shipBits) ? implode(', ', $shipBits) : ($update->tracking_number ?: 'No shipment') }} Shipping rate {{ $viewShippingRate !== null ? '₹'.number_format((float) $viewShippingRate, 2) : '—' }} Additional charge ₹{{ number_format((float) ($reportPayment->additional_charges ?? 0), 2) }} GST {{ $paymentFigures['gst'] !== null ? '₹'.number_format((float) $paymentFigures['gst'], 2) : '—' }} Location {{ $update->location ?: '—' }} Updated by {{ $updatedBy }} {{ $update->days_in_status !== null ? $update->days_in_status.' days' : '—' }} @if($reportPayment) @include('wuser.payments.partials.link-dates', ['payment' => $reportPayment, 'variant' => 'card']) @endif Shipping amount {{ $shippingInr !== null ? '₹'.number_format((float) $shippingInr, 2) : '—' }} @if($shippingUsd !== null)${{ number_format($shippingUsd, 2) }}@endif @if($update->tracking_number && $update->shipment_payment_id) View @endif
@endforeach
@endif
@endsection @push('scripts') @endpush @push('styles') @endpush