@push('styles') .table td { border-top: 1px solid #e3e6f0; padding: 1.5rem 0.5rem; } .progress { border-radius: 10px; overflow: hidden; } .progress-bar { font-size: 0.75rem; font-weight: 600; } @endpush @extends('admin.layout') @section('title', 'Manajemen Invoice') @section('content')

Manajemen Invoice

Kelola semua invoice dan tagihan hotel

Buat Invoice Baru Laporan
Statistik Invoice

Total Invoice

Total Pendapatan

Sudah Dibayar

Belum Dibayar

{{ number_format($stats['total_invoices']) }}

Invoice

Rp {{ number_format($stats['total_amount'], 0, ',', '.') }}

Semua invoice

Rp {{ number_format($stats['paid_amount'], 0, ',', '.') }}

Invoice lunas

Rp {{ number_format($stats['pending_amount'], 0, ',', '.') }}

Menunggu pembayaran
Status Pembayaran:
@php $paidPercentage = $stats['total_amount'] > 0 ? ($stats['paid_amount'] / $stats['total_amount']) * 100 : 0; $pendingPercentage = 100 - $paidPercentage; @endphp
{{ number_format($paidPercentage, 1) }}% Lunas
{{ number_format($pendingPercentage, 1) }}% Pending
Ringkasan:
  • {{ number_format($stats['paid_invoices']) }} invoice sudah dibayar
  • {{ number_format($stats['pending_invoices']) }} invoice belum dibayar
Filter & Pencarian
Reset
Daftar Invoice
{{ $invoices->total() }} Invoice
@if($invoices->count() > 0)
Terpilih: 0
@foreach($invoices as $invoice) @php $statusConfig = [ 'paid' => ['class' => 'success', 'icon' => 'check-circle', 'text' => 'Lunas'], 'overdue' => ['class' => 'danger', 'icon' => 'exclamation-triangle', 'text' => 'Terlambat'], 'draft' => ['class' => 'secondary', 'icon' => 'edit', 'text' => 'Draft'], 'sent' => ['class' => 'info', 'icon' => 'paper-plane', 'text' => 'Terkirim'], 'cancelled' => ['class' => 'dark', 'icon' => 'times-circle', 'text' => 'Dibatalkan'] ]; $status = $statusConfig[$invoice->status] ?? ['class' => 'light', 'icon' => 'file', 'text' => 'Pending']; @endphp @endforeach
Aksi No. Invoice Tanggal Booking Tamu Total Channel
@csrf @method('DELETE')
{{ $invoice->invoice_number }} {{ $status['text'] }}
{{ $invoice->created_at->format('d/m/Y') }} {{ $invoice->booking->booking_code ?? 'N/A' }}
{{ $invoice->booking->guest_name ?? 'N/A' }}
@php $servicesViewTotal = (int) ($invoice->services_total ?? 0); if ($servicesViewTotal <= 0 && $invoice->booking && $invoice->booking->roomServices) { $servicesViewTotal = (int) $invoice->booking->roomServices->sum('total_price'); } if ($servicesViewTotal <= 0 && !empty($invoice->notes) && preg_match('/Merged from:\s*([^|]+)/i', (string) $invoice->notes, $mm)) { $numbers = collect(explode(',', (string) ($mm[1] ?? ''))) ->map(fn($x) => trim($x)) ->filter() ->unique() ->values() ->all(); if (!empty($numbers)) { $sources = \App\Models\Invoice::withTrashed() ->with(['booking.roomServices']) ->whereIn('invoice_number', $numbers) ->get(); $servicesMerged = (int) $sources->sum(function ($srcInv) { if ((int) ($srcInv->services_total ?? 0) > 0) return (int) $srcInv->services_total; if ($srcInv->booking && $srcInv->booking->roomServices) return (int) $srcInv->booking->roomServices->sum('total_price'); return 0; }); if ($servicesMerged > 0) { $servicesViewTotal = $servicesMerged; } else { $qtyList = $sources ->map(function ($srcInv) { if (!empty($srcInv->notes) && preg_match('/Extra\s*Bed\s*Manual:\s*([0-9]+)/i', (string) $srcInv->notes, $ebm)) { return max(0, (int) ($ebm[1] ?? 0)); } return 0; }) ->filter(fn($q) => $q > 0) ->values() ->all(); if (!empty($qtyList)) { $uniqueQty = array_values(array_unique($qtyList)); $effectiveQty = count($uniqueQty) === 1 ? max($qtyList) : array_sum($qtyList); $servicesViewTotal = (int) $effectiveQty * (int) \App\Models\Settings::get('extra_bed_price', 150000); } } } } if ($servicesViewTotal <= 0 && !empty($invoice->notes) && preg_match('/Extra\s*Bed\s*Manual:\s*([0-9]+)/i', (string) $invoice->notes, $ebs)) { $qtyExtra = max(0, (int) ($ebs[1] ?? 0)); if ($qtyExtra > 0) { $servicesViewTotal = $qtyExtra * (int) \App\Models\Settings::get('extra_bed_price', 150000); } } $totalInclude = max(0, (int) ($invoice->subtotal ?? 0) + $servicesViewTotal - (int) ($invoice->discount_amount ?? 0) ); @endphp
Rp {{ number_format($totalInclude, 0, ',', '.') }}
@php $chan = $invoice->paymentChannel; @endphp @if($chan) {{ $chan->name }} @else - @endif
@else
Tidak ada invoice ditemukan

Belum ada invoice yang dibuat untuk kriteria pencarian ini.

@endif @if($invoices->hasPages()) @include('admin.custom-pagination', ['paginator' => $invoices]) @endif
@endsection @push('scripts') @endpush