@php // Variance flag presentation (literal classes so Tailwind scans them). $flagMeta = [ 'size_changed' => ['label' => __('Size changed'), 'color' => 'bg-amber-50 text-amber-700 ring-amber-200', 'icon' => 'adjustments-horizontal'], 'qty_changed' => ['label' => __('Qty changed'), 'color' => 'bg-sky-50 text-sky-700 ring-sky-200', 'icon' => 'queue-list'], 'over_consumed' => ['label' => __('Over-consumed'), 'color' => 'bg-rose-50 text-rose-700 ring-rose-200', 'icon' => 'exclamation-triangle'], ]; $statusChip = [ 'draft' => 'bg-slate-100 text-slate-600', 'confirmed' => 'bg-emerald-50 text-emerald-700', 'reversed' => 'bg-rose-50 text-rose-700', ]; // Trim trailing zeros for tidy numbers. $n = fn ($v, int $dp = 2): string => rtrim(rtrim(number_format((float) $v, $dp), '0'), '.'); @endphp

{{ __('Production History') }}

{{ __('Every confirmed production run, actual sizes, consumption, offcut and variances. Reverse a run to return its stock.') }}

{{-- ============ EMPTY STATE ============ --}} @if ($history->isEmpty())

{{ __('No production recorded yet') }}

{{ __('Use “Record production” on the Production Costs tab to consume stock against this job and log what was actually produced.') }}

@else
@foreach ($history as $production) @php $lineTotal = $production->lines->sum(fn ($l) => (float) $l->total_cost); @endphp
{{ $production->status_label }} @if ($production->has_variance && $production->status === 'confirmed') {{ __('Variance') }} @endif {{ optional($production->produced_at)->format('Y-m-d H:i') }} @if ($production->producer) {{ __('by :name', ['name' => $production->producer->name]) }} @endif
@if ($canSeeCosts) {{ $baseCurrency }} {{ number_format($lineTotal, 2) }} @endif @if ($canManage && $production->status === 'confirmed') @endif
@if ($canSeeCosts) @endif @foreach ($production->lines as $line) @php $flags = $line->variance_flags ?? []; @endphp @if ($canSeeCosts) @endif @endforeach
{{ __('Item') }} {{ __('Material') }} {{ __('Actual') }} {{ __('Consumed') }} {{ __('Offcut') }}{{ __('Cost') }}{{ __('Variance') }}
{{ $line->product?->name ?? __('Line') }} {{ $line->materialVariant?->material?->name ?? '—' }} @if ($line->actual_width || $line->actual_height) {{ $n($line->actual_width, 4) }}×{{ $n($line->actual_height, 4) }} · @endif {{ $n($line->actual_qty, 2) }} {{ $n($line->consumed_base_qty, 3) }} {{ $n($line->offcut_qty, 3) }}{{ number_format((float) $line->total_cost, 2) }} @if ($flags === []) — @else
@foreach ($flags as $flag) @php $fm = $flagMeta[$flag] ?? ['label' => ucfirst(str_replace('_', ' ', $flag)), 'color' => 'bg-slate-100 text-slate-600 ring-slate-200', 'icon' => 'exclamation-triangle']; @endphp {{ $fm['label'] }} @endforeach
@endif
@endforeach
@endif