Customise gst rows into column

Can someone please help to customise GST slabs to appear in a columns view instead of rows

Here is my current invoice format

The code i have used is…

<center><h3>TAX INVOICE</h3><center>
<table width=90% height=30% border=1>
   <tr>
       <td width=50% rowspan=3>
           <strong>{{ doc.company or "" }}</strong><br>
           {{ frappe.db.get_value("Company", doc.company, "registration_details") or "" }}
       </td>
       <td width=25%>
           Invoice No.<br>
           <b>{{ doc.name }}</b>
       </td>
       <td width=25%>
           Dated<br>
	   <b>{{ frappe.utils.formatdate(doc.posting_date) }}</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Delivery Note<br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Mode of Payment<br>
           <b>{{ doc.mode_of_payment or " " }}<b></b><br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Supplier's Ref.<br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Other Reference(s)<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=50% rowspan=4>
           <i>Customer</i><br>
           <strong>{{ doc.customer_name or "" }}</strong><br>
	   {{ doc.address_display or "" }}
       </td>
       <td width=25%>
           PO No.<br>
           <b>{{ doc.po_no or " " }}<b></b><br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Dated<br>
           <b>{{ frappe.utils.formatdate(doc.po_date) }}</b>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Despatch Document No.<br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Dated<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Mode of Transport<br>
           <b></b>{{ doc.mode_of_transport or " " }}<b></b><br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Shipping Address<br>
           {{ doc.shipping_address_name or " " }}<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25% height=100 colspan=2>
           Terms of Delivery<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
</table>
<TABLE cellpadding=0 cellspacing=0 width=90% border=1>
<TR>
<tbody>
	<tr>
		<th>SR</th>
		<th>DISCRIPTION</th>
		<th>HSN/ASN</th>
		<th class="text-right">QTY</th>
		<th class="text-right">UNIT RATE</th>
		<th class="text-right">CGST</th>
		<th class="text-right">SGST</th>
		<th class="text-right">IGST</th>
		<th class="text-right">TAXABLE AMOUNT</th>
	</tr>
	{% set cgst_rate = [] -%}
	 {% set sgst_rate = [] -%}
	 {% set igst_rate = [] -%}
	{% set cgst_account_head = [] -%}
	 {% set sgst_account_head = [] -%}
	 {% set igst_account_head = [] -%}
	{% set tot_cgst_amount = [] %}
	{% set tot_sgst_amount = [] %}
	{% set grand_total = {"qty":0.0, "amount":0.0, "cgst_amt":0.0, "sgst_amt":0.0, "igst_amt":0.0} %}
	{%- for row in doc.taxes -%}
  	   {% if 'CGST' in row.account_head -%}
		{% set _ = cgst_account_head.append(row.account_head) %}
		{% set _ = cgst_rate.append(row.rate) %}
	   {%- endif -%}
	   {% if 'SGST' in row.account_head -%}
		 {% set _ = sgst_account_head.append(row.account_head) %}
		{% set _ = sgst_rate.append(row.rate) %}	
	   {%- endif -%}
	   {% if 'IGST' in row.account_head -%}
		{% set _ = igst_account_head.append(row.account_head) %}
		{% set _ = igst_rate.append(row.rate) %}
	   {%- endif -%}
	{%- endfor -%}
{%- for row in doc.items -%}
	<tr>
	        {% set cgst_amt = [] -%}
	 	 {% set sgst_amt = [] -%}
		 {% set igst_amt = [] -%}
		 {% set it_cgst_rate = [] -%}
	 	 {% set it_sgst_rate = [] -%}
		 {% set it_igst_rate = [] -%}
		 {% set rate_found_item = 0 -%}
	      {%- set item_record = frappe.get_doc("Item", row.item_code) -%}
		{% for item_tax in item_record.taxes %}
		  {% if item_tax.tax_type == igst_account_head[0] %}	
			{% set _ = it_igst_rate.append(item_tax.tax_rate) %}
			{% set _ = igst_amt.append(row.amount * it_igst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}		
		{% if item_tax.tax_type == sgst_account_head[0] %}
			
			{% set _ = it_sgst_rate.append(item_tax.tax_rate) %}
			{% set _ = sgst_amt.append(row.amount * it_sgst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}	
		{% if item_tax.tax_type == cgst_account_head[0] %}
			{% set _ = it_cgst_rate.append(item_tax.tax_rate) %}
			{% set _ = cgst_amt.append(row.amount * it_cgst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}		
	{% endfor %}	
  	{% if rate_found_item == 0 %}

		{% if cgst_rate[0] -%}
		   {% set _ = cgst_amt.append((row.amount * cgst_rate[0])/100) -%}
		   {% set _= it_cgst_rate.append(cgst_rate[0]) -%}
		   {% set rate_found_inv = 1 -%}
	       	{%- endif -%}
		{% if sgst_rate[0] -%}
		   {% set _ = sgst_amt.append((row.amount * sgst_rate[0])/100) -%}
		   {% set _= it_sgst_rate.append(sgst_rate[0]) -%}
		   
	       	{%- endif -%}
		{% if igst_rate[0] -%}
		   {% set _ = igst_amt.append((row.amount * igst_rate[0])/100) -%}
		   {% set _= it_igst_rate.append(igst_rate[0]) -%}
		   {% set rate_found_inv = 1 -%}
	       	{%- endif -%}
	{% endif %}
	{% if not it_cgst_rate[0] %}
		{% set _ = it_cgst_rate.append(0) %}
		{% set _ = cgst_amt.append(0) %}
	{% endif %}
	{% if not it_sgst_rate[0] %}
		{% set _ = it_sgst_rate.append(0) %}
		{% set _ = sgst_amt.append(0) %}
	{% endif %}
	{% if not it_igst_rate[0] %}
		{% set _ = it_igst_rate.append(0) %}
		{% set _ = igst_amt.append(0) %}
	{% endif %}
	{% set temp_cgst_amt = grand_total["cgst_amt"] + cgst_amt[0] %}
	{% set temp_sgst_amt = grand_total["sgst_amt"] + sgst_amt[0] %}
	{% set temp_igst_amt = grand_total["igst_amt"] + igst_amt[0] %}
	{% set temp_qty = grand_total["qty"] + row.qty %}
	{% set temp_amount = grand_total["amount"] + row.amount %}
	{% set check = grand_total.update({"qty": temp_qty, "amount": temp_amount, "cgst_amt":temp_cgst_amt, "sgst_amt":temp_sgst_amt, "igst_amt":temp_igst_amt}) %}
	
		<td style="width: 5%;"><font size = "1">{{ row.idx }}</font></td>
		<td style="width: 25%;"><font size = "1">
			{% if row.item_code != row.item_name -%}
			<b>{{ row.item_code}}</b><br>
			{%- endif %}
                            {{ row.item_name }}
		</font></td>
		<td style="width: 10%;"><font size = "1">{{ row.gst_hsn_code }}</font></td>
		<td style="width: 8%; text-align: left;"><font size = "1">{{ row.qty }}<br><small>{{ row.uom or row.stock_uom }}</small> </font></td>
		<td style="width: 8%; text-align: right;"><font size = "1">{{
			row.get_formatted("rate", doc) }}</font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(cgst_amt[0])  }}<br><small>{{
			it_cgst_rate[0] }}%</small></font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(sgst_amt[0])  }}<br><small>{{
			it_sgst_rate[0] }}%</small></font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(igst_amt[0])  }}<br><small>{{
			it_igst_rate[0] }}%</small></font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			row.get_formatted("amount", doc) }}</font></td>
</tr>
{% set trate = "" %}
{% endfor %}

<!-- {% set loop = 10 - doc.items|length  %}
{% for i in range(loop) %}
<TR>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
</TR>
{% endfor %} -->
</TABLE>

<TABLE cellpadding=0 cellspacing=0 width=90% border=1>
<TR>
        <TD rowspan=3 >
            Amount in Words<br>
            <B>{{ doc.base_in_words }}</B>
        </TD>
	<TD WIDTH=13% align=right><B>SUB TOTAL</B></TD>
	<TD WIDTH=20% align=right><B>{{ doc.get_formatted("total", doc) }}</B></TD>
</TR>
<TR>
	<TD align=right><B>GST 18%</B></TD>
	<TD WIDTH=20% align=right><B>{{ doc.get_formatted("total_taxes_and_charges", doc) }}</B></TD>
	
</TR>
<TR>
	<TD align=right><B>TOTAL</B></TD>
	<TD WIDTH=20% align=right><B>{{ doc.get_formatted("grand_total", doc) }}</B></TD>
</TR>
<TR>
	<TD colspan=2 height=120>{{ doc.remarks }}</B></TD>
	<TD align=right colspan=3>
            <B>for {{ doc.company }}</B>
            <div style="position: relative; height: 100px; border: solid; border-style: none;">
               <div style="position: absolute; height: 10px; border: solid; bottom: 0; right: 0;  left: 0; border-style: none;">
                  Authorised Signatory
               </div>
            </div>

The ideal output gst format i am looking something like below
SampleGST

Thanks in advance
Santhosh Rao

hi

What happens if there are more than 1 item… say 5 items …

Is the Output CGST the total of the 5 items ??

i need to have consolidated CGST and SGST for all items, no need to show GST on each items

basically i need to show SGST and CGST in coulmns instead of Rows

I presume you mean in rows and not columns ???

Well you could try to put the below just above GST

<TR>

    <TD align=right><B>CGST 9%</B></TD>

    <TD WIDTH=20% align=right><B>{{items|sum(attribute='cgst_amt')}}</B></TD>

   

</TR>

<TR>

    <TD align=right><B>SGST 9%</B></TD>

    <TD WIDTH=20% align=right><B>{{items|sum(attribute='sgst_amt')}}</B></TD>

   

</TR>

Yes, Its coming but its not aligning in the table, can you please tell me where exactly i need to paste this

Just add the code below the SUBTOTAL and above the GST

If you want to add it inside the items table as a separate row at the end… You will have to do that after the Item “for loop” and just before the table end.

@centaur
Thanks for help, Please see attached image output

Can you please help

Here is the code i have used which you sent

<center><h3>TAX INVOICE</h3><center>
<table width=90% height=30% border=1>
   <tr>
       <td width=50% rowspan=3>
           <strong>{{ doc.company or "" }}</strong><br>
           {{ frappe.db.get_value("Company", doc.company, "registration_details") or "" }}
       </td>
       <td width=25%>
           Invoice No.<br>
           <b>{{ doc.name }}</b>
       </td>
       <td width=25%>
           Dated<br>
	   <b>{{ frappe.utils.formatdate(doc.posting_date) }}</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Delivery Note<br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Mode of Payment<br>
           <b>{{ doc.mode_of_payment or " " }}<b></b><br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Supplier's Ref.<br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Other Reference(s)<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=50% rowspan=4>
           <i>Customer</i><br>
           <strong>{{ doc.customer_name or "" }}</strong><br>
	   {{ doc.address_display or "" }}
       </td>
       <td width=25%>
           PO No.<br>
           <b>{{ doc.po_no or " " }}<b></b><br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Dated<br>
           <b>{{ frappe.utils.formatdate(doc.po_date) }}</b>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Despatch Document No.<br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Dated<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Mode of Transport<br>
           <b></b>{{ doc.mode_of_transport or " " }}<b></b><br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Shipping Address<br>
           {{ doc.shipping_address_name or " " }}<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25% height=100 colspan=2>
           Terms of Delivery<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
</table>
<TABLE cellpadding=0 cellspacing=0 width=90% border=1>
<TR>
<tbody>
	<tr>
		<th>SR</th>
		<th>DISCRIPTION</th>
		<th>HSN/ASN</th>
		<th class="text-right">QTY</th>
		<th class="text-right">UNIT RATE</th>
		<th class="text-right">CGST</th>
		<th class="text-right">SGST</th>
		<th class="text-right">IGST</th>
		<th class="text-right">TAXABLE AMOUNT</th>
	</tr>
	{% set cgst_rate = [] -%}
	 {% set sgst_rate = [] -%}
	 {% set igst_rate = [] -%}
	{% set cgst_account_head = [] -%}
	 {% set sgst_account_head = [] -%}
	 {% set igst_account_head = [] -%}
	{% set tot_cgst_amount = [] %}
	{% set tot_sgst_amount = [] %}
	{% set grand_total = {"qty":0.0, "amount":0.0, "cgst_amt":0.0, "sgst_amt":0.0, "igst_amt":0.0} %}
	{%- for row in doc.taxes -%}
  	   {% if 'CGST' in row.account_head -%}
		{% set _ = cgst_account_head.append(row.account_head) %}
		{% set _ = cgst_rate.append(row.rate) %}
	   {%- endif -%}
	   {% if 'SGST' in row.account_head -%}
		 {% set _ = sgst_account_head.append(row.account_head) %}
		{% set _ = sgst_rate.append(row.rate) %}	
	   {%- endif -%}
	   {% if 'IGST' in row.account_head -%}
		{% set _ = igst_account_head.append(row.account_head) %}
		{% set _ = igst_rate.append(row.rate) %}
	   {%- endif -%}
	{%- endfor -%}
{%- for row in doc.items -%}
	<tr>
	        {% set cgst_amt = [] -%}
	 	 {% set sgst_amt = [] -%}
		 {% set igst_amt = [] -%}
		 {% set it_cgst_rate = [] -%}
	 	 {% set it_sgst_rate = [] -%}
		 {% set it_igst_rate = [] -%}
		 {% set rate_found_item = 0 -%}
	      {%- set item_record = frappe.get_doc("Item", row.item_code) -%}
		{% for item_tax in item_record.taxes %}
		  {% if item_tax.tax_type == igst_account_head[0] %}	
			{% set _ = it_igst_rate.append(item_tax.tax_rate) %}
			{% set _ = igst_amt.append(row.amount * it_igst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}		
		{% if item_tax.tax_type == sgst_account_head[0] %}
			
			{% set _ = it_sgst_rate.append(item_tax.tax_rate) %}
			{% set _ = sgst_amt.append(row.amount * it_sgst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}	
		{% if item_tax.tax_type == cgst_account_head[0] %}
			{% set _ = it_cgst_rate.append(item_tax.tax_rate) %}
			{% set _ = cgst_amt.append(row.amount * it_cgst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}		
	{% endfor %}	
  	{% if rate_found_item == 0 %}

		{% if cgst_rate[0] -%}
		   {% set _ = cgst_amt.append((row.amount * cgst_rate[0])/100) -%}
		   {% set _= it_cgst_rate.append(cgst_rate[0]) -%}
		   {% set rate_found_inv = 1 -%}
	       	{%- endif -%}
		{% if sgst_rate[0] -%}
		   {% set _ = sgst_amt.append((row.amount * sgst_rate[0])/100) -%}
		   {% set _= it_sgst_rate.append(sgst_rate[0]) -%}
		   
	       	{%- endif -%}
		{% if igst_rate[0] -%}
		   {% set _ = igst_amt.append((row.amount * igst_rate[0])/100) -%}
		   {% set _= it_igst_rate.append(igst_rate[0]) -%}
		   {% set rate_found_inv = 1 -%}
	       	{%- endif -%}
	{% endif %}
	{% if not it_cgst_rate[0] %}
		{% set _ = it_cgst_rate.append(0) %}
		{% set _ = cgst_amt.append(0) %}
	{% endif %}
	{% if not it_sgst_rate[0] %}
		{% set _ = it_sgst_rate.append(0) %}
		{% set _ = sgst_amt.append(0) %}
	{% endif %}
	{% if not it_igst_rate[0] %}
		{% set _ = it_igst_rate.append(0) %}
		{% set _ = igst_amt.append(0) %}
	{% endif %}
	{% set temp_cgst_amt = grand_total["cgst_amt"] + cgst_amt[0] %}
	{% set temp_sgst_amt = grand_total["sgst_amt"] + sgst_amt[0] %}
	{% set temp_igst_amt = grand_total["igst_amt"] + igst_amt[0] %}
	{% set temp_qty = grand_total["qty"] + row.qty %}
	{% set temp_amount = grand_total["amount"] + row.amount %}
	{% set check = grand_total.update({"qty": temp_qty, "amount": temp_amount, "cgst_amt":temp_cgst_amt, "sgst_amt":temp_sgst_amt, "igst_amt":temp_igst_amt}) %}
	
		<td style="width: 5%;"><font size = "1">{{ row.idx }}</font></td>
		<td style="width: 25%;"><font size = "1">
			{% if row.item_code != row.item_name -%}
			<b>{{ row.item_code}}</b><br>
			{%- endif %}
                            {{ row.item_name }}
		</font></td>
		<td style="width: 10%;"><font size = "1">{{ row.gst_hsn_code }}</font></td>
		<td style="width: 8%; text-align: left;"><font size = "1">{{ row.qty }}<br><small>{{ row.uom or row.stock_uom }}</small> </font></td>
		<td style="width: 8%; text-align: right;"><font size = "1">{{
			row.get_formatted("rate", doc) }}</font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(cgst_amt[0])  }}<br><small>{{
			it_cgst_rate[0] }}%</small></font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(sgst_amt[0])  }}<br><small>{{
			it_sgst_rate[0] }}%</small></font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(igst_amt[0])  }}<br><small>{{
			it_igst_rate[0] }}%</small></font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			row.get_formatted("amount", doc) }}</font></td>
</tr>
{% set trate = "" %}
{% endfor %}

<!-- {% set loop = 10 - doc.items|length  %}
{% for i in range(loop) %}
<TR>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
</TR>
{% endfor %} -->
</TABLE>

<TABLE cellpadding=0 cellspacing=0 width=90% border=1>
<TR>
        <TD rowspan=3 >
            Amount in Words<br>
            <B>{{ doc.base_in_words }}</B>
        </TD>
	<TD WIDTH=13% align=right><B>SUB TOTAL</B></TD>
	<TD WIDTH=20% align=right><B>{{ doc.get_formatted("total", doc) }}</B></TD>
	<TR>

    <TD align=right><B>CGST 9%</B></TD>

    <TD WIDTH=20% align=right><B>{{items|sum(attribute='cgst_amt')}}</B></TD>

   

</TR>

<TR>

    <TD align=right><B>SGST 9%</B></TD>

    <TD WIDTH=20% align=right><B>{{items|sum(attribute='sgst_amt')}}</B></TD>

   

</TR>
</TR>
<TR>

	
</TR>
<TR>
	<TD align=right><B>TOTAL</B></TD>
	<TD WIDTH=20% align=right><B>{{ doc.get_formatted("grand_total", doc) }}</B></TD>
</TR>
<TR>
	<TD colspan=2 height=120>{{ doc.remarks }}</B></TD>
	<TD align=right colspan=3>
            <B>for {{ doc.company }}</B>
            <div style="position: relative; height: 100px; border: solid; border-style: none;">
               <div style="position: absolute; height: 10px; border: solid; bottom: 0; right: 0;  left: 0; border-style: none;">
                  Authorised Signatory
               </div>
            </div>![SampleGST|690x293](upload://aAFswgvypDj1SSEoZZsOgN6wrxC.jpeg)![SampleGST|690x293](upload://aAFswgvypDj1SSEoZZsOgN6wrxC.jpeg)

@centaur

hmm

Sorry didn’t check the whole code…

Since you are already setting temp_cgst_amt and temp_sgst_amt in your code…

could you try changing the code i gave you to

<TD align=right><B>Total CGST </B></TD>

<TD WIDTH=20% align=right><B>{{ temp_cgst_amt }}</B></TD>
<TD align=right><B>Total SGST</B></TD>

<TD WIDTH=20% align=right><B>{{ temp_sgst_amt }}</B></TD>

@centaur
Do i need to paste under ''Sub Total" ?

yes… first lets get it to work…

later we will remove the CGST and SGST columns

@centaur

Its not working… ! Notworking

try this

<TR>

    <TD align=right><B>Total CGST</B></TD>

    <TD WIDTH=20% align=right><B>{{ "₹ {:,.2f}".format(grand_total["cgst_amt"])  }}</B></TD>

</TR>

<TR>

    <TD align=right><B>Total SGST</B></TD>

    <TD WIDTH=20% align=right><B>{{ "₹ {:,.2f}".format(grand_total["sgst_amt"])  }}</B></TD>

</TR>

@centaur

@centaur

Its working, however its jumping beside the column

Pls see attached images

GAP

Got… It

Pls see attached image

Can you please help me to remove highlighted in red

Thanks
Santhosh

Could you share the complete code now ?

<left><h1></h1>(ORIGINAL FOR RECIPIENT)<left><h1></h1>
<center><h3>TAX INVOICE</h3><center>
<table width=100% height=30% border=1>
   <tr>
       <td width=50% rowspan=3>
           <strong>{{ doc.company or "" }}</strong><br>
           {{ frappe.db.get_value("Company", doc.company, "registration_details") or "" }}
       </td>
       <td width=25%>
           Invoice No.<br>
           <b>{{ doc.name }}</b>
       </td>
       <td width=25%>
           Dated<br>
	   <b>{{ frappe.utils.formatdate(doc.posting_date) }}</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Delivery Note<br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Mode of Payment<br>
           <b>{{ doc.mode_of_payment or " " }}<b></b><br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Supplier's Ref.<br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Other Reference(s)<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=50% rowspan=4>
           <i>Customer</i><br>
           <strong>{{ doc.customer_name or "" }}</strong><br>
	   {{ doc.address_display or "" }}
       </td>
       <td width=25%>
           PO No.<br>
           <b>{{ doc.po_no or " " }}<b></b><br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Dated<br>
           <b>{{ frappe.utils.formatdate(doc.po_date) }}</b>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Despatch Document No.<br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Dated<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Mode of Transport<br>
           <b></b>{{ doc.mode_of_transport or " " }}<b></b><br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
           Shipping Address<br>
           {{ doc.shipping_address_name or " " }}<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25% height=25 colspan=2>
           Terms of Delivery<br>
            {{ doc.tc_name or " " }}<br>
	   <b>&nbsp;</b>
       </td>
   </tr>
</table>
<TABLE cellpadding=0 cellspacing=0 width=100% border=1>
<TR>
<tbody>
	<tr>
		<th>SR</th>
		<th>DISCRIPTION</th>
		<th>HSN/ASN</th>
		<th class="text-right">QTY</th>
		<th class="text-right">UNIT RATE</th>
		<th class="text-right">CGST</th>
		<th class="text-right">SGST</th>
		<th class="text-right">IGST</th>
		<th class="text-right">TAXABLE AMOUNT</th>
	</tr>
	{% set cgst_rate = [] -%}
	 {% set sgst_rate = [] -%}
	 {% set igst_rate = [] -%}
	{% set cgst_account_head = [] -%}
	 {% set sgst_account_head = [] -%}
	 {% set igst_account_head = [] -%}
	{% set tot_cgst_amount = [] %}
	{% set tot_sgst_amount = [] %}
	{% set grand_total = {"qty":0.0, "amount":0.0, "cgst_amt":0.0, "sgst_amt":0.0, "igst_amt":0.0} %}
	{%- for row in doc.taxes -%}
  	   {% if 'CGST' in row.account_head -%}
		{% set _ = cgst_account_head.append(row.account_head) %}
		{% set _ = cgst_rate.append(row.rate) %}
	   {%- endif -%}
	   {% if 'SGST' in row.account_head -%}
		 {% set _ = sgst_account_head.append(row.account_head) %}
		{% set _ = sgst_rate.append(row.rate) %}	
	   {%- endif -%}
	   {% if 'IGST' in row.account_head -%}
		{% set _ = igst_account_head.append(row.account_head) %}
		{% set _ = igst_rate.append(row.rate) %}
	   {%- endif -%}
	{%- endfor -%}
{%- for row in doc.items -%}
	<tr>
	        {% set cgst_amt = [] -%}
	 	 {% set sgst_amt = [] -%}
		 {% set igst_amt = [] -%}
		 {% set it_cgst_rate = [] -%}
	 	 {% set it_sgst_rate = [] -%}
		 {% set it_igst_rate = [] -%}
		 {% set rate_found_item = 0 -%}
	      {%- set item_record = frappe.get_doc("Item", row.item_code) -%}
		{% for item_tax in item_record.taxes %}
		  {% if item_tax.tax_type == igst_account_head[0] %}	
			{% set _ = it_igst_rate.append(item_tax.tax_rate) %}
			{% set _ = igst_amt.append(row.amount * it_igst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}		
		{% if item_tax.tax_type == sgst_account_head[0] %}
			
			{% set _ = it_sgst_rate.append(item_tax.tax_rate) %}
			{% set _ = sgst_amt.append(row.amount * it_sgst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}	
		{% if item_tax.tax_type == cgst_account_head[0] %}
			{% set _ = it_cgst_rate.append(item_tax.tax_rate) %}
			{% set _ = cgst_amt.append(row.amount * it_cgst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}		
	{% endfor %}	
  	{% if rate_found_item == 0 %}

		{% if cgst_rate[0] -%}
		   {% set _ = cgst_amt.append((row.amount * cgst_rate[0])/100) -%}
		   {% set _= it_cgst_rate.append(cgst_rate[0]) -%}
		   {% set rate_found_inv = 1 -%}
	       	{%- endif -%}
		{% if sgst_rate[0] -%}
		   {% set _ = sgst_amt.append((row.amount * sgst_rate[0])/100) -%}
		   {% set _= it_sgst_rate.append(sgst_rate[0]) -%}
		   
	       	{%- endif -%}
		{% if igst_rate[0] -%}
		   {% set _ = igst_amt.append((row.amount * igst_rate[0])/100) -%}
		   {% set _= it_igst_rate.append(igst_rate[0]) -%}
		   {% set rate_found_inv = 1 -%}
	       	{%- endif -%}
	{% endif %}
	{% if not it_cgst_rate[0] %}
		{% set _ = it_cgst_rate.append(0) %}
		{% set _ = cgst_amt.append(0) %}
	{% endif %}
	{% if not it_sgst_rate[0] %}
		{% set _ = it_sgst_rate.append(0) %}
		{% set _ = sgst_amt.append(0) %}
	{% endif %}
	{% if not it_igst_rate[0] %}
		{% set _ = it_igst_rate.append(0) %}
		{% set _ = igst_amt.append(0) %}
	{% endif %}
	{% set temp_cgst_amt = grand_total["cgst_amt"] + cgst_amt[0] %}
	{% set temp_sgst_amt = grand_total["sgst_amt"] + sgst_amt[0] %}
	{% set temp_igst_amt = grand_total["igst_amt"] + igst_amt[0] %}
	{% set temp_qty = grand_total["qty"] + row.qty %}
	{% set temp_amount = grand_total["amount"] + row.amount %}
	{% set check = grand_total.update({"qty": temp_qty, "amount": temp_amount, "cgst_amt":temp_cgst_amt, "sgst_amt":temp_sgst_amt, "igst_amt":temp_igst_amt}) %}
	
		<td style="width: 5%;"><font size = "1">{{ row.idx }}</font></td>
		<td style="width: 25%;"><font size = "1">
			{% if row.item_code != row.item_name -%}
			<b>{{ row.item_code}}</b><br>
			{%- endif %}
                            {{ row.item_name }}
		</font></td>
		<td style="width: 10%;"><font size = "1">{{ row.gst_hsn_code }}</font></td>
		<td style="width: 8%; text-align: left;"><font size = "1">{{ row.qty }}<br><small>{{ row.uom or row.stock_uom }}</small> </font></td>
		<td style="width: 8%; text-align: right;"><font size = "1">{{
			row.get_formatted("rate", doc) }}</font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(cgst_amt[0])  }}<br><small>{{
			it_cgst_rate[0] }}%</small></font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(sgst_amt[0])  }}<br><small>{{
			it_sgst_rate[0] }}%</small></font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(igst_amt[0])  }}<br><small>{{
			it_igst_rate[0] }}%</small></font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			row.get_formatted("amount", doc) }}</font></td>
</tr>
{% set trate = "" %}
{% endfor %}

<!-- {% set loop = 10 - doc.items|length  %}
{% for i in range(loop) %}
<TR>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
</TR>
{% endfor %} -->
</TABLE>

<TABLE cellpadding=0 cellspacing=0 width=100% border=1>
<TR>
        <TD rowspan=3 >
            Amount in Words<br>
            <B>{{ doc.base_in_words }}</B>
        </TD>
	<TD WIDTH=13% align=right><B>SUB TOTAL</B></TD>
	<TD WIDTH=20% align=right><B>{{ doc.get_formatted("total", doc) }}</B></TD>
<TR>
    

    <TD align=right><B>CGST - 9%</B></TD>
    <TD WIDTH=20% align=right><B>{{ "₹ {:,.2f}".format(grand_total["cgst_amt"])  }}</B></TD>

</TR>

<TR>

    <TD align=right><B>SGST - 9%</B></TD>
    <TD WIDTH=20% align=right><B>{{ "₹ {:,.2f}".format(grand_total["sgst_amt"])  }}</B></TD>

</TR>

<TR>
	<TD align=right><B>TOTAL</B></TD>
	<TD WIDTH=20% align=right><B>{{ doc.get_formatted("base_grand_total", doc) }}</B></TD>
	<TD WIDTH=20% align=right><B>{{ doc.get_formatted("grand_total", doc) }}</B></TD>
</TR>
<TR>
	<TD colspan=2 height=120>{{ doc.remarks }}</B></TD>
	<TD align=right colspan=3>
            <B>for {{ doc.company }}</B>
            <div style="position: relative; height: 100px; border: solid; border-style: none;">
               <div style="position: absolute; height: 10px; border: solid; bottom: 0; right: 0;  left: 0; border-style: none;">
                  Authorised Signatory
               </div>
            </div>
        </TD>
</TR>
</TABLE>`Preformatted text`

Image for your ref