@extends('documents.procurement._layout', [ 'documentTitle' => 'Production Work Order', 'reference' => $order->production_reference, 'documentDate' => \Carbon\Carbon::parse($order->production_date)->format('d M Y'), ]) @section('header-meta')
{{ strtoupper(str_replace('_', ' ', $order->status)) }}
@if($order->planned_quantity)
Planned Qty: {{ number_format($order->planned_quantity) }} {{ $order->quantity_uom ?? $order->product?->uom ?? '' }}
@endif @endsection @section('content') @php $src = $order->source_currency_code; $base = auth()->user()->organization?->currency_code ?? 'UGX'; $isForeign = $src !== $base; @endphp {{-- Order Details --}}
Production Details:
Product: {{ $order->product?->name ?? '—' }}
@if($order->product?->sku) SKU: {{ $order->product->sku }}
@endif Location: {{ $order->location?->name ?? '—' }}
Output Location: {{ $order->outputLocation?->name ?? $order->location?->name ?? '—' }}
Currency: {{ $src }} @if($isForeign) (Base: {{ $base }}, Rate: {{ number_format((float) $order->exchange_rate, 4) }}) @endif
BOM Reference:
@if($order->bom) {{ $order->bom->bom_reference }} @if($order->bom->name) — {{ $order->bom->name }} @endif (Version {{ $order->bom->version }})
@else — No BOM linked —
@endif Planned Quantity: {{ number_format($order->planned_quantity) }} {{ $order->quantity_uom ?? $order->product?->uom ?? '' }}
Production Date: {{ \Carbon\Carbon::parse($order->production_date)->format('d M Y') }}
@if($order->completion_date) Target Completion: {{ \Carbon\Carbon::parse($order->completion_date)->format('d M Y') }}
@endif
{{-- BOM Components --}} @if($order->bom && $order->bom->items->isNotEmpty())

Bill of Materials — Components Required

@foreach($order->bom->items as $i => $item) @php $effPerUnit = (float) $item->quantity_per_unit * (1 + ($item->wastage_pct ?? 0) / 100); $totalRequired = $effPerUnit * $order->planned_quantity; @endphp @endforeach
# Component SKU Qty / Unit Wastage % Effective Qty / Unit Total Required UoM
{{ $i + 1 }} {{ $item->componentProduct?->name ?? '—' }} {{ $item->componentProduct?->sku ?? '—' }} {{ number_format((float) $item->quantity_per_unit, 4) }} {{ number_format((float) ($item->wastage_pct ?? 0), 2) }}% {{ number_format($effPerUnit, 4) }} {{ number_format($totalRequired, 4) }} {{ $item->quantity_uom ?? $item->componentProduct?->uom ?? '—' }}
@endif {{-- Estimated Production Costs --}} @if($order->costLines->isNotEmpty())

Estimated Production Costs

@if($isForeign) @endif @php $totalEstSrc = 0; $totalEstBase = 0; @endphp @foreach($order->costLines->sortBy('cost_type') as $line) @php $totalEstSrc += (float) $line->estimated_amount_source; $totalEstBase += (float) $line->estimated_amount_base; @endphp @if($isForeign) @endif @endforeach @if($isForeign) @endif
Cost Type Description Estimated ({{ $src }})Estimated ({{ $base }})
{{ ucfirst($line->cost_type) }} {{ $line->description ?? '—' }} {{ number_format((float) $line->estimated_amount_source, 2) }}{{ number_format((float) $line->estimated_amount_base, 2) }}
Total Estimated Cost {{ $src }} {{ number_format($totalEstSrc, 2) }}{{ $base }} {{ number_format($totalEstBase, 2) }}
@endif {{-- Notes --}} @if($order->notes)

Production Notes

{{ $order->notes }}

@endif {{-- Signatures --}}
Prepared by
{{ $order->submittedBy?->name ?? '—' }}
Approved by
{{ $order->approvedBy?->name ?? '—' }}
Production Supervisor
Signature & Date
@endsection