@php use Illuminate\Support\Str; $money = fn ($value) => 'R '.number_format((float) $value, 2); $activeTotal = (float) ($summary['active_credit_total'] ?? 0); $draftTotal = (float) ($summary['draft_amount'] ?? 0); $registerTotal = (float) ($summary['register_total'] ?? 0); $activeCount = (int) ($summary['issued_count'] ?? 0) + (int) ($summary['applied_count'] ?? 0); $maxBreakdownTotal = max(1, (float) collect($statusBreakdown)->max('total'), (float) collect($typeBreakdown)->max('total')); $statusBadge = fn (string $status) => (new \App\Models\CreditNote(['status' => $status]))->statusBadgeClass(); @endphp Back @can('view-financial-reports') Export CSV @endcan @can('manage-credit-notes') Create credit note @endcan

Active Credits

{{ $money($activeTotal) }}

Affects balances.

Adjustments

{{ $money($summary['active_adjustment_total'] ?? 0) }}

No cash returned.

Refunds

{{ $money($summary['active_refund_total'] ?? 0) }}

Refund scenarios.

Draft Value

{{ $money($draftTotal) }}

Not applied yet.

Status breakdown

Drafts do not reduce balances.

@foreach ($statusBreakdown as $row) @php $width = min(100, ((float) $row['total'] / $maxBreakdownTotal) * 100); @endphp
{{ $row['label'] }} {{ number_format($row['count']) }} {{ Str::plural('note', $row['count']) }}

{{ $money($row['total']) }}

@endforeach

Active credit mix

Issued and applied only.

@foreach ($typeBreakdown as $row) @php $width = min(100, ((float) $row['total'] / $maxBreakdownTotal) * 100); @endphp

{{ $row['label'] }}

{{ number_format($row['count']) }} active {{ Str::plural('note', $row['count']) }}

{{ $money($row['total']) }}

@endforeach
Register total {{ $money($registerTotal) }}
Draft value {{ $money($draftTotal) }}

Active credits

Already affecting invoice balances.

@if ($recentActiveCredits->isEmpty()) @else
@foreach ($recentActiveCredits as $creditNote) @endforeach
Credit note Invoice Client Status Amount
{{ $creditNote->credit_note_number }} {{ $creditNote->issue_date->format('d M Y') }} {{ $creditNote->invoice?->invoice_number ?? 'Unavailable' }} {{ $creditNote->client?->name ?? 'Client unavailable' }} {{ $creditNote->statusLabel() }} {{ $money($creditNote->amount) }}
@endif

Draft credits

Prepared, not applied.

@if ($draftCredits->isEmpty()) @else @endif