Design Of Full Advance PDF Template using Suitescript PART 2:

PHOTO EMBED

Fri May 27 2022 09:13:55 GMT+0000 (Coordinated Universal Time)

Saved by @mdfaizi

htmlMsg = htmlMsg + "<td border=\"0\" border-bottom=\"none\" width=\"100%\" font-size=\"9\" align=\"left\" style=\"white-space: nowrap\">E-mail: "+ s_vendor_email_address +"</td>";
			htmlMsg = htmlMsg + "</tr>";
			
			htmlMsg = htmlMsg + "<tr>";
		    htmlMsg = htmlMsg + "<td border=\"0\" border-left=\"none\" width=\"30%\" font-size=\"9\" align=\"left\">GST :  "+ s_vendor_gst_no +"</td>";
	     	htmlMsg = htmlMsg + "</tr>";
		    htmlMsg = htmlMsg + "<tr>";
		    htmlMsg = htmlMsg + "<td border=\"0\" border-left=\"none\" border-right=\"none\" border-bottom=\"none\" width=\"30%\" font-size=\"9\" align=\"left\">Contact Name :<br />"+ s_contact_name +"</td>";
	       	htmlMsg = htmlMsg + "</tr>";
			
			htmlMsg = htmlMsg + "</table>";
			htmlMsg = htmlMsg + "</td>";
			
			htmlMsg = htmlMsg + "</tr>";
			htmlMsg = htmlMsg + "</table>";
		
		
		
	        htmlMsg = htmlMsg + "<table border=\"0\" width=\"100%\" align=\"center\" >";
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"30%\" font-size=\"10\">Delivery  Date : "+ d_po_delivery_date +"<br/>Delivery  Terms : "+ i_delivery_terms +"</td>";
  	        htmlMsg = htmlMsg + "<td width=\"5%\"></td>";
  	        
  	        if(i_warranty)
  	        	htmlMsg = htmlMsg + "<td width=\"30%\" font-size=\"10\" align=\"left\" style=\"white-space: nowrap\">Currency : "+ s_po_currency +"<br/>Payment Terms : "+ s_payment_terms +"<br/>Warranty: "+ i_warranty +"</td>";
  	        else
  	            htmlMsg = htmlMsg + "<td width=\"30%\" font-size=\"10\" align=\"left\" style=\"white-space: nowrap\">Currency : "+ s_po_currency +"<br/>Payment Terms : "+ s_payment_terms +"</td>";
  	      
  	        htmlMsg = htmlMsg + "<td width=\"5%\"></td>";
  	     
  	        htmlMsg = htmlMsg + "<td width=\"30%\" font-size=\"10\" align=\"left\">Your quote ref: "+ s_quote_ref +"<br/>Quote date:  "+ d_quote_date +"</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        htmlMsg = htmlMsg + "</table>";
		   
		   
		   
	        if(s_special_instruction)
	        	{
	        	    htmlMsg = htmlMsg + "<table border=\"0\" width=\"100%\" align=\"left\">";
	        	    htmlMsg = htmlMsg + "<tr>";
					if(s_special_instruction.toString().length <= 25)
					{
						 htmlMsg = htmlMsg + "<td font-size=\"10\">Special Instructions - "+ s_special_instruction +"</td>";
					}
					else
					{
						 htmlMsg = htmlMsg + "<td font-size=\"10\">Special Instructions - <br />"+ s_special_instruction +"</td>";
					}
	  	           
	  	            htmlMsg = htmlMsg + "</tr>";
	  	            htmlMsg = htmlMsg + "</table>";
	        	}//end of s_special_instruction
	       
	       
//Hard coded String HTML Details:==	        
	        htmlMsg = htmlMsg + "<table border=\"0\" width=\"100%\" align=\"center\">"; 
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>"; 
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>"; 
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">We are pleased to place order on you for the following goods / services on the terms and conditions herein:</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        htmlMsg = htmlMsg + "</table>";

//Sublist Header HTML Details:==	
	        
	        htmlMsg = htmlMsg + "<table border=\"0\" width=\"100%\" align=\"center\">";   
	        
	        if(f_cgst && f_sgst)
	        {
				 log.debug('f_cgst && f_sgst LABEL');
	        	  htmlMsg = htmlMsg + "<tr>";
	  	          htmlMsg = htmlMsg + "<td width=\"5%\" height=\"30\" font-size=\"10\" border=\"1\" align=\"center\" style=\"white-space: nowrap\"><b>Sl #</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"15%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" ><b>Description</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"5%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>Quantity</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>UoM</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" style=\"white-space: nowrap\"><b>Price per unit</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"5%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" ><b>Basic</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" style=\"white-space: nowrap\"><b>CGST %</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" style=\"white-space: nowrap\"><b>SGST %</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>Tax</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>Total</b></td>";
	              htmlMsg = htmlMsg + "</tr>";
	        	
	        }//end of if(f_cgst && f_sgst)
	        
	        else if (f_igst || f_non_recovery_igst)
	        {
				  log.debug('IGST LABEL');
	        	  htmlMsg = htmlMsg + "<tr>";
	  	          htmlMsg = htmlMsg + "<td width=\"5%\" height=\"30\" font-size=\"10\" border=\"1\" align=\"center\" style=\"white-space: nowrap\"><b>Sl #</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"15%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" ><b>Description</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>Quantity</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>UoM</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" style=\"white-space: nowrap\"><b>Price per unit</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" ><b>Basic</b></td>";
				  
				  if(f_igst)
	                 htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" style=\"white-space: nowrap\"><b>IGST %</b></td>";
	              else
					 htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" style=\"white-space: nowrap\"><b>NonRecovery_IGST %</b></td>";
				   
				  htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>Tax</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>Total</b></td>";
	              htmlMsg = htmlMsg + "</tr>";
	        	
	        }//end of else if (igst)
	        
	        else if (!f_cgst && !f_sgst && !f_igst && !f_non_recovery_igst)
	        {
				  log.debug('NO TAX LABEL');
	        	  htmlMsg = htmlMsg + "<tr>";
	  	          htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" align=\"center\" style=\"white-space: nowrap\"><b>Sl #</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"20%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" ><b>Description</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>Quantity</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>UoM</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" style=\"white-space: nowrap\"><b>Price per unit</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\" ><b>Basic</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>Tax</b></td>";
	              htmlMsg = htmlMsg + "<td width=\"10%\" height=\"30\" font-size=\"10\" border=\"1\" border-left=\"none\" align=\"center\"><b>Total</b></td>";
	              htmlMsg = htmlMsg + "</tr>";
	        	
	        }//end of else if (!f_cgst && !f_sgst && !igst)
	        
//Sublist Header values HTML Details:==	 
           
            var i_cnt, i_cnt_value, i_sgst = 0, i_igst = 0, i_no_tax = 0;
            for (var t_item_value = 0; t_item_value < i_item_cnt; t_item_value++) 
            {
            	i_cnt = parseInt(t_item_value)+ parseInt(1);
            	
            	var s_item_description = obj_purchase_order.getSublistValue({ sublistId: 'item', fieldId: 'description', line: t_item_value });
            	s_item_description = xmlrec.escape({ xmlText : s_item_description });
            	var a_item_description = new Array();
				if(s_item_description)
					a_item_description = s_item_description.toString().split(" ");
            	var d_item_start_date = obj_purchase_order.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ind_start_date', line: t_item_value });  //
            	
   				if(d_item_start_date)
   				{
	   				var d_item_start_date_mon = d_item_start_date.getMonth() + 1;
	   				var d_item_start_Date = d_item_start_date.getDate();
	   				var d_item_start_date_year = d_item_start_date.getFullYear();
	   				
	   				if(d_item_start_Date < 10)
	   					d_item_start_Date = '0' + d_item_start_Date;
	   					
	   				if(d_item_start_date_mon < 10)
	   					d_item_start_date_mon = '0' + d_item_start_date_mon;
	   					
	   				d_item_start_date = d_item_start_date_mon + '/' + d_item_start_Date + '/' + d_item_start_date_year;
	   				
	   			}//end of if(d_item_start_date)
   			
   				var d_item_end_date = obj_purchase_order.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ind_end_date', line: t_item_value });
   				
   				if(d_item_end_date)
   				{
	   				var d_item_end_date_mon = d_item_end_date.getMonth() + 1;
	   				var d_item_end_Date = d_item_end_date.getDate();
	   				var d_item_end_date_year = d_item_end_date.getFullYear();
	   				
	   				if(d_item_end_Date < 10)
	   					d_item_end_Date = '0' + d_item_end_Date;
	   					
	   				if(d_item_end_date_mon < 10)
	   					d_item_end_date_mon = '0' + d_item_end_date_mon;
	   					
	   				d_item_end_date = d_item_end_date_mon + '/' + d_item_end_Date + '/' + d_item_end_date_year;
	   				
	   			}//end of if(d_item_end_date)
   				
   				var i_item_quantity = obj_purchase_order.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: t_item_value });
            	var i_item_uom = obj_purchase_order.getSublistText({ sublistId: 'item', fieldId: 'units', line: t_item_value });
            	if(!i_item_uom)
            		i_item_uom = '';
            	
            	var f_item_rate = obj_purchase_order.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: t_item_value });
            	var f_item_basic = obj_purchase_order.getSublistValue({ sublistId: 'item', fieldId: 'amount', line: t_item_value });
            	var f_item_tax_amt = obj_purchase_order.getSublistValue({ sublistId: 'item', fieldId: 'taxamount', line: t_item_value });
            	var f_item_total = obj_purchase_order.getSublistValue({ sublistId: 'item', fieldId: 'grossamt', line: t_item_value });
            	var i_item_tax_ref_no = obj_purchase_order.getSublistValue({ sublistId: 'item', fieldId: 'taxdetailsreference', line: t_item_value });
            	log.debug('i_item_tax_ref_no', i_item_tax_ref_no);
            	
				var i_item_line_no = obj_purchase_order.findSublistLineWithValue({ sublistId: 'taxdetails', fieldId: 'taxdetailsreference',value: i_item_tax_ref_no });
				log.debug('i_item_line_no:==****',i_item_line_no);
				
				var f_tax_rate;
				if(i_item_line_no>=0)
				{
					f_tax_rate = obj_purchase_order.getSublistValue({sublistId: 'taxdetails',fieldId: 'taxrate',line: i_item_line_no });
					
					log.debug('f_tax_rate:==****',f_tax_rate);
		
				}
            	
				if(!f_item_tax_amt)
				{
					f_item_tax_amt = 0;
				}
					
            	f_item_basic_total += f_item_basic; 
            	f_item_tax_amt_total += f_item_tax_amt;
            	f_item_total_value += f_item_total;
				
            	log.debug({ title: 'Debug Entry',details: 's_item_description:==&nbsp;' + s_item_description + 'i_item_quantity:==&nbsp;' + i_item_quantity
				         + '&nbsp;f_item_rate:==&nbsp;' + f_item_rate + '&nbsp;f_item_basic:==&nbsp;' + f_item_basic
				         + '&nbsp;f_item_tax_amt:==&nbsp;' + f_item_tax_amt + '&nbsp;f_item_total:==&nbsp;' + f_item_total
				         + '&nbsp;f_item_basic_total:==&nbsp;' + f_item_basic_total + '&nbsp;f_item_tax_amt_total:==&nbsp;' + f_item_tax_amt_total
				         + '&nbsp;f_item_total_value:==&nbsp;' + f_item_total_value});
			
            	if(!f_item_basic)
            		f_item_basic = ' ';
            
            	if(!i_item_quantity)
            		i_item_quantity = ' ';
            	
            	if(!d_item_start_date)
   					d_item_start_date = ' ';
   				
   				if(!d_item_end_date)
   					d_item_end_date = ' ';
            	
            	if(!s_item_description)
            		s_item_description = ' ';
            	
            	if(!f_item_rate)
            		f_item_rate = ' ';
            	
            	var s_New_Item_Description = '';
				
			    log.debug({ title: 'Debug a_item_description',details: a_item_description});
				log.debug({ title: 'Debug a_item_description.',details: a_item_description.length});
			
				for(var i=0;i<a_item_description.length;i++)
				{
					log.debug({ title: 'Debug a_item_description[i]',details: a_item_description[i] + 'i=='+i});
					if((i+1)%6==0)
					{
						log.debug({ title: 'If=='+i});
						s_New_Item_Description+="<br />";
					}
					else
					{
						s_New_Item_Description += a_item_description[i];
					}

				}
			
				log.debug({ title: 'Debug s_New_Item_Description',details: s_New_Item_Description});
            	if(f_cgst && f_sgst)
            	{
            	 	log.debug('CGST');
            	 	
            	 	i_sgst = 1;
            	 	 
            		htmlMsg = htmlMsg + "<tr>";
               	    htmlMsg = htmlMsg + "<td width=\"5%\" font-size=\"9\" border=\"1\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ i_cnt +"</td>";
                    htmlMsg = htmlMsg + "<td width=\"25%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"left\" wrap=\"hard\">"+ s_item_description +"</td>";
                    htmlMsg = htmlMsg + "<td width=\"5%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ i_item_quantity  +"</td>";
                    htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ i_item_uom +"</td>";
                    htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ parseFloat(f_item_rate).toFixed(2) +"</td>";
                  	htmlMsg = htmlMsg + "<td width=\"5%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" >"+ parseFloat(f_item_basic).toFixed(2) +"</td>";
					
					if(i_item_line_no>=0)
					{
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ f_tax_rate +"</td>";
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ f_tax_rate +"</td>";
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_item_tax_amt).toFixed(2) +"</td>";
					}
					else
					{	
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\"></td>";
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\"></td>";
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\"></td>";
					}
					htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_item_total).toFixed(2) +"</td>";
               	    htmlMsg = htmlMsg + "</tr>";
            		
            	}//end of if(f_cgst && f_sgst && i_item_tax_ref_no_value >= 0)
            	
            	else if (f_igst || f_non_recovery_igst)
            	{
					log.debug('IGST');
            		 
            		 i_igst = 1;
            		 
            		 htmlMsg = htmlMsg + "<tr>";
                	 htmlMsg = htmlMsg + "<td width=\"5%\" font-size=\"9\" border=\"1\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ i_cnt +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"25%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"left\" wrap=\"hard\">"+ s_item_description +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"5%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ i_item_quantity  +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ i_item_uom +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ parseFloat(f_item_rate).toFixed(2) +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" >"+ parseFloat(f_item_basic).toFixed(2) +"</td>";
					  
					if(i_item_line_no>=0)	
					{
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ f_tax_rate +"</td>";	 
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_item_tax_amt).toFixed(2) +"</td>";
					}
					else
					{
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\"></td>";	 
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\"></td>";
					}
					 htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_item_total).toFixed(2) +"</td>";
                	 htmlMsg = htmlMsg + "</tr>";
                	 
            	}//end of else if (f_igst && i_item_tax_ref_no_value >= 0)
            	
            	else if (!f_cgst && !f_sgst && !f_igst && !f_non_recovery_igst)
            	{
            		     log.debug('NO TAX');
            		 
            		     i_no_tax = 1;
				
						 htmlMsg = htmlMsg + "<tr>";
						 htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ i_cnt +"</td>";
						 htmlMsg = htmlMsg + "<td width=\"25%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"left\" wrap=\"hard\">"+ s_item_description +"</td>";
						 htmlMsg = htmlMsg + "<td width=\"5%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ i_item_quantity  +"</td>";
						 htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ i_item_uom +"</td>";
						 htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ parseFloat(f_item_rate).toFixed(2) +"</td>";
						 htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" >"+ parseFloat(f_item_basic).toFixed(2) +"</td>";
						 htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_item_tax_amt).toFixed(2) +"</td>";
						 htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_item_total).toFixed(2) +"</td>";
						 htmlMsg = htmlMsg + "</tr>";
					
            	}//end of else if (!f_cgst && !sgst && !f_igst && i_item_tax_ref_no_value < 0)
            	
            }//end of for (var t_item_value = 0; t_item_value < i_item_cnt; t_item_value++) 
            
            for (var t_expense_value = 0; t_expense_value < i_expense_cnt; t_expense_value++) 
            {
            	var s_expense_description = obj_purchase_order.getSublistValue({ sublistId: 'expense', fieldId: 'memo', line: t_expense_value  });
            	s_expense_description =  xmlrec.escape({ xmlText : s_expense_description });
            
            	var d_expense_start_date = obj_purchase_order.getSublistValue({ sublistId: 'expense', fieldId: 'custcol_ind_start_date', line: t_expense_value });
            	
            	if(d_expense_start_date)
   				{
	   				var d_expense_start_date_mon = d_expense_start_date.getMonth() + 1;
	   				var d_expense_start_Date = d_expense_start_date.getDate();
	   				var d_expense_start_date_year = d_expense_start_date.getFullYear();
	   				
	   				if(d_expense_start_Date < 10)
	   					d_expense_start_Date = '0' + d_expense_start_Date;
	   					
	   				if(d_expense_start_date_mon < 10)
	   					d_expense_start_date_mon = '0' + d_expense_start_date_mon;
	   					
	   				d_expense_start_date = d_expense_start_date_mon + '/' + d_expense_start_Date + '/' + d_expense_start_date_year;
	   				
	   			}//end of if(d_expense_end_date)
   			
   				var d_expense_end_date = obj_purchase_order.getSublistValue({ sublistId: 'expense', fieldId: 'custcol_ind_end_date', line: t_expense_value });
   					
   				if(d_expense_end_date)
   				{
	   				var d_expense_end_date_mon = d_expense_end_date.getMonth() + 1;
	   				var d_expense_end_Date = d_expense_end_date.getDate();
	   				var d_expense_end_date_year = d_expense_end_date.getFullYear();
	   				
	   				if(d_expense_end_Date < 10)
	   					d_expense_end_Date = '0' + d_expense_end_Date;
	   					
	   				if(d_expense_end_date_mon < 10)
	   					d_expense_end_date_mon = '0' + d_expense_end_date_mon;
	   					
	   				d_expense_end_date = d_expense_end_date_mon + '/' + d_expense_end_Date + '/' + d_expense_end_date_year;
	   				
	   			}//end of if(d_expense_end_date)
   				
   				var i_expense_quantity = obj_purchase_order.getSublistValue({ sublistId: 'expense', fieldId: 'custcol_ind_quantity', line: t_expense_value });
   				var i_expense_uom = '';
   				var f_expense_rate = obj_purchase_order.getSublistValue({ sublistId: 'expense', fieldId: 'custcol_ind_rate', line: t_expense_value });
   				var f_expense_basic = obj_purchase_order.getSublistValue({ sublistId: 'expense', fieldId: 'amount', line: t_expense_value });
   				var f_expense_tax_amt = obj_purchase_order.getSublistValue({ sublistId: 'expense', fieldId: 'taxamount', line: t_expense_value });
   				var f_expense_total = obj_purchase_order.getSublistValue({ sublistId: 'expense', fieldId: 'grossamt', line: t_expense_value });
   				var i_expense_tax_ref_no = obj_purchase_order.getSublistValue({ sublistId: 'expense', fieldId: 'taxdetailsreference', line: t_expense_value });
            	log.debug('i_expense_tax_ref_no', i_expense_tax_ref_no);
            	
				var i_expense_line_no = obj_purchase_order.findSublistLineWithValue({ sublistId: 'taxdetails', fieldId: 'taxdetailsreference',value: i_expense_tax_ref_no });
				log.debug('i_expense_line_no:==****',i_expense_line_no);
				
				var f_expense_tax_rate;
				if(i_expense_line_no>=0)
				{
					f_expense_tax_rate = obj_purchase_order.getSublistValue({sublistId: 'taxdetails',fieldId: 'taxrate',line: i_expense_line_no });
					
					log.debug('f_expense_tax_rate:==****',f_expense_tax_rate);
		
				}
				
				if(!f_expense_tax_amt)
				{
					f_expense_tax_amt = 0;
				}
				
            	f_expense_basic_total += f_expense_basic; 
            	f_expense_tax_amt_total += f_expense_tax_amt;
            	f_expense_total_value += f_expense_total;
            	
            	log.debug({ title: 'Debug Entry',details: 's_expense_description:==&nbsp;' + s_expense_description + 'i_expense_quantity:==&nbsp;' + i_expense_quantity
		                  + '&nbsp;f_expense_rate:==&nbsp;' + f_expense_rate + '&nbsp;f_expense_basic:==&nbsp;' + f_expense_basic
		                  + '&nbsp;f_expense_tax_amt:==&nbsp;' + f_expense_tax_amt + '&nbsp;f_expense_total:==&nbsp;' + f_expense_total
		                  + '&nbsp;f_expense_basic_total:==&nbsp;' + f_expense_basic_total + '&nbsp;f_expense_tax_amt_total:==&nbsp;' + f_expense_tax_amt_total 
		                  + '&nbsp;f_expense_total_value:==&nbsp;' + f_expense_total_value });
            	
            	if(!f_expense_basic)
            		f_expense_basic = ' ';
            	
   				if(!d_expense_start_date)
   					d_expense_start_date = '';
   				
   				if(!d_expense_end_date)
   					d_expense_end_date = '';
   				
   				if(!s_expense_description)
   					s_expense_description = ' ';
   			
            	
            	htmlMsg = htmlMsg + "<tr>";
              	
	       	   	if (i_cnt != null) 
       	   		{
	           	    htmlMsg = htmlMsg + "<td width=\"2%\"  border=\"1\" border-bottom=\"none\" border-top=\"none\" font-size=\"9\" align=\"center\">"+ (++i_cnt) +"</td>"; 
       	   		}
	       	   	else
	       	   	{
	       	   		i_cnt = parseInt(t_expense_value) + parseInt(1);
	       	   		
	           	    htmlMsg = htmlMsg + "<td width=\"2%\"  border=\"1\" border-bottom=\"none\" border-top=\"none\" font-size=\"9\" align=\"center\">"+ i_cnt +"</td>"; 
	           	    
		       	}
	       	   	
	       		if(f_cgst && f_sgst)
            	{
            	 	log.debug('EXPENSE CGST');
            	 	
            	 	htmlMsg = htmlMsg + "<td width=\"15%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"left\" wrap=\"hard\">"+ s_expense_description +"</td>";
                    htmlMsg = htmlMsg + "<td width=\"5%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ i_expense_quantity  +"</td>";
                    htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ i_expense_uom +"</td>";
                    htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ parseFloat(f_expense_rate).toFixed(2) +"</td>";
                    htmlMsg = htmlMsg + "<td width=\"5%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" >"+ parseFloat(f_expense_basic).toFixed(2) +"</td>";
                 
				 	if(i_expense_line_no>=0)
					{
                    	htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ f_expense_tax_rate +"</td>";
                       	htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ f_expense_tax_rate +"</td>";
                        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_expense_tax_amt).toFixed(2) +"</td>";
					}
					else
					{
						htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\"></td>";
                       	htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\"></td>";
                        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\"></td>";
					}
					
                    htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_expense_total).toFixed(2) +"</td>";
               	    
            	}//end of if(f_cgst && f_sgst && i_item_tax_ref_no_value >= 0)
            	
            	else if (f_igst || f_non_recovery_igst)
            	{
            		 log.debug('EXPENSE IGST');
            		 
            		 htmlMsg = htmlMsg + "<td width=\"15%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"left\" wrap=\"hard\">"+ s_expense_description +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"5%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ i_expense_quantity  +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ i_expense_uom +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ parseFloat(f_expense_rate).toFixed(2) +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" >"+ parseFloat(f_expense_basic).toFixed(2) +"</td>";
                   
				   if(i_expense_line_no>=0)
				   {
                    	 htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ f_expense_tax_rate +"</td>";
                         htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_expense_tax_amt).toFixed(2) +"</td>";
				   }
				   else
				   {
					    htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\"></td>";
                        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\"></td>";
				   }
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_expense_total).toFixed(2) +"</td>";
                	
            	}//end of else if (f_igst && i_item_tax_ref_no_value >= 0)
            	
		      else if ( !f_cgst && !f_sgst && !f_igst && !f_non_recovery_igst)
            	{
            		 log.debug('EXPENSE NO TAX');
            		
                     htmlMsg = htmlMsg + "<td width=\"20%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"left\" wrap=\"hard\">"+ s_expense_description +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"5%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ i_expense_quantity  +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ i_expense_uom +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" style=\"white-space: nowrap\">"+ parseFloat(f_expense_rate).toFixed(2) +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\" >"+ parseFloat(f_expense_basic).toFixed(2) +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_expense_tax_amt).toFixed(2) +"</td>";
                     htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"9\" border=\"1\" border-left=\"none\" border-bottom=\"none\" border-top=\"none\" align=\"center\">"+ parseFloat(f_expense_total).toFixed(2) +"</td>";
                	
            	}//end of else if (!f_cgst && !sgst && !f_igst && i_item_tax_ref_no_value < 0)
            	
	       	 htmlMsg = htmlMsg + "</tr>";
	       	 
            }//end of for (var t_expense_value = 0; t_expense_value < i_expense_cnt; t_expense_value++) 
            
            var f_total_basic = parseFloat(f_expense_basic_total) + parseFloat(f_item_basic_total);
            f_total_basic = parseFloat(f_total_basic).toFixed(2);
			 
			var f_total_tax_amt = parseFloat(f_expense_tax_amt_total) + parseFloat(f_item_tax_amt_total);
			 f_total_tax_amt = parseFloat(f_total_tax_amt).toFixed(2);
			 
            var f_total_amt = parseFloat(f_expense_total_value) + parseFloat(f_item_total_value);
            f_total_amt = parseFloat(f_total_amt).toFixed(2);
			
             if(f_cgst && f_sgst)
             {
            	 log.debug('TOTAL CGST');
           
	             htmlMsg = htmlMsg + "<tr>";
	       	     htmlMsg = htmlMsg + "<td width=\"5%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"left\"></td>";
	             htmlMsg = htmlMsg + "<td width=\"15%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"left\"></td>";
	             htmlMsg = htmlMsg + "<td width=\"5%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\"></td>";
	             htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\"></td>";
	             htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\" style=\"white-space: nowrap\">Total</td>";
	             htmlMsg = htmlMsg + "<td width=\"5%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\">"+ f_total_basic +"</td>";
	             htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\"></td>";
	             htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\" style=\"white-space: nowrap\"><b>Grand Total</b></td>";
	             htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\">"+ f_total_tax_amt +"</td>";
	             htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\">"+ f_total_amt +"</td>";
	       	     htmlMsg = htmlMsg + "</tr>";
	       	     
             }//end of if(f_cgst && f_sgst)
             
             else if(f_igst || f_non_recovery_igst)
             {
            	 log.debug('TOTAL IGST');
            	 
            	 htmlMsg = htmlMsg + "<tr>";
         	     htmlMsg = htmlMsg + "<td width=\"5%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"left\"></td>";
         	     htmlMsg = htmlMsg + "<td width=\"15%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"left\"></td>";
     	         htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\"></td>";
     	         htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\"></td>";
     	         htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\" style=\"white-space: nowrap\">Total</td>";
     	         htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\">"+ f_total_basic +"</td>";
     	         htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\" style=\"white-space: nowrap\"><b>Grand Total</b></td>";
     	         htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\">"+ f_total_tax_amt +"</td>";
     	         htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\">"+ f_total_amt +"</td>";
     	    	 htmlMsg = htmlMsg + "</tr>"; 
     	    	 
             }//end of else if(f_igst)
       	    
             else if (!f_cgst && !f_sgst && ! f_igst && !f_non_recovery_igst)
             {
            	  log.debug('TOTAL NO TAX');
            	 
            	   htmlMsg = htmlMsg + "<tr>";
             	   htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"left\"></td>";
                   htmlMsg = htmlMsg + "<td width=\"20%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"left\"></td>";
                   htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\"></td>";
                   htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\" style=\"white-space: nowrap\">Total</td>";
                   htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\">"+ f_total_basic +"</td>";
                   htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\" style=\"white-space: nowrap\"><b>Grand Total</b></td>";
                   htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\">"+ f_total_tax_amt +"</td>";
                   htmlMsg = htmlMsg + "<td width=\"10%\" border=\"1\" border-right=\"none\" border-left=\"none\" border-bottom=\"none\" font-size=\"10\" align=\"center\">"+ f_total_amt +"</td>";
             	   htmlMsg = htmlMsg + "</tr>";
            	 
             }//end of else if (!f_cgst || !f_sgst || ! f_igst)
       	   
    	    
	        htmlMsg = htmlMsg + "</table>";

//Total HTML Details:==	
	        var d_Start_Date_Body_Level = obj_purchase_order.getValue({ fieldId: 'custbody_ind_start_date_c' });
			
			if(d_Start_Date_Body_Level)
				{ 
				    var d_start_date_month = d_Start_Date_Body_Level.getMonth() + 1;
					var d_start_date_Date = d_Start_Date_Body_Level.getDate();
					var d_start_date_Year = d_Start_Date_Body_Level.getFullYear();
					
					if(d_start_date_Date < 10)
						d_start_date_Date = '0' + d_start_date_Date;
						
					if(d_start_date_month < 10)
						d_start_date_month = '0' + d_start_date_month;
						
					d_Start_Date_Body_Level = d_start_date_month + '/' + d_start_date_Date + '/' + d_start_date_Year;
					d_Start_Date_Body_Level = xmlrec.escape({ xmlText : d_Start_Date_Body_Level });
				}
			
			var d_End_Date_Body_Level = obj_purchase_order.getValue({ fieldId: 'custbody_ind_end_date_c' });
			
			if(d_End_Date_Body_Level)
				{ 
				    var d_end_date_month = d_End_Date_Body_Level.getMonth() + 1;
					var d_end_date_Date = d_End_Date_Body_Level.getDate();
					var d_end_date_Year = d_End_Date_Body_Level.getFullYear();
					
					if(d_end_date_Date < 10)
						d_end_date_Date = '0' + d_end_date_Date;
						
					if(d_end_date_month < 10)
						d_end_date_month = '0' + d_end_date_month;
						
					d_End_Date_Body_Level = d_end_date_month + '/' + d_end_date_Date + '/' + d_end_date_Year;
					d_End_Date_Body_Level = xmlrec.escape({ xmlText : d_End_Date_Body_Level });
				}
			if(d_Start_Date_Body_Level && d_End_Date_Body_Level)
			{
				htmlMsg = htmlMsg + "<table width=\"100%\">";
				htmlMsg = htmlMsg + "<tr>";
							htmlMsg = htmlMsg + "<td  width=\"20%\" font-size=\"10\">Start  Date : "+ d_Start_Date_Body_Level +"</td>";
							//htmlMsg = htmlMsg + "<td width=\"5%\"></td>";
							 htmlMsg = htmlMsg + "<td  width=\"70%\" font-size=\"10\" align=\"left\">End Date : "+ d_End_Date_Body_Level +"</td>";
						   // htmlMsg = htmlMsg + "<td width=\"5%\"></td>";
							htmlMsg = htmlMsg + "</tr>";
							htmlMsg = htmlMsg + "</table>";
							
			}
			
	       htmlMsg = htmlMsg + "<table border=\"0\" width=\"100%\" align=\"center\">";
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"20%\"></td>";
	        htmlMsg = htmlMsg + "<td width=\"80%\"></td>";
	        htmlMsg = htmlMsg + "</tr>"; 
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"20%\" font-size=\"10\" align=\"left\" style=\"white-space: nowrap\"><b>Total Amount (in words)&nbsp;</b></td>";
	        htmlMsg = htmlMsg + "<td width=\"80%\" font-size=\"10\" align=\"left\">"+ s_amount_of_words +"</td>";
	        htmlMsg = htmlMsg + "</tr>";  
	        htmlMsg = htmlMsg + "</table>";
	        
	        htmlMsg = htmlMsg + "<table border=\"0\" width=\"100%\" align=\"center\">"; 
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"100%\" font-size=\"10\" align=\"center\">This Purchase order is system generated and does not require any signature</td>";
	        htmlMsg = htmlMsg + "</tr>"; 
	        htmlMsg = htmlMsg + "</table>";
		       
//Hard coded Strings HTML Details:==		
	        
	        htmlMsg = htmlMsg + "<table>";
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>"; 
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>"; 
	        htmlMsg = htmlMsg + "</table>";
	        
	        htmlMsg = htmlMsg + "<table border=\"1\" border-bottom=\"none\"  border-left=\"none\"  border-right=\"none\"  width=\"100%\" align=\"center\">";
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\"></td>";
	        htmlMsg = htmlMsg + "<td width=\"90%\" font-size=\"10\" align=\"center\"><b>General  Terms and Conditions</b></td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>"; 
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>"; 
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">1</td>";
	        htmlMsg = htmlMsg + "<td width=\"90%\" font-size=\"10\" align=\"left\">Invoices should mention the Purchase Order number</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">2</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">Supply of goods / services shall be  complete only upon acceptance by Company post which invoice has to be raised</td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">3</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">Proof / Sample needs to be approved by Company prior to final printing</td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">4</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">Unless otherwise specified, all delivery of goods / services will be on DAP (Delivered at Place) - at Ship To address</td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">5</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">Delay in delivery will entitle  deduct liquidated damages @ 0.5% for every week of delay or part thereof subject to a maximum of 5%.  In addition, Company may cancel the Purchase Order, at its sole option and place the Order on alternate vendor  and debit the differential cost to the vendor and initiate sue the vendor for damages and reserve its rights to proceed against the vendor, nothing herein prevents the Company from pursuing any other action against the vendor, together, in combination or in addition any of these actions</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">6</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">Transfer of ownership / risk from Vendor to Company will happen only upon acceptance by Company at Ship To address</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">7</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">Vendor shall warrant that no supply of goods / services infringe upon any Trademark or Intellectual Property rights and hereby agrees to indemnify the Company for any claim on the Company by third party</td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">8</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">Rejections at a date later than the delivery date shall be replaced free of cost at the Company's option and all costs including freight - inward and outward, incidenal charges shall be borne by vendor</td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">9</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">Unless PO is amended, no part or excess delivery will be accepted</td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">10</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">The company will not be in any way liable for non-performance either in whole or in part in any contract or for in any delay in performance thereof as a result of Force Majeure</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">11</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">Warranty, where applicable, replacement should be within 24 hours</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        var s_12_default_string = '"UNREGISTERED DEALER - TAX NOT APPLICABLE” has to be mentioned on your tax invoice.  Invoices not conforming to the above will not be accepted for payment.  Once tax invoice is submitted and paid, no claims on account of GST / any tax due to change in rates or failure to charge tax or charged at a lower rate or whatsoever reason will be payable by the Company.';
	        s_12_default_string =  xmlrec.escape({ xmlText : s_12_default_string });
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">12</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">All disputes arising herefrom shall be subject to Bengaluru jurisdiction only</td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\"></td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">Invoices to conform to all applicable regulations.  Invoice must contain the GSTIN of vendor and the relevant Company Unit as mentioned in the PO.  If you are unregistered,  </td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\"></td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\">"+ s_12_default_string + "</td>";
	        htmlMsg = htmlMsg + "</tr>";

//If subsidiary is SEZ
	    if(i_Subsidiary == '37')
	    {
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">13</td>";
	        htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\"><b>SEZ related requirements</b></td>";
	        htmlMsg = htmlMsg + "</tr>";
	        htmlMsg = htmlMsg + "</table>";
	     
	        htmlMsg = htmlMsg + "<table border=\"0\"  width=\"100%\" align=\"center\">"; 
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.</td>";
	        htmlMsg = htmlMsg + "<td width=\"90%\" font-size=\"10\" align=\"left\"> As per applicable regulations, Tax on supply to SEZ unit is zero rated.</td>";
	        htmlMsg = htmlMsg + "</tr>";
	   
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b.</td>";
	        htmlMsg = htmlMsg + "<td width=\"90%\" font-size=\"10\" align=\"left\">Supply to SEZ unit is treated as supply in the course of Interstate trade or commerce.</td>";
	        htmlMsg = htmlMsg + "</tr>";
	    
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.</td>";
	        htmlMsg = htmlMsg + "<td width=\"90%\" font-size=\"10\" align=\"left\">Vendor has to adhere to all applicable documentation / approval process of the SEZ authority in relation to Supply, including obtaining seal and signature of the authority before delivery of goods to SEZ unit within the working timings of the SEZ authority (Monday to Friday only).  Approval to be obtained in advance for supply / activity on weekends.</td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d.</td>";
	        htmlMsg = htmlMsg + "<td width=\"90%\" font-size=\"10\" align=\"left\">Invoices must contain either of the following declaration after filling in the blanks:</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        htmlMsg = htmlMsg + "</table>";
	        
	        htmlMsg = htmlMsg + "<table border=\"0\"  width=\"100%\" align=\"center\">";    
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a)</td>";
	        htmlMsg = htmlMsg + "<td width=\"90%\" font-size=\"10\" align=\"left\">SUPPLY TO SEZ UNIT FOR AUTHORISED OPERATIONS ON PAYMENT OF INTEGRATED TAX</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>";
	     
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\"></td>";
	        htmlMsg = htmlMsg + "<td width=\"90%\" align=\"center\">OR</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>";
	  htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "<td></td>";
	        htmlMsg = htmlMsg + "</tr>";
	       
	        var s_b_default_string = '"SUPPLY TO SEZ UNIT FOR AUTHORISED OPERATIONS UNDER BOND OR LETTER OF UNDERTAKING WITHOUT PAYMENT OF INTEGRATED TAX (BOND / LUT number _________ dated ________ valid till _________")';
	        s_b_default_string =  xmlrec.escape({ xmlText : s_b_default_string });
		      
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"10%\" font-size=\"10\" align=\"left\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b)</td>";
	        htmlMsg = htmlMsg + "<td width=\"90%\" font-size=\"10\" align=\"left\">"+ s_b_default_string +"</td>";
	        htmlMsg = htmlMsg + "</tr>";
	        
       }//end of if(i_Subsidiary == '29') 
		 htmlMsg = htmlMsg + "</table><br />";
	     htmlMsg = htmlMsg + "<table border=\"1\" border-bottom=\"none\"  border-left=\"none\"  border-right=\"none\"  width=\"100%\" align=\"center\">";
	        htmlMsg = htmlMsg + "<tr>";
	        htmlMsg = htmlMsg + "<td width=\"100%\"></td>";
	       
	        htmlMsg = htmlMsg + "</tr></table>";
	        htmlMsg = htmlMsg + "</body>";
	            
  	        log.debug({ title: 'Debug Entry',details: 'htmlMsg:==' + htmlMsg  });
			
			//XML generation with the body level of the PDF
			  var xml = "<?xml version=\"1.0\"?><!DOCTYPE pdf PUBLIC \"-\/\/big.faceless.org\/\/report\" \"report-1.1.dtd\">";
			  xml += "<pdf>";
			  xml += htmlMsg;
			  xml += "</pdf>";
			  
			  var pdfFile = render.xmlToPdf({
			      								xmlString: xml	
			  							  });
			log.debug({ title: 'Debug Entry',details: 'pdfFile:==' + pdfFile  });
			if(parseInt(i_Flag) == parseInt(0))
			{
			  response.writeFile(pdfFile,true);    
			}
	        else
			if(parseInt(i_Flag) == parseInt(1))
			{
			
			pdfFile.name = i_po_tran_no +'-'+ s_vendor_name + '.pdf';
			pdfFile.folder = 1774;

        var id = pdfFile.save();
			var s_JSON_Response = [];
			s_JSON_Response = {'file_object':id};
			 var s_JSON = JSON.stringify(s_JSON_Response);
      
			log.debug({ title: 'Debug Entry',details: 'id:==' + id  });
				response.write(s_JSON);    
			} 
  	           
    	}//end of if ((_logValidation(s_rec_type) == true) && (_logValidation(i_rec_id) == true))
			
	}//end of if (context.request.method == 'GET')
	
}//end of onRequest_PO_PDF_Layout

    return {
        onRequest: onRequest_PO_PDF_Layout
    };
    
});

function _logValidation(value) {
    if (value != null && value != '' && value != undefined && value.toString() != 'NaN' && value != NaN) {
        return true;
    } else {
        return false;
    }
}    
	       
content_copyCOPY