@extends('layouts.app') @section('title', $product->name . ' - ' . setting('system_name')) @section('content') @php $qty = fn ($value) => rtrim(rtrim(number_format((float) $value, 2), '0'), '.'); $user = auth()->user(); $inStock = $batches->filter(fn ($b) => $b->quantity > 0); $usedUp = $batches->filter(fn ($b) => $b->quantity <= 0); $expiredQty = $inStock->filter->isExpired()->sum('quantity'); @endphp
@if($product->image) @endif

{{ $product->name }}

SKU {{ $product->sku }} @if($product->category) · {{ $product->category->name }} @endif @if($product->brand) · {{ $product->brand->name }} @endif
Back to List @if($user->hasPermission('view_stock_report')) Sales & stock history @endif @if($user->hasPermission('create_stock_adjustment')) Adjust Stock @endif @if($user->hasPermission('edit_product')) Edit @endif
@if(session('success'))
{{ session('success') }}
@endif
In stock
{{ $qty($product->current_stock) }} {{ $product->unit?->short_name ?? 'pcs' }}
@if($expiredQty > 0)
{{ $qty($expiredQty) }} expired, {{ $qty($sellable) }} can be sold
@else
Alert at {{ $qty($product->alertLevel()) }}
@endif
Selling price
{{ formatCurrency($product->selling_price) }}
@if($user->hasPermission('view_purchase_price'))
Cost {{ formatCurrency($product->purchase_price) }}
@endif
Next to sell expires
@php $next = $batches->firstWhere('id', $nextBatchId); $days = $next?->expiry_date ? today()->diffInDays($next->expiry_date, false) : null; @endphp
@if($product->isExpired()) Expired @elseif($next?->expiry_date) {{ $next->expiry_date->format('d M Y') }} @else - @endif
@if($next)
Batch {{ $next->label() }}
@endif
Supplier
{{ $product->supplier?->name ?? '-' }}
@if($product->supplier?->phone)
{{ $product->supplier->phone }}
@endif

Batches

Sold first-expiry-first. Expired batches are not sold.
@if($inStock->isEmpty())

No stock. Batches appear here when stock is received.

@else
@foreach($inStock as $batch) @php $days = $batch->expiry_date ? today()->diffInDays($batch->expiry_date, false) : null; @endphp @endforeach
Batch NoExpiryIn stockReceivedSold
{{ $batch->label() }} @if($batch->id === $nextBatchId)sold next@endif @if($batch->expiry_date) {{ $batch->expiry_date->format('d M Y') }} @if($batch->isExpired())Expired @elseif($days <= \App\Models\Product::EXPIRING_SOON_DAYS){{ (int) $days }} days left@endif @else None @endif {{ $qty($batch->quantity) }} {{ $qty($batch->received_quantity) }}
{{ $batch->received_at?->format('d M Y') }}
{{ $qty($sold[$batch->id] ?? 0) }} @if($batch->batch_no && $user->hasPermission('view_stock_report')) Trace @endif
@if($expiredQty > 0)

Take expired batches off the shelf and record a Stock Out adjustment (reason: Expired).

@endif @endif @if($usedUp->isNotEmpty())
Used-up batches ({{ $usedUp->count() }})
@foreach($usedUp as $batch) @endforeach
Batch NoExpiryReceivedSold
{{ $batch->label() }} {{ $batch->expiry_date?->format('d M Y') ?? 'None' }} {{ $qty($batch->received_quantity) }}
{{ $batch->received_at?->format('d M Y') }}
{{ $qty($sold[$batch->id] ?? 0) }} @if($batch->batch_no && $user->hasPermission('view_stock_report')) Trace @endif
@endif
@if($product->description)

Description

{{ $product->description }}

@endif
@endsection