@extends('layouts.app') @section('content')
{{-- Include stock navigation tabs --}}
@include('stock.nav', ['tab' => 'expired-items'])
{{-- Header --}}

Expired Items Management

Manage expired batches: acknowledge, dispose, or recover value

{{-- Summary Stats --}}
{{ $stats['unnoticed'] ?? 0 }}
Unnoticed Batches
{{ $stats['pending_resolution'] ?? 0 }}
Pending Resolution
Rs. {{ number_format($stats['total_recovered_this_month'] ?? 0, 2) }}
Recovered This Month
Rs. {{ number_format($stats['total_loss_this_month'] ?? 0, 2) }}
Net Loss This Month
{{-- Tabs --}} {{-- Flash Messages --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- Tab Content --}} @if($tab === 'unnoticed') {{-- Unnoticed Expired Batches --}}
These batches have passed their expiry date and still have stock. Mark as "Noticed" to acknowledge and remove from active stock.
@if($unnoticedBatches->isEmpty())
✓ No expired batches need attention
@else
@foreach($unnoticedBatches as $batch) @php $daysExpired = (int) abs(now()->diffInDays(\Carbon\Carbon::parse($batch->expiry_date), false)); $totalCost = (float) $batch->qty * (float) $batch->unit_cost; @endphp @endforeach
Product Batch Expired Qty Cost Supplier Action
{{ $batch->name_local ?: $batch->product_name }}
{{ $batch->barcode }}
{{ $batch->batch_name ?: 'No batch name' }}
#{{ $batch->price_detail_id }}
{{ \Carbon\Carbon::parse($batch->expiry_date)->format('Y-m-d') }}
{{ $daysExpired }} {{ $daysExpired === 1 ? 'day' : 'days' }} ago
{{ number_format((float) $batch->qty, 3) }}
Rs. {{ number_format((float) $batch->unit_cost, 2) }}/ea
Total: Rs. {{ number_format($totalCost, 2) }}
{{ $batch->supplier_name ?: '-' }}
@if($unnoticedBatches->hasPages())
{{ $unnoticedBatches->links() }}
@endif @endif
@elseif($tab === 'pending') {{-- Pending Resolution --}}
These items have been noticed (stock deducted). Choose how to resolve each one.
@if($pendingItems->isEmpty())
✓ No items pending resolution
@else
@foreach($pendingItems as $item)
{{ $item->reference_number }} Noticed {{ $item->noticed_at?->diffForHumans() }}
{{ $item->product?->name_local ?: $item->product?->name }}
Batch: {{ $item->batch_name ?: '#' . $item->price_detail_id }}
Expired: {{ $item->expiry_date?->format('Y-m-d') }}
{{ number_format($item->qty, 3) }} units
Cost: Rs. {{ number_format($item->total_cost, 2) }}
@if($item->supplier)
Supplier: {{ $item->supplier->name }}
@endif
@endforeach
@if($pendingItems->hasPages())
{{ $pendingItems->links() }}
@endif @endif
@else {{-- History --}}
History of resolved expired items showing recovery and loss.
@if($historyItems->isEmpty())
No history records yet
@else
@foreach($historyItems as $item) @php $loss = $item->total_cost - $item->refund_value; $recoveryPct = $item->total_cost > 0 ? round(($item->refund_value / $item->total_cost) * 100, 0) : 0; $outcomeColors = [ 'disposed' => 'bg-gray-100 text-gray-700', 'refund_cash' => 'bg-green-100 text-green-700', 'exchange_product' => 'bg-blue-100 text-blue-700', ]; $outcomeLabels = [ 'disposed' => 'Disposed', 'refund_cash' => 'Cash Refund', 'exchange_product' => 'Product Exchange', ]; @endphp @endforeach
Reference Product Qty Outcome Cost Recovered Loss Resolved
{{ $item->reference_number }}
{{ $item->product?->name_local ?: $item->product?->name }}
{{ $item->batch_name }}
{{ number_format($item->qty, 3) }} {{ $outcomeLabels[$item->outcome_type] ?? $item->outcome_type }} Rs. {{ number_format($item->total_cost, 2) }} Rs. {{ number_format($item->refund_value, 2) }} @if($recoveryPct > 0) ({{ $recoveryPct }}%) @endif Rs. {{ number_format($loss, 2) }} {{ $item->resolved_at?->format('Y-m-d H:i') }}
@if($historyItems->hasPages())
{{ $historyItems->links() }}
@endif @endif
@endif
{{-- Result Modal (custom in-page popup) --}} {{-- Mark Noticed Modal --}} {{-- Mark Off-POS Sale Modal --}} {{-- Dispose Modal --}} {{-- Refund Cash Modal --}} {{-- Exchange Product Modal --}} {{-- Undo Modal --}} @push('scripts') @endpush @endsection