@extends('layouts.master') @section('css') @endsection @section('title') {{ __('home.sales_and_return') }} @stop @section('content')
{{ Namear ?? '' }}

{{ describtionar ?? '' }}

{{ STar ?? '' }}

{{ Taxar ?? '' }}

@php $logo = camplogo ?? 'default.png'; @endphp logo
{{ Nameen ?? '' }}

{{ describtionen ?? '' }}

{{ STen ?? '' }}

{{ Taxen ?? '' }}

{{ __('home.sales_and_return') }}
{{ __('report.fromdate') }} {{ $start }} {{ __('report.todate') }} {{ $end }}
{{ __('home.sales') }}
@php $totalprice = 0; $totaldiscount = 0; $totaladdedvalue = 0; $totalpriceafterdiscount = 0; $avtModel = App\Models\Avt::find(1); $saleavt = $avtModel ? $avtModel->AVT : 0; @endphp
@foreach ($data['invoices'] as $product) @php $price = ($product->cashamount + $product->bankamount + $product->Bank_transfer + $product->creaditamount); // حساب الخصم والمرتجعات المرتبطة بالفاتورة بشكل آمن $discoundoninvoice = 0; $discountreturn = 0; if ($product->Number_of_Quantity == 0) { foreach (App\Models\return_sales::where('invoice_id', $product->id)->get() as $item) { $discoundoninvoice += $item->discountoninvoice; } } else { $discoundoninvoice = $product->discount - $product->discountOnProduct; } foreach (App\Models\return_sales::where('invoice_id', $product->id)->get() as $item) { $discountreturn += $item->discountvalue; } foreach (App\Models\sales::where('invoice_id', $product->id)->get() as $item) { $discountreturn += $item->Discount_Value; } $discountreturn += $discoundoninvoice; $price_befor_tax = $saleavt > 0 ? ($price * 100) / (100 + ($saleavt * 100)) : $price; $invoicetotal_addedvalue = $price_befor_tax * $saleavt; $totalprice += $price; $totaldiscount += $discountreturn; $totaladdedvalue += $invoicetotal_addedvalue; $totalpriceafterdiscount += $price_befor_tax; // ترجمة طريقة الدفع $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 @endforeach
{{ __('home.Invoice_no') }} {{ __('home.date') }} {{ __('home.clietName') }} {{ __('home.paymentmethod') }} {{ __('home.total') }} {{ __('home.discount') }} {{ __('home.totalafterdiscount') }} {{ __('home.avt') }} {{ __('home.totalwithTax') }}
{{ $product->id }} {{ $product->created_at }} {{ optional($product->customer)->name }} {{ $pays }} {{ number_format($price_befor_tax + $discountreturn, 2) }} {{ number_format($discountreturn, 2) }} {{ number_format($price_befor_tax, 2) }} {{ number_format($invoicetotal_addedvalue, 2) }} {{ number_format($price, 2) }}
المجموع الكلي {{ number_format($totaldiscount + $totalpriceafterdiscount, 2) }} {{ number_format($totaldiscount, 2) }} {{ number_format($totalpriceafterdiscount, 2) }} {{ number_format($totaladdedvalue, 2) }} {{ number_format($totalprice, 2) }}
@if (isset($data['returnsales']) && count($data['returnsales']) > 0)
{{ __('home.salesـreturned') }}
@php $invoiceIds = collect($data['returnsales'])->pluck('invoice_id')->unique()->toArray(); $totalReturnsPrice = 0; @endphp
@foreach ($invoiceIds as $index => $invoiceid) @php $datainvoice = App\Models\invoices::find($invoiceid); $returnItems = App\Models\return_sales::where('invoice_id', $invoiceid) ->whereDate('created_at', '>=', $start) ->whereDate('created_at', '<=', $end) ->get(); $eachreturn = 0; $numberofPice = 0; $date = ''; foreach ($returnItems as $item) { $subTotal = ($item->return_Unit_Price * $item->return_quantity) - $item->discountvalue - $item->discountoninvoice; $eachreturn += $subTotal; $numberofPice += $item->return_quantity; $date = $item->created_at; } $eachreturn += ($eachreturn * $saleavt); $totalReturnsPrice += $eachreturn; $payType = optional(optional($returnItems->first())->Invoice)->Pay; @endphp @endforeach
# {{ __('report.date') }} {{ __('report.invoiceNo') }} {{ __('home.clietName') }} {{ __('home.paymentmethod') }} {{ __('home.total') }} {{ __('home.quantity') }} {{ __('home.operations') }}
{{ $index + 1 }} {{ $date ? explode(' ', $date)[0] : '' }} {{ $invoiceid }} {{ optional(optional($datainvoice)->customer)->name }} @if ($payType == 'Cash') {{ __('report.cash') }} @elseif($payType == 'Credit') {{ __('report.credit') }} @elseif($payType == 'Bank_transfer') {{ __('home.Bank_transfer') }} @else {{ __('report.shabka') }} @endif {{ number_format($eachreturn, 2) }} {{ $numberofPice }} {{ __('home.show') }}
{{ __('report.totalallprice') }} {{ number_format($totalReturnsPrice, 2) }}
@endif
@endsection @section('js') @endsection