@php $avtData = App\Models\Avt::find(1); $avtSaleRate = $avtData ? $avtData->AVT : 1; @endphp @foreach ($data as $product) @php // حساب الإجمالي والخصم لكل بند في عرض السعر $items = App\Models\offer_price_to_customer_items::where('order_id', $product->id)->get(); $totalpricePurchases = $items->sum(function($item) { return $item->PriceWithoudTax * $item->quantity; }); $totaldiscount = $items->sum('discount'); // خصم إضافي من جدول عرض السعر نفسه $offerQuote = App\Models\offer_price_to_customer::find($product->id); $extraDiscount = $offerQuote ? $offerQuote->discount : 0; $netPrice = round($totalpricePurchases, 2) - round($totaldiscount + $extraDiscount, 2); $total_value_quote = round($netPrice * $avtSaleRate, 2) + $netPrice; @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($total_value_quote, 2) }}
@csrf