{{ __('hotel::modules.checkOut.checkOut') }}

@if($stays->count())
@foreach ($stays as $stay) @php $isOverdue = $stay->expected_checkout_at->isPast(); $isDueToday = $stay->expected_checkout_at->isToday() && !$isOverdue; @endphp
{{-- Stay number + balance badge --}}

{{ $stay->stay_number }}

@if($stay->folio) {{ currency_format($stay->folio->balance) }} @endif
{{-- Room info --}}
{{ $stay->room->room_number }} · {{ $stay->room->roomType->name }}
{{-- Guest name --}}
{{ $stay->stayGuests->first()?->guest->full_name ?? 'N/A' }}
{{-- Divider --}}
{{-- Date/time + button on same row --}}
{{ $stay->expected_checkout_at->format('M d, Y') }} · {{ $stay->expected_checkout_at->format('g:i A') }}
@endforeach
@else

{{ __('hotel::modules.checkOut.noStaysReadyForCheckOut') }}

@endif
{{ $stays->links() }}
@if ($selectedStay && $selectedStay->folio) {{ __('hotel::modules.checkOut.checkOutModalTitle', ['number' => $selectedStay->stay_number]) }} @php $advancePayments = $selectedStay->folio->folioPayments->where('payment_method', 'advance'); $otherPayments = $selectedStay->folio->folioPayments->where('payment_method', '!=', 'advance'); $advanceTotal = $advancePayments->sum('amount'); $otherTotal = $otherPayments->sum('amount'); $paidRsTotal = $paidRoomServiceTotal ?? 0; $baseBalance = $effectiveBalance ?? $selectedStay->folio->balance; $discount = max(0, (float)($discountAmount ?? 0)); $displayBalance = max(0, $baseBalance - $discount); @endphp
{{-- ══ Stay banner ══ --}}

{{ __('hotel::modules.checkOut.room') }} {{ $selectedStay->room->room_number }} — {{ $selectedStay->room->roomType->name }}

{{ $selectedStay->stayGuests->first()?->guest->full_name ?? '—' }}

{{ $displayBalance > 0 ? currency_format($displayBalance) . ' due' : '✓ Paid' }}
{{-- ══ SECTION 1: Folio lines ══ --}}
{{ __('hotel::modules.checkOut.folioSummary') }}
@foreach($selectedStay->folio->folioLines as $line) @endforeach {{-- Advance payment row --}} @if($advanceTotal > 0) @endif {{-- Prior payments row --}} @if($otherTotal > 0) @endif {{-- Paid room-service row --}} @if($paidRsTotal > 0) @endif {{-- Live discount row (shows as soon as user types) --}} @if($discount > 0) @endif
{{ __('hotel::modules.checkOut.date') }} {{ __('hotel::modules.checkOut.description') }} {{ __('hotel::modules.checkOut.amount') }}
{{ $line->posting_date->format('M d, Y') }} {{ $line->description }} {{ currency_format($line->net_amount) }}
{{ __('hotel::modules.reservation.advancePaid') }} −{{ currency_format($advanceTotal) }}
{{ __('hotel::modules.checkOut.payments') }} −{{ currency_format($otherTotal) }}
{{ __('hotel::modules.checkOut.paidRoomService') }} −{{ currency_format($paidRsTotal) }}
{{ __('hotel::modules.checkOut.discountAmount') }} −{{ currency_format($discount) }}
{{ __('hotel::modules.checkOut.totalBalance') }} {{ $displayBalance > 0 ? currency_format($displayBalance) : '✓ ' . currency_format(0) }}
{{-- ══ SECTION 2: Discount ══ --}} @if(user_can('Apply Hotel Folio Discount'))
{{ __('hotel::modules.checkOut.discountAmount') }}

{{ __('hotel::modules.checkOut.discountAmount') }} — {{ __('hotel::modules.checkIn.balanceDue') ?? 'balance updates instantly above' }}

@endif {{-- ══ SECTION 3: Payment ══ --}}
{{ __('hotel::modules.checkOut.paymentMethod') }}
{{ __('hotel::modules.checkOut.paymentMethod') }}
{{ __('hotel::modules.checkOut.paymentAmount') }}
{{ __('hotel::modules.checkOut.transactionReference') }}
{{ __('hotel::modules.checkOut.cancel') }} {{ __('hotel::modules.checkOut.confirmCheckOut') }}
@endif