@extends($bookingLayout ?? 'crm.master') @section('title', 'Booking Invoice — ' . $booking->booking_number) @php $bookingRoutePrefix = request()->routeIs('crm.booking.*') ? 'crm.booking.' : (request()->routeIs('car-rental.*') ? 'car-rental.' : 'booking.'); $readOnlyInvoice = $readOnlyInvoice ?? request()->routeIs('car-rental.*'); @endphp @section('head-extra') @endsection @section('content')
@include('crm.components.alerts') @php $editingNoteId = (int) request()->query('edit_note'); $invoiceNotes = $booking->bookingNotes->where('show_on_invoice', true)->values(); $hasLiveTransactions = $booking->transactions->contains(function ($transaction) { return $transaction->payment_provider !== 'Test Payment Provider'; }); @endphp {{-- ── Top action bar ── --}}
@if($readOnlyInvoice) Back to Listings @else New Booking @endif
{{ $booking->customer_name }}, {{ $booking->start_datetime->format('F d Y') }}
@auth @unless($readOnlyInvoice) Edit Booking @endunless @endauth Print PDF
Invoice @auth @unless($readOnlyInvoice) Edit Transactions ({{ $booking->transactions->count() }}) @endunless @endauth
{{-- ══════════════ MAIN INVOICE ══════════════ --}}
{{-- Status --}} @unless($readOnlyInvoice)
@auth @unless($readOnlyInvoice)
Change the booking status and choose whether to notify the customer.
@endunless @if($readOnlyInvoice) {{ $booking->status_label }} @endif @else {{ $booking->status_label }} @endauth
@endunless {{-- Header: title + company --}}

Booking Invoice

{{-- Customer address --}}
{{ $booking->customer_name }}
@if($booking->customer_email) {{ $booking->customer_email }}
@endif @if($booking->customer_phone) {{ $booking->customer_phone }}
@endif @if($booking->customer_address) {{ $booking->customer_address }}
@endif @if($booking->customer_city || $booking->customer_state || $booking->customer_postal_code) {{ implode(', ', array_filter([$booking->customer_city, $booking->customer_state, $booking->customer_postal_code])) }}
@endif @if($booking->customer_country) {{ $booking->customer_country }} @endif

{{ $businessSetup?->company_name ?: config('app.name') }}

Booking ID: {{ $booking->booking_number }}
Created: {{ $booking->created_at->format('F j, Y') }}
Booking Date: {{ $booking->start_datetime->format('F j, Y') }}
Total (USD): ${{ number_format($booking->total_amount, 2) }}
{{-- Item table --}} @foreach($booking->items as $item) @endforeach {{-- Notes row spans left; sums on the right --}} @foreach($booking->tax_lines ?? [] as $tl) @endforeach @if($booking->discount_amount > 0) @endif @if($booking->balance_due > 0) @endif {{-- Footer buttons --}}
Product Rate Amount
{{ $item->product_name }}
{{ $booking->start_datetime->format('D M j, Y') }}
{{ $booking->start_datetime->format('g:i A') }} – {{ $booking->end_datetime->format('g:i A') }} @if($booking->rate_label)
{{ $booking->rate_label }} @endif
Qty: {{ $item->quantity }} @ ${{ number_format($item->unit_price, 2) }}
@if($item->rate_type === 'per_hour') {{ (int)$item->duration_hours }} Hour{{ (int)$item->duration_hours != 1 ? 's' : '' }} @elseif($item->rate_type === 'per_day') {{ max(1, ceil($item->duration_hours / 24)) }} Day{{ ceil($item->duration_hours/24) != 1 ? 's' : '' }} @elseif($item->rate_type === 'per_24_hours') {{ max(1, ceil($item->duration_hours / 24)) }} × 24 Hours @else 1 Booking @endif
${{ number_format($item->subtotal, 2) }}
@if($booking->rental_location)

Rental Location: {{ $booking->rental_location }}

@endif

Is this rental for a Wedding? {{ $booking->is_wedding ? 'Yes' : 'No' }}

@if($booking->is_wedding && $booking->bride_groom_name)

Bride & Groom: {{ $booking->bride_groom_name }}

@endif @if($booking->purpose)

Purpose of the booking: {{ $booking->purpose }}

@endif
Sub-Total: ${{ number_format($booking->subtotal, 2) }}
{{ $tl['name'] }} ({{ $tl['percent'] }}%): ${{ number_format($tl['amount'], 2) }}
Discount{{ $booking->discount_code ? ' (' . $booking->discount_code . ')' : '' }}: -${{ number_format($booking->discount_amount, 2) }}
Total: ${{ number_format($booking->total_amount, 2) }}
Amount Paid: @if($booking->amount_paid > 0 && $booking->amount_paid < $booking->total_amount) ${{ number_format($booking->amount_paid, 2) }} (partial) @else ${{ number_format($booking->amount_paid, 2) }} @endif
Balance Due: ${{ number_format($booking->balance_due, 2) }}
{{-- Payments line --}}
@php $latestTransaction = $booking->transactions->first(); @endphp Transactions: {{ optional($latestTransaction?->processed_at)->format('m/d/y') ?: $booking->created_at->format('m/d/y') }} ${{ number_format($booking->amount_paid, 2) }} @if($latestTransaction) ({{ $latestTransaction->status_label }}{{ $latestTransaction->payment_display ? ' - ' . $latestTransaction->payment_display : '' }}) @else (No payments) @endif
@if($invoiceNotes->isNotEmpty())

Notes

@foreach($invoiceNotes as $invoiceNote)
{{ $invoiceNote->note }}
@endforeach
@endif {{-- Created by / meta --}}
@unless($readOnlyInvoice) Source: {{ $booking->source_label }}    @endunless Booking #: {{ $booking->booking_number }}
@if(!empty($businessSetup?->company_policy))

Rental Policy

{!! $businessSetup->company_policy !!}
@endif
{{-- ══════════════ SIDEBAR: NOTES ══════════════ --}} @unless($readOnlyInvoice)
Booking Notes
@auth
@csrf
@endauth

Current booking status: {{ $booking->status_label }}. @if($booking->status === 'pending') We will confirm your reservation shortly via email. @elseif($booking->status === 'reserved') Your reservation has been reserved for the selected time. @elseif($booking->status === 'deposit') Your booking is reserved and waiting on the deposit stage. @elseif($booking->status === 'paid') Your booking has been paid. @elseif($booking->status === 'waiting') Your booking is currently waiting for the next update. @elseif($booking->status === 'cancelled') This booking has been cancelled. @elseif($booking->status === 'void') This booking is no longer active. @endif


@forelse($booking->bookingNotes as $note)
{{ $note->author_name ?: 'Staff' }} {{ $note->created_at->format('m/d/y h:i A') }} @if($note->show_on_invoice) Shown on invoice @endif @auth
Edit
@csrf @method('DELETE')
@endauth
@if(auth()->check() && $editingNoteId === $note->id)
@csrf @method('PATCH')
show_on_invoice) ? 'checked' : '' }}>
Cancel
@else
{{ $note->note }}
@endif
@empty

No booking notes yet.

@endforelse {{-- Quick booking info summary --}}
@foreach($booking->items as $item) @php $photo = $item->product?->photos?->first(); @endphp
@if($photo) @else
@endif
{{ $item->product_name }}
{{ $booking->start_datetime->format('M j') }} · {{ $booking->start_datetime->format('g:i A') }} – {{ $booking->end_datetime->format('g:i A') }}
@endforeach
Sub-Total ${{ number_format($booking->subtotal, 2) }}
@foreach($booking->tax_lines ?? [] as $tl)
{{ $tl['name'] }} ({{ $tl['percent'] }}%) ${{ number_format($tl['amount'], 2) }}
@endforeach @if($booking->discount_amount > 0)
Discount -${{ number_format($booking->discount_amount, 2) }}
@endif
Total ${{ number_format($booking->total_amount, 2) }}
@endunless
@auth @unless($readOnlyInvoice) @include('booking.partials.add-payment-modal') @endunless @endauth
@endsection @section('page-script') @auth @unless($readOnlyInvoice) @endunless @endauth @endsection