@extends('layouts.app') @section('title', 'Invoice Details') @section('content') @php $rateVal = $currentCurrencyRate?->rate ?? 0; @endphp
{{-- Header Section --}}
@php $isFingerprintOnlyViewer = auth()->user()->branch_id && auth()->user()->branch_id === $booking->fingerprint_branch_id && auth()->user()->branch_id !== $booking->booking_branch_id; $isCrossBranchViewer = auth()->user()->branch_id && auth()->user()->branch_id !== $booking->booking_branch_id && auth()->user()->branch_id !== $booking->fingerprint_branch_id; $canEditBooking = !$isFingerprintOnlyViewer && !$isCrossBranchViewer && (auth()->user()->hasRole('Super Admin') || auth()->user()->hasRole('Co Admin') || ($booking->created_at->diffInHours(now()) < 12 && (auth()->user()->branch_id || $booking->user_id === auth()->id()))); $canViewRequestButtons = !$isFingerprintOnlyViewer && !$isCrossBranchViewer && (auth()->user()->branch_id || auth()->user()->roles->pluck('name')->intersect(['Super Admin', 'Co Admin', 'Ticket Admin', 'Ticket Staff'])->isNotEmpty()); $canAddPassenger = !$isFingerprintOnlyViewer && !$isCrossBranchViewer && (auth()->user()->hasRole('Super Admin') || auth()->user()->hasRole('Co Admin') || auth()->user()->branch_id || $booking->user_id === auth()->id()); $canDeleteDocument = auth()->user()->roles->pluck('name')->intersect(['Super Admin', 'Co Admin'])->isNotEmpty(); $canDeletePassengerDocument = auth()->user()->roles->pluck('name')->intersect(['Super Admin', 'Co Admin', 'Fingerprint Admin'])->isNotEmpty(); $canApplyDiscount = auth()->user()->roles->pluck('name')->intersect(['Super Admin', 'Co Admin'])->isNotEmpty(); @endphp

Invoice Details

ID: {{ $booking->id }}

Print @if($canEditBooking) @endif
Invoice No

{{ $booking->invoice_id ?? 'N/A' }}

Booking Date

{{ $booking->created_at->format('Y-m-d') }}

Customer

{{ $booking->customer->name ?? 'N/A' }}

Status {{ $booking->invoice && $booking->invoice->balance <= 0 ? 'Paid' : 'Due' }}
Original Total

@currency($originalTotal, 2, $rateVal)

−@currency($booking->discount_amount ?? 0, 2, $rateVal) discount @if($booking->discount_type?->value === 'percentage') ({{ rtrim(rtrim(number_format((float) $booking->discount_value, 2), '0'), '.') }}%) @endif

Discounted Total

@currency($booking->invoice?->total_amount ?? 0, 2, $rateVal)

Total Paid

@currency($booking->invoice?->paid_amount ?? 0, 2, $rateVal)

Due

@currency($booking->invoice?->balance ?? 0, 2, $rateVal)

@if($canApplyDiscount) @endif
@if(!$isFingerprintOnlyViewer && !$isCrossBranchViewer) {{-- Passengers Section --}}

Passengers

@forelse($booking->passengers as $index => $passenger) @php $passengerTotal = ($passenger->ticketFare?->fare ?? 0) + ($passenger->package_value ?? 0); @endphp
{{ $passenger->first_name ?? '' }} {{ $passenger->last_name ?? '' }} ({{ $passenger->passport_no ?? 'N/A' }})
@currency($passengerTotal, 2, $rateVal)
@empty

No passengers found.

@endforelse
@if($canAddPassenger)
@endif
@endif @if(!$isFingerprintOnlyViewer && !$isCrossBranchViewer) {{-- Documents Section --}}

Customer Documents

Max 5 MB per file, 20 MB total

@php $allCustomerDocs = collect($booking->documents) ->merge($booking->customer?->documents ?? collect()) ->sortBy(fn($d) => (int) preg_replace('/.*\s(\d+)$/', '$1', $d->display_name ?? '0')); @endphp @forelse($allCustomerDocs as $doc)
{{ $doc->display_name ?? 'Document' }}
@if($canDeleteDocument) @endif
@empty

No customer documents

@endforelse

Passenger Documents

@forelse($booking->passengers->flatMap->documents as $doc)
{{ $doc->display_name ?? 'Document' }}
@if($canDeletePassengerDocument) @endif
@empty

No passenger documents

@endforelse
@endif {{-- Action Buttons Row --}}
@if($canViewRequestButtons && !$booking->is_cancelled) @endif @if(!$isFingerprintOnlyViewer && !$isCrossBranchViewer) @endif @php $cancelledStatus = $booking->cancelledBooking?->status?->value; $isPaymentFrozen = $booking->is_cancelled && $cancelledStatus === 'cancelled'; @endphp
{{-- Tab Navigation --}}
@if($canViewRequestButtons) @endif
{{-- Payment History Tab --}}

Payment History

@forelse($booking->payments as $payment) @empty @endforelse
Date Voucher No Method Trx ID Receive By Receive At Amount Actions
{{ $payment->created_at->format('Y-m-d') }} {{ $payment->vouchers->first()?->voucher_id ?? 'N/A' }} {{ $payment->payment_method?->value ?? 'Cash' }} {{ $payment->transaction_id ?? '-' }} {{ $payment->user?->name ?? '-' }} {{ $payment->user?->branch?->name ?? 'Central' }} @currency($payment->amount, 2, $rateVal) @if(auth()->user()->hasRole('Super Admin')) @endif
No payments recorded
@if($canViewRequestButtons) {{-- Re-issue History Tab --}} {{-- Additional Ticket Tab --}} {{-- Refund Tab --}} @endif {{-- Back Button --}}
@include('partials.passenger-form-modal') {{-- Custom Duration Modal --}}

Set Custom Duration

{{-- Payment Modal --}}

Total Package Value: @currency($booking->invoice?->total_amount ?? 0, 2, $rateVal)
Paid: @currency($booking->invoice?->paid_amount ?? 0, 2, $rateVal)
Due: @currency($booking->invoice?->balance ?? 0, 2, $rateVal)
@if($canViewRequestButtons) {{-- Request Re-Issue Modal --}} {{-- Re-Issue Details Modal --}} {{-- Request Refund Modal --}} {{-- Refund Details Modal --}} {{-- Request Additional Ticket Modal --}} {{-- Additional Ticket Details Modal --}} @endif @if($canApplyDiscount) {{-- Discount Modal --}} @endif {{-- Toast Container --}}
@push('scripts') @endpush @endsection