@extends('layouts.app') @section('title','Profit & Loss Summary') @section('styles')@endsection @section('content')

Profit & Loss Summary

{{ $from->format('d M Y') }} — {{ $to->format('d M Y') }}

@php $exportType = 'profit-loss'; @endphp @include('reports._date-filter') @php // Two distinct net positions — both meaningful, different purposes. // Cash Net = Collections − Expenses Paid (pure cash-flow view) // Accrual Net = Invoiced − Expenses Paid (mixed; what the old card showed) $cashNet = $collections - $expensesPaid; $accrualNet = $revenue - $expensesPaid; @endphp {{-- ═══ HEADLINE CARDS ═══════════════════════════════════════════════ Four cards: Invoiced + Collections + Expenses Paid + Cash Net. Tooltips on each tile clarify the definition. --}}

Invoiced

KES {{ number_format($revenue) }}

All invoices raised

Collections

KES {{ number_format($collections) }}

Completed payments

Expenses Paid

KES {{ number_format($expensesPaid) }}

Cash-out only

Cash Net

KES {{ number_format($cashNet) }}

Collections − Expenses Paid

{{-- ═══ RECONCILIATION NOTE ═══════════════════════════════════════════ The relationship between Invoiced, Collections, and the gap is non-obvious for non-finance users. This panel explains it in plain language. --}} @php $arGap = $revenue - $collections; @endphp @if($revenue > 0)

Invoiced − Collections = KES {{ number_format($arGap) }}. This gap is money the hospital billed but hasn't yet collected — it sits in Accounts Receivable (patients owing balances + insurance claims pending settlement). See Open Balance report for the breakdown.

@if($accrualNet !== $cashNet)

Accrual Net (Invoiced − Expenses Paid): KES {{ number_format($accrualNet) }} — this is the figure if you treat unbilled receivables as already-earned revenue. Cash Net (above) is the conservative measure based on cash actually in hand.

@endif
@endif {{-- ═══ DEPARTMENT + CATEGORY BREAKDOWNS ═══════════════════════════ --}}

Revenue by Department

By invoice line department (pharmacy, lab, consultation, etc.)

@forelse($revenueByDept as $r) @empty @endforelse
{{ $r->department ?: 'Other' }} KES {{ number_format($r->total) }}
No invoiced revenue in window.

Expenses by Category

By recorded expense date (accrual basis)

@forelse($expensesByCategory as $e) @empty @endforelse
{{ $e->category }} KES {{ number_format($e->total) }}
No expenses recorded in window.
@endsection