@extends('layouts.master') @section('css') @section('title') {{ __('report.customerـpurchases') }}@stop @endsection @section('page-header')
@endsection @section('content') @if (count($errors) > 0)
خطا
@endif
{{ csrf_field() }}

{{ __('users.branch') }}

بحث باسم العميل أو رقم الجوال


@if (isset($Invoices))
@php $i = 0; $seq = 0; // جلب قيمة الضريبة مرة واحدة خارج الحلقة لتحسين الأداء $avtModel = App\Models\Avt::find(1); $saleavt = $avtModel ? $avtModel->AVT : 0; // متغيرات الملخص $grandTotal = 0; $grandDiscount = 0; $grandTax = 0; $grandAmount = 0; $invoiceCount = 0; $totalThobes = 0; @endphp @foreach ($Invoices as $product) @php if ($i == 0) { $startat = $product->created_at; } $endat = $product->created_at; $i++; $seq++; // منطق الحالة (Status Logic) $status = $product->status_invoice; switch ($status) { case 'NOT_STARTED': $statusText = 'لم يبدأ'; $badgeClass = 'badge-danger'; break; case 'IN_PROGRESS': $statusText = 'قيد التنفيذ'; $badgeClass = 'badge-warning'; break; case 'COMPLETED': $statusText = 'تم الانتهاء'; $badgeClass = 'badge-success'; break; default: $statusText = $status; $badgeClass = 'badge-secondary'; } // حساب الإجمالي شامل الضريبة $subtotal = $product->Price - $product->discount; $totalPrice = $subtotal * (1 + $saleavt); $taxAmount = $subtotal * $saleavt; // تجميع الإجماليات $grandTotal += $subtotal; $grandDiscount += $product->discount; $grandTax += $taxAmount; $grandAmount += $totalPrice; $invoiceCount++; $totalThobes += $product->sales->sum('quantity'); @endphp @php // جلب رصيد العميل الحالي من الحساب المالي المرتبط به $currentBalance = 0; if($product->customer && $product->customer->financial_account) { $account = $product->customer->financial_account; // حساب الصافي (مدين - دائن) $currentBalance = $account->credit_transactions->where('save', 1)->sum('debtor') - $account->credit_transactions->where('save', 1)->sum('creditor'); } @endphp @endforeach
# {{ __('home.Invoice_no') }} {{ __('home.sallerName') }} {{ __('home.clietName') }} {{ __('home.quantity_thobe') }} {{ __('home.date') }} {{ __('home.branch') }} {{ __('home.total') }} مدين (الرصيد الحالي) {{ __('home.thobe_status') }} {{ __('home.operations') }}
{{ $seq }} {{ $product->id }} {{ $product->user->name ?? 'N/A' }} {{ $product->customer->name ?? '' }} {{ $product->sales->sum('quantity') }} {{ $product->created_at->format('Y-m-d H:i') }} {{ $product->branch->name ?? '' }} {{ number_format($totalPrice, 2) }} {{ number_format($currentBalance, 2) }} {{ $statusText }}
@if($product->customer && $product->customer->financial_account) @endif {{ __('home.show') }}
@if (count($Invoices) > 0)
ملخص الإجماليات
إجمالي المبلغ (بدون ضريبة) {{ number_format($grandTotal, 2) }} ريال
إجمالي الضريبة المضافة {{ number_format($grandTax, 2) }} ريال
إجمالي الخصومات {{ number_format($grandDiscount, 2) }} ريال
الإجمالي النهائي (شامل الضريبة) {{ number_format($grandAmount, 2) }} ريال
عدد الفواتير
{{ count($Invoices) }} فاتورة
إجمالي عدد الأثواب
{{ $Invoices->sum(function($inv) { return $inv->sales->sum('quantity'); }) }} ثوب
@endif
Fatal error: Uncaught Error: Class "App\Models\Avt" not found in /home/ebdea/public_html/sewing.ebdea.online/resources/views/reports/customerpurchases.blade.php:347 Stack trace: #0 {main} thrown in /home/ebdea/public_html/sewing.ebdea.online/resources/views/reports/customerpurchases.blade.php on line 347