@extends('layouts.master') @section('css') @include('admin.stock-items.create-modal-css') @endsection @section('title') Sales @endsection @section('content') @isset($accountingVoucher)
@method('put') @else @endisset @csrf
@isset($accountingVoucher) Edit Sales @else Add Sales @endisset
{{--

Barcode Scan

--}} {{--

Select Item

--}}

Barcode Scan

Select Item

@isset($accountingVoucherItems) @foreach ($accountingVoucherItems as $key => $accountingVoucherItem) @php $unitQty = App\Models\StockItemUnits::where('stock_item_id',$accountingVoucherItem->stock_item_id)->where('unit_id', $accountingVoucherItem->unit_id)->where('business_key', Auth::user()->business_key)->first()->unit_qty; $sumInwards = App\Models\StockLedger::select( 'stock_item_id', DB::raw('COUNT(*) as count'), DB::raw('SUM(value) as value'), DB::raw('SUM(inwards) as inwards'), ) ->where('business_key', Auth::user()->business_key) ->where('inwards', '!=', null) ->where('transaction', '!=', 'Sales Return') ->where('stock_item_id', $accountingVoucherItem->stock_item_id) ->whereDate('date', '<=', $accountingVoucher->voucher_date) ->groupBy('stock_item_id') ->first(); if ($sumInwards == null) { $avgPrice = 0; } else { $avgPrice = $sumInwards->inwards != 0 ? $sumInwards->value / $sumInwards->inwards : 0; } if ($avgPrice == 0) { $lastInward = \App\Models\StockLedger::where( 'stock_item_id', $accountingVoucherItem->stock_item_id, ) ->whereNotNull('inwards') ->where('date', '<=', $accountingVoucher->voucher_date) ->where('business_key', Auth::user()->business_key) ->where('transaction', '!=', 'Sales Return') ->select('value', 'inwards') ->orderBy('id', 'desc') ->first(); if ( $lastInward && $lastInward->value != 0 && $lastInward->inwards != 0 ) { $avgPrice = $lastInward->value / $lastInward->inwards; } else { $avgPrice = 0; } } @endphp @endforeach @endisset {{ isset($accountingVoucher) ? $accountingVoucher->items()->sum('total') : '' }}
SN Item Quantity Unit Price Price(Inc GST) Gross Value Disc % Disc Amt Taxable Value Tax Total Action
{{ $key + 1 }}
Total
%
%
{{-- Open Modal button --}}
{{-- Customer Details Modal --}}
{{-- history Modal --}} @include('admin.stock-items.create-modal') @endsection @section('script') @include('admin.stock-items.create-modal-script') @endsection