@extends('admin.layout') @section('title', 'Invoice ' . $invoice->invoice_number) @section('content')

Invoice {{ $invoice->invoice_number }}

{{ strtoupper($invoice->hotel_name) }}
@if($settings && $settings->hotel_logo) @if($settings->hotel_logo && Storage::disk('public')->exists($settings->hotel_logo)) Hotel Logo @else
LOGO
HOTEL
@endif @endif
{{ $invoice->hotel_name }}
@if($settings)
{{ $settings->hotel_address }}
{{ $settings->hotel_phone }} | {{ $settings->hotel_email }}
@endif

INVOICE

# {{ $invoice->invoice_number }}
{{ $invoice->created_at->format('d F Y') }}
@if(($invoice->non_refundable ?? false) || (!empty($invoice->notes) && preg_match('/non[- ]?refund/i', $invoice->notes)))
NON-REFUNDABLE
@endif
Bill To:
{{ $invoice->guest_name }}
{{ $invoice->guest_email }}
@if($invoice->guest_phone)
{{ $invoice->guest_phone }}
@endif
Booking Details:
Booking ID: {{ $invoice->booking->booking_code ?? 'N/A' }}
Check-in: {{ $invoice->check_in_date->format('d/m/Y') }}
Check-out: {{ $invoice->check_out_date->format('d/m/Y') }}
Duration: {{ $invoice->nights }} {{ $invoice->nights > 1 ? 'nights' : 'night' }}
@php $statusClass = match($invoice->status ?? 'draft') { 'draft' => 'status-draft', 'sent' => 'status-sent', 'paid' => 'status-paid', 'cancelled' => 'status-cancelled', default => 'status-draft' }; @endphp {{ ucfirst($invoice->status ?? 'Draft') }}
@if($invoice->paymentChannel)
Payment Method: {{ $invoice->paymentChannel->name }}
@endif @if($invoice->paid_at)
Paid At: {{ $invoice->paid_at->format('d/m/Y H:i') }}
@endif
@php $hasMerged = isset($mergedSources) && ($mergedSources->count() > 0); $overrideSegments = []; if (!empty($invoice->notes) && preg_match('/Overrides:\s*([^|]+)/i', $invoice->notes, $ovm)) { $ovraw = trim($ovm[1] ?? ''); if ($ovraw !== '') { foreach (explode(';', $ovraw) as $seg) { $seg = trim($seg); if ($seg === '') continue; $parts = array_map('trim', explode(':', $seg)); if (count($parts) >= 4) { $overrideSegments[] = [ 'name' => $parts[0], 'rate' => is_numeric($parts[1]) ? intval($parts[1]) : 0, 'nights' => is_numeric($parts[2]) ? intval($parts[2]) : 0, 'subtotal' => is_numeric($parts[3]) ? intval($parts[3]) : 0, 'start' => $parts[4] ?? null, 'end' => $parts[5] ?? null, ]; } } } } @endphp @if($hasMerged) @foreach($mergedSources as $src) @php $ov = isset($itemOverrides) ? ($itemOverrides[$src->invoice_number] ?? null) : null; $nights = $ov['nights'] ?? ($src->nights ?? (\Carbon\Carbon::parse($src->check_in_date)->diffInDays(\Carbon\Carbon::parse($src->check_out_date)) ?: 1)); $rate = $ov['rate'] ?? ($src->room_rate ?? 0); $amount = $ov['subtotal'] ?? ($src->subtotal ?? 0); $baseCheckIn = $src->booking->check_in_date ?? $src->check_in_date; $isExtendRow = (\Carbon\Carbon::parse($src->check_in_date)->toDateString() !== \Carbon\Carbon::parse($baseCheckIn)->toDateString()); $startDisp = isset($ov['start']) && $ov['start'] ? \Carbon\Carbon::parse($ov['start'])->format('d M Y') : \Carbon\Carbon::parse($src->check_in_date)->format('d M Y'); $endDisp = isset($ov['end']) && $ov['end'] ? \Carbon\Carbon::parse($ov['end'])->format('d M Y') : \Carbon\Carbon::parse($src->check_out_date)->format('d M Y'); @endphp @endforeach @elseif(count($overrideSegments) > 0) @foreach($overrideSegments as $item) @php $roomDisplay = '-'; $name = $item['name'] ?? ''; if (strpos($name, ' - ') !== false) { $partsNm = explode(' - ', $name); $roomDisplay = $partsNm[1] ?? '-'; $name = $partsNm[0] ?? $name; } @endphp @endforeach @else @php $isExtend = (\Carbon\Carbon::parse($invoice->check_in_date)->toDateString() !== \Carbon\Carbon::parse($invoice->booking->check_in_date)->toDateString()); @endphp @php $ratePerNight = (int) ($invoice->room_rate ?? ((($invoice->nights ?? 1) > 0) ? (int) (($invoice->subtotal ?? 0) / ($invoice->nights ?? 1)) : (int) ($invoice->subtotal ?? 0))); @endphp @endif @if($invoice->booking && $invoice->booking->roomServices && $invoice->booking->roomServices->count() > 0) @foreach($invoice->booking->roomServices as $service) @endforeach @endif
Description Room Nights Rate Amount
{{ $src->room_type ?? ($src->booking->room->roomType->name ?? 'Room') }}@if($isExtendRow) (Extend)@endif
{{ $startDisp }} - {{ $endDisp }}
{{ $src->room_number ?? ($src->booking->room->room_number ?? '-') }} {{ $nights }} Rp {{ number_format($rate, 0, ',', '.') }} Rp {{ number_format($amount, 0, ',', '.') }}
{{ $name }} Room @if(!empty($item['start']) && !empty($item['end']))
{{ \Carbon\Carbon::parse($item['start'])->format('d M Y') }} - {{ \Carbon\Carbon::parse($item['end'])->format('d M Y') }}
@endif
{{ $roomDisplay }} {{ $item['nights'] }} Rp {{ number_format($item['rate'], 0, ',', '.') }} Rp {{ number_format($item['subtotal'], 0, ',', '.') }}
{{ $invoice->room_type ?? ($invoice->booking->room->roomType->name ?? 'Room') }}@if($isExtend) (Extend)@endif
{{ $invoice->check_in_date->format('d M Y') }} - {{ $invoice->check_out_date->format('d M Y') }}
{{ $invoice->room_number }} {{ $invoice->nights }}Rp {{ number_format($ratePerNight, 0, ',', '.') }} Rp {{ number_format($invoice->subtotal, 0, ',', '.') }}
Room Service - {{ $service->service_name }} - {{ $service->quantity }} Rp {{ number_format($service->unit_price, 0, ',', '.') }} Rp {{ number_format($service->total_price, 0, ',', '.') }}
@php $cardCharge = 0; if (!empty($invoice->notes) && preg_match('/Card\s*Charge:\s*Rp\s*([0-9\.,]+)/i', $invoice->notes, $m)) { $raw = $m[1] ?? '0'; $cardCharge = (int) preg_replace('/[^0-9]/', '', $raw); } $taxRate = (int) \App\Models\Settings::get('tax_rate', 10); $servicesViewTotal = (int) ($invoice->services_total ?? 0); if ($servicesViewTotal <= 0 && $invoice->booking && $invoice->booking->roomServices) { $servicesViewTotal = (int) $invoice->booking->roomServices->sum('total_price'); } $totalInclude = max(0, (int) ($invoice->subtotal ?? 0) + $servicesViewTotal - (int) ($invoice->discount_amount ?? 0) ); $rawDPP = $totalInclude / (1 + ($taxRate / 100)); $baseDPP = floor($rawDPP); $dpp = (($rawDPP - $baseDPP) < 0.5) ? $baseDPP : ($baseDPP + 1); $computedTax = max(0, $totalInclude - $dpp); $finalTotal = $totalInclude + $cardCharge; @endphp
Total Included Tax: Rp {{ number_format($totalInclude, 0, ',', '.') }}
@if($cardCharge > 0)
Card Charge: Rp {{ number_format($cardCharge, 0, ',', '.') }}
@endif
Total: Rp {{ number_format($finalTotal, 0, ',', '.') }}
Tax Included: Rp {{ number_format($computedTax, 0, ',', '.') }}
@if($invoice->notes)
Special Requests / Notes:
{{ $invoice->notes }}
@endif
Thank you for choosing {{ $invoice->hotel_name }}!
This is a computer-generated invoice and does not require a signature.
Generated on {{ now()->format('d F Y, H:i') }} WIB
@if($settings && $settings->hotel_website)
Visit us at: {{ $settings->hotel_website }}
@endif
Update Invoice Status
@endsection