{{-- Paid / Partial / Unpaid pill with a small progress bar. Works for orders and vendor bills. --}} @props(['total', 'paid', 'cancelled' => false, 'bar' => true]) @php $total = (float) $total; $paid = (float) $paid; $pct = $total > 0 ? min(100, round($paid / $total * 100)) : 0; [$state, $label, $color] = match (true) { $cancelled => ['na', 'Cancelled', 'secondary'], $total <= 0.004 => ['na', '—', 'secondary'], $paid >= $total - 0.004 => ['paid', 'Paid', 'success'], $paid > 0.004 => ['partial', 'Partial', 'warning'], default => ['unpaid', 'Unpaid', 'danger'], }; @endphp
{{ $label }}@if ($state === 'partial') · {{ $pct }}%@endif @if ($bar && $state !== 'na')
@endif