@extends('layouts.app') @section('title', 'Status Update') @push('styles') @endpush @section('content')

Update shipping status

{{ $paymentGroups->count() }} payment{{ $paymentGroups->count() === 1 ? '' : 's' }} ready for a status update.

@if(session('success')) @endif @if(session('error')) @endif
@if($paymentGroups->isEmpty())
No payments found

No payment processed received shipments found.

@else
@foreach($paymentGroups as $detail) @php $payment = $detail['payment']; $paymentDetails = $payment->getPaymentDetailsArray(); $paidMethod = strtolower((string) ($paymentDetails['paid_via'] ?? $payment->payment_method ?? '')); $isWalkIn = in_array($paidMethod, ['upi', 'cash'], true); $paymentState = strtolower((string) $payment->payment_status); $isPaid = in_array($paymentState, ['success', 'paid', 'completed'], true); $isFailed = $paymentState === 'failed'; if ($isWalkIn && $isPaid) { $badgeClass = 'su-paid'; $badgeLabel = 'Paid · ' . strtoupper($paidMethod); } elseif ($isWalkIn) { $badgeClass = 'su-pending'; $badgeLabel = strtoupper($paidMethod); } elseif ($isPaid) { $badgeClass = 'su-paid'; $badgeLabel = 'Paid'; } elseif ($isFailed) { $badgeClass = 'su-failed'; $badgeLabel = 'Failed'; } else { $badgeClass = 'su-pending'; $badgeLabel = 'Pending'; } $shipmentCount = (int) ($detail['shipment_count'] ?? 0); $itemCount = (int) ($detail['item_count'] ?? 0); $shipmentLabel = $shipmentCount === 1 ? '1 shipment' : $shipmentCount . ' shipments'; $itemLabel = $itemCount === 1 ? '1 item' : $itemCount . ' items'; $currentDisplayStatus = $detail['current_status'] ?? null; if (in_array($currentDisplayStatus, ['Processed', 'Delivered'], true)) { $shipmentBadgeClass = 'su-paid'; } elseif (in_array($currentDisplayStatus, ['In Transit', 'Out for Delivery'], true)) { $shipmentBadgeClass = 'su-transit'; } elseif ($currentDisplayStatus) { $shipmentBadgeClass = 'su-pending'; } else { $shipmentBadgeClass = 'su-none'; } $statusUpdatedBy = $detail['status_updated_by'] ?? null; $partnerInfo = $detail['partner_info'] ?? null; $wuserInfo = $detail['wuser_info'] ?? null; $updatedAt = $detail['latest_status_date'] ?? $payment->paid_at; if (is_string($updatedAt)) { $updatedAt = \Carbon\Carbon::parse($updatedAt); } @endphp @endforeach
Payment Customer Received shipments Amount Payment Status Status Updated
{{ $payment->tracking_number ?: ('#' . $payment->id) }}
Suite {{ $payment->suite_number ?: 'N/A' }}
{{ $payment->kuser->name ?? 'Not linked' }}
@php $listedShipment = $payment->warehousePaymentShipments->map->shipment->filter()->first(); $listedAddress = optional(optional($listedShipment)->virtualAddress)->formattedDeliveryAddress(); @endphp @if($listedAddress)
{{ $listedAddress }}
@endif
{{ $shipmentLabel }} · {{ $itemLabel }}
@foreach($payment->warehousePaymentShipments as $paymentShipment) @php $linkedShipment = $paymentShipment->shipment; $lineCount = 0; if ($linkedShipment) { $lineCount = $linkedShipment->items->count(); if ($lineCount === 0 && $linkedShipment->item_name) { $lineCount = 1; } } $lineLabel = $lineCount === 1 ? '1 item' : $lineCount . ' items'; @endphp
{{ optional($linkedShipment)->tracking_number ?: 'N/A' }} {{ $lineLabel }}
@endforeach
@php $paymentFigures = $payment->shippingFigures(); @endphp @include('wuser.partials.shipping-figures', [ 'figureStyle' => 'stack', 'notaxShipping' => $paymentFigures['notax'], 'gstAmount' => $paymentFigures['gst'], 'shippingTotal' => $paymentFigures['shipping'], ]) {{ $badgeLabel }} {{ $currentDisplayStatus ?: 'N/A' }} @if($statusUpdatedBy)
Updated by @if($statusUpdatedBy === 'partner' && $partnerInfo) {{ $partnerInfo->name }} @elseif($statusUpdatedBy === 'wuser' && $wuserInfo) {{ $wuserInfo->name }} @elseif($statusUpdatedBy === 'mms') MMS Sync @else {{ ucfirst($statusUpdatedBy) }} @endif
@endif
{{ $updatedAt ? $updatedAt->format('d M Y, h:i A') : 'N/A' }}
@endif
@endsection @push('scripts') @endpush