@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->orderable->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 = []; foreach ($order->bookings as $booking) { $tourName = $booking->tour->name ?? 'N/A'; foreach ($booking->passengers as $passenger) { $type = $passenger->type ?? 'N/A'; $price = $passenger->price ?? 0; $discount = (float) $passenger->discountedPrice(); $tax = $passenger->effectiveTaxTotal(); 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; @endphp {{-- Tour Name Column --}}
@foreach ($tourTypeCounts as $tour => $types)
@foreach ($types as $type => $count)
{{ $tour }}
@endforeach @endforeach @foreach ($groupedLineItems as $groupedLineItem ) {{ $groupedLineItem->$name }} @endforeach |
{{-- Type Column --}}
@foreach ($tourTypeCounts as $tour => $types)
@foreach ($types as $type => $count)
{{ ucfirst($type) }}
@endforeach @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 |
{{-- Quantity Column --}}
@foreach ($tourTypeCounts as $tour => $types)
@foreach ($types as $type => $count)
{{ $count }}
@endforeach @endforeach @foreach ($groupedLineItems as $groupedLineItem ) {{ $groupedLineItem->$qty }} @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 ($tourTypeDiscounts as $tour => $types)
@foreach ($types as $type => $discount)
{{ $discount < 0 ? '-$' . number_format(abs($discount), 2) : '$' . number_format($discount, 2) }}
@endforeach @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 $calculated = $groupedLineItem->effectiveTaxTotal(); @endphp {{ $calculated < 0 ? '-$' . number_format(abs($calculated), 2) : '$' . number_format($calculated, 2) }} @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?->billing_email_address ?? '' }}
@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' }} | {{ ucfirst($lineItem->type ?? 'Individual') }} | ${{ number_format($lineItem->price, 2) }} | {{ $qty }} | ${{ number_format($subtotal, 2) }} | {{ $lineItemDiscount < 0 ? '-' : '' }}${{ number_format(abs($lineItemDiscount), 2) }} | ${{ number_format($taxes, 2) }} | @php $rowTotal = $subtotal + $lineItemDiscount + $taxes; @endphp ${{ number_format($rowTotal, 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