{{-- Status pill of one invoice (#2957 slice 6d, card #3020), used by the invoice list and the invoice page. Expects: $invoice. The words are the invoice keys the old views used (Skickad for a credit invoice, Krediterad, Betald, Obetald); the colour follows DESIGN.md's status table. An unpaid invoice whose due date has come is red, as the old list coloured its due date. Optional $paymentPending (admin invoice list only, #2957 Nov11): an unpaid invoice whose registered payments match its amount shows "Betalning registrerad" in amber with an explanation in the shared tooltip (focusable for keyboard). --}} @php $invoicePaymentPending = (bool) ($paymentPending ?? false); [$invoiceWord, $invoicePill] = match (true) { $invoice->status == Invoice::_get('statusTypes')['credit'] => ['invoice.sent', 'neutral'], $invoice->isCredited() => ['invoice.credited', 'neutral'], (bool) $invoice->isPaid() => ['invoice.paid', 'done'], $invoicePaymentPending => ['feedback_nov11.invoice.paymentPending', 'running'], $invoice->duedate <= \Carbon\Carbon::today() => ['invoice.notPaid', 'stopped'], default => ['invoice.notPaid', 'planned'], }; @endphp @if ($invoiceWord === 'feedback_nov11.invoice.paymentPending') {{ __($invoiceWord) }} @else {{ __($invoiceWord) }} @endif