@if (session('status'))
{{ session('status') }}
@endif @if (session('error'))
{{ session('error') }}
@endif @php $invoiceNumber = $invoice->whmcs_invoice_id ?: preg_replace('/\D+/', '', (string) $invoice->invoice_number) ?: $invoice->invoice_number; $status = strtolower(str_replace(' ', '_', (string) $invoice->status)); $statusLabel = [ 'payment_pending_whmcs' => 'Payment Processing', 'payment_received' => 'Payment Received', 'whmcs_sync_failed' => 'Processing', 'sync_failed' => 'Processing', 'manual_review' => 'Under Review', ][$status] ?? ucwords(str_replace('_', ' ', $status ?: 'pending')); $isPayable = ! in_array($status, ['paid', 'cancelled', 'refunded', 'payment_received', 'payment_pending_whmcs'], true); $money = function ($amount, $currency = null) use ($invoice) { $currency = strtoupper((string) ($currency ?: $invoice->currency)); $value = number_format((float) $amount, 2); return $currency === 'USD' ? '$'.$value.' USD' : $currency.' '.$value; }; $invoiceDate = data_get($invoice->whmcs_payload, 'date') ?: data_get($invoice->whmcs_payload, 'datecreated') ?: $invoice->created_at; $displayDate = function ($value) { try { return $value ? \Illuminate\Support\Carbon::parse($value)->format('l, F jS, Y') : '-'; } catch (\Throwable) { return '-'; } }; @endphp
Invoice

Invoice #{{ $invoiceNumber }}

Due Date: {{ $displayDate($invoice->due_date) }}

{{ $statusLabel }} {{ $money($invoice->total) }}
Invoice Details

Items

Invoice Date: {{ $displayDate($invoiceDate) }}
@forelse ($invoice->items as $item) @empty @endforelse
Description Total
{{ $item->description }} {{ $money($item->total) }}
{{ data_get($invoice->whmcs_payload, 'description', 'Invoice items will appear after refresh.') }} {{ $money($invoice->total) }}
Sub Total {{ $money($invoice->subtotal ?: $invoice->total) }}
Credit {{ $money($invoice->discount ?: 0) }}
Balance {{ $money($invoice->total) }}