@extends('layouts.app') @php $locale = app()->getLocale(); $isRtl = $locale === 'ar'; $currency = \App\Models\Setting::currencyLabel($locale); $typeLabels = [ 'sale' => $isRtl ? 'مبيعات' : 'Sale', 'subscription' => $isRtl ? 'اشتراك' : 'Subscription', 'service' => $isRtl ? 'خدمة' : 'Service', 'purchase' => $isRtl ? 'مشتريات' : 'Purchase', ]; $statusLabels = [ 'draft' => $isRtl ? 'مسودة' : 'Draft', 'sent' => $isRtl ? 'مرسلة' : 'Sent', 'paid' => $isRtl ? 'مدفوعة' : 'Paid', 'partial' => $isRtl ? 'جزئية' : 'Partial', 'overdue' => $isRtl ? 'متأخرة' : 'Overdue', 'cancelled' => $isRtl ? 'ملغاة' : 'Cancelled', ]; $paymentStatusLabels = [ 'unpaid' => $isRtl ? 'غير مدفوعة' : 'Unpaid', 'partial' => $isRtl ? 'مدفوعة جزئياً' : 'Partial', 'paid' => $isRtl ? 'مدفوعة' : 'Paid', ]; $statusColors = [ 'draft' => 'bg-slate-100 text-slate-700', 'sent' => 'bg-blue-100 text-blue-700', 'paid' => 'bg-emerald-100 text-emerald-700', 'partial' => 'bg-amber-100 text-amber-700', 'overdue' => 'bg-rose-100 text-rose-700', 'cancelled' => 'bg-slate-100 text-slate-600', ]; $computedStatus = $invoice->status; if ($invoice->due_date && $invoice->due_date->isPast() && (float) $invoice->remaining_amount > 0) { $computedStatus = 'overdue'; } @endphp @section('title', ($isRtl ? 'فاتورة' : 'Invoice') . ' - ' . $invoice->invoice_number) @section('content')

{{ $invoice->invoice_number }}

{{ $statusLabels[$computedStatus] ?? $computedStatus }} {{ $typeLabels[$invoice->type] ?? $invoice->type }}

{{ $isRtl ? 'حالة الدفع:' : 'Payment status:' }} {{ $paymentStatusLabels[$invoice->payment_status] ?? $invoice->payment_status }}

{{ $isRtl ? 'طباعة' : 'Print' }} {{ $isRtl ? 'PDF' : 'PDF' }} @if($invoice->payment_status !== 'paid') {{ $isRtl ? 'تعديل' : 'Edit' }} @endif @if((float) $invoice->remaining_amount > 0) @endif @if((float) $invoice->paid_amount <= 0)
@csrf @method('DELETE')
@endif

{{ $isRtl ? 'العميل والتواريخ' : 'Customer & Dates' }}

{{ $isRtl ? 'العميل' : 'Customer' }}

{{ $invoice->customer_name_display }}

@if($invoice->customer_phone)

{{ $invoice->customer_phone }}

@endif

{{ $isRtl ? 'أنشئت بواسطة' : 'Created by' }}

{{ $invoice->createdBy?->name ?? '—' }}

{{ optional($invoice->created_at)->format('Y-m-d H:i') }}

{{ $isRtl ? 'تاريخ الفاتورة' : 'Invoice date' }}

{{ optional($invoice->invoice_date)->format('Y-m-d') }}

{{ $isRtl ? 'تاريخ الاستحقاق' : 'Due date' }}

{{ $invoice->due_date ? $invoice->due_date->format('Y-m-d') : '—' }}

@if($invoice->notes)

{{ $isRtl ? 'ملاحظات' : 'Notes' }}

{{ $invoice->notes }}

@endif

{{ $isRtl ? 'الإجماليات' : 'Totals' }}

{{ $isRtl ? 'المجموع الفرعي' : 'Subtotal' }} {{ number_format((float) $invoice->subtotal, 2) }} {{ $currency }}
{{ $isRtl ? 'الخصم' : 'Discount' }} ({{ number_format((float) $invoice->discount_percent, 0) }}%) {{ number_format((float) $invoice->discount, 2) }} {{ $currency }}
{{ $isRtl ? 'الضريبة' : 'Tax' }} ({{ number_format((float) $invoice->tax_rate, 0) }}%) {{ number_format((float) $invoice->tax_amount, 2) }} {{ $currency }}
{{ $isRtl ? 'الإجمالي' : 'Total' }} {{ number_format((float) $invoice->total, 2) }} {{ $currency }}
{{ $isRtl ? 'المدفوع' : 'Paid' }} {{ number_format((float) $invoice->paid_amount, 2) }} {{ $currency }}
{{ $isRtl ? 'المتبقي' : 'Remaining' }} {{ number_format((float) $invoice->remaining_amount, 2) }} {{ $currency }}

{{ $isRtl ? 'بنود الفاتورة' : 'Invoice Items' }}

@foreach($invoice->items as $item) @endforeach
{{ $isRtl ? 'الوصف' : 'Description' }} {{ $isRtl ? 'الكمية' : 'Qty' }} {{ $isRtl ? 'سعر الوحدة' : 'Unit price' }} {{ $isRtl ? 'الإجمالي' : 'Total' }}

{{ $item->description }}

@if($item->product)

{{ $isRtl ? 'منتج:' : 'Product:' }} {{ $isRtl && $item->product->name_ar ? $item->product->name_ar : $item->product->name }}

@elseif($item->membershipPlan)

{{ $isRtl ? 'خطة:' : 'Plan:' }} {{ $isRtl && $item->membershipPlan->name_ar ? $item->membershipPlan->name_ar : $item->membershipPlan->name }}

@endif
{{ (int) $item->quantity }} {{ number_format((float) $item->unit_price, 2) }} {{ $currency }} {{ number_format((float) $item->total, 2) }} {{ $currency }}

{{ $isRtl ? 'الدفعات' : 'Payments' }}

@if((float) $invoice->remaining_amount > 0) @endif
@forelse($invoice->payments as $pay) @empty @endforelse
{{ $isRtl ? 'التاريخ' : 'Date' }} {{ $isRtl ? 'المبلغ' : 'Amount' }} {{ $isRtl ? 'الطريقة' : 'Method' }} {{ $isRtl ? 'المرجع' : 'Reference' }} {{ $isRtl ? 'المستلم' : 'Received by' }}
{{ optional($pay->payment_date)->format('Y-m-d') }} {{ number_format((float) $pay->amount, 2) }} {{ $currency }} {{ $pay->payment_method }} {{ $pay->reference ?: '—' }} {{ $pay->receivedBy?->name ?? '—' }}
{{ $isRtl ? 'لا توجد دفعات' : 'No payments yet' }}

{{ $isRtl ? 'إضافة دفعة' : 'Add Payment' }}

@csrf

{{ $isRtl ? 'المبلغ المتبقي:' : 'Remaining:' }} {{ number_format((float) $invoice->remaining_amount, 2) }} {{ $currency }}

@push('scripts') @endpush @endsection