@extends('admin.layouts.inventory') @section('title', $dispatch->document_number) @section('content') @php $statusValue = $dispatch->status?->value ?? $dispatch->status; $useAverageGst = (bool) $dispatch->use_average_gst; $lineTotal = fn ($line) => $line->unit_price !== null ? (float) $line->qty * (float) $line->unit_price : null; $grandSubtotal = $dispatch->lines->sum(fn ($line) => $lineTotal($line) ?? 0); $grandTax = $useAverageGst ? (float) ($dispatch->average_gst_amount ?? 0) : $dispatch->lines->sum(fn ($line) => (float) ($line->tax_amount ?? 0)); $grandTotal = $grandSubtotal + $grandTax; $hasPricing = $dispatch->lines->contains(fn ($line) => $line->unit_price !== null); $hasTax = $useAverageGst || $dispatch->lines->contains(fn ($line) => $line->tax_id || $line->tax_amount); $showLineTax = $hasTax && ! $useAverageGst; @endphp
@include('admin.inventory.partials.document_show_header', [ 'title' => $dispatch->document_number, 'subtitle' => 'Site dispatch', 'back' => route('admin.inventory.dispatches.index'), 'backLabel' => 'Back to list', 'status' => $dispatch->status, 'actions' => $statusValue === 'draft' ? 'Edit' : ($statusValue === 'completed' ? 'Download PDF' : null), ])
Destination project {{ $dispatch->project?->customer_name ?? '—' }} @if ($dispatch->project?->assignedUser?->name) ({{ $dispatch->project->assignedUser->name }}) @endif
Revision {{ $dispatch->projectRevision?->document_number ?? '—' }}
Source warehouse {{ $dispatch->sourceWarehouse?->name ?? '—' }}
Transaction date {{ $dispatch->transaction_date?->format('d M Y') ?? '—' }}
Effective date {{ $dispatch->effective_date?->format('d M Y') ?? '—' }}
@if ($useAverageGst)
GST method Average GST ({{ number_format((float) $dispatch->average_gst_rate, 2) }}%)
@endif
@if ($dispatch->remarks)
Remarks

{{ $dispatch->remarks }}

@endif

Line items

{{ $dispatch->lines->count() }} {{ str('item')->plural($dispatch->lines->count()) }}
@if ($dispatch->lines->isEmpty())

No line items on this dispatch.

@else
@if ($hasPricing) @if ($showLineTax) @endif @endif @foreach ($dispatch->lines as $line) @php $item = $line->sku?->variant?->item; $total = $lineTotal($line); @endphp @if ($hasPricing) @if ($showLineTax) @endif @endif @endforeach
# SKU / Item Batch Qty UnitUnit priceGST / Tax Tax amountLine total
{{ $line->line_number }}
{{ $line->sku?->sku_code }}
@if ($item)
{{ $item->name }} @if ($line->sku?->variant?->variant) — {{ $line->sku->variant->variant }} @endif
@endif
@if ($line->batch) {{ $line->batch->batch_no ?: 'Batch #'.$line->batch->id }} @else — @endif @qty($line->qty) {{ $line->unit?->symbol ?? $line->unit?->name ?? '—' }}{{ $line->unit_price !== null ? number_format((float) $line->unit_price, 2) : '—' }} @if ($line->tax) {{ $line->tax->name }} ({{ $line->tax->rate }}%) @else — @endif {{ $line->tax_amount !== null ? number_format((float) $line->tax_amount, 2) : '—' }}{{ $total !== null ? number_format($total, 2) : '—' }}
@if ($hasPricing && ($grandSubtotal > 0 || $grandTax > 0))
Subtotal (taxable) ₹{{ number_format($grandSubtotal, 2) }}
@if ($hasTax && $grandTax > 0)
@if ($useAverageGst) Average GST {{ number_format((float) $dispatch->average_gst_rate, 2) }}% @else GST / Tax @endif ₹{{ number_format($grandTax, 2) }}
@endif
Grand total ₹{{ number_format($grandTotal, 2) }}
@endif @endif
@if ($statusValue === 'draft')

Completing this dispatch moves stock from the warehouse to the project site and locks the document.

Edit
@csrf
@endif
@include('admin.inventory.partials.attachments', [ 'documentType' => $attachmentDocumentType ?? 'site_dispatch', 'documentId' => $dispatch->id, 'documentStatus' => $statusValue, ])
@endsection