@extends('layouts.app') @section('title', 'Bad Debt Report') @section('content')

Bad Debt / Write-Off Report

Invoices written off as uncollectable. Used for management review and tax reporting.

{{-- Date filter --}}
Reset
{{-- Totals card --}}
Total Written Off
KES {{ number_format($totals['amount'], 2) }}
across {{ $totals['count'] }} {{ \Illuminate\Support\Str::plural('invoice', $totals['count']) }} · {{ $from->format('d M Y') }} — {{ $to->format('d M Y') }}
@if($totals['count'] === 0)
No write-offs in this period
Nothing has been written off between {{ $from->format('d M Y') }} and {{ $to->format('d M Y') }}.
@else {{-- Breakdown by reason --}}
Breakdown by Reason
@foreach($byReason as $row) @endforeach
Reason Count Amount (KES) % of Total
{{ $row['label'] }} {{ $row['count'] }} {{ number_format($row['amount'], 2) }} {{ $totals['amount'] > 0 ? number_format(($row['amount'] / $totals['amount']) * 100, 1) : '0' }}%
{{-- Breakdown by month --}} @if($byMonth->count() > 1)
Monthly Trend
@foreach($byMonth as $row) @endforeach
Month Count Amount (KES)
{{ $row['label'] }} {{ $row['count'] }} {{ number_format($row['amount'], 2) }}
@endif {{-- Detail list --}}
Written-Off Invoices ({{ $invoices->count() }})
@foreach($invoices as $inv) @endforeach
Date Invoice Patient Module Reason Amount By
{{ $inv->written_off_at ? \Carbon\Carbon::parse($inv->written_off_at)->format('d M Y') : '—' }} @if($inv->visit) {{ $inv->invoice_number }} @else {{ $inv->invoice_number }} @endif {{ $inv->patient->full_name ?? '—' }} @if($inv->patient?->mrn) {{ $inv->patient->mrn }} @endif {{ $inv->visit?->visit_type ?? '—' }} {{ \App\Services\WriteOffService::REASONS[$inv->written_off_reason] ?? $inv->written_off_reason ?? '—' }} KES {{ number_format((float) $inv->written_off_amount, 2) }} {{ $inv->writtenOffBy->name ?? '—' }}
@endif @endsection