@extends('layouts.master') @section('css') @endsection @section('title') {{ __('home.recentquotation') }} @endsection @section('page-header') @endsection @section('content') @if (count($errors) > 0)
خطأ
@endif
@php $avtData = App\Models\Avt::find(1); $avtSaleRate = $avtData ? (float)$avtData->AVT : 0.15; // 0.15 @endphp @foreach ($data as $product) @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 ?? '—' }} @php $items = App\Models\offer_price_to_customer_items::where('order_id', $product->id)->get(); $subTotal = 0; $itemsDiscount = 0; foreach($items as $item) { // قراءة السعر بأي من المسجّلات المتاحة في الموديل $price = $item->PriceWithoudTax ?? $item->PriceWithoutTax ?? $item->getAttributes()['PriceWithoudTax'] ?? $item->getAttributes()['PriceWithoutTax'] ?? 0; $qty = $item->quantity ?? 1; $subTotal += ((float)$price * (float)$qty); $itemsDiscount += (float)($item->discount ?? 0); } // الخصم الرئيسي المسجل على الفاتورة ككل $mainDiscount = (float)($product->discount ?? 0); $totalDiscount = $itemsDiscount + $mainDiscount; // الصافي الخاضع للضريبة $netPrice = round($subTotal - $totalDiscount, 2); // حساب الضريبة والإجمالي النهائي $taxAmount = round($netPrice * $avtSaleRate, 2); $calculatedTotal = $netPrice + $taxAmount; // حماية وتعديل فارق كسور الهللة لتصبح 3000.00 مباشرة if (abs($calculatedTotal - round($calculatedTotal)) < 0.03) { $totalWithTax = round($calculatedTotal); } else { $totalWithTax = $calculatedTotal; } @endphp {{ number_format($totalWithTax, 2) }}
@csrf
{{ $data->links() }}
@endsection @section('js') @endsection