@section('title', 'Invoices') @section('heading', 'Invoices') @section('top-menu-items') @endsection
@if (isset($invoice->id))

INVOICE

{{-- Logo --}}
{{ $invoice->partner?->organization_name }}
{{ $invoice->partner ? implode(', ', $invoice->partner->getInvoiceRecipientEmails()) : '' }}
Invoice ID #{{ $invoice->id }}
Status {{ $invoice->status ?? '' }}
Open Date {{ $invoice->created_at->format('d M, Y') }}
Closed Date {{ $invoice->closed_at ? \Carbon\Carbon::parse($invoice->closed_at)->format('d M, Y') : '' }}
Paid Date {{ $invoice->paid_at ? \Carbon\Carbon::parse($invoice->paid_at)->format('d M, Y') : '' }}
Billing Address Unit 1/23 Hastings Road,
Melbourne 3000,
Victoria,
Australia.
Shipping Address Unit 1/23 Hastings Road,
Melbourne 3000,
Victoria,
Australia.
@if ($invoice->status == 'Sent') @endif {{-- --}} @if ($invoice->status == 'Sent') @endif @foreach ($orders as $order) @if ($invoice->status == 'Sent') @endif {{-- --}} @php $tourTypeCounts = []; $tourTypePrices = []; $tourTypeDiscounts = []; $tourTypeTaxes = []; $totalTaxAmount = 0; $totalDiscounts = 0; foreach ($order->bookings as $booking) { $tourName = $booking->tour->name ?? 'N/A'; $tourTaxes = $booking->tour->taxes ?? 'N/A'; foreach ($booking->passengers as $passenger) { $type = $passenger->type ?? 'N/A'; $price = $passenger->price ?? 0; // Calculate discount $discount = 0; if ($passenger->passengerItems) { foreach ($passenger->passengerItems as $dis) { $discount += $dis->price; } } // Calculate tax $tax = 0; if ($passenger->taxes) { foreach ($passenger->taxes as $t) { $tax += $t->price ?? 0; $totalTaxAmount += $t->price ?? 0; } } // Store data if (!isset($tourTypeCounts[$tourName][$type])) { $tourTypeCounts[$tourName][$type] = 1; $tourTypePrices[$tourName][$type] = $price; $tourTypeDiscounts[$tourName][$type] = $discount; $tourTypeTaxes[$tourName][$type] = $tax; } else { $tourTypeCounts[$tourName][$type]++; $tourTypePrices[$tourName][$type] += $price; $tourTypeDiscounts[$tourName][$type] += $discount; $tourTypeTaxes[$tourName][$type] += $tax; } } } $name = 'name'; $price = 'price'; $qty = 'qty'; $taxes = 'taxes'; $groupedLineItems = $order->lineItems; $pfLines = []; foreach ($order->bookings as $invBooking) { foreach ($invBooking->lineitems ?? [] as $invLine) { if (stripos((string) ($invLine->name ?? ''), 'private flight') !== false && (float) ($invLine->price ?? 0) != 0.0) { $pfLines[] = $invLine; } } } @endphp {{-- Tour Name Column --}} {{-- Type Column --}} {{-- Price per Single Passenger Type --}} {{-- Quantity Column --}} {{-- Total Price Column --}} @if ($invoice->status == 'Sent') @endif @endforeach

Select All

Order# Reference #Ref#Date Products Rate Price Qty Subtotal Discount Taxes Total Paid DuePayment
#{{ $order->id }} {{ $order->partner_ref_id ?? 'N/A' }} {{ $order->Partner_ref_id ?? 'N/A' }} {{ optional($order->bookings->first())->booking_date ? \Carbon\Carbon::parse($order->bookings->first()->booking_date)->format('d-m-Y') : '' }}
@foreach ($tourTypeCounts as $tour => $types) @foreach ($types as $type => $count) {{ $tour }}
@endforeach @endforeach @foreach ($groupedLineItems as $groupedLineItem ) {{ $groupedLineItem->$name }}
@endforeach @foreach ($pfLines as $pfLine) {{ $pfLine->name }}
@endforeach
@foreach ($tourTypeCounts as $tour => $types) @foreach ($types as $type => $count) {{ ucfirst($type) }}
@endforeach @endforeach @foreach ($pfLines as $pfLine) {{-- Private flight
--}} @endforeach
@foreach ($tourTypePrices as $tour => $types) @foreach ($types as $type => $total) @php $count = $tourTypeCounts[$tour][$type] ?? 1; $singlePrice = $count > 0 ? $total / $count : 0; @endphp {{ $singlePrice < 0 ? '-$' . number_format(abs($singlePrice), 2) : '$' . number_format($singlePrice, 2) }}
@endforeach @endforeach @foreach ($groupedLineItems as $groupedLineItem ) {{ number_format($groupedLineItem->$price, 2) }}
@endforeach @foreach ($pfLines as $pfLine) ${{ number_format((float) $pfLine->price, 2) }}
@endforeach
@foreach ($tourTypeCounts as $tour => $types) @foreach ($types as $type => $count) {{ $count }}
@endforeach @endforeach @foreach ($groupedLineItems as $groupedLineItem ) {{ $groupedLineItem->$qty }}
@endforeach @foreach ($pfLines as $pfLine) {{ (int) ($pfLine->qty ?? 1) }}
@endforeach
@foreach ($tourTypePrices as $tour => $types) @foreach ($types as $type => $total) @php $numericTotal = is_numeric($total) ? (float) $total : 0; @endphp {{ $numericTotal < 0 ? '-$' . number_format(abs($numericTotal), 2) : '$' . number_format($numericTotal, 2) }}
@endforeach @endforeach @foreach ($groupedLineItems as $groupedLineItem ) {{ $groupedLineItem->$qty * $groupedLineItem->$price }}
@endforeach @foreach ($pfLines as $pfLine) ${{ number_format(((int) ($pfLine->qty ?? 1)) * ((float) $pfLine->price), 2) }}
@endforeach
@foreach ($tourTypeDiscounts as $tour => $types) @foreach ($types as $type => $discount) {{ $discount < 0 ? '-$' . number_format(abs($discount), 2) : '$' . number_format($discount, 2) }}
@endforeach @endforeach @foreach ($pfLines as $pfLine) @php $pfDiscDisplay = 0.0; $pfLineSub = (float) $pfLine->price * (int) ($pfLine->qty ?? 1); if (! empty($pfLine->discounts) && is_array($pfLine->discounts)) { foreach ($pfLine->discounts as $pd) { if (($pd['type'] ?? '') === 'percentage') { $pfDiscDisplay += $pfLineSub * ((float) ($pd['value'] ?? 0) / 100); } else { $pfDiscDisplay += (float) ($pd['value'] ?? 0); } } } @endphp {{ $pfDiscDisplay != 0.0 ? ($pfDiscDisplay < 0 ? '-$' . number_format(abs($pfDiscDisplay), 2) : '$' . number_format($pfDiscDisplay, 2)) : '$0.00' }}
@endforeach
@foreach ($tourTypeTaxes as $tour => $types) @foreach ($types as $type => $tax) {{ $tax < 0 ? '-$' . number_format(abs($tax), 2) : '$' . number_format($tax, 2) }}
@endforeach @endforeach @foreach ($groupedLineItems as $groupedLineItem ) @php $taxes = json_decode($groupedLineItem->taxes, true); $price = $groupedLineItem->price; @endphp @if (!empty($taxes)) @foreach ($taxes as $tax) @php $isPercentage = $tax['type'] == 'percentage'; $calculated = $isPercentage ? ($price * $tax['value']) / 100 : $tax['value']; $totalTaxAmount += $calculated ?? 0; @endphp {{ $calculated < 0 ? '-$' . number_format(abs($calculated), 2) : '$' . number_format($calculated, 2) }}
@endforeach @else $0.00
@endif @endforeach @foreach ($pfLines as $pfLine) @php $pfTaxes = json_decode($pfLine->taxes, true); $pfPrice = (float) $pfLine->price; @endphp @if (!empty($pfTaxes)) @foreach ($pfTaxes as $tax) @php $isPercentage = ($tax['type'] ?? '') == 'percentage'; $pfCalc = $isPercentage ? ($pfPrice * (float) ($tax['value'] ?? 0)) / 100 : (float) ($tax['value'] ?? 0); $totalTaxAmount += $pfCalc ?? 0; @endphp {{ $pfCalc < 0 ? '-$' . number_format(abs($pfCalc), 2) : '$' . number_format($pfCalc, 2) }}
@endforeach @else $0.00
@endif @endforeach
@php $orderTotal = ($order->total_price + $order->discount) + ($order->taxes ?? 0); @endphp {{ $orderTotal < 0 ? '-$' . number_format(abs($orderTotal), 2) : '$' . number_format($orderTotal, 2) }} @php $orderPaid = (float) $order->paid; @endphp {{ $orderPaid < 0 ? '-$' . number_format(abs($orderPaid), 2) : '$' . number_format($orderPaid, 2) }} @php $due = $orderTotal - ($orderPaid ?? 0); @endphp {{ $due < 0 ? '-$' . number_format(abs($due), 2) : '$' . number_format($due, 2) }}
@php $balance = ($total_val + $total_dis + $total_tax) - $paid; $balance = abs($balance) < 0.5 ? 0 : $balance; @endphp
@if ($invoice->status == 'Sent') @endif
Sub-Total {{ $total_val < 0 ? '-$' . number_format(abs($total_val), 2) : '$' . number_format($total_val, 2) }}
Discount {{ $total_dis < 0 ? '-$' . number_format(abs($total_dis), 2) : '$' . number_format($total_dis, 2) }}
Taxes {{ $total_tax < 0 ? '-$' . number_format(abs($total_tax), 2) : '$' . number_format($total_tax, 2) }}
Total @php $grandTotal = $total_val + $total_dis + $total_tax; @endphp {{ $grandTotal < 0 ? '-$' . number_format(abs($grandTotal), 2) : '$' . number_format($grandTotal, 2) }}
Payments {{ $paid < 0 ? '-$' . number_format(abs($paid), 2) : '$' . number_format($paid, 2) }}
Balance {{ $balance < 0 ? '-$' . number_format(abs($balance), 2) : '$' . number_format($balance, 2) }}
@if ($status === 'Open') @endif @if ($status === 'Closed' || $status === 'Sent')
@if ($invoice->sent_date) Last Sent Date: {{ $invoice->sent_date->format('Y-m-d') }} @else Not sent yet @endif
@endif
@endif
@if (!empty($uploadedFiles))
    @foreach ($uploadedFiles as $file) @if ($file)
  • @if(in_array(pathinfo($file->name, PATHINFO_EXTENSION), ['jpg', 'jpeg', 'png', 'gif'])) @else @endif {{ basename($file->name) }}
  • @endif @endforeach
@else

No files uploaded yet.

@endif
@push('scripts') @endpush