@extends('documents.inventory._layout', [ 'documentTitle' => 'Stock Take Variance Report', 'reference' => $take->reference, 'documentDate' => $take->completed_date ? \Carbon\Carbon::parse($take->completed_date)->format('d M Y') : now()->format('d M Y'), ]) @section('header-meta')
Location: {{ $take->location?->name ?? '—' }}
Status: {{ ucwords(str_replace('_', ' ', $take->status)) }}
@endsection @section('content') @php $itemsWithVariance = $take->items->filter(fn($i) => $i->variance !== 0 && $i->variance !== null); $surplus = $take->items->filter(fn($i) => ($i->variance ?? 0) > 0); $shortage = $take->items->filter(fn($i) => ($i->variance ?? 0) < 0); $matched = $take->items->filter(fn($i) => ($i->variance ?? 0) === 0); $totalSystem = $take->items->sum('system_quantity'); $totalCounted = $take->items->sum('counted_quantity'); $totalVariance = $totalCounted - $totalSystem; @endphp {{-- Summary --}}
✓ Matched
{{ $matched->count() }}
↑ Surplus
{{ $surplus->count() }}
↓ Shortage
{{ $shortage->count() }}
Total Lines
{{ $take->items->count() }}
Net Variance
{{ $totalVariance >= 0 ? '+' : '' }}{{ number_format($totalVariance) }}
@if($take->approvedBy) @endif
Initiated By {{ $take->initiatedBy?->name ?? '—' }} Initiated Date {{ $take->initiated_date ? \Carbon\Carbon::parse($take->initiated_date)->format('d M Y') : '—' }}
Approved / Posted By {{ $take->approvedBy->name }} Posted Date {{ $take->posted_date ? \Carbon\Carbon::parse($take->posted_date)->format('d M Y') : '—' }}
{{-- All items table --}}

Count Results

@foreach($take->items as $i => $item) @php $v = $item->variance ?? 0; $rowClass = $v > 0 ? 'bg-blue' : ($v < 0 ? 'bg-amber' : ''); @endphp @endforeach
# Product Lot System Qty Counted Qty Variance Variance Reason Counted By
{{ $i + 1 }} {{ $item->product?->name ?? '—' }} @if($item->product?->sku)
{{ $item->product->sku }}@endif
{{ $item->lot?->lot_number ?? '—' }} {{ number_format($item->system_quantity) }} {{ $item->counted_quantity !== null ? number_format($item->counted_quantity) : '—' }} @if($v !== 0){{ $v > 0 ? '+' : '' }}{{ number_format($v) }}@else —@endif {{ $item->variance_reason ?? ($v === 0 ? '—' : 'Not specified') }} {{ $item->countedBy?->name ?? '—' }}
Totals {{ number_format($totalSystem) }} {{ number_format($totalCounted) }} {{ $totalVariance >= 0 ? '+' : '' }}{{ number_format($totalVariance) }}
@if($take->status === 'posted')

✓ Adjustment movements have been posted for all non-zero variances.

@endif @endsection