@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') }}

{{ __('home.searchbyclientname') }}


@if (isset($Invoices))
@php $i = 0; // جلب قيمة الضريبة مرة واحدة خارج الحلقة لتحسين الأداء $avtModel = App\Models\Avt::find(1); $saleavt = $avtModel ? $avtModel->AVT : 0; @endphp @foreach ($Invoices as $product) @php if ($i == 0) { $startat = $product->created_at; } $endat = $product->created_at; $i++; // منطق الحالة (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'; } // حساب الإجمالي شامل الضريبة $totalPrice = ($product->Price - $product->discount) * (1 + $saleavt); @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') }}
{{ $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') }}

Fatal error: Uncaught Error: Class "App\Models\Avt" not found in /home/ebdea/public_html/khuyut.ebdea.online/resources/views/reports/customerpurchases.blade.php:258 Stack trace: #0 {main} thrown in /home/ebdea/public_html/khuyut.ebdea.online/resources/views/reports/customerpurchases.blade.php on line 258