@extends('layouts.app') @section('title', 'Cash Shift #' . $cashShift->id) @section('content') @php $isAdmin = auth()->user()->hasAnyRole('Super Admin', 'Hospital Admin'); $isOwner = auth()->id() === $cashShift->opened_by_user_id; $variance = $cashShift->variance(); $expected = $cashShift->expectedCash(); $collected = $cashShift->cashCollected(); @endphp
← Back to Cash Recon
@if(session('success'))
{{ session('success') }}
@endif @if(session('warning'))
{{ session('warning') }}
@endif {{-- Header card --}}

Cash Shift #{{ $cashShift->id }} {{ $cashShift->shift_label }}

{{ $cashShift->shift_date->format('l, d M Y') }} · Opened by {{ $cashShift->openedBy->name ?? '—' }} at {{ $cashShift->opened_at->format('H:i') }} @if($cashShift->closed_at) · Closed by {{ $cashShift->closedBy->name ?? '—' }} at {{ $cashShift->closed_at->format('H:i') }} @endif

@php $statusMap = [ 'open' => ['Open', 'bg-emerald-100 text-emerald-800'], 'pending_review' => ['Pending Review', 'bg-amber-100 text-amber-800'], 'closed' => ['Closed', 'bg-gray-100 text-gray-700'], ]; [$label, $class] = $statusMap[$cashShift->status] ?? [$cashShift->status, 'bg-gray-100 text-gray-700']; @endphp {{ $label }}
{{-- Reconciliation panel --}}

Reconciliation

@if($cashShift->closing_count !== null) @endif
Opening float {{ number_format($cashShift->opening_float, 2) }}
+ Cash collected during shift {{ number_format($collected, 2) }}
Expected cash {{ $cashShift->status === 'open' ? 'now' : 'at close' }} {{ number_format($expected, 2) }}
Counted at close {{ number_format($cashShift->closing_count, 2) }}
Variance {{ $variance >= 0 ? '+' : '' }}{{ number_format($variance, 2) }}
@if($cashShift->status === 'open')
@if($isOwner || $isAdmin) Close Shift @else

Only {{ $cashShift->openedBy->name ?? 'the opener' }} or an admin can close this shift.

@endif
@endif
{{-- Variance notes (if closed) --}} @if($cashShift->variance_notes)

Variance Notes (from {{ $cashShift->closedBy->name ?? '—' }})

{{ $cashShift->variance_notes }}

@endif {{-- Admin approval inline (pending_review only, admin only) --}} @if($cashShift->status === 'pending_review' && $isAdmin)

Admin Variance Approval

This shift was closed with a variance of KES {{ number_format($variance, 2) }} (threshold is KES 200). Approving acknowledges the variance and closes the shift permanently. This action is one-way — the receptionist cannot reopen to find missing cash.

@if($errors->any())
    @foreach($errors->all() as $e)
  • {{ $e }}
  • @endforeach
@endif
@csrf
@elseif($cashShift->status === 'pending_review' && !$isAdmin)
Awaiting Hospital Admin review. Variance: KES {{ number_format($variance, 2) }}.
@endif {{-- Admin approval record (closed-with-approval shifts) --}} @if($cashShift->approved_at)

Variance Approved

{{ $cashShift->approvedBy->name ?? '—' }} approved this shift's variance on {{ $cashShift->approved_at->format('d M Y, H:i') }}.

@if($cashShift->approval_notes)

{{ $cashShift->approval_notes }}

@endif
@endif {{-- Cash payments list --}}

Cash Payments {{ $payments->count() }} payment(s) · KES {{ number_format($payments->sum('amount'), 2) }}

@if($cashShift->status === 'open')

Live list — refresh to update.

@endif
@if($payments->isEmpty())
No cash payments collected during this shift yet.
@else @foreach($payments as $p) @endforeach
Time Patient Invoice Received By Amount (KES)
{{ $p->created_at->format('H:i:s') }} {{ $p->patient->full_name ?? '—' }} {{ $p->invoice->invoice_number ?? '—' }} {{ $p->receiver->name ?? '—' }} {{ number_format($p->amount, 2) }}
@endif
@endsection