@extends('layouts.app') @section('title', 'Detail Invoice - MCU Klinik Mustika') @section('breadcrumb')

Detail Invoice

@endsection @section('content') @php $healthInvoice = $additionalInvoices['health'] ?? [ 'available' => false, 'count' => 0, 'total_amount' => 0, ]; $drugInvoice = $additionalInvoices['drug'] ?? [ 'available' => false, 'count' => 0, 'total_amount' => 0, ]; $totalLetterPatients = 0; $totalLetterAmount = 0; if ($healthInvoice['available']) { $totalLetterPatients += $healthInvoice['count']; $totalLetterAmount += $healthInvoice['total_amount']; } if ($drugInvoice['available']) { $totalLetterPatients += $drugInvoice['count']; $totalLetterAmount += $drugInvoice['total_amount']; } @endphp @if (session('success')) @endif @if (session('error')) @endif
@canRoute ('invoices.index') Kembali ke Daftar @endcanRoute @canRoute ('invoices.pdf') Download PDF @endcanRoute @canRoute ('invoices.pdf-view') Preview PDF @endcanRoute
@if ($invoice->status === 'draft') @canRoute ('invoices.edit') Edit Invoice @endcanRoute @canRoute ('invoices.regenerate')
@csrf
@endcanRoute @endif @if ($invoice->status === 'draft') @canRoute ('invoices.mark-sent')
@csrf
@endcanRoute @endif @if ($invoice->status === 'sent') @canRoute ('invoices.mark-paid')
@csrf
@endcanRoute @endif

Invoice #{{ $invoice->invoice_number }}

Tanggal Invoice: {{ \App\Helpers\DateHelper::formatDate($invoice->invoice_date) }}

{{ $invoice->status_text }} @if ($invoice->needs_regeneration && $invoice->status !== 'paid')
Perlu Regenerate @endif
Informasi Perusahaan
{{ $invoice->company->name }} {{ $invoice->company->address ?? '-' }} {{ $invoice->company->phone ?? '-' }} {{ $invoice->company->email ?? '-' }}
Informasi Invoice
@if ($invoice->corporate_invitation_id) Tanggal MCU: @else Periode: @endif @if ($invoice->corporate_invitation_id) {{ \App\Helpers\DateHelper::formatShort( $invoice->corporateInvitation->mcu_date, ) }} @else {{ \App\Helpers\DateHelper::formatShort( $invoice->period_start, ) }} - {{ \App\Helpers\DateHelper::formatShort( $invoice->period_end, ) }} @endif
Jatuh Tempo: {{ \App\Helpers\DateHelper::formatShort( $invoice->due_date, ) }} @if ($invoice->due_date < now() && $invoice->status !== 'paid') @php $diff = $invoice->due_date->diff(now()); $daysLate = (int) $diff->days; $hoursLate = (int) $diff->h; $minutesLate = (int) $diff->i; if ($daysLate >= 1) { $lateText = 'Terlambat ' . $daysLate . ' hari'; if ($hoursLate > 0) { $lateText .= ' ' . $hoursLate . ' jam'; } } elseif ($hoursLate >= 1) { $lateText = 'Terlambat ' . $hoursLate . ' jam'; if ($minutesLate > 0) { $lateText .= ' ' . $minutesLate . ' menit'; } } else { $lateText = 'Terlambat ' . $minutesLate . ' menit'; } @endphp @endif
Dibuat oleh: {{ $invoice->creator->name }}
@if ($invoice->sent_date)
Tanggal Terkirim: {{ \App\Helpers\DateHelper::formatShort( $invoice->sent_date, ) }} {{ $invoice->sent_date->format('H:i') }}
@endif @if ($invoice->paid_date)
Tanggal Dibayar: {{ \App\Helpers\DateHelper::formatShort( $invoice->paid_date, ) }} {{ $invoice->paid_date->format('H:i') }}
@endif
@if ($invoice->notes)
Catatan

{{ $invoice->notes }}

@endif
Ringkasan Invoice Surat
Jumlah Pasien Surat: {{ $totalLetterPatients }} pasien
Subtotal Surat: {{ 'Rp ' . number_format($totalLetterAmount, 0, ',', '.') }}

Grand Total Surat: {{ 'Rp ' . number_format($totalLetterAmount, 0, ',', '.') }}
@if ($invoice->due_date < now() && $invoice->status !== 'paid')
@php $diff = $invoice->due_date->diff(now()); $daysLate = (int) $diff->days; $hoursLate = (int) $diff->h; $minutesLate = (int) $diff->i; if ($daysLate >= 1) { $lateText = 'Terlambat ' . $daysLate . ' hari'; if ($hoursLate > 0) { $lateText .= ' ' . $hoursLate . ' jam'; } } elseif ($hoursLate >= 1) { $lateText = 'Terlambat ' . $hoursLate . ' jam'; if ($minutesLate > 0) { $lateText .= ' ' . $minutesLate . ' menit'; } } else { $lateText = 'Terlambat ' . $minutesLate . ' menit'; } @endphp Invoice sudah jatuh tempo ({{ $lateText }})
@endif
@if (isset($additionalInvoices) && ($additionalInvoices['health']['available'] || $additionalInvoices['drug']['available']))
Invoice Surat
@if ($invoice->period_start && $invoice->period_end) Periode {{ \App\Helpers\DateHelper::formatShort($invoice->period_start) }} - {{ \App\Helpers\DateHelper::formatShort($invoice->period_end) }} @endif
@foreach (['health', 'drug'] as $invoiceKey) @php $data = $additionalInvoices[$invoiceKey]; @endphp @if ($data['available'])
{{ $data['title'] }}
{{ $data['count'] }} surat x Rp {{ number_format($data['unit_price'], 0, ',', '.') }}
Rp {{ number_format($data['total_amount'], 0, ',', '.') }}
@canRoute ('invoices.health-letter-invoice') Download PDF @endcanRoute
@foreach ($data['items'] as $letter) @endforeach
No. Nama Pasien Perusahaan Tanggal Surat Nomor Surat Harga
{{ $loop->iteration }} {{ strtoupper( $letter->name_snapshot ?? ($letter->patient->name ?? '-'), ) }} {{ $letter->patient && $letter->patient->company ? $letter->patient->company->name : '-' }} {{ $letter->created_at ? \App\Helpers\DateHelper::formatShort($letter->created_at) : '-' }} #{{ $letter->id }} Rp {{ number_format($data['unit_price'], 0, ',', '.') }}
@endif @endforeach
Grand Total Invoice Surat:
{{ 'Rp ' . number_format($totalLetterAmount, 0, ',', '.') }}
@endif @if ($invoice->status === 'paid')
Invoice Sudah Dibayar

Invoice ini sudah dibayar pada {{ \App\Helpers\DateHelper::formatDate($invoice->paid_date) }}, {{ $invoice->paid_date->format('H:i') }} WITA

@endif @endsection @push('styles') @endpush @push('scripts') @endpush