@extends('layouts.app') @section('title', $stock->description) @section('breadcrumb')Inventory {{ $stock->sku }}@endsection @section('content') @if(session('success'))

{{ session('success') }}

@endif @if($errors->any())
@foreach($errors->all() as $e)

{{ $e }}

@endforeach
@endif {{-- Header --}}

{{ $stock->description }}

{{ $stock->sku }} · {{ $stock->unit }} · {{ $stock->category ?? 'Uncategorised' }}

@if($stock->needsReorder()) Reorder Needed @endif Edit {{-- Delete Confirmation Modal --}}

Delete Inventory Item

Are you sure you want to delete {{ $stock->description }} ({{ $stock->sku }})?

This cannot be undone. Items with active job allocations cannot be deleted.

@csrf @method('DELETE')
{{-- Reorder Modal --}}

Create Reorder PO

Creates a draft PO for {{ $stock->description }} ({{ $stock->sku }}). Set the quantity to order below.

@csrf

Default reorder qty: {{ max((int)($stock->reorder_qty ?? 1), 1) }} {{ $stock->unit }}

{{-- KPI cards --}}
{{ number_format($stock->qty_on_hand, 2) }}
On Hand
{{ number_format($stock->jobAllocations->count()) }}
Job Allocations
{{ number_format($stock->qty_on_hand, 2) }}
Available
${{ number_format($stock->unit_cost, 2) }}
Unit Cost
{{-- Left: tabs --}}
{{-- Tab bar --}}
{{-- TAB 1: Job Allocations --}}
{{-- Allocate to Job form --}}

Allocate to a Job

@csrf

Allocating deducts from stock on hand and adds the cost (${{ number_format($stock->unit_cost, 2) }}/{{ $stock->unit }}) to the job's Gross Profit report.

{{-- Current allocations list --}}

Current Allocations

{{ $stock->jobAllocations->count() }} allocation(s)
@if($stock->jobAllocations->count()) @foreach($stock->jobAllocations as $alloc) @endforeach
Date Job Client Qty Unit Cost Total By
{{ $alloc->created_at->format('d M Y') }} {{ $alloc->job?->job_number ?? '—' }} {{ $alloc->job?->contact?->full_name ?? $alloc->job?->contact?->company ?? '—' }} {{ number_format($alloc->qty, 2) }} {{ $stock->unit }} ${{ number_format($alloc->unit_cost, 2) }} ${{ number_format($alloc->total_cost, 2) }} {{ $alloc->createdBy?->name ?? '—' }}
@csrf @method('DELETE')
Total allocated cost ${{ number_format($stock->jobAllocations->sum('total_cost'), 2) }}
@else

No stock has been allocated to any job yet.

Use the form above to allocate stock to a job.

@endif
{{-- TAB 2: PO History --}}

Purchase Order History

{{ $stock->purchaseOrderItems->count() }} PO line(s) for SKU: {{ $stock->sku }}

Reorder Qty

@csrf
@if($stock->purchaseOrderItems->count())
@foreach($stock->purchaseOrderItems->sortByDesc(fn($i) => $i->purchaseOrder?->order_date) as $item) @php $po = $item->purchaseOrder; @endphp @endforeach
PO # Date Supplier Status Qty Ordered Qty Received Unit Cost Total
{{ $po?->po_number ?? '—' }} {{ $po?->order_date?->format('d M Y') ?? '—' }} {{ $po?->supplier?->company ?: ($po?->supplier?->full_name ?? '—') }} @if($po) {{ ucfirst($po->status) }} @endif {{ number_format($item->qty_ordered, 2) }} {{ number_format($item->qty_received, 2) }} ${{ number_format($item->unit_cost, 2) }} ${{ number_format($item->total_cost, 2) }} @if($po) @endif
Totals {{ number_format($stock->purchaseOrderItems->sum('qty_ordered'), 2) }} {{ number_format($stock->purchaseOrderItems->sum('qty_received'), 2) }} ${{ number_format($stock->purchaseOrderItems->sum('total_cost'), 2) }}
@else

No purchase order history for this SKU.

PO lines are matched by SKU code ({{ $stock->sku }}).

Reorder Qty

@csrf
@endif
{{-- TAB 3: Movement History --}}

Stock Movement History

@if($stock->movements->count()) @foreach($stock->movements as $mv) @endforeach
Date Type Job Qty Unit Cost Notes By
{{ $mv->created_at->format('d M Y H:i') }} {{ ucfirst($mv->type) }} @if($mv->job) {{ $mv->job->job_number }} @else @endif {{ $mv->qty >= 0 ? '+' : '' }}{{ number_format($mv->qty, 2) }} {{ $mv->unit_cost ? '$'.number_format($mv->unit_cost, 2) : '—' }} {{ $mv->notes ?? '—' }} {{ $mv->createdBy?->name ?? '—' }}
@else
No movements recorded yet.
@endif
{{-- Right sidebar --}}
{{-- Stock info card --}}

Stock Info

Unit Cost${{ number_format($stock->unit_cost, 2) }}
Stock Value${{ number_format($stock->qty_on_hand * $stock->unit_cost, 2) }}
Reorder Point{{ number_format($stock->reorder_point, 2) }}
Reorder Qty{{ number_format($stock->reorder_qty, 2) }}
Supplier {{ $stock->preferredSupplier?->company ?: ($stock->preferredSupplier?->full_name ?? '—') }}
{{-- Quick Reorder --}}

Quick Reorder

Creates a draft PO pre-filled with this item's details, ready for you to review and send.

@csrf

Default: {{ max((int)($stock->reorder_qty ?? 1), 1) }} {{ $stock->unit }}

{{-- Manual Adjustment --}}

Manual Adjustment

@csrf
@if($stock->notes)

Notes

{{ $stock->notes }}

@endif
@endsection