@extends('layouts.app')
@section('title', 'Stock count #' . $count->id)
@php
$qty = fn ($v) => $v === null ? '' : rtrim(rtrim(number_format((float) $v, 2), '0'), '.');
$counted = $count->lines->whereNotNull('counted_qty')->count();
$total = $count->lines->count();
@endphp
@section('content')
Pharmacy Health
Stock count #{{ $count->id }}
{{ $count->scope_label }} · started {{ $count->created_at->format('d M Y H:i') }} by {{ $count->user->name ?? '-' }}
@if($count->note) · {{ $count->note }} @endif
@unless($count->isOpen())
@endunless
@if($count->isOpen())
@php
$missedIds = collect(session('missed', []));
$missedLines = $count->lines->whereIn('id', $missedIds->all())->sortBy(fn ($l) => $l->product->name ?? '');
$reasons = \App\Services\PharmacyHealth::SKIP_REASONS;
@endphp
{{-- Blind count: the system figure is not on this page --}}
Count each product on the shelf and type the number. The system figure is hidden and taken at the moment you save,
so sales during the count are fine. Save as you go. If you no longer have a product, press Skip and say why.
{{-- Missed products: filled by the server after Finish, or by the page before sending --}}
{{ $missedLines->count() === 1 ? 'One product was missed.' : $missedLines->count() . ' products were missed.' }}
Please count {{ $missedLines->count() === 1 ? 'it' : 'them' }}, or skip any you no longer have.
@else
@php
$grade = \App\Models\StockCount::grade((float) $count->health_score);
[$gradeLabel, $gradeTone] = \App\Models\StockCount::GRADES[$grade];
$order = ['short' => 0, 'over' => 1, 'match' => 2, 'skipped' => 3];
@endphp
@foreach([
['Health', rtrim(rtrim(number_format((float) $count->health_score, 1), '0'), '.') . '%', $gradeLabel, $gradeTone],
['Matched', $count->lines_matched . ' / ' . $count->lines_counted, 'products', 'secondary'],
['Short', $count->lines_short, formatCurrency((float) $count->shortage_value) . ' at cost', $count->lines_short ? 'danger' : 'success'],
['More than system', $count->lines_over, formatCurrency((float) $count->over_value) . ' at cost', $count->lines_over ? 'warning' : 'secondary'],
] as [$label, $value, $hint, $tone])
{{ $label }}
{{ $value }}
{{ $hint }}
@endforeach
| Product | System | Shelf | Difference |
Value (cost) | |
@foreach($count->lines->sortBy(fn ($l) => [$order[$l->result] ?? 3, $l->product->name ?? '']) as $line)
@php $value = abs((float) $line->difference) * (float) $line->unit_cost; @endphp
|
{{ $line->product->name ?? 'Deleted product' }}
{{ $line->result === 'skipped' ? 'skipped ' . $line->skipped_at?->format('d M H:i') : 'counted ' . $line->counted_at?->format('d M H:i') }}{{ $line->counter ? ' by ' . $line->counter->name : '' }}
|
{{ $qty($line->expected_qty) }} |
{{ $qty($line->counted_qty) }} |
@if($line->result === 'match')
0
@elseif($line->result === 'skipped')
–
@else
{{ (float) $line->difference > 0 ? '+' : '' }}{{ $qty($line->difference) }}
@endif
|
{{ in_array($line->result, ['match', 'skipped'], true) ? '' : formatCurrency($value) }} |
@if($line->result === 'short')
Missing from the shelf
@elseif($line->result === 'over')
More than the system: a delivery or a return not entered?
@elseif($line->result === 'skipped')
Skipped: {{ $line->skip_reason }}
@endif
|
@endforeach
System figures were taken when each product was counted; the person counting did not see them.
@if($count->lines_short) The shortage is recorded once in Loss Prevention as the pharmacy's, not against any one person. @endif
The system stock was not changed: correct it with a stock adjustment once you know what happened.
@endif
@endsection