@extends('layouts.app') @section('title', 'تفاصيل فاتورة الشراء') @section('content') @php $invoice = $data['invoice'] ?? null; $items = $data['items'] ?? collect(); $payments = $data['payments'] ?? collect(); $remaining = $data['remaining_balance'] ?? (($invoice->total_amount ?? 0) - ($invoice->paid_amount ?? 0)); $paymentStatus = $invoice->payment_status ?? 'pending'; $approvalStatus = $invoice->status ?? 'pending'; $paymentStatusMap = [ 'paid' => ['label' => 'مدفوعة', 'class' => 'bg-green-100 text-green-700', 'dot' => 'bg-green-500'], 'partial' => ['label' => 'مدفوعة جزئياً', 'class' => 'bg-yellow-100 text-yellow-700', 'dot' => 'bg-yellow-500'], 'overdue' => ['label' => 'متأخرة', 'class' => 'bg-red-100 text-red-700', 'dot' => 'bg-red-500'], 'sent' => ['label' => 'مُرسلة', 'class' => 'bg-blue-100 text-blue-700', 'dot' => 'bg-blue-500'], 'approved'=> ['label' => 'معتمدة', 'class' => 'bg-green-100 text-green-700', 'dot' => 'bg-green-500'], 'pending' => ['label' => 'معلقة', 'class' => 'bg-gray-100 text-black', 'dot' => 'bg-gray-500'], ]; $paymentBadge = $paymentStatusMap[$paymentStatus] ?? ['label' => ucfirst($paymentStatus ?: 'معلقة'), 'class' => 'bg-gray-100 text-black', 'dot' => 'bg-gray-500']; $approvalMap = [ 'approved' => ['label' => 'معتمدة', 'class' => 'bg-green-100 text-green-700'], 'rejected' => ['label' => 'مرفوضة', 'class' => 'bg-red-100 text-red-700'], 'cancelled' => ['label' => 'ملغاة', 'class' => 'bg-red-100 text-red-700'], 'draft' => ['label' => 'مسودة', 'class' => 'bg-gray-100 text-black'], 'pending' => ['label' => 'قيد المراجعة', 'class' => 'bg-yellow-100 text-yellow-700'], ]; $approvalBadge = $approvalMap[$approvalStatus] ?? ['label' => ucfirst($approvalStatus ?: '-'), 'class' => 'bg-gray-100 text-black']; @endphp
{{ session('success') }}
{{ session('error') }}
رقم الفاتورة: {{ $invoice->invoice_number ?? '-' }}
إجمالي الفاتورة
{{ number_format($invoice->total_amount ?? 0, 2) }} ر.س
المدفوع
{{ number_format($invoice->paid_amount ?? 0, 2) }} ر.س
المتبقي
{{ number_format($remaining, 2) }} ر.س
عدد البنود
{{ $items->count() }}
{{ $invoice->notes }}
| # | الصنف | الوصف | الكمية | سعر الوحدة | الخصم | الضريبة | الإجمالي |
|---|---|---|---|---|---|---|---|
| {{ $loop->iteration }} | {{ $item->item->name ?? ($item->item_id ? '#'.$item->item_id : '—') }} | {{ $item->description ?: '—' }} | {{ number_format($item->quantity ?? 0, 2) }} | {{ number_format($item->unit_price ?? 0, 2) }} | {{ number_format($item->discount_amount ?? 0, 2) }} | {{ number_format($item->tax_amount ?? 0, 2) }} | {{ number_format($item->line_total ?? 0, 2) }} |
|
لا توجد بنود لهذه الفاتورة |
|||||||
| إجمالي البنود | {{ number_format($items->sum('line_total'), 2) }} ر.س | ||||||
| # | رقم الدفعة | تاريخ الدفع | طريقة الدفع | المرجع | المبلغ |
|---|---|---|---|---|---|
| {{ $loop->iteration }} | {{ $payment->payment_number ?? '—' }} | {{ $payment->payment_date ? $payment->payment_date->format('Y-m-d') : '—' }} | {{ $payment->payment_method ?? '—' }} | {{ $payment->reference_number ?? '—' }} | {{ number_format($payment->amount ?? 0, 2) }} ر.س |
| إجمالي المدفوع | {{ number_format($payments->sum('amount'), 2) }} ر.س | ||||