@php $avtSetting = App\Models\Avt::find(1); $avtRate = $avtSetting ? $avtSetting->AVT : 0.15; // الافتراضي 15% إذا لم يوجد @endphp @foreach ($data as $product) @php // حساب الإجماليات والخصومات $items = App\Models\offer_price_to_customer_items::where('order_id', $product->id)->get(); $subTotal = $items->sum(fn($i) => $i->PriceWithoudTax * $i->quantity); $itemsDiscount = $items->sum('discount'); // خصم إضافي على مستوى الفاتورة $invoice = App\Models\offer_price_to_customer::find($product->id); $extraDiscount = $invoice ? $invoice->discount : 0; $totalNet = round($subTotal, 2) - round($itemsDiscount + $extraDiscount, 2); $totalWithTax = round($totalNet * $avtRate, 2) + $totalNet; @endphp @endforeach
{{ __('home.Invoice_no') }} {{ __('home.clietName') }} {{ __('home.date') }} {{ __('home.branch') }} {{ __('home.total') }} {{ __('home.operations') }}
{{ $product->id }} {{ $product->customer->name }} {{ $product->created_at->format('Y-m-d') }} {{ $product->branch->name }} {{ number_format($totalWithTax, 2) }}
@csrf