{{-- رأس الفاتورة: بيانات العيادة + الفاتورة --}}

{{ $invoice->clinic?->name ?? 'اسم العيادة' }}

@if($invoice->clinic?->address)
العنوان: {{ $invoice->clinic->address }}
@endif @if($invoice->clinic?->phone)
الجوال: {{ $invoice->clinic->phone }}
@endif @if($invoice->branch)
الفرع: {{ $invoice->branch->name }}
@endif

فاتورة

رقم الفاتورة: {{ $invoice->invoice_number }}
تاريخ الفاتورة: {{ $invoice->date?->format('Y-m-d') }}
@if($invoice->payment_due_date)
تاريخ الاستحقاق: {{ $invoice->payment_due_date?->format('Y-m-d') }}
@endif
الحالة: @php $statusBadgeClass = match($invoice->status) { 'paid' => 'badge-paid', 'partial' => 'badge-partial', 'refunded' => 'badge-refunded', default => 'badge-unpaid', }; $statusText = match($invoice->status) { 'paid' => 'مدفوعة', 'partial' => 'مدفوعة جزئياً', 'refunded' => 'مستردة', default => 'غير مدفوعة', }; @endphp {{ $statusText }}
{{-- بيانات المريض --}}
المريض: {{ $invoice->patient?->first_name }} {{ $invoice->patient?->last_name }}
@if($invoice->patient?->code)
كود المريض: {{ $invoice->patient->code }}
@endif @if($invoice->patient?->phone)
الجوال: {{ $invoice->patient->phone }}
@endif
@if($invoice->patient?->gender)
النوع: @if($invoice->patient->gender === 'male') ذكر @elseif($invoice->patient->gender === 'female') أنثى @else — @endif
@endif @if($invoice->patient?->birth_date)
تاريخ الميلاد: {{ $invoice->patient->birth_date }} @php try { $age = \Carbon\Carbon::parse($invoice->patient->birth_date)->age; } catch (\Exception $e) { $age = null; } @endphp @if($age) ({{ $age }} سنة) @endif
@endif @if($invoice->visit)
مرتبطة بزيارة رقم: {{ $invoice->visit->id }} – {{ $invoice->visit->visit_date ?? '' }}
@endif @if($invoice->treatmentPlan)
خطة علاج: {{ $invoice->treatmentPlan->title ?? ('خطة #' . $invoice->treatmentPlan->id) }}
@endif
{{-- جدول البنود --}} @php $row = 1; @endphp @forelse($invoice->items as $item) @php $desc = $item->description; if ($item->service && !str_contains($desc, $item->service->name)) { // مجرد تحسين بسيط .. اختياري //$desc = $item->service->name . ' - ' . $desc; } @endphp @empty @endforelse
# الوصف الكمية سعر الوحدة الخصم الإجمالي الفرعي
{{ $row++ }} {{ $desc }} {{ $item->quantity }} {{ number_format($item->unit_price, 2) }} ر.س {{ number_format($item->discount, 2) }} ر.س {{ number_format($item->line_total, 2) }} ر.س
لا توجد بنود في هذه الفاتورة.
{{-- ملخص المبالغ --}} @php $subtotal = (float) $invoice->subtotal; $discount = (float) $invoice->discount; $taxPercent = (float) $invoice->tax_percent; $taxAmount = (float) $invoice->tax_amount; $total = (float) $invoice->total; $paid = (float) $invoice->paid_amount; $due = $total - $paid; if ($due < 0) { $due = 0; } $baseAfterDiscount = $subtotal - $discount; if ($baseAfterDiscount < 0) { $baseAfterDiscount = 0; } @endphp
المبالغ محسوبة بالريال السعودي. في حال وجود أي خطأ، يرجى التواصل مع الإدارة المالية في العيادة.
الإجمالي قبل الخصم: {{ number_format($subtotal, 2) }} ر.س
إجمالي الخصم: {{ number_format($discount, 2) }} ر.س
الإجمالي بعد الخصم: {{ number_format($baseAfterDiscount, 2) }} ر.س
الضريبة ({{ number_format($taxPercent, 2) }}%): {{ number_format($taxAmount, 2) }} ر.س
الإجمالي النهائي: {{ number_format($total, 2) }} ر.س
المدفوع: {{ number_format($paid, 2) }} ر.س
المتبقي على المريض: {{ number_format($due, 2) }} ر.س
{{-- توقيع بسيط --}}
مسؤول الاستقبال: _____________________
توقيع المريض: _____________________