{{ __('main.branch_stock_report') }}
@if (Auth::user()->user_type == 2)
@endif
# {{ __('main.material_name') }} {{ __('main.received') }} {{ __('main.sales') }} {{ __('main.sales_return') }} {{ __('main.in_stock') }}
@php $total_count = 0; $i = 1; @endphp @foreach ($materials as $row) @php if ($branch_id != '') { $invoices = \App\Models\Invoice::where('branch_id', $branch_id)->get(); } else { $invoices = \App\Models\Invoice::get(); } $sales_count = 0; foreach ($invoices as $base_invoice_row) { $invoice_details = \App\Models\InvoiceDetail::where('invoice_id', $base_invoice_row->id) ->where('type', 2) ->get(); foreach ($invoice_details as $invoice_row) { if ($invoice_row->item_id == $row->id) { $sales_count = $sales_count + $invoice_row->quantity; } } } /* transfers */ if ($branch_id != '') { $transfers = \App\Models\StockTransfer::where('warehouse_to', $branch_id)->get(); } else { $transfers = \App\Models\StockTransfer::get(); } $transfer_count = 0; foreach ($transfers as $base_transfer_row) { $transfer_details = \App\Models\StockTransferDetail::where('stock_transfer_id', $base_transfer_row->id)->get(); foreach ($transfer_details as $transfer_row) { if ($transfer_row->material_id == $row->id) { $transfer_count = $transfer_count + $transfer_row->quantity; } } } /* transfers */ if ($branch_id != '') { $returns = \App\Models\SalesReturn::where('branch_id', $branch_id)->get(); } else { $returns = \App\Models\SalesReturn::get(); } $return_count = 0; foreach ($returns as $sales_return_row) { $return_details = \App\Models\SalesReturnDetail::where('sales_return_id', $sales_return_row->id)->get(); foreach ($return_details as $return_row) { if ($return_row->item_id == $row->id) { if ($return_row->type == 2) { $return_count = $return_count + $return_row->quantity; } } } } @endphp @if ($transfer_count != 0 || $sales_count != 0) @php $total_count = $total_count + 1; @endphp @endif @endforeach
{{ $i++ }} {{ $row->name }} {{ $transfer_count }} {{ getUnitType($row->unit) }} {{ $sales_count }} {{ getUnitType($row->unit) }} {{ $return_count }} {{ getUnitType($row->unit) }} {{ $transfer_count - $sales_count + $return_count }} {{ getUnitType($row->unit) }}
@if ($hasMorePages)
Loading...
Loading...
@endif