@php use App\Helpers\GstHelper; $items = $documentItems ?? collect(); $gstIsIgst = $gstIsIgst ?? false; $hasDiscountCol = $items->contains(fn ($li) => (float) $li->discount_percent > 0); $totalTaxable = 0; $totalCgst = 0; $totalSgst = 0; $totalIgst = 0; $totalAmount = 0; $combinedRate = 0; $labelColspan = 4; @endphp @if($hasDiscountCol) @endif @if($gstIsIgst) @else @endif @foreach($items as $i => $line) @php $lineTaxable = round((float) $line->amount - (float) $line->tax_amount, 2); $cgstAmt = (float) ($line->cgst_amount ?? 0); $sgstAmt = (float) ($line->sgst_amount ?? 0); $igstAmt = (float) ($line->igst_amount ?? 0); if ($cgstAmt + $sgstAmt + $igstAmt <= 0 && (float) $line->tax_amount > 0) { $split = GstHelper::splitLineTax($lineTaxable, (float) $line->tax_rate, $gstIsIgst); $cgstAmt = $split['cgst_amount']; $sgstAmt = $split['sgst_amount']; $igstAmt = $split['igst_amount']; $cgstRate = $split['cgst_rate']; $sgstRate = $split['sgst_rate']; $igstRate = $split['igst_rate']; } else { $cgstRate = (float) ($line->cgst_rate ?? 0); $sgstRate = (float) ($line->sgst_rate ?? 0); $igstRate = (float) ($line->igst_rate ?? 0); } $qtyDisplay = number_format($line->quantity, 0) == $line->quantity ? (string) (int) $line->quantity : number_format($line->quantity, 3); $qtyUom = trim($qtyDisplay . ($line->unit ? ' ' . $line->unit : '')); $totalTaxable += $lineTaxable; $totalCgst += $cgstAmt; $totalSgst += $sgstAmt; $totalIgst += $igstAmt; $totalAmount += (float) $line->amount; if ((float) $line->tax_rate > $combinedRate) { $combinedRate = (float) $line->tax_rate; } @endphp @if($hasDiscountCol) @endif @if($gstIsIgst) @else @endif @endforeach @if($hasDiscountCol) @endif @if($gstIsIgst) @else @endif
# {{ $docLbl['col_item'] ?? 'Item' }} & {{ $docLbl['col_description'] ?? 'Description' }} HSN/SAC Qty / UoM Price (₹){{ $docLbl['col_discount'] ?? 'Discount' }}IGST (₹)CGST (₹) SGST (₹)Amount (₹)
{{ $i + 1 }} {{ $line->item_name }} @if($line->description) {{ $line->description }} @endif {{ $line->hsn_sac ?: '—' }} {{ $qtyUom ?: '—' }} {{ number_format($line->rate, 2) }} @if((float) $line->discount_percent > 0) {{ rtrim(rtrim(number_format($line->discount_percent, 2), '0'), '.') }}% @else — @endif @if($igstAmt > 0) {{ number_format($igstAmt, 2) }} @if($igstRate > 0){{ rtrim(rtrim(number_format($igstRate, 2), '0'), '.') }}%@endif @else — @endif @if($cgstAmt > 0) {{ number_format($cgstAmt, 2) }} @if($cgstRate > 0){{ rtrim(rtrim(number_format($cgstRate, 2), '0'), '.') }}%@endif @else — @endif @if($sgstAmt > 0) {{ number_format($sgstAmt, 2) }} @if($sgstRate > 0){{ rtrim(rtrim(number_format($sgstRate, 2), '0'), '.') }}%@endif @else — @endif {{ number_format($line->amount, 2) }}
@if($combinedRate > 0) Total ({{ rtrim(rtrim(number_format($combinedRate, 2), '0'), '.') }}%) @else Total @endif {{ number_format($totalTaxable, 2) }}{{ number_format($totalIgst, 2) }}{{ number_format($totalCgst, 2) }} {{ number_format($totalSgst, 2) }}{{ number_format($totalAmount, 2) }}