@php use App\Models\stocktransfer; @endphp @extends('backend.layouts.app') @section('content')

{{__('Stock Report')}}

Stock Rules: Stock= purchase - (stock transfer + sell + supplier + Stock transfer pending return) + customer return + stock receive

@foreach($products as $product ) @php $qty = 0; foreach ($product->stocks as $key => $stock) { if ($stock->warehouse_id==auth()->user()->warehouse_id){ $qty += $stock->qty; } } $stock_transfer=stocktransfer::where('product_id',$stock->product_id)->where('status',2)->where('from',auth()->user()->warehouse_id)->sum('qty'); $stock_receive=stocktransfer::where('product_id',$stock->product_id)->where('status',2)->where('to',auth()->user()->warehouse_id)->sum('qty'); $stock_pending=stocktransfer::where('product_id',$stock->product_id)->where('status',0)->where('to',auth()->user()->warehouse_id)->sum('qty'); $purchase_qty = App\Models\Purchase::where('product_id',$stock->product_id)->sum('stock'); $return_stock=\App\Models\RefundRequest::where('product_id',$stock->product_id)->where('refund_status',1)->sum('product_qty'); $supplier_return=\App\Models\StockReturn::where('product_id',$stock->product_id)->sum('return_stock'); $sell = App\Models\OrderDetail::where('product_id',$stock->product_id)->where('warehouse_id',auth()->user()->warehouse_id)->where('delivery_status','!=','cancelled')->sum('quantity'); @endphp @endforeach
{{__('Product Name')}} {{__('Purchase')}} {{__('Stock transfer')}} {{__('Stock Receive')}} {{__('Stock Transfer Pending')}} {{__('Sell')}} {{__('Customer Return')}} {{__('Supplier Return')}} {{__('Current Stock')}}
{{$product->getTranslation('name') }} {{ $purchase_qty }} {{$stock_transfer}} {{$stock_receive}} {{$stock_pending}} {{$sell}} {{$return_stock}} {{$supplier_return}} {{$qty}}
@endsection