@if (isset($Invoices))
@php
$userId = 0;
$count = 0;
$startat = '';
$endat = '';
$total = 0;
$totaldiscount = 0;
$avt = App\Models\Avt::find(1);
$saleavt = $avt ? $avt->AVT : 0;
// تصفير المجاميع قبل بداية اللوب لتفادي أي قيم قديمة
$totalCashAmount = 0;
$totalNetworkAmount = 0;
$totalBankTransferAmount = 0;
$totalCreditAmount = 0;
@endphp
| {{ __('home.Invoice_no') }} |
{{ __('home.sallerName') }} |
{{ __('home.clietName') }} |
{{ __('home.date') }} |
{{ __('home.branch') }} |
{{ __('home.total') }} |
{{ __('home.paymentmethod') }} |
{{ __('report.cash') }} |
{{ __('report.shabka') }} |
{{ __('home.bank_transfer') }} |
{{ __('report.credit') }} |
{{ __('home.operations') }} |
@foreach ($Invoices as $product)
@php
$totaldiscount += $product->discount;
$cashAmount = $product->cashamount;
$networkAmount = $product->bankamount;
$Bank_transfer = $product->Bank_transfer;
$creditAmount = $product->creaditamount;
// شامل التحويل البنكي ضمن إجمالي الفاتورة
$invoiceTotal = $cashAmount + $networkAmount + $Bank_transfer + $creditAmount;
$total += $invoiceTotal;
// مجاميع لعرضها أسفل الجدول
$totalCashAmount += $cashAmount;
$totalNetworkAmount += $networkAmount;
$totalBankTransferAmount += $Bank_transfer;
$totalCreditAmount += $creditAmount;
if ($count == 0) {
$userId = $product->user_id;
$startat = $product->created_at;
}
$endat = $product->created_at;
$count++;
$pays = match($product->Pay) {
'Cash' => __('report.cash'),
'Shabka' => __('report.shabka'),
'Credit' => __('report.credit'),
'Bank_transfer' => __('home.Bank_transfer'),
default => __('home.Partition of the amount'),
};
@endphp
| {{ $product->id }} |
{{ $product->user->name ?? '-' }} |
{{ $product->customer->name ?? '-' }} |
{{ $product->created_at }} |
{{ $product->branch->name ?? '-' }} |
{{ round($invoiceTotal, 2) }} |
{{ $pays }}
|
{{ $cashAmount > 0 ? number_format($cashAmount) : '-' }} |
{{ $networkAmount > 0 ? number_format($networkAmount) : '-' }} |
{{ $Bank_transfer > 0 ? number_format($Bank_transfer) : '-' }} |
{{ $creditAmount > 0 ? number_format($creditAmount) : '-' }} |
{{ __('home.show') }}
|
@endforeach
| {{ __('report.cash') }} |
{{ __('report.shabka') }} |
{{ __('home.bank_transfer') }} |
{{ __('report.credit') }} |
{{ __('report.totalallprice') }} |
| {{ number_format($totalCashAmount, 2) }} |
{{ number_format($totalNetworkAmount, 2) }} |
{{ number_format($totalBankTransferAmount, 2) }} |
{{ number_format($totalCreditAmount, 2) }} |
{{ number_format($total, 2) }} |
@php
// معالجة آمنة لتفادي أخطاء الـ Array في روابط الطباعة إذا لم يتم تمريرهم بشكل مصفوفة
$printPay = is_array($pay ?? null) ? $pay : [0 => ($pay ?? '-'), 1 => '-'];
$printCustomerId = $customer_id ?? ($UserId ?? '-');
@endphp