How to display Item Wise Tax in invoice?

I tried the above code. It worked. Really thankful to the community out there.

Could someone help me tweak the above code to do the following:

  1. Add a row total at the end of the item table. ie. Taxable Value + SGST + CGST + IGST

  2. Show only applicable columns - ie. If only IGST is applicable, it need not show SGST & CGST and wise verse.

It makes more sense with a total column at the end.
The new format takes up a lot of space. So its better to display only the required fields.

Please help me out.

ERPNext Team is working on creating a new GST format.
https://github.com/frappe/erpnext/issues/9566

Thanks LifeP for creating issue on github. I am also waiting for this feature because I feel above code is not right way to approach it.

Hi,

I have created some code for calculating tax at item level. Here is the link for it. This method checks for the tax rate at item level first, and calculates the tax amount based on that. If the tax rate is not found at item level, it calculates the tax at invoice level. Have added some custom fields on that for state and gstin and HSN code on Sales Invoice. Though, the code is a little long, it works for me. Maybe, ERPNext might come up with some simpler code… Till then, you can check this out.

Regards
Uma

3 Likes

Is item wise tax is shown while generating PDF or taking print?

Yes… it is getting printed.

1 Like

Thanks :slight_smile:

1 Like

Hi @UmaG

Really awesome you made Sales Invoice format but, i could not able to load in pdf, it keeps loading . where as my other sales invoice format get able to print in pdf. ??

what is the issue ??

Not sure why it’s not loading. Could you check your logo and custom fields definition? Maybe check the console with ctrl+shift +j

Ok… will let you know… let me set all the field …

hey how do i achieve this

can anyone guide me the step by step process i am new to erpnext

hi @Azhar_Umar

How did you achieved this ?

update to the latest bench, it is present as new a print format → GST Invoice

Could not able to fetch HSN Code from item Master,

Did you find a way to print this in PDF?

Sharing a very simple GST compatible item table

<table class="table table-bordered">
<tbody>
	<tr>
		<th>Sr</th>
		<th>Product Details</th>
		<th>Tariff/HSN</th>
		<th class="text-right">Quantity</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>
{%- endfor -%}
</tbody>
</table>

The output on Print, PDF, Full Page is coming correctly.

8 Likes

Hi,

In which file we will update this script , can you please give some idea

Hi,

This has to be updated on the print format for Sales Invoice.

Thanks @UmaG

1 Like