@extends('layouts.master') @section('title', $title) {{-- One cash session's own page (CashSessionController@profile): who / when, the totals, and tabs for the close by method, every payment, expenses, refunds and the day's unpaid bills. $b = App\Services\CashSessionReport. --}} @php $diff = (float) $item->total_difference; $balanced = abs($diff) < 0.01; $refundTotal = $b['refunds']->sum(fn ($r) => (float) $r->payment); @endphp @section('page_css') @endsection @section('content')
{{-- header --}}

Cash Session #{{ $item->id }}

@if ($item->status == 'closed') Locked @else Open @endif
{{ \Illuminate\Support\Carbon::parse($item->date)->format('l, d M Y') }} Shift {{ $item->shift_id ?: '—' }} {{ $item->usr?->name ?? 'Unknown cashier' }} Previous cashier: {{ $item->prev_cashier?->name ?? '—' }} @if ($item->updated_at) Closed {{ local_time($item->updated_at, 'd M Y, h:i A') }} @endif
{{-- totals --}}
@foreach ([ ['Opening', $item->total_open_balance, 'ti-wallet', 'secondary', ''], ['Payments received', $item->total_payments, 'ti-cash', 'success', count($b['lines']) . ' payment(s)'], ['Expenses', $item->total_expenses, 'ti-receipt', 'warning', count($b['expenses']) . ' expense(s)'], ['Expected in hand', $item->total_expected, 'ti-calculator', 'info', 'opening + payments − expenses'], ['Actual counted', $item->total_actual, 'ti-coins', 'primary', ''], ['Difference', $diff, $balanced ? 'ti-circle-check' : 'ti-alert-triangle', $balanced ? 'success' : 'danger', $balanced ? 'balanced' : ($diff < 0 ? 'short' : 'over')], ] as [$label, $value, $icon, $tone, $sub])
{{ $label }}

{{ number_format((float) $value, 2) }}

@if ($sub){{ $sub }}@endif
@endforeach
{{-- tabs --}}
{{-- overview: close by method + money by source --}}
Cash close by payment method
@forelse ($item->cashclose as $row) @empty @endforelse
MethodOpeningPaymentsExpenses ExpectedActual countedDifference
{{ $row->method->name ?? '—' }} {{ number_format($row->opening, 2) }} {{ number_format($row->payments, 2) }} {{ number_format($row->expenses, 2) }} {{ number_format($row->expected, 2) }} {{ number_format($row->actual, 2) }} {{ number_format($row->difference, 2) }}
No methods recorded.
TOTAL{{ number_format($item->total_open_balance, 2) }}{{ number_format($item->total_payments, 2) }} {{ number_format($item->total_expenses, 2) }}{{ number_format($item->total_expected, 2) }} {{ number_format($item->total_actual, 2) }} {{ number_format($diff, 2) }}
Where the payments came from
@if ($b['sources']->isEmpty())

No payments received this day.

@else
@foreach ($b['methods'] as $name)@endforeach @foreach ($b['sources'] as $s) @foreach ($b['methods'] as $mid => $name)@endforeach @endforeach @foreach ($b['methods'] as $mid => $name)@endforeach
SourceCount{{ $name }}TotalDiscount
{{ $s['source'] }}{{ $s['count'] }}{{ number_format($s['methods'][$mid] ?? 0, 2) }}{{ number_format($s['amount'], 2) }}{{ number_format($s['discount'], 2) }}
TOTAL{{ count($b['lines']) }}{{ number_format($b['by_method'][$mid] ?? 0, 2) }}{{ number_format($b['total'], 2) }}{{ number_format($b['total_discount'], 2) }}
@endif
{{-- every payment, searchable --}}
@foreach ($b['lines'] as $i => $l) @endforeach
#TimeSourceBillPatientMethodAmountDiscount
{{ $i + 1 }} {{ $l['time'] ? local_time($l['time'], 'h:i A') : '' }} {{ $l['source'] }} {{ $l['bill'] }} {{ $l['patient'] ?? '—' }} @if ($l['patient_code'])({{ $l['patient_code'] }})@endif {{ $l['method'] }} {{ number_format($l['amount'], 2) }} {{ number_format($l['discount'], 2) }}
TOTAL{{ number_format($b['total'], 2) }}{{ number_format($b['total_discount'], 2) }}
{{-- expenses --}}
@if ($b['expenses']->isEmpty())

No expenses paid out this day.

@else @foreach ($b['expenses'] as $e) @endforeach
ExpenseNoteMethodAmount
{{ $e['what'] }}{{ $e['note'] }}{{ $e['method'] }}{{ number_format($e['amount'], 2) }}
TOTAL{{ number_format($b['expenses']->sum('amount'), 2) }}
@endif
{{-- refunds --}}
@if ($b['refunds']->isEmpty())

No refunds this day.

@else

Refunded payments are not counted in the session's payments.

@foreach ($b['refunds'] as $r) @endforeach
SourceBillPatientReason / noteAmount
{{ $r->source }}{{ $r->bill }}{{ $r->patient_name ?? '—' }} {{ $r->description }}{{ number_format($r->payment, 2) }}
TOTAL{{ number_format($refundTotal, 2) }}
@endif
{{-- unpaid bills of the day --}}
@if ($b['unpaid']->isEmpty())

Every bill entered by this cashier this day is paid.

@else
@foreach ($b['unpaid_summary'] as $u) {{ $u['label'] }} {{ $u['count'] }} · $ {{ number_format($u['balance'], 2) }} @endforeach
@foreach ($b['unpaid'] as $u) @endforeach
PatientTypeBillDescriptionChargePaidBalanceStatus
{{ $u['patient_name'] }} ({{ $u['patient_code'] }}){{ $u['type_label'] }}{{ $u['ref'] }} {{ $u['label'] }}{{ number_format($u['charge'], 2) }} {{ number_format($u['paid'] + $u['discount'], 2) }}{{ number_format($u['balance'], 2) }} {{ $u['status'] }}
@can('payment-view') Collect in Unpaid Bills @endcan @endif
@endsection @section('page_js') @endsection