Multiple copies of invoices

Hi,

I would like to split the Sales invoice into multiple copies with “Original for
Buyer”, “Duplicate for Transporter”, “Triplicate for Assessee” etc. Can you please let me know how to work on this? Basically, I would like to print 3 copies of the same invoice with 3 separate headings. I understand that a new html print format will have to be created for this. It would be great if somebody could assist me with that.

Thanks
Uma

Hi @uma13,

Using print heading feature you can achieve it, create 3 different print heading for “Original”, “Duplicate”, “Triplicate”. Before printing select respective print heading on form.
Documentation: https://frappe.github.io/erpnext/user/manual/en/setting-up/print/print-headings.html

You can create separate print format using print format builder.
Documentation: https://frappe.github.io/erpnext/user/manual/en/setting-up/print/print-format-builder.html

Thanks, Rohit

Thanks for the quick response Rohit. Is there a way all the copies can come out together instead of selecting it one by one?

Thanks
Uma

Hi @uma13,

It’s difficult to implement, you have to create custom print format and have to write jquery to printing each type of invoice on new page which seems to be difficult.

Thanks, Rohit

Hi @uma13,

I have the same issue. Current we use tally and it allows us to print the original, duplicate and triplicate in one go. Have you been able to create a custom print format to achieve this?

Thanks/Sesha.

Hi @spalakodety,

For this particular issue, I just copied over the code 3 times in the print format, with a page break in between. And, I just changed it to Duplicate for Transporter and Triplicate for Assessee in that particular place.

A very simple and basic solution. And, even though, it adds repetitive code, the invoice prints perfectly… :slight_smile:

6 Likes

@UmaG

can you share sample? i have same requirement.

Hi @UmaG can you please help me or share a sample with me, I have the same issue

Hi @sooraj, @ismailgarig,

I no longer work on ERPNext, so I don’t have access to the sample report. Sorry about that. You can check with @JayRam, if he can assist.

Regards
Uma

Thanks Uma! Will post the code later this week.

Thanks

Jay

@UmaG can you pls share the code ,I have same requirement

@JayRam - Just a gentle reminder to post the code.

Many Thanks

Here you go guys. Maybe there is a more elegant way of doing this, but hey, it does what it’s supposed to do. This is for the Sales Invoice document. Thanks to @UmaG for the code.

                               <div class = "text-center">
			      <font size = "2"><b>INVOICE CUM DELIVERY CHALLAN</b></font><br>
			      <font size = "3"><b>My Company Pvt. Ltd.</b></font>
                               </div>
                               <div class = "text-center">
                                   <font size = "0">My Address 1 </font>
                               </div>
                               <div class = "text-center">
                                <font size = "0">My Address 2 <font>
			   </div>
			   <div class = "text-center">
                                <font size = "0"> CIN: My CIN No </font> <br>
			    <font size = "0"> GSTIN: My GSTIN  PAN Number: My PAN No </font>
			     <br><br>
			    </div>
			
                           </td>
                         <td style=" padding: 0px 0px 0px 0px !important;" colspan=1 width = 200">
                           <div class = "text-right">
                             <font size = "1">(Original for Buyer)</font>
                          </div>  
                         </td>
                      </tr>
                  </tbody>
               </table>
			  <div><font size = "2">Invoice No: </font></div>
		          
		  
                             </td>
                            <td style=" padding: 0px 3px 0px 3px !important; text-align: left;" colspan=1 width = "300">

			  <div><font size = "2"><b>{{ doc.name }}</b></font></div>
                                
                            </td>
			
			<td style=" padding: 0px 3px 0px 3px !important; text-align: left;" colspan=1 width = "200">
			 <div><font size = "2">Date of Invoice: </font></div>
                            </td>

                           <td style=" padding: 0px 3px 0px 3px !important; text-align: left;" colspan=1 width = "200">
							   <div><font size = "2"><b>{{ doc.get_formatted("posting_date") }}</b></font></div>
                            
		      </td>
                        </tr>
                      </tbody>
	</table>
         </div>

                           <td style=" padding: 0px 6px 0px 6px !important;" colspan = 2 width = "400">
			 <div> <font size = "2"><b>Delivery At: </b></font> </div> <br>
			 <div><b><font size = "2"> {{ doc.customer_name }}</font></b> </div>
                              <div> {{ doc.delivery_at }} </font></div>
			</td>		
	 
		</tr>					
		<tr>
		    <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			<br>
			<div><b>State</b> </div>
                              <div><b>GSTIN </b> </div><br>
			
                         </td>
		     <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			<br>
			<div>{{ doc.billto_gst_state }} : {{doc.billto_gst_state_number}}</div>

                            <div>{{ doc.billto_gstin }}</div><br>

                          </td>
		    
                       </tr>
   			<tr>
                      
                           <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			 <div><b>Customer PAN</b> </div>
			</td>
			<td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			  <div>{{ doc.customer_data }}</div>
			</td>
			<td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			 <div><b>Buyer's Order Ref</b></div>
			</td>
			<td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			 <div>{{ doc.buyers_order_ref }}</div>
			</td>

		</tr> 			
					
                    </tbody>
                  </table>
             </div>
Billto Address:

{{ doc.customer_name }}
{{ doc.address_line1 }}
{{ doc.address_line2 }}
{{ doc.city }}, {{ doc.state }} - {{ doc.pincode }}
	<tr>
                    <th><font size = "1">Sr</font></th>
		<th><font size = "1">Description</font></th>
		<th><font size = "1">Tariff/HSN</font></th>
		<th class="text-right"><font size = "1">Qty</font></th>
		<th class="text-right"><font size = "1">Rate</font></th>
		<th class="text-right"><font size = "1">Amount</font></th>
		
                  </font>
	</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, "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: 40%;"><font size = "1">
			{% if row.item_code != row.item_name -%}
			<b>{{ row.item_code}}</b><br>
			   {{ row.item_name }}
			{%- else %}
    			    <b>{{ row.item_code}}</b><br>
			   {{ row.description}}
			{%- endif %}
		</font></td>
		<td style="width: 10%;"><font size = "1">{{ row.gst_hsn_code }}</font></td>
		<td style="width: 15%; text-align: left;"><font size = "1"> {{ row.qty }} {{ row.uom or row.stock_uom }}</font></td>
		<td style="width: 15%; text-align: right;"><font size = "1"> {{ "₹{:,.2f}".format(row.rate) }}</font></td>
		<td style="width: 15%; text-align: right;"><font size = "1">{{
			row.get_formatted("amount", doc) }}</font></td>

	</tr>
	{%- endfor -%}

</tbody>
       	{%- for row in doc.taxes -%}
  	  {%- if not row.included_in_print_rate -%}
	  <tr>
		<td class="text-right" width = "500">
			<b>{{ row.description }}</b>
		</td>
		<td class="text-right" width= "150">
			{{ row.get_formatted("tax_amount", doc) }}
		</td>
	 </tr>
	{%- endif -%}
	{%- endfor -%}
	{%- if doc.discount_amount -%}
	<tr>
		<td class="text-right" width = "500">
			{{ ("Discount") }}
		</td>
		<td class="text-right" width = "150">
			{{ doc.get_formatted("discount_amount") }}
		</td>
	</tr>
	{%- endif -%}
	<tr>
		<td class="text-right" width = "500">
			<b>Grand Total</b>
		</td>
		<td class="text-right" width = "150">
			{{ doc.get_formatted("grand_total") }}
		</td>
	</tr>
                             
            <tr>
		<td class="text-right" width = "1000" colspan="2">
			<b>In Words</b>
                    	{{ doc.in_words }} <br>
                    </td>
             </tr>
Total {{ doc.get_formatted("net_total") }}

{{ doc.terms or "" }}

for My Company Pvt. Ltd.


Authorized Signatory

Subject to Bangalore jurisdiction
                               <div class = "text-center">
			      <font size = "2"><b>INVOICE CUM DELIVERY CHALLAN</b></font><br>
			      <font size = "3"><b>My Company Pvt. Ltd.</b></font>
                               </div>
                               <div class = "text-center">
                                   <font size = "0">My Address1 </font>
                               </div>
                               <div class = "text-center">
                                <font size = "0">My Address2<font>
			   </div>
			   <div class = "text-center">
                                <font size = "0"> CIN: My CIN No </font> <br>
			    <font size = "0"> GSTIN: My GSTIN  PAN Number: My PAN No </font>
			     <br><br>
			    </div>
			
                           </td>
                         <td style=" padding: 0px 0px 0px 0px !important;" colspan=1 width = 200">
                           <div class = "text-right">
                             <font size = "1">(Duplicate for Transporter)</font>
                          </div>  
                         </td>
                      </tr>
                  </tbody>
               </table>
			  <div><font size = "2">Invoice No: </font></div>
		          
		  
                             </td>
                            <td style=" padding: 0px 3px 0px 3px !important; text-align: left;" colspan=1 width = "300">

			  <div><font size = "2"><b>{{ doc.name }}</b></font></div>
                                
                            </td>
			
			<td style=" padding: 0px 3px 0px 3px !important; text-align: left;" colspan=1 width = "200">
			 <div><font size = "2">Date of Invoice: </font></div>
                            </td>

                           <td style=" padding: 0px 3px 0px 3px !important; text-align: left;" colspan=1 width = "200">
							   <div><font size = "2"><b>{{ doc.get_formatted("posting_date") }}</b></font></div>
                            
		      </td>
                        </tr>
                      </tbody>
	</table>
         </div>

                           <td style=" padding: 0px 6px 0px 6px !important;" colspan = 2 width = "400">
			 <div> <font size = "2"><b>Delivery At: </b></font> </div> <br>
			 <div><b><font size = "2"> {{ doc.customer_name }}</font></b> </div>
                              <div> {{ doc.delivery_at }} </font></div>
			</td>		
	 
		</tr>					
		<tr>
		    <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			<br>
			<div><b>State</b> </div>
                              <div><b>GSTIN </b> </div><br>
			
                         </td>
		     <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			<br>
			<div>{{ doc.billto_gst_state }} : {{doc.billto_gst_state_number}}</div>

                            <div>{{ doc.billto_gstin }}</div><br>

                          </td>
		    
                       </tr>
   			<tr>
                      
                           <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			 <div><b>Customer PAN</b> </div>
			</td>
			<td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			  <div>{{ doc.customer_data }}</div>
			</td>
			<td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			 <div><b>Buyer's Order Ref</b></div>
			</td>
			<td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
			 <div>{{ doc.buyers_order_ref }}</div>
			</td>

		</tr> 			
					
                    </tbody>
                  </table>
             </div>
Billto Address:

{{ doc.customer_name }}
{{ doc.address_line1 }}
{{ doc.address_line2 }}
{{ doc.city }}, {{ doc.state }} - {{ doc.pincode }}
	<tr>
                    <th><font size = "1">Sr</font></th>
		<th><font size = "1">Description</font></th>
		<th><font size = "1">Tariff/HSN</font></th>
		<th class="text-right"><font size = "1">Qty</font></th>
		<th class="text-right"><font size = "1">Rate</font></th>
		<th class="text-right"><font size = "1">Amount</font></th>
		
                  </font>
	</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, "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: 40%;"><font size = "1">
			{% if row.item_code != row.item_name -%}
			<b>{{ row.item_code}}</b><br>
			   {{ row.item_name }}
			{%- else %}
    			    <b>{{ row.item_code}}</b><br>
			   {{ row.description}}
			{%- endif %}
		</font></td>
		<td style="width: 10%;"><font size = "1">{{ row.gst_hsn_code }}</font></td>
		<td style="width: 15%; text-align: left;"><font size = "1"> {{ row.qty }} {{ row.uom or row.stock_uom }}</font></td>
		<td style="width: 15%; text-align: right;"><font size = "1"> {{ "₹{:,.2f}".format(row.rate) }}</font></td>
		<td style="width: 15%; text-align: right;"><font size = "1">{{
			row.get_formatted("amount", doc) }}</font></td>

	</tr>
	{%- endfor -%}

</tbody>
       	{%- for row in doc.taxes -%}
  	  {%- if not row.included_in_print_rate -%}
	  <tr>
		<td class="text-right" width = "500">
			<b>{{ row.description }}</b>
		</td>
		<td class="text-right" width= "150">
			{{ row.get_formatted("tax_amount", doc) }}
		</td>
	 </tr>
	{%- endif -%}
	{%- endfor -%}
	{%- if doc.discount_amount -%}
	<tr>
		<td class="text-right" width = "500">
			{{ ("Discount") }}
		</td>
		<td class="text-right" width = "150">
			{{ doc.get_formatted("discount_amount") }}
		</td>
	</tr>
	{%- endif -%}
	<tr>
		<td class="text-right" width = "500">
			<b>Grand Total</b>
		</td>
		<td class="text-right" width = "150">
			{{ doc.get_formatted("grand_total") }}
		</td>
	</tr>
                             
            <tr>
		<td class="text-right" width = "1000" colspan="2">
			<b>In Words</b>
                    	{{ doc.in_words }} <br>
                    </td>
             </tr>
Total {{ doc.get_formatted("net_total") }}

{{ doc.terms or "" }}

for My Company Pvt. Ltd.


Authorized Signatory

Subject to Bangalore jurisdiction
1 Like

i am not using any custom script i did some customization from format builder how can i get the default code?

1 Like