@php $voucherIds = $vouchers->pluck('id'); $hsnCodes = \App\Models\AccountingVoucherItem::whereIn('accounting_voucher_id', $voucherIds) ->join('stock_items', 'accounting_voucher_items.stock_item_id', '=', 'stock_items.id') ->groupBy('stock_items.hsn_code') ->select('stock_items.hsn_code') ->get(); @endphp @foreach ($hsnCodes as $hsnCode) @php $acVoucherItems = \App\Models\AccountingVoucherItem::whereIn( 'accounting_voucher_id', $vouchers->pluck('id'), ) ->WhereHas('stockItem', function ($query) use ($hsnCode) { $query->where('stock_items.hsn_code', $hsnCode->hsn_code); }) ->get(); @endphp @endforeach
HSN UQC Total Quantity Total Value Taxable Value Integrated Tax Amount Central Tax Amount State/UT Tax Amount Cess Amount
{{ $hsnCode->hsn_code }} {{ $acVoucherItems->first()->unit->uqc }} {{ $acVoucherItems->sum('quantity') }} {{ $acVoucherItems->sum('total') }} {{ $acVoucherItems->sum('taxable_value') }} {{ $acVoucherItems->sum('igst') }} {{ $acVoucherItems->sum('cgst') }} {{ $acVoucherItems->sum('sgst') }} {{ $acVoucherItems->sum('cess') }}