Print Format Debugging Help

Hi All,

I have make the a new Print Format, Please help me to enhance it. below is the code for Quotation and attaching the image

<div class = "letter head">
    <table border =0>
		<tbody>
            <tr>
            	<td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "170">
                	<img src = "/private/files/logo.png" width = "80" height = "100">
                </td>
                <td style=" padding: 40px 6px 0px 6px !important;" colspan=1 width = "650"> 
					<div class = "text-center">
                    <font size = "3"><b>Company Name</b></font>
                    </div>
                    <div class = "text-center">
                    <font size = "1"><b>Company Address</b></font>
                    </div>
                    <div class = "text-center">
                    <font size = "1"><b>Company State</b><font><br><br>
                    </div>
                </td>
                <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "150">
                </td>
                </tr>
        </tbody>
    </table>
</div>

        
<div class="Header">
	<table border =0>
		<tbody>
            <tr>
                <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "160">

	            	<div> <font size = "1">GSTIN </font> </div> 
	                <div><font size = "1">State</font></div>
	                <div><font size = "1"><b>Sales Person</b></font></div>
                                  
                </td>
                <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">

	            	<div > <font size = "1">: 07AAXXXXXXXX2ZB</font> </div> 
	                <div><font size = "1">: Delhi</font></div>
	                <div>: {{ doc.sales_person_name or ''}}</div>
                                 
                </td>
				<td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "160">
                	<div><font size = "1">Quotation No </font></div>
				  	<div><font size = "1">Date of Quotation</font></div>      
				  	<div><font size = "1"><b>Valid Till</b></font></div>
				</td>
                <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
   					<div><font size = "1"><b>: {{ doc.name }}</b></font></div>
				  	<div><font size = "1"><b>: {{ doc.transaction_date }}</b></font></div>
				  	<div><font size = "1"><b>: {{ doc.valid_till }}</b></font></div>
            </tr>
			
        </tbody>
    </table>
</div>

<hr>

<div class="seller-info new-seller-info">
	<table border =0>
		<tbody>
            <tr>
            	<td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "100">
	                <div><font size = "1"><b>Company</b></font></div><br>
	            </td>    
	            <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "200">
                    <div><font size = "1"><b>{{ doc.customer_name }}</b></font></div>
                </td>
            </tr>
            <tr>
	            <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "100">
	                <div><font size = "1"><b>Contact</b></font></div><br>
	            </td>
	            <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "100">
                    <div><font size = "1"><b>{{ doc.contact_display }}</b></font></div>
                </td>

	            <td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "100">
					<div><font size = "1"><b>Mobile No</b></font></div><br>
				</td>
				<td style=" padding: 0px 6px 0px 6px !important;" colspan=1 width = "100">    
                    <div><font size = "1"><b>{{ doc.contact_mobile }}</b></font></div>
                </td>
			</tr>					
			
	    </tbody>
    </table>
</div>
			<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">Quantity</font></th>
			<th class="text-right"><font size = "1">Rate</font></th>
			<th class="text-right"><font size = "1">Amount</font></th>
			<th class="text-right"><font size = "1">CGST Rate</font></th>
			<th class="text-right"><font size = "1">CGST Amount</font></th>
			<th class="text-right"><font size = "1">SGST Rate</font></th>
			<th class="text-right"><font size = "1">SGST Amount</font></th>
			<th class="text-right"><font size = "1">IGST Rate</font></th>
			<th class="text-right"><font size = "1">IGST 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.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: 15%;"><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: 10%; text-align: left;"><font size = "1">{{ row.uom or row.stock_uom }}&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp {{ row.qty }} </font></td>
			<td style="width: 5%; text-align: right;"><font size = "1">{{
				row.get_formatted("rate", doc) }}</font></td>
			<td style="width: 10%; text-align: right;"><font size = "1">{{
				row.get_formatted("amount", doc) }}</font></td>
			
			<td style="width: 4%; text-align: right;"><font size = "1">{{
				it_cgst_rate[0] }}%</font></td>
			<td style="width: 10%; text-align: right;"><font size = "1">{{
				"₹ {:,.2f}".format(cgst_amt[0])  }}</font></td>
			<td style="width: 4%; text-align: right;"><font size = "1">{{
				it_sgst_rate[0] }}%</font></td>
			<td style="width: 10%; text-align: right;"><font size = "1">{{
				"₹ {:,.2f}".format(sgst_amt[0])  }}</font></td>
			<td style="width: 4%; text-align: right;"><font size = "1">{{
				it_igst_rate[0] }}%</font></td>
			<td style="width: 10%; text-align: right;"><font size = "1">{{
				"₹ {:,.2f}".format(igst_amt[0])  }}</font></td>

			
		
</tr>
{%- endfor -%}
<tr>

			<td style="width: 5%;"><font size = "1"></font></td>
			<td style="width: 15%;"><font size = "1"><b>
				Total
			</b></font></td>
			<td style="width: 10%;"><font size = "1"></font></td>
			<td style="width: 10%; text-align: left;"><font size = "1"><b> {{ grand_total["qty"] }} </b></font></td>
			<td style="width: 5%; text-align: right;"><font size = "1"></font></td>
			<td style="width: 10%; text-align: right;"><font size = "1"><b>{{
				"₹ {:,.2f}".format(grand_total["amount"]) }}</b></font></td>
			
			<td style="width: 4%; text-align: right;"><font size = "1"><font></td>
			<td style="width: 10%; text-align: right;"><font size = "1"><b>{{
				"₹ {:,.2f}".format(grand_total["cgst_amt"])  }}</b></font></td>
			<td style="width: 4%; text-align: right;"><font size = "1"></font></td>
			<td style="width: 10%; text-align: right;"><font size = "1"><b>{{
				"₹ {:,.2f}".format(grand_total["sgst_amt"])  }}</b></font></td>
			<td style="width: 4%; text-align: right;"><font size = "1"></font></td>
			<td style="width: 10%; text-align: right;"><font size = "1"><b>{{
				"₹ {:,.2f}".format(grand_total["igst_amt"])  }}</b></font></td>
		
</tr>
</tbody>
</table>

<table class="noborder">
	<tbody>
            	<tr>
                   <td class="text-right" width = "600"><font size = "1">
				<b>{{ ("Total") }}</b>
		    </font></td>
                    <td class="text-right" width= "200"><font size = "1">
				{{ doc.get_formatted("net_total") }}
		    </font></td>
		</tr>
             
              
           	{%- for row in doc.taxes -%}
	  	  {%- if not row.included_in_print_rate -%}
		  <tr>
			<td class="text-right" width = "600"><font size = "1">
				<b>{{ row.description }}</b>
			</font></td>
			<td class="text-right" width= "200"><font size = "1">
				{{ row.get_formatted("tax_amount", doc) }}
			</font></td>
		 </tr>
                
		{%- endif -%}
		{%- endfor -%}
		{%- if doc.discount_amount -%}
		<tr>
			<td class="text-right" width = "600"><font size = "1">
				{{ ("Discount") }}
			</font></td>
			<td class="text-right" width = "200"><font size = "1">
				{{ doc.get_formatted("discount_amount") }}
			</font></td>
		</tr>
		{%- endif -%}
		<tr>
			<td class="text-right" width = "600"><font size = "1">
				<b>{{ ("Grand Total") }}</b>
			</font></td>
			<td class="text-right" width = "200"><font size = "1">
				{{ doc.get_formatted("grand_total") }}
			</font></td>
		</tr>
                <tr>
			<td class="text-right" width = "600"><font size = "1">
				<b>{{ ("Rounded Total") }}</b>
			</font></td>
			<td class="text-right" width = "200"><font size = "1">
				{{ doc.get_formatted("rounded_total") }}
			</font></td>
		</tr>
                  
                <tr>
			<td class="text-right" width = "1000"><font size = "1">
				<b>{{ ("In Words :") }}</b>
                        	{{ doc.in_words }} <br>
                        </font></td>
                 </tr>
		   <tr>
		</tr>
                                


 </tbody>
</table>          

<hr>
<div class = "text-left">
<font size = "2"><b>Tearms & Condition</b></font>
</div>
                    
<p>{{ doc.terms or "" }}</p>

<div class="col-md-9 text-right"><font size = "1">for <b>Company Name</b> </font></div><br><br><br>
       
<div class="col-md-9 text-right"><font size = "1"><b>Authorized Signatory</b></font></div>

1 Like

What do you mean by “enhance”? Please ask specific questions to get help.

you can use

frappe.utils.fmt_money(grand_total["igst_amt"], precision = 2, currency= "INR")

By default, precision = 2.

@Parag_Kapoor Kindly provide me the css code for this above code as I need to design similar kind of quotation

Hi

You can use the default CSS or without the CSS it will work

Hi,

Quote is not properly displaying. Attached is the screenshot.

I just copied your codes to get this. Only the screenshot part is not working properly. Rest is fine.

Change to custom , and print format ,type is server

I have already done the same yesterday itself. But the result is shown in the screenshot

Please share your contact

kp@ekabyte.com

@Parag_Kapoor Please update on above about Quote is not properly displaying.