@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 {{ ucfirst($doc->kind) }} {{ $doc->number }}
@if(!empty($logo))@endif
{{ $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 }}
{{ $doc->kind === 'estimate' ? 'Prepared for' : 'Billed to' }}
{{ $doc->customer_name }}
@if($doc->customer_email)
{{ $doc->customer_email }}
@endif @if($doc->customer_address)
{!! nl2br(e($doc->customer_address)) !!}
@endif
@foreach(($doc->items ?? []) as $item) @endforeach
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))) }}
@if((float) $doc->discount_total > 0) @endif @if((float) $doc->tax_total > 0) @endif @if($doc->kind === 'invoice') @endif
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()) }}
@if($doc->kind === 'invoice' && $payments->isNotEmpty())

Payments

@foreach($payments as $p) @endforeach
DateMethodReferenceAmount
{{ $p->paid_at?->format('M j, Y') }} {{ $p->method ? ucfirst($p->method) : '—' }} {{ $p->reference ?: '—' }} {{ $fmt($p->amount) }}
@endif @if($doc->notes)

Notes

{!! nl2br(e($doc->notes)) !!}
@endif @if($doc->terms)

Terms

{!! nl2br(e($doc->terms)) !!}
@endif