@extends('layouts.master') @section('css') @endsection @section('title') {{ __('home.print') }} @stop @section('content')
{{-- أزرار التحكم --}}
EXPORT EXCEL
{{-- الهيدر الخاص بالشركة --}}

{{ Nameen }}

{{ describtionen }}
{{ STen }}
{{ Taxen }}

@php $logo = camplogo; @endphp

{{ Namear }}

{{ describtionar }}
{{ STar }}
{{ Taxar }}

@if (isset($Invoices) && $Invoices->count() > 0)
{{ \Carbon\Carbon::now()->addHours(3)->format("Y-m-d H:i:s") }}
@php // تعريف متغيرات الإجماليات العامة للتقرير $totalAllBeforeTax = 0; $totalAllTax = 0; $totalAllDiscount = 0; $totalAllShipping = 0; // المتغيرات الجديدة للتصنيف $totalNetNonTaxable = 0; // إجمالي صافي الفواتير الصفرية $totalNetTaxable = 0; // إجمالي صافي الفواتير الضريبية @endphp @foreach ($Invoices as $invoice) @php $invoiceSubtotalBeforeTax = 0; $invoiceVAT = 0; $shipping = ($invoice['shipping fee'] ?? 0) + ($invoice['Other expenses'] ?? 0); // جلب تفاصيل الأصناف وحساب ضريبة كل صنف بدقة $details = App\Models\orderDetails::where('order_owner', $invoice->orderId)->get(); foreach($details as $p) { $qty = $p->numberofpice + $p->returns_purchase; // حساب سعر الشراء الإجمالي للسطر $lineAmount = $qty * $p->purchasingـprice; $invoiceSubtotalBeforeTax += $lineAmount; // المنطق الجديد: إذا كانت القيمة المضافة أكبر من الصفر نحسب 15%، وإلا فالضريبة صفر $taxRate = ($p->Added_Value > 0) ? 0.15 : 0; $invoiceVAT += ($lineAmount * $taxRate); } // معالجة ضريبة الخصم: تخصم الضريبة فقط إذا كانت الفاتورة ضريبية أصلاً $discount_net_vat = 0; if ($invoiceVAT > 0 && $invoice->discount > 0) { // حساب قيمة الضريبة الموجودة داخل مبلغ الخصم (بفرض أن الخصم شامل الضريبة) $discount_net_vat = $invoice->discount - ($invoice->discount / 1.15); $invoiceVAT -= $discount_net_vat; } // الصافي النهائي لهذه الفاتورة $invoiceGrandTotal = ($invoiceSubtotalBeforeTax - $invoice->discount) + $invoiceVAT + $shipping; // تصنيف الفاتورة if ($invoiceVAT <= 0) { $totalNetNonTaxable += $invoiceGrandTotal; $rowClass = 'border-danger'; $headerClass = 'bg-danger-transparent'; } else { $totalNetTaxable += $invoiceGrandTotal; $rowClass = 'border-success'; $headerClass = 'bg-success-transparent'; } // تحديث الإجماليات العامة $totalAllBeforeTax += $invoiceSubtotalBeforeTax; $totalAllTax += $invoiceVAT; $totalAllDiscount += $invoice->discount; $totalAllShipping += $shipping; @endphp
@foreach ($details as $product) @php $lineQty = $product->numberofpice + $product->returns_purchase; $currentTaxRate = ($product->Added_Value > 0) ? 0.15 : 0; $lineTax = ($lineQty * $product->purchasingـprice) * $currentTaxRate; $lineTotal = ($lineQty * $product->purchasingـprice) + $lineTax; @endphp @endforeach
رقم الفاتورة: {{ $invoice->orderId }} الحالة: {{ $invoiceVAT <= 0 ? 'معفاة / صفرية' : 'خاضعة للضريبة' }}
المنتج الكمية السعر (قبل الضريبة) الضريبة ({{ $invoiceVAT > 0 ? '15%' : '0%' }}) الإجمالي
{{ $product->productData->product_name ?? 'N/A' }} {{ $lineQty }} {{ number_format($product->purchasingـprice, 2) }} {{ number_format($lineTax, 2) }} {{ number_format($lineTotal, 2) }}
الخصم: {{ number_format($invoice->discount, 2) }} الشحن: {{ number_format($shipping, 2) }} صافي الفاتورة: {{ number_format($invoiceGrandTotal, 2) }}
@endforeach {{-- جدول الخلاصة النهائية للتقرير بالكامل --}}
ملخص إجماليات التقرير
إجمالي صافي الفواتير (غير الخاضعة للضريبة) {{ number_format($totalNetNonTaxable, 2) }}
إجمالي صافي الفواتير (الخاضعة للضريبة) {{ number_format($totalNetTaxable, 2) }}
إجمالي القيمة (قبل الضريبة) لكل الفواتير {{ number_format($totalAllBeforeTax, 2) }}
إجمالي الخصومات {{ number_format($totalAllDiscount, 2) }}
إجمالي ضريبة القيمة المضافة {{ number_format($totalAllTax, 2) }}
الإجمالي النهائي (صافي المشتريات) {{ number_format(($totalAllBeforeTax - $totalAllDiscount) + $totalAllTax + $totalAllShipping, 2) }}
@else
لا توجد نتائج لهذا البحث
@endif
@endsection @section('js') @endsection