@php $org = auth()->user()->organization ?? \App\Models\System\Organization::find(auth()->user()->organization_id); $documentTitle = 'Stock Position Report'; $isPdf = false; @endphp @extends('documents.inventory._layout', [ 'documentTitle' => 'Stock Position Report', 'reference' => null, 'documentDate' => $reportDate, ]) @section('header-meta')
Generated: {{ $reportDate }}
@endsection @section('styles') @php $totalOnHand = $levels->sum('quantity_on_hand'); $totalReserved = $levels->sum('quantity_reserved'); $totalAvailable = $levels->sum(fn($l) => ($l->quantity_on_hand ?? 0) - ($l->quantity_reserved ?? 0)); $belowMinCount = $levels->filter(fn($l) => ($l->quantity_on_hand ?? 0) < ($l->product?->minimum_stock_level ?? 0))->count(); $mismatchCount = $levels->filter(fn($l) => ($l->active_serial_count ?? 0) !== ($l->quantity_on_hand ?? 0))->count(); @endphp @endsection @section('content') {{-- Summary strip --}} @if($belowMinCount > 0) @endif @if($mismatchCount > 0) @endif
Total Lines
{{ $levels->count() }}
On Hand
{{ number_format($totalOnHand) }}
Reserved
{{ number_format($totalReserved) }}
Available
{{ number_format($totalAvailable) }}
⚠ Below Minimum
{{ $belowMinCount }}
⚠ Serial Mismatch
{{ $mismatchCount }}
{{-- Main table --}} @php $byLocation = $levels->groupBy(fn($l) => $l->location?->name ?? 'Unknown'); @endphp @foreach($byLocation as $locationName => $locationLevels)

{{ $locationName }}

@foreach($locationLevels as $i => $level) @php $avail = ($level->quantity_on_hand ?? 0) - ($level->quantity_reserved ?? 0); $belowMin = ($level->quantity_on_hand ?? 0) < ($level->product?->minimum_stock_level ?? 0); $mismatch = ($level->active_serial_count ?? 0) !== ($level->quantity_on_hand ?? 0); $rowClass = $belowMin ? 'bg-red' : ($mismatch ? 'bg-amber' : ''); @endphp @endforeach
# Product SKU Lot On Hand Reserved Available Serial Records Last Updated
{{ $i + 1 }} {{ $level->product?->name ?? '—' }} {{ $level->product?->sku ?? '—' }} {{ $level->lot?->lot_number ?? '—' }} {{ number_format($level->quantity_on_hand ?? 0) }} {{ number_format($level->quantity_reserved ?? 0) }} {{ number_format($avail) }} {{ $level->active_serial_count ?? 0 }} {{ $level->last_updated ? \Carbon\Carbon::parse($level->last_updated)->format('d M Y') : '—' }}
{{ $locationName }} Totals {{ number_format($locationLevels->sum('quantity_on_hand')) }} {{ number_format($locationLevels->sum('quantity_reserved')) }} {{ number_format($locationLevels->sum(fn($l) => ($l->quantity_on_hand ?? 0) - ($l->quantity_reserved ?? 0))) }}
@endforeach {{-- Legend --}}
Legend: Red = Below minimum stock level Amber = Serial records don't match on-hand qty
@endsection