How to display Item Wise Tax in invoice?

Reference post suggests tax_breakup to be Text Editor field not Code field.

can you try

cur_frm.set_value("tax_breakup", JSON.stringify(rows))
1 Like

While using JSON.stringify, I couldn’t loop over the array because it stored as string.

For Ex: I am trying like
{%- for tax in doc.tax_breakup -%}

I somehow displayed item wise tax. I believe there must be some better approach. I don’t find any. But this is not rendered while printing invoice :frowning: Can somebody guide me in the right direction ?

Here is my code:

<table class="table table-bordered">
            <th>Item Name</th>
            <th class="text-right">Qty</th>
            <th class="text-right">Rate</th>
            <th class="text-right">Amount</th>
            <th class="text-right">CGST</th>
            <th class="text-right">SGST</th>
            <th class="text-right">IGST</th>
        {%- for row in doc.items -%}
            <td style="width: 3%;">{{ row.idx }}</td>
            <td style="width: 20%;">
                {{ row.item_name }}
            <td style="width: 20%;">
                <div style="border: 0px;">{{ row.description }}</div>
            <td style="width: 10%; text-align: right;">{{ row.qty }} {{ row.uom or row.stock_uom }}</td>
            <td style="width: 15%; text-align: right;">{{ row.get_formatted("rate", doc) }}</td>
            <td style="width: 10%; text-align: right;">{{ row.get_formatted("amount", doc) }}</td>
            <td class="sgst{{loop.index}}">Nil</td>
            <td class="cgst{{loop.index}}">Nil</td>
            <td class="igst{{loop.index}}">Nil</td>
        {%- endfor -%}
 <script type="text/javascript">
    var $table = $(".tax-break-up");  // as far as i saw tax-break-up is not assigned to any form field.
    var sgst_name = "SGST - N" // change according to ur tax type name
	var cgst_name = "CGST - N" // change according to ur tax type name
	var igst_name = "IGST - N" // change according to ur tax type name
    var header = [];
    var rows = [];
    $table.find("thead th").each(function() {
    $table.find("tbody tr").each(function() {
        var row = {};
        $(this).find("td").each(function(i) {
            var key = header[i],
                value = $(this).html();
            row[key] = value;
    $.each(rows, function(key, value) {
        if (value.hasOwnProperty(sgst_name)) {
            $(".sgst".concat(key + 1)).html('<span>' + value[sgst_name] + '</span>');
        if (value.hasOwnProperty(cgst_name)) {
            $(".cgst".concat(key + 1)).html('<span>' + value[cgst_name] + '</span>');
        if (value.hasOwnProperty(igst_name)) {
            $(".igst".concat(key + 1)).html('<span>' + value[igst_name] + '</span>');

You may either create custom print format or else in the existing standard drag and drop form replace item table with custom html and copy, paste above code and reload.

This is showing NIL for taxes?

Could you changed the sgst_name, cgst_name , igst_name ?

Also pls note this is not rendered in PDF, Full page, Print. I don’t know why. I raised another question regarding this here.

Is this format required for everyone? For me there’s only a single tax rate for all the products. Will I have to show taxes individually for each product?

It’s your wish. This is not required for everyone. I saw Govt doesn’t insist any standard invoice format for GST.

Then its better this way. Adding 3 tax columns will reduce the space for title and description considerably!

Can you please share a screenshot of the Invoice this code gets.


See what I want section in my above original question.

It works perfectly.

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.

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.


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.



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 ??