@php // Ensure QR code exists if(empty($invoice->qr_code) && isset($onboarding)) { $invoice->qr_code = \Modules\Zatca\Utils\ZatcaQrGenerator::generateForInvoice($invoice, $onboarding); $invoice->save(); } @endphp

Tax Invoice / فاتورة ضريبية

@if(!empty($invoice->qr_code))
QR Code
@endif
Invoice Number
رقم الفاتورة
{{ $invoice->invoice_number }} Invoice Date
تاريخ الفاتورة
{{ \Carbon\Carbon::parse($transaction->transaction_date)->format('d/m/Y H:i') }} Invoice Due Date
تاريخ استحقاق الفاتورة
{{ \Carbon\Carbon::parse($transaction->transaction_date)->format('d/m/Y') }} Payment Terms
شروط الدفع
{{ ucfirst($transaction->payment_status) }}
Seller / البائع Buyer / المشتري
{{ $onboarding->organization_name }}
{{ $onboarding->street_name }}, {{ $onboarding->building_number }}
@if($onboarding->plot_identification) {{ $onboarding->plot_identification }}
@endif @if($onboarding->sub_division_name) {{ $onboarding->sub_division_name }}, @endif {{ $onboarding->city_name }}, {{ $onboarding->postal_number }}
{{ $onboarding->country_name ?? 'Saudi Arabia' }}
{{ $onboarding->vat_number }}
@if($transaction->contact) {{ $transaction->contact->name }}
@php $taxId = $transaction->contact->tax_number ?? $transaction->contact->tax_id ?? $transaction->contact->vat_number ?? null; @endphp @if(!empty($taxId)) VAT / Tax ID: {{ $taxId }}
@endif @if(!empty($transaction->contact->landmark)) {{ $transaction->contact->landmark }}
@endif @if(!empty($transaction->contact->city) || !empty($transaction->contact->state)) {{ $transaction->contact->city ?? '' }}@if(!empty($transaction->contact->state)), {{ $transaction->contact->state }}@endif
@endif @if(!empty($transaction->contact->country)) {{ $transaction->contact->country }}
@endif @if(!empty($transaction->contact->mobile)) {{ $transaction->contact->mobile }} @endif @else Walk-In Customer @endif
@php $subtotalExcTax = 0; $totalTaxAmount = 0; $totalAmountIncTax = 0; @endphp @foreach($transaction->sell_lines as $index => $line) @php // unit_price_before_discount already excludes tax in your POS $priceExcTax = $line->unit_price_before_discount; // Derive effective tax percent from inclusive vs exclusive prices when available if (!empty($line->unit_price_inc_tax) && $line->unit_price_before_discount > 0) { $effectiveTaxPercent = round((($line->unit_price_inc_tax / $line->unit_price_before_discount) - 1) * 100, 2); } else { $effectiveTaxPercent = round($line->item_tax ?? 0, 2); } $lineSubtotal = $priceExcTax * $line->quantity; // Prefer inc-tax to avoid rounding drift $lineTotal = (!empty($line->unit_price_inc_tax) ? $line->unit_price_inc_tax : ($priceExcTax * (1 + $effectiveTaxPercent/100))) * $line->quantity; $lineTaxAmount = $lineTotal - $lineSubtotal; $subtotalExcTax += $lineSubtotal; $totalTaxAmount += $lineTaxAmount; $totalAmountIncTax += $lineTotal; @endphp @endforeach
Seq / ترتيب Description / البيان Quantity / الكمية Unit Price / سعر الوحدة Disc / نسبة الخصم Taxes / الضريبة Tax Amount / مقدار الضريبة Total Price / السعر الكلي
{{ $index + 1 }} {{ $line->product->name }}
{{ $line->product->sku ?? '' }}
{{ number_format($line->quantity, 0) }} ({{ $line->product->unit->short_name ?? 'Pc(s)' }}) $ {{ number_format($priceExcTax, 2) }} $ {{ number_format($line->line_discount_amount ?? 0, 2) }} {{ number_format($effectiveTaxPercent, 2) }}% $ {{ number_format($lineTaxAmount, 2) }} $ {{ number_format($lineTotal, 2) }}
Subtotal / المجموع الفرعي $ {{ number_format($subtotalExcTax, 2) }}
Total Discount / إجمالي الخصم $ {{ number_format($transaction->discount_amount ?? 0, 2) }}
Net Amount / المبلغ الصافي $ {{ number_format($subtotalExcTax - ($transaction->discount_amount ?? 0), 2) }}
Total Tax / إجمالي الضريبة $ {{ number_format($totalTaxAmount, 2) }}
Total Amount / المبلغ الإجمالي $ {{ number_format($totalAmountIncTax, 2) }}
Due Amount / المبلغ المستحق {{ number_format($totalAmountIncTax - $transaction->payment_lines->sum('amount'), 2) }}
مبلغ الفاتورة: أربعة مائة و سبعة و ثلاثون فاصل خمسة