@extends('pdf.layout') @section('content') @php $today = \Carbon\Carbon::today(); $value = $expiryItems->getCollection()->sum(fn ($b) => (float) $b->quantity_remaining * (float) ($b->unit_cost ?? $b->product?->purchase_price ?? 0)); @endphp
Batches with expiry
{{ number_format($totalItems) }}
in stock
Expired
{{ number_format($expiredItems) }}
remove from the shelf
Expiring in 30 days
{{ number_format($expiringSoonItems) }}
sell first
Value listed
MWK {{ number_format($value, 2) }}
at cost
@if($expiryItems->count()) @foreach($expiryItems as $b) @php $days = $b->expiry_date ? (int) $today->diffInDays($b->expiry_date, false) : null; [$class, $text] = $days === null ? ['badge-grey', 'No date'] : ($days < 0 ? ['badge-red', 'Expired'] : ($days <= 30 ? ['badge-amber', 'Expiring soon'] : ['badge-green', 'Valid'])); @endphp @endforeach
ProductBatchSupplierReceivedExpiryDays leftQtyValue (MWK)Status
{{ $b->product?->name ?? 'Deleted product' }}
{{ $b->product?->sku }}
{{ $b->batch_no }} {{ $b->purchaseItem?->purchase?->supplier?->name ?? $b->product?->supplier?->name ?? '-' }} {{ ($b->received_at ?? $b->created_at)->format('d M Y') }} {{ $b->expiry_date?->format('d M Y') }} {{ $days === null ? '-' : ($days < 0 ? abs($days) . ' ago' : $days) }} {{ (float) $b->quantity_remaining }} {{ number_format((float) $b->quantity_remaining * (float) ($b->unit_cost ?? $b->product?->purchase_price ?? 0), 2) }} {{ $text }}
Total ({{ $expiryItems->count() }} batches){{ (float) $expiryItems->getCollection()->sum('quantity_remaining') }}{{ number_format($value, 2) }}
@else
No batches match these filters.
@endif @endsection