@extends('layouts.app') @section('title', 'Invoices') @section('content')
{{-- Flash messages --}} @if (session('success'))
{{ session('success') }}
@endif @if (session('error'))
{{ session('error') }}
@endif {{-- Page header --}}

Invoices

@if ($unpaidCount > 0) {{ $unpaidCount }} {{ Str::plural('invoice', $unpaidCount) }} pending @else All invoices settled @endif

{{-- No create button — invoices are auto-generated --}}
{{-- Stat cards --}}
{{-- Unpaid --}}

Unpaid

{{ $unpaidCount }}

{{-- Overdue --}}

Overdue

{{ $overdueCount }}

@if ($overdueCount > 0)

requires action

@endif
{{-- Paid this month --}}

Paid this month

{{ $paidCount }}

{{-- Invoices table --}}
@if ($invoices->isEmpty())

No invoices yet

Invoices are generated automatically when a proposal is approved

@else @foreach ($invoices as $invoice) @php $sv = $invoice->status instanceof \App\Enums\InvoiceStatus ? $invoice->status->value : $invoice->status; $symbol = $invoice->currency instanceof \App\Enums\Currency ? $invoice->currency->symbol() : (string) $invoice->currency; $isOverdue = $invoice->due_date->isPast() && $sv === 'unpaid'; $totalAmt = (float) $invoice->amount; $paidAmt = $invoice->relationLoaded('payments') ? $invoice->payments->sum(fn ($p) => (float) $p->amount) : 0; $paidPct = $totalAmt > 0 ? min(100, round($paidAmt / $totalAmt * 100)) : 0; $progressColor = match($sv) { 'paid' => 'bg-emerald-500', 'partial' => 'bg-sky-600', default => 'bg-slate-200', }; $badgeClass = match($sv) { 'unpaid' => 'bg-amber-50 text-amber-700', 'partial' => 'bg-sky-50 text-sky-700', 'paid' => 'bg-emerald-50 text-emerald-700', default => 'bg-slate-100 text-slate-600', }; $badgeLabel = match($sv) { 'unpaid' => 'Unpaid', 'partial' => 'Partial', 'paid' => 'Paid', default => ucfirst($sv), }; @endphp @endforeach
Invoice # Client Project Amount Status Due Date Actions
{{ $invoice->invoice_number }} {{ $invoice->client->name }} {{ $invoice->project->title }}

{{ $symbol }} {{ number_format($totalAmt, 2) }}

@if ($sv !== 'unpaid' || $paidPct > 0)
@endif
{{ $badgeLabel }} {{ $invoice->due_date->format('d M Y') }} View @if ($sv === 'paid') · Paid {{ $invoice->paid_at->format('d M Y') }} @else · View & Pay @endif
@if ($invoices->hasPages())

Showing {{ $invoices->firstItem() }}–{{ $invoices->lastItem() }} of {{ $invoices->total() }}

{{ $invoices->links() }}
@endif @endif
@endsection