@forelse($locations as $key => $value)

@lang('sale.location'): {{$value}}

{{--
{!! Form::label("location.$key.payment_method", __('accounting::lang.account_type') . ':' ) !!} {!! Form::select("location[$key][account_type_id]", !is_null($payment_account) ? [$payment_account->id => $payment_account->name] : [], $payment_account->id??null, ['class' => 'form-control accounts-dropdown width-100','placeholder' => __('accounting::lang.account_type')]) !!}
--}}
@if($enable_expiry == 1 && $product->enable_stock == 1) @endif @if($enable_lot == 1) @endif @php $subtotal = 0; $getStocks = $stocks->where('location_id', $key)->pluck('name','id')??[]; @endphp @foreach($product->variations as $vk => $variation) @if(empty($purchases[$key][$variation->id])) @php $purchases[$key][$variation->id][] = ['quantity' => 0, 'purchase_price' => $variation->default_purchase_price, 'purchase_line_id' => null, 'lot_number' => null, 'transaction_date' => null, 'purchase_line_note' => null, 'secondary_unit_quantity' => 0 ] @endphp @endif @foreach($purchases[$key][$variation->id] as $sub_key => $var) @php $payment_account = null; if(!empty($transactions) && !empty($var['location_id'])){ $paymentAccountId = $transactions->where('location_id', $var['location_id'])->where('stock_id', $var['stock_id'])->first()??''; if($paymentAccountId){ $accTrans = \Modules\Accounting\Entities\AccountingAccountsTransaction::where('transaction_id', $paymentAccountId->id)->where('type', 'credit')->first()??''; if($accTrans){ $payment_account = \Modules\Accounting\Entities\AccountingAccount::find($accTrans->accounting_account_id)??null; } } } $purchase_line_id = $var['purchase_line_id']; $qty = $var['quantity']; $purcahse_price = $var['purchase_price']; $row_total = $qty * $purcahse_price; $subtotal += $row_total; $lot_number = $var['lot_number']; $transaction_date = $var['transaction_date']; $purchase_line_note = $var['purchase_line_note']; @endphp {{-- @if($enable_expiry == 1 && $product->enable_stock == 1) @endif --}} @if($enable_lot == 1) @endif @endforeach @endforeach
@lang( 'stock.stock') @lang( 'product.product_name' ) @lang( 'lang_v1.quantity_left' ) @lang( 'purchase.unit_cost_before_tax' )Exp. Date@lang( 'lang_v1.lot_number' )@lang( 'purchase.subtotal_before_tax' ) @lang( 'lang_v1.date' ) @lang( 'brand.note' )  
{!! Form::select('stocks[' . $key . '][' . $variation->id . '][' . $sub_key . '][stock_id]', $getStocks, $var['stock_id']??null, [ 'class' => 'form-control select2', 'placeholder' => __('messages.please_select'), ]) !!} {{ $product->name }} @if( $product->type == "variable" ) ({{ $variation->product_variation->name }} : {{ $variation->name }}) @endif
{!! Form::text('stocks[' . $key . '][' . $variation->id . '][' . $sub_key . '][quantity]', @format_quantity($qty) , ['class' => 'form-control input-sm input_number purchase_quantity input_quantity', 'required']); !!} {{ $product->unit->short_name }}
@if(!empty($product->second_unit))
@lang('lang_v1.quantity_in_second_unit', ['unit' => $product->second_unit->short_name])*:
{!! Form::text('stocks[' . $key . '][' . $variation->id . '][' . $sub_key . '][secondary_unit_quantity]', @format_quantity($var['secondary_unit_quantity']) , ['class' => 'form-control input-sm input_number input_quantity', 'required']); !!} @endif
{!! Form::text('stocks[' . $key . '][' . $variation->id . '][' . $sub_key . '][purchase_price]', $purcahse_price , ['class' => 'form-control input-sm input_number unit_price', 'required']); !!} {!! Form::text('stocks[' . $key . '][' . $variation->id . '][' . $sub_key . '][exp_date]', !empty($var['exp_date']) ? @format_date($var['exp_date']) : null , ['class' => 'form-control input-sm os_exp_date', 'readonly']); !!} {!! Form::text('stocks[' . $key . '][' . $variation->id . '][' . $sub_key . '][lot_number]', $lot_number , ['class' => 'form-control input-sm']); !!} {{@num_format($row_total)}}
{!! Form::text('stocks[' . $key . '][' . $variation->id . '][' . $sub_key . '][transaction_date]', $transaction_date?? $start_date , ['class' => 'form-control input-sm os_date', 'readonly']); !!}
{!! Form::textarea('stocks[' . $key . '][' . $variation->id . '][' . $sub_key . '][purchase_line_note]', $purchase_line_note , ['class' => 'form-control input-sm', 'rows' => 3 ]); !!}  
@lang( 'lang_v1.total_amount_exc_tax' ): {{@num_format($subtotal)}}
@empty

@lang( 'lang_v1.product_not_assigned_to_any_location' )

@endforelse
@section('javascript') @include('accounting::accounting.common_js') @endsection