@extends('layouts.app') @section('title', 'Shipment Details') @push('styles') @endpush @section('content') @php $paymentStatus = $shipmentPayment->payment_status ?? null; $isPaymentDone = $shipmentPayment->isPaymentCompleted(); $shipmentLinkExpired = false; $shipmentLinkDetails = $shipmentPayment->getPaymentDetailsArray(); if (!empty($shipmentLinkDetails['link_expires_at'])) { try { $shipmentLinkExpired = \Carbon\Carbon::parse($shipmentLinkDetails['link_expires_at'], 'Asia/Kolkata') ->lte(\Carbon\Carbon::now('Asia/Kolkata')); } catch (\Exception $e) { $shipmentLinkExpired = false; } } $freightMethod = strtolower((string) $shipmentPayment->payment_method); $freightPathway = $freightMethod === 'pathway b' ? 'b' : ($freightMethod === 'pathway c' ? 'c' : (($shipmentLinkDetails['purchase_pathway'] ?? '') === 'a' ? 'a' : '')); $figures = $shipmentPayment->shippingFigures(); $shippingRate = $shipmentPayment->shipping_rate; if ($shippingRate === null && $figures['notax'] !== null) { $shippingRate = round((float) $figures['notax'] - (float) ($shipmentPayment->additional_charges ?? 0), 2); } $methodLabel = $shipmentPayment->paymentMethodLabel(); $latest = $shipmentPayment->latestTrackingStatus; $statusLabel = ''; if (is_array($currentStatusData ?? null) && !empty($currentStatusData['display_status'])) { $statusLabel = trim((string) $currentStatusData['display_status']); } elseif ($latest) { $statusLabel = trim((string) ($latest->display_status ?: $latest->status)); } $paymentState = strtolower((string) $paymentStatus); if ($isPaymentDone) { $payLabel = 'Paid'; } elseif ($paymentState === 'failed' || $paymentState === 'failure') { $payLabel = 'Failed'; } else { $payLabel = 'Pending'; } $totalAmount = $figures['shipping'] !== null ? $figures['shipping'] : $shipmentPayment->amount; $photoGallery = []; foreach ($allShipments as $galleryShipment) { $galleryPhotos = $galleryShipment->relationLoaded('photos') ? $galleryShipment->photos : collect(); foreach ($galleryPhotos as $galleryPhoto) { $path = trim((string) $galleryPhoto->photo_path); if ($path === '') { continue; } try { $photoGallery[] = \Illuminate\Support\Facades\Storage::disk('s3')->url($path); } catch (\Throwable $e) { } } } $photoGallery = array_values(array_unique($photoGallery)); $hasAdditionalServices = $shipmentPayment->additionalServices->count() > 0 || $shipmentPayment->additionalAmounts->count() > 0; $pendingAdditionalPayment = $shipmentPayment->additionalPayments->first(function ($payment) { return !in_array($payment->payment_status, ['success', 'completed', 'paid', 'payment_processed'], true); }); $additionalLinkExpired = false; $additionalExpiryDetails = ($pendingAdditionalPayment && is_array($pendingAdditionalPayment->payment_details ?? null)) ? $pendingAdditionalPayment->payment_details : []; if (!empty($additionalExpiryDetails['link_expires_at'])) { try { $additionalLinkExpired = \Carbon\Carbon::parse($additionalExpiryDetails['link_expires_at'], 'Asia/Kolkata') ->lte(\Carbon\Carbon::now('Asia/Kolkata')); } catch (\Exception $e) { $additionalLinkExpired = false; } } $backHash = $isPaymentDone ? '#history-tab' : '#shipments-tab'; $updatedBy = ($latest && method_exists($latest, 'updatedByLabel')) ? $latest->updatedByLabel() : ''; @endphp
{{ $isPaymentDone ? 'Shipment history' : 'My shipments' }}
{{ $shipmentPayment->tracking_number ?: ('Payment #'.$shipmentPayment->id) }}
Back
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif @if(is_array($trackingData ?? null) && !empty($trackingData['mms_last_sync_error'] ?? null)) @endif
Payment {{ $shipmentPayment->tracking_number ?: ('#'.$shipmentPayment->id) }} {{ $payLabel }} @if($statusLabel !== ''){{ $statusLabel }}@endif @if($methodLabel !== ''){{ $methodLabel }}@endif Suite {{ $shipmentPayment->suite_number ?: 'N/A' }} {{ $allShipments->count() }} {{ $allShipments->count() === 1 ? 'shipment' : 'shipments' }} @if($shippingRate !== null)Shipping rate ₹{{ number_format((float) $shippingRate, 2) }}@endif Additional charge ₹{{ number_format((float) ($shipmentPayment->additional_charges ?? 0), 2) }} @if($figures['gst'] !== null)GST ₹{{ number_format((float) $figures['gst'], 2) }}@endif @if($updatedBy !== '')Updated by {{ $updatedBy }}@endif @php $paymentDeadWeight = $shipmentPayment->deadWeightLabel(); $paymentPackDimension = $shipmentPayment->packDimensionLabel(); $measureRows = []; if ($paymentDeadWeight !== '' || $paymentPackDimension !== '') { $measureRows[] = ['track' => '', 'dead' => $paymentDeadWeight, 'box' => $paymentPackDimension]; } else { foreach ($allShipments as $measureShipment) { $deadWeight = trim((string) $measureShipment->weight); $packDimension = trim((string) $measureShipment->dimensions); if ($deadWeight === '' && $packDimension === '') { continue; } $measureRows[] = [ 'track' => $allShipments->count() > 1 ? ($measureShipment->tracking_number ?: 'Shipment') : '', 'dead' => $deadWeight, 'box' => $packDimension, ]; } } @endphp @foreach($measureRows as $measureRow) @if($measureRow['track'] !== '') {{ $measureRow['track'] }} @endif @if($measureRow['dead'] !== '') Dead Wt: {{ $measureRow['dead'] }} @endif @if($measureRow['box'] !== '') Retail Box: {{ $measureRow['box'] }} @endif @endforeach @include('wuser.payments.partials.link-dates', ['payment' => $shipmentPayment, 'variant' => 'card', 'onlyWhenLink' => true]) @if($freightPathway === 'b' && !$isPaymentDone)
Payment is through Maldives Post and is collected outside Kurigo. Link: {{ $shipmentPayment->maldivianpost_link_status ?: 'Not sent' }}@if($shipmentPayment->maldivianpost_link_date) · {{ $shipmentPayment->maldivianpost_link_date->format('d M Y, h:i A') }}@endif. Payment: {{ $shipmentPayment->maldivianpost_payment_status ?: 'Not completed' }}@if($shipmentPayment->maldivianpost_payment_date) · {{ $shipmentPayment->maldivianpost_payment_date->format('d M Y, h:i A') }}@endif.
@elseif($freightPathway === 'c')
@if($shipmentPayment->bank_transaction_id) @php $savedBank = $shipmentPayment->bankAccount; @endphp @if($savedBank)
{{ $savedBank->bank_name ?: 'Bank' }}

Account holder{{ $savedBank->account_holder_name ?: '—' }}

Account No.{{ $savedBank->account_number ?: '—' }}

Currency{{ $savedBank->currency ?: '—' }}

@endif
Transaction ID{{ $shipmentPayment->bank_transaction_id }}
Date{{ optional($shipmentPayment->bank_transaction_date)->format('d M Y') }}
Status{{ $shipmentPayment->marked_by ? 'Cash received and verified' : 'Waiting for warehouse to verify the cash or transfer' }}
@if($shipmentPayment->bank_transaction_screenshot)
ScreenshotView
@endif
@elseif(!$isPaymentDone)
@csrf

Select the account you transferred to.

@forelse($freightBanks as $bank) @empty

No active bank account is available.

@endforelse
@endif
@endif @if(!in_array($freightPathway, ['b', 'c'], true) && !$isPaymentDone) @include('kuser.shipment-payments.partials.link-expiry-notice', ['payment' => $shipmentPayment, 'linkNoticeTitle' => 'Shipping payment link'])
@if($shipmentPayment->hasPayableWarehouseSession() && !$shipmentLinkExpired) @elseif($shipmentLinkExpired) Payment link expired @else Payment link not generated yet @endif
@endif @if($hasAdditionalServices && $pendingAdditionalPayment)
Additional service amount ₹{{ number_format($pendingAdditionalPayment->amount ?? 0, 2) }}
@include('kuser.shipment-payments.partials.link-expiry-notice', ['payment' => $pendingAdditionalPayment, 'linkNoticeTitle' => 'Additional payment link'])
@if(!$additionalLinkExpired) @else Expired @endif
@endif
Total amount ₹{{ number_format((float) $totalAmount, 2) }}

Shipments ({{ $allShipments->count() }})

@forelse($allShipments as $shipment) @php $itemRows = $shipment->relationLoaded('items') ? $shipment->items : collect(); $itemLines = $itemRows->map(function ($item) { $name = trim((string) $item->item_name); if ($name === '') { return null; } $qty = (float) $item->unit_quantity; if ($qty > 1) { $qtyText = abs($qty - round($qty)) < 0.001 ? (string) (int) round($qty) : rtrim(rtrim(number_format($qty, 2, '.', ''), '0'), '.'); return $name.' ('.$qtyText.')'; } return $name; })->filter()->values(); if ($itemLines->isEmpty() && $shipment->item_name) { $itemLines = collect([$shipment->item_name]); } $cargoLabel = method_exists($shipment, 'cargoTypeLabel') ? $shipment->cargoTypeLabel() : ''; if ($cargoLabel === 'N/A') { $cargoLabel = ''; } $streamLabel = method_exists($shipment, 'customsShipmentStreamLabel') ? $shipment->customsShipmentStreamLabel() : ''; if ($streamLabel === 'N/A') { $streamLabel = ''; } $portLabel = $shipment->port_of_destination === 'male' ? 'Male' : ($shipment->port_of_destination === 'rest' ? 'Rest of Maldives' : ''); @endphp
{{ $shipment->sender_name ?: 'Shipment' }} {{ $shipment->tracking_number ?: 'N/A' }} @if($streamLabel !== '') {{ $streamLabel }} @endif @if($portLabel !== '') {{ $portLabel }} @endif @if($cargoLabel !== '') {{ $cargoLabel }} @endif {{ $itemLines->isNotEmpty() ? $itemLines->implode(', ') : 'No items recorded' }} @if($shipment->weight)Weight {{ $shipment->weight }}@endif Declared ₹{{ number_format((float) $shipment->declared_value_inr, 2) }}
@empty

No shipments are attached to this payment.

@endforelse

Tracking flow

@php $useFormattedTrackingFlow = is_array($trackingData ?? null) && empty($trackingData['error'] ?? null) && isset($trackingData['statuses']) && count($trackingData['statuses']) > 0; $flowItems = []; if ($useFormattedTrackingFlow) { foreach ($trackingData['statuses'] as $status) { $flowItems[] = $status; } } elseif ($shipmentPayment->trackingStatuses && $shipmentPayment->trackingStatuses->count() > 0) { $seenMailItemGenerated = false; $historyStatuses = $shipmentPayment->trackingStatuses ->sortBy(function ($status) { $timestamp = $status->status_date ? $status->status_date->timestamp : PHP_INT_MAX; return [$timestamp, (int) $status->id]; }) ->filter(function ($status) use (&$seenMailItemGenerated) { if (strtoupper(trim((string) $status->status)) !== 'EMA') { return true; } if ($seenMailItemGenerated) { return false; } $seenMailItemGenerated = true; return true; }) ->values(); $lastIndex = $historyStatuses->count() - 1; foreach ($historyStatuses as $index => $status) { $flowItems[] = [ 'display_status' => $status->display_status, 'description' => $status->description, 'status' => $status->status, 'status_date' => $status->status_date ? $status->status_date->toDateTimeString() : null, 'time_zone_display_label' => ($status->status_updated_type === 'mms') ? 'Maldives Time' : 'Indian Standard Time', 'location' => $status->location, 'is_completed' => true, 'is_active' => $index === $lastIndex, 'icon' => 'check', 'mms_tracking_number' => $trackingData['mms_tracking_number'] ?? $shipmentPayment->activeMmsTrackingNumberList(), ]; } } @endphp @if(count($flowItems) > 0)
@foreach($flowItems as $status) @php $isCompleted = $status['is_completed'] ?? true; $isActive = $status['is_active'] ?? false; $markerClass = $isCompleted ? ($isActive ? 'active' : 'completed') : ''; $iconClass = 'fas fa-' . ($status['icon'] ?? 'check'); $dateText = !empty($status['status_date']) ? \Carbon\Carbon::parse($status['status_date'])->format('d-m-Y H:i') : ''; $statusKey = strtoupper((string) ($status['status'] ?? '')); $statusTitle = strtolower((string) ($status['display_status'] ?? '')); $isMailItemGenerated = $statusKey === 'EMA' || strpos($statusTitle, 'mail item generated') !== false; @endphp
{{ $status['display_status'] ?? 'N/A' }}
@if(!empty($status['description']))

{{ $status['description'] }}

@endif @if($dateText !== ''){{ $dateText }}@endif @if(!empty($status['time_zone_display_label'])){{ $status['time_zone_display_label'] }}@endif @if($isMailItemGenerated) @include('partials.mms-tracking-number', ['mmsTrackingNumber' => $status['mms_tracking_number'] ?? ($trackingData['mms_tracking_number'] ?? null)]) @endif
@endforeach
@else

No tracking flow has been recorded yet.

@endif
@include('kuser.partials.surface-styles') @push('scripts') @endpush @endsection