@extends('admin.layouts.app') @section('title', 'Invoice Details') @section('content')

Invoice {{ $invoice->invoice_number }}

Back to Invoices View PDF @if($invoice->payment_status !== 'paid') @endif
Invoice Information
Invoice Number: {{ $invoice->invoice_number }}
Invoice Date: {{ $invoice->formatted_invoice_date }}
Due Date: {{ $invoice->due_date ? $invoice->due_date->format('M d, Y') : 'N/A' }}
Status: {{ ucfirst($invoice->status) }}
Payment Status: @php $paymentColors = ['unpaid' => 'danger', 'partial' => 'warning', 'paid' => 'success', 'overdue' => 'dark']; @endphp {{ ucfirst($invoice->payment_status) }}
Property Address
{{ $invoice->full_property_address ?: 'No address specified' }}
@if($invoice->invoice_note)
Invoice Note

{{ $invoice->invoice_note }}

@endif

Customers ({{ $invoice->customers->count() }})
@forelse($invoice->customers as $contact)
{{ $contact->full_name }} @if($contact->is_primary) Primary @endif @if($contact->email)
{{ $contact->email }} @endif @if($contact->phone)
{{ $contact->formatted_phone }} @endif
@empty

No customers

@endforelse
Agents ({{ $invoice->agents->count() }})
@forelse($invoice->agents as $contact)
{{ $contact->full_name }} @if($contact->email)
{{ $contact->email }} @endif @if($contact->phone)
{{ $contact->formatted_phone }} @endif
@empty

No agents

@endforelse
Inspectors ({{ $invoice->inspectors->count() }})
@forelse($invoice->inspectors as $contact)
{{ $contact->full_name }} @if($contact->email)
{{ $contact->email }} @endif
@empty

No inspectors

@endforelse

Service Details
@foreach($invoice->schedule->services as $scheduleService) @php $service = $scheduleService->service; $quantity = $scheduleService->quantity ?? 1; $unitPrice = $service->fee ?? $service->base_fee ?? 0; $total = $quantity * $unitPrice; @endphp @endforeach @if($invoice->schedule->scheduleDiscounts->count() > 0) @foreach($invoice->schedule->scheduleDiscounts as $discount) @endforeach @endif @if($invoice->schedule->scheduleAdditionalFees->count() > 0) @foreach($invoice->schedule->scheduleAdditionalFees as $fee) @endforeach @endif @if($invoice->tax_amount > 0) @endif @if($invoice->coupon_discount > 0) @endif
Service Quantity Unit Price Total
{{ $service->service_name ?? 'Unknown Service' }} {{ $quantity }} ${{ number_format($unitPrice, 2) }} ${{ number_format($total, 2) }}
{{ $discount->title }} (Discount) 1 -${{ number_format($discount->amount, 2) }} -${{ number_format($discount->amount, 2) }}
{{ $fee->title }} (Additional Fee) 1 ${{ number_format($fee->amount, 2) }} ${{ number_format($fee->amount, 2) }}
Subtotal: ${{ number_format($invoice->subtotal_amount ?? 0, 2) }}
Tax: ${{ number_format($invoice->tax_amount, 2) }}
Coupon Discount ({{ $invoice->coupon_code }}): -${{ number_format($invoice->coupon_discount, 2) }}
Total: {{ $invoice->formatted_total }}

Payment History
@if($invoice->payments->count() > 0)
@foreach($invoice->payments as $payment) @endforeach @if($invoice->balance_amount > 0) @endif
Date Amount Method Reference Status Recorded By
{{ $payment->formatted_payment_date }} {{ $payment->formatted_amount }} {{ $payment->payment_method_display }} {{ $payment->reference_number ?: '-' }} {{ $payment->status_display }} {{ $payment->recordedBy->first_name ?? 'Unknown' }} {{ $payment->recordedBy->last_name ?? '' }}
Total Paid: ${{ number_format($invoice->paid_amount, 2) }}
Balance Due: {{ $invoice->formatted_balance }}
@else

No payments recorded yet.

@endif
@endsection @push('scripts') @endpush