@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')
Kelola semua invoice dan tagihan hotel
|
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 |
| Aksi | No. Invoice | Tanggal | Booking | Tamu | Total | Channel | |
|---|---|---|---|---|---|---|---|
|
{{ $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 |
Belum ada invoice yang dibuat untuk kriteria pencarian ini.