@extends('layouts.app') @section('title', 'Batch Recall Lookup') @section('content')
All batches

Batch recall

How much of this batch is still on the shelf and which customers it was sold to.

@if($batches->isNotEmpty())
@endif
@if($batchNo !== '' && $batches->isEmpty())
No batch matching "{{ $batchNo }}" has been received in this pharmacy.
@endif @foreach($batches as $batch) @php $batchSales = $sales->get($batch->id, collect()); @endphp @php $batchAdjustments = $adjustments->get($batch->id, collect()); @endphp
{{ $batch->batch_no ?? 'No batch number' }}
{{ $batch->product?->name ?? 'Deleted product' }} {{ $batch->product?->sku }}
Expiry
{{ $batch->expiry_date?->format('d M Y') ?? 'None' }}
Received
{{ rtrim(rtrim(number_format($batch->received_quantity, 2), '0'), '.') }}
{{ $batch->received_at?->format('d M Y') }}
Still in stock
{{ rtrim(rtrim(number_format($batch->quantity, 2), '0'), '.') }}
Sold
{{ rtrim(rtrim(number_format($batchSales->sum('quantity'), 2), '0'), '.') }}
@if($batch->quantity > 0)
If this batch is recalled, take the {{ rtrim(rtrim(number_format($batch->quantity, 2), '0'), '.') }} left off the shelf and record a Stock Out adjustment from batch {{ $batch->batch_no }}.
@endif
Sold to
@if($batchSales->isEmpty())

Not sold yet.

@else
@foreach($batchSales as $row) @endforeach
DateInvoiceCustomerPhoneQuantitySold by
{{ $row->sale->created_at->format('d M Y H:i') }} {{ $row->sale->invoice_no }} {{ $row->sale->customer_name ?: 'Walk-in customer' }} {{ $row->sale->contact_number ?: '-' }} {{ rtrim(rtrim(number_format($row->quantity, 2), '0'), '.') }} {{ $row->sale->user?->name ?? '-' }}
@endif @if($batchAdjustments->isNotEmpty())
Stock adjustments
@foreach($batchAdjustments as $adjustment) @endforeach
DateTypeQuantityReasonBy
{{ $adjustment->created_at->format('d M Y H:i') }} {{ $adjustment->adjustment_type === 'add' ? 'Stock in' : 'Stock out' }} {{ rtrim(rtrim(number_format($adjustment->quantity, 2), '0'), '.') }} {{ $adjustment->reason }} {{ $adjustment->user?->name ?? '-' }}
@endif
@endforeach
@endsection