@extends('documents.inventory._layout', [ 'documentTitle' => 'Lot Detail Sheet', 'reference' => $lot->lot_number, 'documentDate' => now()->format('d M Y'), ]) @section('header-meta')
Source: {{ ucwords(str_replace('_', ' ', $lot->source_type)) }}
Received: {{ $lot->received_date ? \Carbon\Carbon::parse($lot->received_date)->format('d M Y') : '—' }}
@endsection @section('content') {{-- Product & lot summary --}} @if($lot->batch_number) @endif @if($lot->expiry_date) @php $expired = \Carbon\Carbon::parse($lot->expiry_date)->isPast(); @endphp @endif
Product {{ $lot->product?->name ?? '—' }} @if($lot->product?->sku) ({{ $lot->product->sku }})@endif
Received Location {{ $lot->receivedLocation?->name ?? '—' }} ({{ $lot->receivedLocation?->type ?? '' }})
Qty Received {{ number_format($lot->quantity_received) }} {{ $lot->quantity_uom ?? $lot->product?->uom ?? '' }}
Current On Hand {{ number_format($currentStock) }} @if($currentStock < $lot->quantity_received) ({{ number_format($lot->quantity_received - $currentStock) }} issued/adjusted) @endif
Batch Number {{ $lot->batch_number }}
Expiry Date {{ \Carbon\Carbon::parse($lot->expiry_date)->format('d M Y') }} {{ $expired ? ' ⚠ EXPIRED' : '' }}
Costing Method {{ strtoupper($lot->costing_method) }}
{{-- Pricing --}}

Pricing

@if($lot->selling_price) @endif @if($lot->outlet_price) @endif @if($lot->discount_cap) @endif
Price Type Amount Details (snapshot at receipt)
Landed Cost {{ $lot->landed_cost_per_unit ? number_format($lot->landed_cost_per_unit, 4) : '—' }} Per unit — batch-specific
Selling Price {{ number_format($lot->selling_price, 2) }} {{ $lot->selling_price_method ? ucwords(str_replace('_', ' ', $lot->selling_price_method)) : '' }} @if($lot->margin_pct) · Margin: {{ $lot->margin_pct }}%@endif @if($lot->markup_amount) · Markup: {{ number_format($lot->markup_amount, 2) }}@endif
Outlet Price {{ number_format($lot->outlet_price, 2) }} {{ $lot->outlet_price_method ? ucwords(str_replace('_', ' ', $lot->outlet_price_method)) : '' }}
Discount Floor {{ number_format($lot->discount_cap, 2) }} Minimum sale price
{{-- Stock Movements --}} @if($lot->stockMovements->isNotEmpty())

Stock Movements

@foreach($lot->stockMovements as $m) @endforeach
Date Type Qty From To Reason
{{ \Carbon\Carbon::parse($m->moved_at)->format('d M Y') }} {{ ucwords(str_replace('_', ' ', $m->movement_type)) }} {{ number_format($m->quantity) }} {{ $m->fromLocation?->name ?? '—' }} {{ $m->toLocation?->name ?? '—' }} {{ $m->adjustment_reason ?? '—' }}
@endif {{-- Serial Numbers --}} @if($lot->product?->is_serialised && $lot->serialNumbers->isNotEmpty())

Serial Numbers ({{ $lot->serialNumbers->count() }})

@php $statusGroups = $lot->serialNumbers->groupBy('status'); $statusColors = ['in_stock' => 'bg-green', 'reserved' => 'bg-amber', 'sold' => '', 'transferred' => 'bg-blue', 'written_off' => 'bg-red']; @endphp @foreach($lot->serialNumbers->sortBy('serial_number') as $i => $sn) @endforeach
# Serial Number Status
{{ $i + 1 }} {{ $sn->serial_number }} {{ ucwords(str_replace('_', ' ', $sn->status)) }}
@php $statusSummary = $lot->serialNumbers->groupBy('status')->map->count(); @endphp

@foreach($statusSummary as $status => $count) {{ ucwords(str_replace('_', ' ', $status)) }}: {{ $count }}{{ !$loop->last ? ' · ' : '' }} @endforeach

@endif @endsection