@extends('layouts.app') @section('title', 'Consolidation & Freight') @push('styles') @endpush @section('content') @include('wuser.partials.delivery-badge-styles')

Consolidation & Freight

{{ $payments->count() }} for your warehouse.

Create new
@if($payments->isEmpty())
No payments yet

Create a payment when a shipment is ready to bill.

Create Payment
@else
@foreach($payments as $payment) @php $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', 'payment_processed'], true); $isFailed = $paymentState === 'failed'; if ($isWalkIn && $isPaid) { $badgeClass = 'pl-paid'; $badgeLabel = 'Paid · ' . strtoupper($paidMethod); } elseif ($isWalkIn) { $badgeClass = 'pl-pending'; $badgeLabel = strtoupper($paidMethod); } elseif ($isPaid) { $badgeClass = 'pl-paid'; $badgeLabel = 'Paid'; } elseif ($isFailed) { $badgeClass = 'pl-failed'; $badgeLabel = 'Failed'; } else { $badgeClass = 'pl-pending'; $badgeLabel = 'Pending'; } $displayStatus = null; if ($payment->latestTrackingStatus && $payment->latestTrackingStatus->display_status) { $displayStatus = $payment->latestTrackingStatus->display_status; } if (in_array($displayStatus, ['Processed', 'Delivered'], true)) { $shipmentBadgeClass = 'pl-paid'; } elseif (in_array($displayStatus, ['In Transit', 'Out for Delivery'], true)) { $shipmentBadgeClass = 'pl-transit'; } elseif ($displayStatus) { $shipmentBadgeClass = 'pl-pending'; } else { $shipmentBadgeClass = 'pl-none'; } @endphp @php $shipBits = []; $rateShipment = null; foreach ($payment->warehousePaymentShipments as $paymentShipment) { $linkedShipment = $paymentShipment->shipment; if (!$linkedShipment) { continue; } if (!$rateShipment) { $rateShipment = $linkedShipment; } $itemCount = $linkedShipment->items->count(); if ($itemCount === 0 && $linkedShipment->item_name) { $itemCount = 1; } $shipBits[] = ($linkedShipment->tracking_number ?: 'N/A').' ('.$itemCount.' '.($itemCount === 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; $paymentFigures = $payment->shippingFigures(); $viewShippingRate = $payment->shipping_rate; if ($viewShippingRate === null && $paymentFigures['notax'] !== null) { $viewShippingRate = round((float) $paymentFigures['notax'] - (float) ($payment->additional_charges ?? 0), 2); } $shippingInr = $paymentFigures['shipping'] !== null ? (float) $paymentFigures['shipping'] : (float) $payment->amount; $amountUsd = $usdRate > 0 ? ($shippingInr / $usdRate) : null; $paidWhen = $payment->paid_at ? $payment->paid_at->format('d M Y, h:i A') : ($payment->created_at ? $payment->created_at->format('d M Y, h:i A') : ''); $popId = 'payPop'.$payment->id; $suite = $payment->suiteAddress; $deliveryBadges = ($suite && method_exists($suite, 'deliveryBadges')) ? $suite->deliveryBadges() : []; $customerName = trim((string) ($deliveryBadges['name'] ?? '')); if ($customerName === '' || $customerName === '—') { $customerName = trim((string) optional($payment->kuser)->name); } $suiteText = trim((string) $payment->suite_number); $photoUrls = collect(); foreach ($payment->warehousePaymentShipments as $paymentShipment) { $linkedShipment = $paymentShipment->shipment; if (!$linkedShipment || !$linkedShipment->relationLoaded('photos')) { continue; } foreach ($linkedShipment->photos as $photo) { $path = trim((string) $photo->photo_path); if ($path === '') { continue; } try { $photoUrls->push(\Illuminate\Support\Facades\Storage::disk('s3')->url($path)); } catch (\Throwable $e) { } } } $photoUrls = $photoUrls->filter()->unique()->values(); $paySearch = strtolower(implode(' ', array_filter([ $payment->tracking_number, $payment->suite_number, optional($payment->kuser)->name, $badgeLabel, $displayStatus, implode(' ', $shipBits), $paidWhen, ]))); @endphp
{{ $customerName !== '' ? $customerName : 'No customer' }} Suite {{ $suiteText !== '' ? $suiteText : 'N/A' }} @if($photoUrls->isNotEmpty()) @foreach($photoUrls as $photoUrl) Shipment photo @endforeach @endif @include('wuser.partials.delivery-badges', ['badges' => $deliveryBadges, 'popId' => $popId, 'suiteLine' => $suiteText]) {{ $payment->tracking_number ?: ('#' . $payment->id) }} {{ $badgeLabel }} {{ $displayStatus ?: 'N/A' }} @forelse($payment->warehousePaymentShipments as $paymentShipment) @php $linkedShipment = $paymentShipment->shipment; $lineCount = 0; if ($linkedShipment) { $lineCount = $linkedShipment->items->count(); if ($lineCount === 0 && $linkedShipment->item_name) { $lineCount = 1; } } @endphp @if($linkedShipment && $linkedShipment->id) {{ $linkedShipment->tracking_number ?? 'N/A' }} ({{ $lineCount }} {{ $lineCount === 1 ? 'item' : 'items' }})@if(!$loop->last), @endif @endif @empty No shipment @endforelse Shipping rate {{ $viewShippingRate !== null ? '₹'.number_format((float) $viewShippingRate, 2) : '—' }} Additional charge ₹{{ number_format((float) ($payment->additional_charges ?? 0), 2) }} GST {{ $paymentFigures['gst'] !== null ? '₹'.number_format((float) $paymentFigures['gst'], 2) : '—' }} @include('wuser.payments.partials.link-dates', ['payment' => $payment, 'variant' => 'card']) Shipping amount ₹{{ number_format($shippingInr, 2) }} @if($amountUsd !== null)${{ number_format($amountUsd, 2) }}@endif View Additional charge
@endforeach
@endif
@endsection @push('scripts') @endpush @push('scripts') @endpush