@php /** @var \App\Models\FinanceDocument $doc */ $cur = $doc->currency ?: 'USD'; $fmt = fn ($n) => ($n < 0 ? '-' : '').$cur.' '.number_format(abs((float) $n), 2); $title = $doc->kind === 'estimate' ? 'ESTIMATE' : 'INVOICE'; $status = $doc->displayStatus(); $badge = match ($status) { 'paid', 'accepted' => ['#dcfce7', '#166534'], 'overdue', 'declined', 'void' => ['#fee2e2', '#991b1b'], 'sent', 'converted' => ['#dbeafe', '#1e40af'], default => ['#f3f4f6', '#374151'], }; @endphp
|
@if(!empty($logo)) {{ $business ?: config('app.name') }}
|
{{ $title }}{{ $doc->number }}
@if($doc->issue_date)Issued: {{ $doc->issue_date->format('M j, Y') }} @endif
@if($doc->due_date){{ $doc->kind === 'estimate' ? 'Valid until' : 'Due' }}: {{ $doc->due_date->format('M j, Y') }} @endif
{{ $status }}
|
| Description | Qty | Unit price | Amount |
|---|---|---|---|
| {{ $item['description'] ?? '' }} | {{ rtrim(rtrim(number_format((float) ($item['quantity'] ?? 0), 2), '0'), '.') }} | {{ $fmt($item['unit_price'] ?? 0) }} | {{ $fmt($item['amount'] ?? ((float) ($item['quantity'] ?? 0) * (float) ($item['unit_price'] ?? 0))) }} |
| Subtotal | {{ $fmt($doc->subtotal) }} |
| Discount{{ $doc->discount_type === 'percent' ? ' ('.rtrim(rtrim(number_format((float) $doc->discount_value, 2), '0'), '.').'%)' : '' }} | -{{ $fmt($doc->discount_total) }} |
| Tax ({{ rtrim(rtrim(number_format((float) $doc->tax_rate, 2), '0'), '.') }}%) | {{ $fmt($doc->tax_total) }} |
| Total | {{ $fmt($doc->total) }} |
| Paid | {{ $fmt($doc->amount_paid) }} |
| Balance due | {{ $fmt($doc->balance()) }} |
| Date | Method | Reference | Amount |
|---|---|---|---|
| {{ $p->paid_at?->format('M j, Y') }} | {{ $p->method ? ucfirst($p->method) : '—' }} | {{ $p->reference ?: '—' }} | {{ $fmt($p->amount) }} |