Tally format for Tax Invoice

Hi,

I have created the invoice using your code, however I am unable to fetch buyer’s details and delivery note columns

Could you please help me

Thanks
Santhosh

I have used the tally format and its working if we select “Sales Taxes and Charges Template”. If we use item tax then its not working. Could you please help on this.

If I use item tax the I get below error:

Traceback (most recent call last):
File “apps/frappe/frappe/utils/jinja.py”, line 86, in render_template
return get_jenv().from_string(template).render(context)
File “env/lib/python3.9/site-packages/jinja2/environment.py”, line 1291, in render
self.environment.handle_exception()
File “env/lib/python3.9/site-packages/jinja2/environment.py”, line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "

Where are you failing to fetch?

In the error log I can see below error:

File “”, line 171, in top-level template code
jinja2.exceptions.UndefinedError: ‘erpnext.stock.doctype.item_tax.item_tax.ItemTax object’ has no attribute ‘tax_rate’

At the same time in PDF I can see below error log:
“_lang”: “en”
},
“headers”: {},
“error_handlers”: {},
“url”: “/api/method/frappe.www.printview.get_html_and_style”
}

### Response Data

{
“exception”: “TypeError: ‘list’ object is not callable”
}



Below is the code we are using:
<table>
<tbody>
    
    <tr style="border-color : black ;">
       <td width=15% rowspan=4 colspan=2 style="border-color : black ; border-right-color : white ;" >
      
      <img src=http://192.168.1.30/files/Ekabyte%20logo.jpg alt="logo" width="150" height="39"><br><br>
<td width=35% rowspan=4  colspan=4 > 
            <b><span style="font-family:verdana;"><span style="font-size: 12px;">{{ doc.company or "" }}</span></span></b>
            {{ frappe.db.get_value("Company", doc.company, "registration_details") or "" }} 
        <p>    #8/2, 1st Floor, ARK Complex,<br>
Sri Abhinav Vidyathirta Road,<br>
Chikkanna Garden, Shankarapuram,<br>
Bengaluru-560 004.India <br>
<br>
</br>
 </p>
       </td>
      
       <td width=25% colspan=2>
           Invoice No.<br>
           <b>{{ doc.name }}</b>
       </td>
       <td width=25% colspan=8>
           Dated<br>
	   <b>{{ frappe.utils.formatdate(doc.posting_date) }}</b>
       </td>
   </tr>
   <tr>
       <td width=25% colspan=2>
            Referrence No. & &nbsp; Date<br>
           <b>{{ doc.name }}&nbsp;</b>dt.<b> &nbsp;{{ frappe.utils.formatdate(doc.posting_date) }}</b>
	   <b>&nbsp;</b>
       </td>
       <td width=25% colspan=8>
            Other Reference(s)<br>
           <b>{{doc.contact_display or ""}}</b>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25% colspan=2>
             Buyer's Order No.<br>
           <b>{{doc.po_no or " "}}</b>
	   <b>&nbsp;</b>
       </td>
       <td width=25% colspan=8>
           Dated<br>
           <b>{{doc.po_date or ""}}</b>
	   <b>&nbsp;</b>
       </td>
   </tr>
    <tr>
    <td width=25% colspan=2>
           Eway Bill No.<br>
           <b>{{doc.ewaybill or ""}}</b>
	   <b>&nbsp;</b>
       </td>
       <td width=25% colspan=8>
           Despatch Document No & Date<br>
           <b>{{doc.despatch_document_no_and_date or ""}}</b>
	   <b>&nbsp;</b>
       </td>
       </tr>
   <tr>
       <td width=50% rowspan=4 colspan=6>
          <b> Buyer (Bill to)</b><br>
           <strong>{{ doc.customer_name or "" }}</strong><br>
	   {{ doc.address_display or "" }}<br>
	
      
       
       </td>
       
   
    </tr>
   <tr>
       <td width=25% colspan=2>
          Despatched through<br>
           <b>{{doc.transporter or ""}}</b>
	   <b>&nbsp;</b>
       </td>
       <td width=25% colspan=8>
          Destination<br>
           <b>{{doc.destination or ""}}</b>
	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       
       
       
       
       
       
   </tr>
   <tr>
      <td width=25% height=50 colspan=6>
           <b> Shipping Address</b>
	  
           <p><b>{{ doc.dispatch_address_name or "" }}</b></p>
            <p>{{ doc.dispatch_address or "" }}</p>
	   
	  
       </td>
   </tr>
   </tbody>
   </table>
    
    

    
    <table>
        
    <tbody>
    
	<tr class="">
		<th bgcolor= "orange" width="3%" class="text-center">Sl.<br>No</th>
		<th bgcolor= "orange" colspan=3 width="54%" class="text-center">Product Description</th>
        <th bgcolor= "orange" width="5%" class="text-center">HSN/SAC Code</th>
        <th bgcolor= "orange" width="5%" class="text-center">Unit Price</th>
		<th bgcolor= "orange" width="2%" class="text-center">Qty</th>
		<th bgcolor= "orange" width="8%" class="text-center">CGST</th>
		<th bgcolor= "orange" width="9%" class="text-center">SGST</th>
		<th bgcolor= "orange" width="9%" class="text-center">IGST</th>
		<th bgcolor= "orange" width="5%" class="text-center">Total</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: 6%; text-align: center;"><span style="font-family:verdana;"><span style="font-size: 8px;"></span></span>{{ row.idx }}</td>
    
        
		<td style="width: 48%;" colspan=3><span style="font-family:verdana;"><span style="font-size: 8px;"></span></span>
			                  
          
			     
          <b> {{ row.item_name }} </b> <br>
            <p> {{ row.description }} </p>
            
             {% if row.part_number != None %}
           <b>Part No: {{row.get_formatted("part_number", doc) }}</b><br>
          {%- endif %}
			     
                        
         {% if row.warranty != None %}
          <b> Wty:  {{row.get_formatted("warranty", doc) }}</b><br>
         {%- endif %} 

         {% if row.serial_no != None %}
          <b>Serial No: {{ row.serial_no }} </b>
         {%- endif %}

</td>

	

                
        <td style="width: 10%; text-align: center;"><span style="font-family:verdana;"><span style="font-size: 8px;"></span></span>{% if row.gst_hsn_code != None %}{{ row.gst_hsn_code }} {%- endif %}</td>
        <td style="width: 1%; text-align: right;"><span style="font-family:verdana;"><span style="font-size: 8px;"></span></span>{{
			row.get_formatted("rate", doc) }}</td>
        
            
        
             
        
		
		<td style="width: 1%; text-align: center;"><span style="font-family:verdana;"><span style="font-size: 8px;"></span></span>{{ row.qty|round|int }}<br><small>{{ row.uom or row.stock_uom }}</small></td>
		
		<td style="width: 9%; text-align: right;"><span style="font-family:verdana;"><span style="font-size: 8px;"></span></span>{{
			"{:,.2f}".format(cgst_amt[0])  }}<br><small>{{
			it_cgst_rate[0] }}%</small></td>
		<td style="width: 9%; text-align: right;"><span style="font-family:verdana;"><span style="font-size: 8px;"></span></span>{{
			"{:,.2f}".format(sgst_amt[0])  }}<br><small>{{
			it_sgst_rate[0] }}%</small></td>
		<td style="width: 9%; text-align: right;"><span style="font-family:verdana;"><span style="font-size: 8px;"></span></span>{{
			"{:,.2f}".format(igst_amt[0])  }}<br><small>{{
			it_igst_rate[0] }}%</small></td>
        
		<td style="width: 10%; text-align: right;" colspan=2><span style="font-family:verdana;"><span style="font-size: 8px;"></span></span> <b>  {{
			row.get_formatted("amount", doc) }} </b></td>
</tr>
{%- endfor -%}


<TR>
	  
	  
	<TD  colspan=6 align=left ><B>SUB TOTAL</B></TD>

   
    <TD WIDTH=10% align=center><B>{{ doc.get_formatted("total_qty", doc) }}</B></TD>      
    <TD WIDTH=10% align=right><B>{{ "{:,.2f}".format(grand_total["cgst_amt"])  }}</B></TD>
    <TD WIDTH=10% align=right><B>{{ "{:,.2f}".format(grand_total["sgst_amt"])  }}</B></TD>
    <TD  WIDTH=10% align=right><B>{{ "{:,.2f}".format(grand_total["igst_amt"])  }}</B></TD>
        
	<TD  WIDTH=20% align=right><B>{{ doc.get_formatted("total", doc) }}</B></TD>
</TR>
	
	<TR>
<TD colspan=7 align=left><B>GST Total</B></TD>
<TD colspan=2 align=center><B>{{ doc.get_formatted("total_taxes_and_charges", doc) }}</B></TD>
<TD  align=left><B>ADJ</B></TD>
<TD  align=right><B>{{ doc.get_formatted("base_rounding_adjustment", doc) }}</B></TD>
</TR>
	

<TR>
<TD colspan=10 align=left><B>Grand Total (INR) </B></TD>
<TD colspan=2 align=right><B>{{ doc.get_formatted("base_grand_total", doc) }}</B></TD>
</TR>





<TR>
	<TD colspan=11 align=left>Amount Chargeable (in Words):<br><B><span>{{ doc.get_formatted("base_in_words", doc) }}</span></B></TD>
</TR>




<TR>

	<TD  colspan=5 align=left >
<u>Declaration</u>	<br>
1. Goods once sold will not be taken back or exchanged.<br>
2. All Payments should be made by A/C Payee Cheque/DD.<br>
3. Payment should be made immediately on delivery
otherwise interest @ 21% Per annum will be charged Rs.250/- will
be charged for cheque bounce.<br>
4. Warranty on all materials are as per manufacturer's policy.<br>
5. No Warranty on Burnt, Physical damage and Track cut items.

<TD  colspan=6 align=left ><span>Date & Time &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:<B> {{ doc.get_formatted("posting_date", doc) }} at {{ doc.get_formatted("posting_time", doc) }} </B> <br>
Company's Bank Details<br>
Bank Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <B> </B> <br>
A/c No.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <B></B> <br>
</B>
</span></TD>


	
</TR>
<tr>
<td colspan="5" height="50" width="30%">Customer's seal and Signature</td>
<td align="right" colspan="6" width="30%"> <b>for {{ doc.company }}</b>
<div align="left" style="position: relative; height: 50px; border: solid; border-style: none;">
<div style="position: absolute; height: 10px; border: solid; bottom: 0; right: 0; left: 0; border-style: none;">
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     Authorised Signatory
</div> </div>
</td> </tr>


   


<P style="page-break-before: always">
    
 
</tbody>
</table>
<p align="center">This is a Computer Generated Invoice </p>

Please help on this

Any updates please

Seems this was only working for v11 and we never used it again for v12. You may remove the tax_rate field and pick up from line items of Item Tax Template.

Could you please let me know which field I need to use instead of tax_rate

Hi, How this can be done?

You will have to engage a programmer to figure out your needs