@php
            //CSGT+SGST Total Footer Printing related
            $totalCsgstTaxableAmt0 = 0;
            $totalCsgstTaxableAmt5 = 0;
            $totalCsgstTaxableAmt12 = 0;
            $totalCsgstTaxableAmt18 = 0;
            $totalCsgstTaxableAmount = 0;
            $totalCsgstGstValue0 = 0;
            $totalCsgstGstValue5 = 0;
            $totalCsgstGstValue12 = 0;
            $totalCsgstGstValue18 = 0;
            $totalCsgstGstAmount = 0;
            $totalCsgstAmount0 = 0;
            $totalCsgstAmount5 = 0;
            $totalCsgstAmount12 = 0;
            $totalCsgstAmount18 = 0;
            $totalCsgstAmount = 0;
            //IGST Total Footer Printing related
            $totalIgstTaxableAmt0 = 0;
            $totalIgstTaxableAmt5 = 0;
            $totalIgstTaxableAmt12 = 0;
            $totalIgstTaxableAmt18 = 0;
            $totalIgstTaxableAmount = 0;
            $totalIgstGstValue0 = 0;
            $totalIgstGstValue5 = 0;
            $totalIgstGstValue12 = 0;
            $totalIgstGstValue18 = 0;
            $totalIgstGstAmount = 0;
            $totalIgstAmount0 = 0;
            $totalIgstAmount5 = 0;
            $totalIgstAmount12 = 0;
            $totalIgstAmount18 = 0;
            $totalIgstAmount = 0;
            //Total Footer Printing related
            $totalTaxableAmt0 = 0;
            $totalTaxableAmt5 = 0;
            $totalTaxableAmt12 = 0;
            $totalTaxableAmt18 = 0;
            $totalTaxableAmount = 0;
            $totalGstValue0 = 0;
            $totalGstValue5 = 0;
            $totalGstValue12 = 0;
            $totalGstValue18 = 0;
            $totalGstAmount = 0;
            $totalAmount0 = 0;
            $totalAmount5 = 0;
            $totalAmount12 = 0;
            $totalAmount18 = 0;
            $totalAmount = 0;
            @endphp
            @foreach($trnDetail as $trn)
            @php
            $taxableAmt0 = 0;
            $taxableAmt5 = 0;
            $taxableAmt12 = 0;
            $taxableAmt18 = 0;
            $totalTaxableAmt = 0;
            $gstValue0 = 0;
            $gstValue5 = 0;
            $gstValue12 = 0;
            $gstValue18 = 0;
            $totalGstValue = 0;
            $total0 = 0;
            $total5 = 0;
            $total12 = 0;
            $total18 = 0;
            $total = 0;
            @endphp
            @if($trn->taxableAmt0 != null)
            @php
            $taxableAmt0 = round($trn->taxableAmt0,2);
            $gstValue0 = round($trn->cgstPercent0,2);
            $total0 = $taxableAmt0 + $gstValue0;
            $totalTaxableAmt += $taxableAmt0;
            $totalGstValue += $gstValue0;
            $total += ($taxableAmt0 + $gstValue0);
            $totalTaxableAmt0 += $taxableAmt0;
            $totalGstValue0 += $gstValue0;
            $totalAmount0 += $total0;
            if ($trnType == "P" || $trnType == "PR" || $trnType == "CSN" || $trnType == "CSNR"){
                if ($trn->supplier_supply_type == "inter_state") {
                    $totalIgstTaxableAmt0 += $taxableAmt0;
                    $totalIgstGstValue0 += $gstValue0;
                    $totalIgstAmount0 += $total0;
                } else {
                    $totalCsgstTaxableAmt0 += $taxableAmt0;
                    $totalCsgstGstValue0 += $gstValue0;
                    $totalCsgstAmount0 += $total0;
                }
            }
            @endphp
            @endif
            @if($trn->cgstPercent5 != null)
            @php
            $taxableAmt5 = round($trn->taxableAmt5,2);
            $gstValue5 = round($trn->cgstPercent5,2);
            $total5 = $taxableAmt5 + $gstValue5;
            $totalTaxableAmt += $taxableAmt5;
            $totalGstValue += $gstValue5;
            $total += ($taxableAmt5 + $gstValue5);
            $totalTaxableAmt5 += $taxableAmt5;
            $totalGstValue5 += $gstValue5;
            $totalAmount5 += $total5;
            if ($trnType == "P" || $trnType == "PR" || $trnType == "CSN" || $trnType == "CSNR"){
                if ($trn->supplier_supply_type == "inter_state") {
                    $totalIgstTaxableAmt5 += $taxableAmt5;
                    $totalIgstGstValue5 += $gstValue5;
                    $totalIgstAmount5 += $total5;
                } else {
                    $totalCsgstTaxableAmt5 += $taxableAmt5;
                    $totalCsgstGstValue5 += $gstValue5;
                    $totalCsgstAmount5 += $total5;
                }
            }
            @endphp
            @endif
            @if($trn->cgstPercent12 != null)
            @php
            $taxableAmt12 = round($trn->taxableAmt12,2);
            $gstValue12 = round($trn->cgstPercent12,2);
            $total12 = $taxableAmt12 + $gstValue12;
            $totalTaxableAmt += $taxableAmt12;
            $totalGstValue += $gstValue12;
            $total += ($taxableAmt12 + $gstValue12);
            $totalTaxableAmt12 += $taxableAmt12;
            $totalGstValue12 += $gstValue12;
            $totalAmount12 += $total12;
            if ($trnType == "P" || $trnType == "PR" || $trnType == "CSN" || $trnType == "CSNR"){
                if ($trn->supplier_supply_type == "inter_state") {
                    $totalIgstTaxableAmt12 += $taxableAmt12;
                    $totalIgstGstValue12 += $gstValue12;
                    $totalIgstAmount12 += $total12;
                } else {
                    $totalCsgstTaxableAmt12 += $taxableAmt12;
                    $totalCsgstGstValue12 += $gstValue12;
                    $totalCsgstAmount12 += $total12;
                }
            }
            @endphp
            @endif
            @if($trn->cgstPercent18 != null)
            @php
            $taxableAmt18 = round($trn->taxableAmt18,2);
            $gstValue18 = round($trn->cgstPercent18,2);
            $total18 = $taxableAmt18 + $gstValue18;
            $totalTaxableAmt += $taxableAmt18;
            $totalGstValue += $gstValue18;
            $total += ($taxableAmt18 + $gstValue18);
            $totalTaxableAmt18 += $taxableAmt18;
            $totalGstValue18 += $gstValue18;
            $totalAmount18 += $total18;
            if ($trnType == "P" || $trnType == "PR" || $trnType == "CSN" || $trnType == "CSNR") {
                if ($trn->supplier_supply_type == "inter_state") {
                    $totalIgstTaxableAmt18 += $taxableAmt18;
                    $totalIgstGstValue18 += $gstValue18;
                    $totalIgstAmount18 += $total18;
                } else {
                    $totalCsgstTaxableAmt18 += $taxableAmt18;
                    $totalCsgstGstValue18 += $gstValue18;
                    $totalCsgstAmount18 += $total18;
                }
            }
            @endphp
            @endif
            @php
            $patOrCusttBillType = "Cash";   
            @endphp
            @if($trn->is_credit_bill == 'Y')
            @php
            $patOrCusttBillType = "Credit";   
            @endphp
            @endif
            
                @if($trnType == "P" || $trnType == "PR" || $trnType == "CSN" || $trnType == "CSNR")
                    @if($trn->supplier_supply_type == "inter_state")
                    @php
                    $isIgstApplicable = "Yes";
                    @endphp
                    @else
                    @php
                    $isIgstApplicable = "";
                    @endphp
                    @endif
                |  {{$trn->trn_type."/".$trn->trn_fyear."/".$trn->trn_id}} | 
                {{\Helper::getDisplayDate($trn->trn_date)}} | 
                {{$trn->supplier_name}} | 
                {{$trn->supplier_gstin_no}} | 
                {{$trn->purchase_bill_no}} | 
                {{\Helper::getDisplayDate($trn->purchase_bill_date)}}
                 | {{$patOrCusttBillType}} | 
                {{$isIgstApplicable}} | 
                @else
                    @if($trn->patient_id == NULL || $trn->patient_id == '0')
                    @php
                    $patOrCustDetail = "*" . $trn->ph_cust_id." / ".$trn->ph_cust_name;
                    @endphp
                    @else
                    @php
                    $patOrCustDetail = $trn->patient_id." / ".$trn->patient_name;
                    @endphp
                    @endif
                 {{$trn->trn_type."/".$trn->trn_fyear."/".$trn->trn_id}} | 
                {{\Helper::getDisplayDate($trn->trn_date)}} | 
                {{ \Helper::zeroValueToDash($trn->opd_reg_id) }} | 
                {{ \Helper::zeroValueToDash($trn->ipd_reg_id) }} | 
                {{$patOrCustDetail}} | 
                {{$patOrCusttBillType}} | 
                @endif
                {{\Helper::customAmountFormat($total0)}} | 
                {{\Helper::customAmountFormat($taxableAmt5)}} | 
                {{\Helper::customAmountFormat($gstValue5)}} | 
                {{\Helper::customAmountFormat($total5)}} | 
                {{\Helper::customAmountFormat($taxableAmt12)}} | 
                {{\Helper::customAmountFormat($gstValue12)}} | 
                {{\Helper::customAmountFormat($total12)}} | 
                {{\Helper::customAmountFormat($taxableAmt18)}} | 
                {{\Helper::customAmountFormat($gstValue18)}} | 
                {{\Helper::customAmountFormat($total18)}} | 
                {{\Helper::customAmountFormat($totalTaxableAmt)}} | 
                {{\Helper::customAmountFormat($totalGstValue)}} | 
                {{\Helper::customAmountFormat($total)}} | 
            
            @endforeach
            @if($trnType == "P" || $trnType == "PR" || $trnType == "CSN" || $trnType == "CSNR")
                @php
                $totalTaxableAmount = ($totalCsgstTaxableAmt0 + $totalCsgstTaxableAmt5 + $totalCsgstTaxableAmt12 + $totalCsgstTaxableAmt18);
                $totalGstAmount = ($totalCsgstGstValue0 + $totalCsgstGstValue5 + $totalCsgstGstValue12 + $totalCsgstGstValue18);
                $totalAmount = ($totalCsgstAmount0 + $totalCsgstAmount5 + $totalCsgstAmount12 + $totalCsgstAmount18);
                @endphp
            
                | (CGST + SGST) Total  | 
                {{\Helper::customAmountFormat($totalCsgstAmount0)}} | 
                {{\Helper::customAmountFormat($totalCsgstTaxableAmt5)}} | 
                {{\Helper::customAmountFormat($totalCsgstGstValue5)}} | 
                {{\Helper::customAmountFormat($totalCsgstAmount5)}} | 
                {{\Helper::customAmountFormat($totalCsgstTaxableAmt12)}} | 
                {{\Helper::customAmountFormat($totalCsgstGstValue12)}} | 
                {{\Helper::customAmountFormat($totalCsgstAmount12)}} | 
                {{\Helper::customAmountFormat($totalCsgstTaxableAmt18)}} | 
                {{\Helper::customAmountFormat($totalCsgstGstValue18)}} | 
                {{\Helper::customAmountFormat($totalCsgstAmount18)}} | 
                {{\Helper::customAmountFormat($totalTaxableAmount)}} | 
                {{\Helper::customAmountFormat($totalGstAmount)}} | 
                {{\Helper::customAmountFormat($totalAmount)}} | 
            
                @php
                $totalTaxableAmount = ($totalIgstTaxableAmt0 + $totalIgstTaxableAmt5 + $totalIgstTaxableAmt12 + $totalIgstTaxableAmt18);
                $totalGstAmount = ($totalIgstGstValue0 + $totalIgstGstValue5 + $totalIgstGstValue12 + $totalIgstGstValue18);
                $totalAmount = ($totalIgstAmount0 + $totalIgstAmount5 + $totalIgstAmount12 + $totalIgstAmount18);
                @endphp
            
                | IGST Total  | 
                {{\Helper::customAmountFormat($totalIgstAmount0)}} | 
                {{\Helper::customAmountFormat($totalIgstTaxableAmt5)}} | 
                {{\Helper::customAmountFormat($totalIgstGstValue5)}} | 
                {{\Helper::customAmountFormat($totalIgstAmount5)}} | 
                {{\Helper::customAmountFormat($totalIgstTaxableAmt12)}} | 
                {{\Helper::customAmountFormat($totalIgstGstValue12)}} | 
                {{\Helper::customAmountFormat($totalIgstAmount12)}} | 
                {{\Helper::customAmountFormat($totalIgstTaxableAmt18)}} | 
                {{\Helper::customAmountFormat($totalIgstGstValue18)}} | 
                {{\Helper::customAmountFormat($totalIgstAmount18)}} | 
                {{\Helper::customAmountFormat($totalTaxableAmount)}} | 
                {{\Helper::customAmountFormat($totalGstAmount)}} | 
                {{\Helper::customAmountFormat($totalAmount)}} | 
            
            @endif
            @php
            $totalTaxableAmount = ($totalTaxableAmt0 + $totalTaxableAmt5 + $totalTaxableAmt12 + $totalTaxableAmt18);
            $totalGstAmount = ($totalGstValue0 + $totalGstValue5 + $totalGstValue12 + $totalGstValue18);
            $totalAmount = ($totalAmount0 + $totalAmount5 + $totalAmount12 + $totalAmount18);
            @endphp
            
                | Grand Total  | 
                {{\Helper::customAmountFormat($totalAmount0)}} | 
                {{\Helper::customAmountFormat($totalTaxableAmt5)}} | 
                {{\Helper::customAmountFormat($totalGstValue5)}} | 
                {{\Helper::customAmountFormat($totalAmount5)}} | 
                {{\Helper::customAmountFormat($totalTaxableAmt12)}} | 
                {{\Helper::customAmountFormat($totalGstValue12)}} | 
                {{\Helper::customAmountFormat($totalAmount12)}} | 
                {{\Helper::customAmountFormat($totalTaxableAmt18)}} | 
                {{\Helper::customAmountFormat($totalGstValue18)}} | 
                {{\Helper::customAmountFormat($totalAmount18)}} | 
                {{\Helper::customAmountFormat($totalTaxableAmount)}} | 
                {{\Helper::customAmountFormat($totalGstAmount)}} | 
                {{\Helper::customAmountFormat($totalAmount)}} |