@section('title', 'Invoices')
@section('heading', 'Invoices')
@section('top-menu-items')
|
Select All |
@endif
Order# | Reference # | {{--Ref# | --}}Date | Products | Rate | Price | Qty | Subtotal | Discount | Taxes | Total | Paid | Due | @if ($invoice->status == 'Sent')Payment | @endif
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@endif
#{{ $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') : '' }} | @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 --}}
@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 |
{{-- Type Column --}}
@foreach ($tourTypeCounts as $tour => $types)
@foreach ($types as $type => $count)
{{ ucfirst($type) }}
@endforeach @endforeach @foreach ($pfLines as $pfLine) {{-- Private flight --}} @endforeach |
{{-- Price per Single Passenger Type --}}
@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 |
{{-- Quantity Column --}}
@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 |
{{-- Total Price Column --}}
@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) }} | @if ($invoice->status == 'Sent')@endif |
{{ $invoice->partner?->organization_name ?? 'N/A' }}
{{ $invoice->partner ? implode(', ', $invoice->partner->getInvoiceRecipientEmails()) : '' }}
@if($invoice->partner){{ $invoice->partner->address_line1 ?? '' }} {{ $invoice->partner->address_line2 ? ', ' . $invoice->partner->address_line2 : '' }}
{{ $invoice->partner->city ?? '' }}, {{ $invoice->partner->province ?? '' }}
{{ $invoice->partner->country ?? '' }}, {{ $invoice->partner->postal_code ?? '' }}
@endif| Order# | Reference # | Date | Products | Rate | Price | Qty | Subtotal | Discount | Taxes | Total | Paid | Due | @if($invoice->status == 'Sent')Payment | @endif
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| #{{ $order->id }} | {{ $partnerId }} | {{ $orderDate }} | @endif{{ $tourName }} | {{ ucfirst($type) }} | ${{ number_format($singlePrice, 2) }} | {{ $count }} | ${{ number_format($subtotal, 2) }} | {{ $totalDiscount < 0 ? '-' : '' }}${{ number_format(abs($totalDiscount), 2) }} | ${{ number_format($totalTax, 2) }} | @if ($isFirstRow)${{ number_format($orderTotal ?? 0, 2) }} | ${{ number_format($order->paid ?? 0, 2) }} | ${{ number_format($orderDue, 2) }} | @if($invoice->status == 'Sent')$0.00 | @endif @endif
| {{ $lineItem->name ?? 'Item' }} | @if (stripos((string) ($lineItem->name ?? ''), 'private flight') !== false) @else {{ ucfirst($lineItem->type ?? 'Individual') }} @endif | ${{ number_format($lineItem->price, 2) }} | {{ $qty }} | ${{ number_format($subtotal, 2) }} | {{ $lineItemDiscount < 0 ? '-' : '' }}${{ number_format(abs($lineItemDiscount), 2) }} | ${{ number_format($taxes, 2) }} | {{-- Paid, Due, and Payment are already shown with rowspan in first row --}}
| Subtotal: | ${{ number_format($total_val ?? 0, 2) }} |
| Discount: | {{ ($total_dis ?? 0) < 0 ? '-' : '' }}${{ number_format(abs($total_dis ?? 0), 2) }} |
| Taxes: | ${{ number_format($total_tax ?? 0, 2) }} |
| Total: | ${{ number_format(($total_val ?? 0) + ($total_tax ?? 0) + ($total_dis ?? 0), 2) }} |
| Paid: | ${{ number_format($paid ?? 0, 2) }} |
| Balance Due: | @php $balance = ($total_val ?? 0) + ($total_tax ?? 0) + ($total_dis ?? 0) - ($paid ?? 0); @endphp ${{ number_format($balance, 2) }} |
No files uploaded yet.
@endif