@if($stockRequest->is_test_data)
QA TEST DATA - NOT FOR OPERATIONAL USE
@endif @php($receiptItems=$stockRequest->receipts->flatMap->items) @php($shipped=$stockRequest->items->sum(fn($i)=>(float)$i->shipped_qty)) @php($received=$receiptItems->sum(fn($i)=>(float)$i->received_qty)) @php($accepted=$receiptItems->sum(fn($i)=>(float)$i->accepted_qty))
Stock Receiving Report
{{ $stockRequest->request_number }} · {{ strtoupper(str_replace('_',' ',$stockRequest->status)) }}
Salesman: {{ $stockRequest->salesman?->name }}Van: {{ $vanName }}Dispatch: {{ $stockRequest->dispatched_at?->format('d M Y H:i') }}Receiving: {{ $stockRequest->receiving_started_at?->format('d M Y H:i') ?? '—' }}
Delivery Note: {{ $stockRequest->delivery_note_number ?: '—' }}Driver: {{ $stockRequest->dispatch_driver ?: '—' }}Vehicle: {{ $stockRequest->dispatch_vehicle ?: '—' }}Confirmed By: {{ $stockRequest->receipts->last()?->receiver?->name ?? '—' }}
@if($stockRequest->dispatch_note)
Dispatch Notes: {!! nl2br(e($stockRequest->dispatch_note)) !!}
@endif @foreach($stockRequest->items as $i) @php($lineReceipts=$receiptItems->where('stock_replenishment_item_id',$i->id)) @php($lineReceived=$lineReceipts->sum(fn($r)=>(float)$r->received_qty)) @php($lineAccepted=$lineReceipts->sum(fn($r)=>(float)$r->accepted_qty)) @php($types=$lineReceipts->pluck('discrepancy_type')->unique()->map(fn($v)=>str_replace('_',' ',ucwords($v,'_')))->implode(', ') ?: 'Pending') @php($diff=$lineAccepted-(float)$i->shipped_qty)@endforeach
SKUProductShipped QtyReceived QtyAccepted QtyDifferenceDiscrepancy
{{ $i->sku_snapshot }}{{ $i->name_snapshot }}{{ number_format($i->shipped_qty,2) }}{{ number_format($lineReceived,2) }}{{ number_format($lineAccepted,2) }}{{ number_format($diff,2) }}{{ $types }}@foreach($lineReceipts->whereNotNull('notes') as $ri)
{{ $ri->notes }}@endforeach
@php($short=max(0,$shipped-$received)) @php($excess=max(0,$received-$shipped)) @php($damaged=$receiptItems->where('discrepancy_type','damaged')->sum(fn($r)=>max(0,(float)$r->received_qty-(float)$r->accepted_qty)))
Summary: Shipped Pieces {{ number_format($shipped,2) }} · Received Pieces {{ number_format($received,2) }} · Accepted Pieces {{ number_format($accepted,2) }} · Short Pieces {{ number_format($short,2) }} · Excess Pieces {{ number_format($excess,2) }} · Damaged Pieces {{ number_format($damaged,2) }} · Wrong Item Lines {{ $receiptItems->where('discrepancy_type','wrong_item')->count() }} · Not Received Lines {{ $receiptItems->where('discrepancy_type','not_received')->count() }}
@if(in_array($stockRequest->status,['receiving','partially_received','in_transit'],true))
OPEN DISCREPANCIES — this shipment is not fully reconciled.
@endif @if($stockRequest->receiving_note)
Receiving Notes: {{ $stockRequest->receiving_note }}
@endif
Received Qty records physical receipt. Accepted Qty alone enters sellable VAN stock. Discrepancies and historical receipts are never erased. Generated {{ now()->format('d M Y H:i') }}.