@php
$companyKeys = [
'company_name_en',
'company_name_ar',
'company_address_en',
'company_address_ar',
'tax_number',
'commercial_register',
'tourism_license',
];
$company = \App\Models\Setting::whereIn('key', $companyKeys)->pluck('value', 'key');
$isOther = $invoice->free_invoiceable_type === 'other';
$linked = $isOther ? null : $invoice->freeInvoiceable;
$displayName = $isOther
? $invoice->beneficiary_name ?? '-'
: $linked->company_name ?? ($linked->name ?? '-');
$displayAddress = $isOther ? $invoice->beneficiary_address ?? '-' : $linked->address ?? '-';
$displayTax = $isOther ? $invoice->beneficiary_tax_number ?? '-' : $linked->tax_number ?? '-';
$displayPhone = $isOther
? $invoice->beneficiary_phone ?? '-'
: optional(optional($linked)->contactInfos->first())->phone ?? '-';
$displayEmail = $isOther
? $invoice->beneficiary_email ?? '-'
: optional(optional($linked)->contactInfos->first())->email ?? '-';
@endphp
رقم الفاتورة:
{{ $invoice->invoice_number ?? $invoice->id }}
تاريخ الإصدار:
{{ optional($invoice->issue_date)->format('Y-m-d') ?? now()->format('Y-m-d') }}
تاريخ الاستحقاق:
{{ optional($invoice->due_date)->format('Y-m-d') ?? '-' }}
حالة الدفع:
استحقت الدفع - مسجلة
العملة:
SAR
المستفيد - Beneficiary
:الاسم
{{ $displayName }}
:العنوان
{{ $displayAddress }}
:رقم الهاتف
{{ $displayPhone }}
:البريد الإلكتروني
{{ $displayEmail }}
:الرقم الضريبي
{{ $displayTax }}
الشركة - Company
:الاسم
{{ $company['company_name_ar'] ?? ($company['company_name_en'] ?? '-') }}
:العنوان
{{ $company['company_address_ar'] ?? ($company['company_address_en'] ?? '-') }}
:الرقم الضريبي
{{ $company['tax_number'] ?? '-' }}
:السجل التجاري
{{ $company['commercial_register'] ?? '-' }}
:رخصة السياحة
{{ $company['tourism_license'] ?? '-' }}
| # |
البند |
الكمية |
سعر الوحدة |
الإجمالي |
@php $items = (array) ($invoice->items ?? []); @endphp
@forelse($items as $idx => $item)
@php
$qty = (float) ($item['quantity'] ?? 0);
$price = (float) ($item['price'] ?? 0);
$rowTotal = $qty * $price;
@endphp
| {{ $loop->iteration }} |
{{ $item['name'] ?? '-' }}
|
{{ number_format($qty, 0) }} |
{{ number_format($price, 2) }} |
{{ number_format($rowTotal, 2) }} |
@empty
| لا توجد بنود |
@endforelse
@php
$items = (array) ($invoice->items ?? []);
$subtotal = collect($items)->sum(fn($i) => ($i['quantity'] ?? 0) * ($i['price'] ?? 0));
$taxAmount = $invoice->total - $subtotal;
$taxName = $invoice->taxType?->name ?? 'بدون ضريبة';
@endphp
المبلغ قبل الضريبة:
{{ number_format($subtotal, 2) }} SAR
الضريبة ({{ $taxName }}):
{{ number_format($taxAmount, 2) }} SAR
الإجمالي النهائي:
{{ number_format($invoice->total, 2) }} SAR