Add backorder on Packing Slip PDF

Solution

A sample Packing slip PDF having backorder field is given below

<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
<pdf>
<head>
<meta name="title"   value="${record@title} #${record.tranid} for ${record.entityname?replace('\"','')}" />
<meta name="subject" value="${record@title} #${record.tranid} for ${record.entityname?replace('\"','')}" />


<!-- Configuration -->
<#assign TESTING = false />
<#assign REMOVE_DOC_PREFIX = false />
<#assign SHIPPING_COST_LINE = true /> 		<!-- If true then print the shipping cost in the lines section. Otherwise include the shipping cost in the total section -->
<#assign DISPLAY_SOLINE_SHADDING = false /> 	<!-- Shade every 2nd item line -->
<#assign TRANSFER_ORDER_FIX = true /> 		<!-- There is a bug in NetSuite with transfer orders where the ItemFulfillment orderline # is 1 number less than the Sales Order line # -->
<#assign PRICED_PACKINGSLIP = false /> 		<!-- By default the packing slip is not priced --><#if record.custbody_priced_packingslip?has_content><#assign PRICED_PACKINGSLIP = record.custbody_priced_packingslip /></#if>
<#assign PRINT_BACKORDER_LIST = false />

<!-- Note: To reference Sales Order fields in the invoice, use  record.createdfrom.saleseffectivedate -->


<!-- Macros -->
<!-- Print the transaction id. Strip any prefixs from the number if REMOVE_DOC_PREFIX = true -->
<#macro printDocNumber docName>
	<#if REMOVE_DOC_PREFIX>
      	${docName?replace("[^0-9]*","irf")}
    <#else>
       	${docName}
    </#if>
</#macro>

<!-- Print only the first word -->
<#macro printCode value >
  	<#assign newvalue = value />
    <#if newvalue?index_of(":") gt -1> <!-- Remove Parent -->
      <#assign newvalue = newvalue[newvalue?index_of(":")+1..] />
    </#if>
    ${newvalue}
 </#macro>
 
<!-- Print project -->
<#macro printProject value billaddress >
 	 <#if value != billaddress> <!-- If the customer name is not equal to the billaddress then it must be a project -->
         ${value}
     <#else>
         &nbsp;
	 </#if>
</#macro>

<!-- Stylesheets -->
<#if .locale == "ru_RU">
    <link name="verdana" type="font" subtype="opentype" src="${nsfont.verdana}" src-bold="${nsfont.verdana_bold}" bytes="2" />
</#if>
<style type="text/css">
	<#if TESTING>
      table, th, td {
        border: 1px dotted black;
 	 }
  	</#if>
    .TBC {
      font-weight: bold;
      color: red;
    }

      table {
        <#if .locale == "zh_CN">
            font-family: stsong, sans-serif;
        <#elseif .locale == "zh_TW">
            font-family: msung, sans-serif;
        <#elseif .locale == "ja_JP">
            font-family: heiseimin, sans-serif;
        <#elseif .locale == "ko_KR">
            font-family: hygothic, sans-serif;
        <#elseif .locale == "ru_RU">
            font-family: verdana;
        <#else>
        <!--    font-family: sans-serif; -->
          	font-family: sans-serif;
  		</#if>
        	color: black;
            font-size: 9pt;
            table-layout: fixed;

        }

		<!-- Header -->
  		.headerTable {
          	width:				100%;
           	margin-top:			10px;
        }

  		<!-- Company Header -->
  		.companyTable {
          	width:				100%;
        }
  		.companyHeader {
          	font-weight: 		bold;
          	padding-top: 		-20px;
          	padding-bottom:		-20px;
          	padding-left:		-20px;
        }
  		.companyDetail {
          	padding-top: 		0px;
        }
  		.companyAddress {
			padding-top:		10px;
          	color:			#003662;
        }

  		<!-- Document Header -->
		.docTable {
    		width:				100%;
          	margin-top:			20px;
  		}

  		.docType {
          	font-size: 			16pt;
          	font-weight: 		bold;
          	padding-bottom: 	10px;
        }
  		.docNumber {
          	font-size: 			13pt;
          	padding-bottom: 	11px;
        }
    	.docdateHeader, .docdateDetail {
          	padding-top: 		5px;
          	padding-bottom: 	5px;
  			border-top:	 		1px solid #d3d1d1;
  			border-bottom: 		1px solid #d3d1d1;
        }
  		.docdateHeader {
 			border-left: 		1px solid #d3d1d1;
           	background-color:	#d3d1d1;
          	padding-right: 		10px;
        }
  		.docdateDetail {
 			border-right: 		1px solid #d3d1d1;
        }

  		<!-- Document Detail Header -->
  	  	.referenceTable{
    		width:				100%;
  		}
  		.tagLine {
          	padding-top: 5px;
        }
  		.referenceAddress{
          	padding-top: 1px;
          	padding-bottom: 1px;
          	margin-top: 13px;
        }
  		.referenceHeader {
           	font-size: 8pt;
          	font-weight: bold;
          	padding-top: 0px;
        }
  		.referenceDetail {
           	font-size: 8pt;
          	padding-top: 0px;
        }
		.referenceGST, .referencePage {
          	padding-top: 	5px;
        }
		.referencePage {
          padding-right: -20px;
        }
  		.referenceNewSection {
          margin-top: 5px;
        }


  		<!-- Address Details -->
  		.addressTable {
          	width:				100%;
          	margin-top:			20px;
        }
  		.addressBillingTable, .addressShippingTable {
          	width:				100%;
          	margin-left:		20px;
           	margin-top:			-10px;
            height: 			90px;
        }
  		.addressBillingTable {
          	margin-left:		20px;
        }
  		.addressHeader {
          	font-weight: 		bold;
        }
  		.addressDetail {
          	padding-top: 		0px;
		}


  		<!--Details Header -->
  		.detailsTable {
          width: 				60%;
          margin-bottom: 		10px;
          text-align:			left;
        }
  		.detailsHeader, .detailsHeaderEnd {
    	    background-color: 	#d3d1d1;
          	padding-left: 		2px;
        }
  		.detailsHeaderEnd {
         <!-- 	border-right: 		1px solid black; -->
        }
    	.detailsHeaderBottom, .detailsHeaderBottomEnd {
          	border-left: 		1px solid #d3d1d1;
          	border-bottom: 		1px solid #d3d1d1;
          	padding-top: 		2px;
        }
  		.detailsHeaderBottomEnd {
          	border-right: 		1px solid #d3d1d1;
        }


  		<!--Items List -->
  		.itemTable {
          	width: 				100%;
          	height:				500px;
          	page-break-inside:	auto;
        }
  		.itemHeader, .itemHeaderEnd {
    	    background-color:	#d3d1d1;
          	padding:			5px;
        }
    	.itemHeaderEnd {
       <!--   	border-right: 		1px solid black; -->
        }
  		.itemDetail, .itemDetailEnd {
          	border-left: 		1px solid #d3d1d1;
          	padding-top: 		5px;
          	padding-right:		5px;
            padding-bottom:		0px;
          	padding-left:		5px;        	
        }
  		.itemDetailEnd {
          	border-right: 		1px solid #d3d1d1;
        }

  		.rowItem {
          	height: 			17px;
			padding:			0px;
          	page-break-inside:	avoid;
        }
  		.rowItemBottom {
           	border-bottom: 		1px solid #d3d1d1;
        }

  		<!-- Terms and Conditions. Bank Details -->
   		.footerTable {
          	width:				100%;
          	height:				40px;
          	padding:			0px;
        }
  		.bankHeader {
          	font-weight: 		bold;
          	padding-bottom: 	1px;
          	margin-top: 		10px;
        }
    	.bankDetail {
          	font-size: 			8pt;
          	padding-top: 		1px;
          	padding-bottom:		1px;
        }


		<!-- Shipping and Terms -->
  		.termsTable {
          	width: 				100%;
          	padding:			0px;
          	margin-left:		-2px;
          	margin-top:			10px;
        }
   		.termsDetail {
          	font-size: 			8pt;
          	padding-top: 		5px;
          	padding-bottom:		1px;
        }

  		.shipHeader, .shipHeaderEnd {
          	background-color: 	#d3d1d1;
          	padding:			5px;
        }
		.shipDetail, .shipDetailEnd {
          	border-left: 		1px solid #d3d1d1;
          	border-bottom:	 	1px solid #d3d1d1;
            padding:			5px;
        }
  		.shipHeaderEnd, .shipDetailEnd {
          	border-right: 		1px solid #d3d1d1;
        }
    	.shipHeaderBottom, .shipHeaderBottomEnd {
          	border-left: 		1px solid #d3d1d1; <!--#BFC0C0;-->
          	border-bottom: 		1px solid #d3d1d1;
          	padding-top: 		2px;
        }
  		.shipHeaderBottomEnd {
          	border-right: 		1px solid #d3d1d1;
        }



  		<!-- Totals -->
  		.totalTable {
          	width: 				100%;
        }

  		.subtotalHeader, .subtotalDetail, .shiptotalHeader, .shiptotalDetail, .gsttotalHeader, .gsttotalDetail, .totalHeader, .totalDetail {
           	padding-left: 		10px;
          	padding-right: 		10px;
          	padding-top: 		1px;
          	padding-bottom: 	1px;
        }
    	.subtotalHeader, .shiptotalHeader, .gsttotalHeader, .totalHeader {
           	font-weight: 		bold;
          	font-size:			10pt;
        }
  		.totalDate {
            font-size: 10pt;
          	margin-top: 10px;
        }
</style>

<macrolist>
   <!-- Header -->
   <macro id="nlheader">
	  <table class="headerTable">
	  <tr>
		<td width="55%">
			<table class="companyTable" >
			<tr>
				<td colspan="12" class="companyHeader"> <#if companyInformation.logoUrl?length != 0><img src="${companyInformation.logoUrl}" style="float: left; border: 0px;" width="180" height="90"/> </#if></td>
			</tr>
			<tr>
				<td colspan="12" class="companyAddress">${companyInformation.mainaddress_text}</td>
			</tr>
		  </table>
        </td>
		<td width="5%">&nbsp;</td>
		<td width="40%" align="right" valign="top">
			<table class="docTable" >
			<tr>
				<td colspan="15" class="docType" align="right">${record@title}</td>
				<td colspan="9" class="docNumber" align="right"><@printDocNumber record.tranid /></td>
			</tr>
			<tr>
				<td colspan="10" >&nbsp;</td>
				<td colspan="6" class="docdateHeader" align="right">Date</td>
				<td colspan="8" class="docdateDetail" align="right">${record.trandate}</td>
			</tr>
			<tr>
				<td colspan="24" class="tagLine" align="right">Flowco Ltd T/A Waterworks</td>
			</tr>
			<tr>
				<td colspan="24" class="referenceGST" align="right">GST No: ${companyInformation.employerid}</td>
			</tr>
            <tr>
				<td colspan="24" class="referencePage" style="padding-right: -20px;" align="right">Page No: <pagenumber/> of <totalpages/></td>
			</tr>
            </table>
		</td>
        </tr>
	  </table>


     <!-- Address Details -->
	<table class="addressTable">
    <tr>
      	<td colspan="9" class="addressBillingTable">
            <table width="100%">
            <tr>
                  <td class="addressHeader">Bill To:</td>
            </tr>
            <tr>
                  <td class="addressDetail">${salesorder.billaddress}</td>
            </tr>
            </table>
      	</td>
      	<td colspan="1">&nbsp;</td>
    	<td colspan="11" class="addressShippingTable">
            <table width="100%">
              <tr>
                <td class="addressHeader">Ship To:</td>
              </tr>
              <tr>
                <td class="addressDetail">${record.shipaddress}</td>
              </tr>
            </table>
         </td>
    </tr>
	</table>

    <!-- Document Details -->
	<table class="detailsTable" align="right">
    <tr valign="middle">
      	<td colspan="4" class="detailsHeader"			align="center">S.O. No.</td>
      	<td colspan="4" class="detailsHeader"			align="center">P.O. No.</td>
      	<td colspan="4" class="detailsHeader"			align="center">Job Ref.</td>
      	<td colspan="4" class="detailsHeader"			align="center">Account No.</td>
      	<td colspan="4" class="detailsHeaderEnd"		align="center">Terms</td>
    </tr>
	<tr>
    	<td colspan="4" class="detailsHeaderBottom"		align="center">${record.createdfrom?replace("Sales Order #","")}</td>
    	<td colspan="4" class="detailsHeaderBottom"		align="center"><p style="text-align: center;">${salesorder.otherrefnum}</p></td>
    	<td colspan="4" class="detailsHeaderBottom"		align="center">${salesorder.custbody_project}</td>
    	<td colspan="4" class="detailsHeaderBottom"		align="center">${salesorder.custbody_account_no}</td>
    	<td colspan="4" class="detailsHeaderBottomEnd"	align="center">${salesorder.terms}</td>
    </tr>
    </table>
	</macro>


</macrolist>
</head>


<body header="nlheader" header-height="250pt"  padding="5mm 10mm 5mm 10mm" size="A4">

    <table style="width: 100%; margin-top: 10px;"><tr>
	<td class="addressheader" colspan="6"><b>${record.address@label}</b></td>
	<td class="totalboxtop" colspan="5"><b>${record.total@label?upper_case}</b></td>
	</tr>
	<tr>
	<td class="address" colspan="6">${record.address}</td>
	<td align="right" class="totalboxmid" colspan="5">${record.total}</td>
	</tr></table>

<!-- Item Configuration -->
<#assign colDesc 	= 21 />
<#assign classEnd 	= "End" />
<#if PRICED_PACKINGSLIP>
  	<#assign colDesc 	= 21 />
    <#assign classEnd 	= "" />
</#if>

<#assign lineNo = 0 />
<#assign subTotal = 0 />

<!-- Line Header -->
<table class="itemtable" style="width: 100%">
<thead>
  <tr>
      <th colspan="6"  class="itemHeader" 	 			align="center">Stockcode</th>
      <th colspan="${colDesc}" class="itemHeader"	 	align="center">Description</th>
      <th colspan="4"  class="itemHeader"	 			align="center">Qty Ord</th>
      <th colspan="4"  class="itemHeader" 				align="center">Qty B/O</th>
      <th colspan="4"  class="itemHeader${classEnd}"	align="center">Qty Sply</th>
  <#if PRICED_PACKINGSLIP>
      <th colspan="4"  class="itemHeader"	 			align="center">Rate</th>
      <th colspan="5"  class="itemHeaderEnd" 			align="center">Amount</th>
  </#if>
  </tr>
</thead>


<!-- Line Detail Layout -->
<!-- Not currently using the itemRate as this customer also has a discount column. So will calculate the itemRate after discount using the itemAmount -->
<#macro printItemDetail itemSKU, itemDescription, itemQuantity, itemQuantityCommitted, itemQuantityBO, shippedQty, itemRate, itemAmount, lineNo, lineClass,RemainQty,fulfillQty,isClosed>
    <!--https://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places-only-if-necessary-->

	<#assign lineNo = lineNo + 1 />
    <#assign itemTotalAmount = "" />
  	<#if shippedQty?is_number && itemRate?is_number >
      	<#assign itemTotalAmount = shippedQty * itemRate />
   		<#assign subTotal = subTotal + itemTotalAmount/>
   	</#if>

 	<#assign closed='No'/>
  <#if closed==isClosed?string>
  	<#if itemQuantityCommitted?has_content>
      <#if itemQuantityCommitted==0>
  	<#assign itemTotalBO = itemQuantityBO />
        <#else>
   	<#if itemQuantityBO?is_number && itemQuantityCommitted?is_number><#assign itemTotalBO = ((itemQuantityCommitted+fulfillQty+itemQuantityBO)-RemainQty) /></#if></#if><#else><#assign itemTotalBO=0/></#if> <!-- If item is still committed then it hasn't been packed yet -->
        <#if itemTotalBO==0 && shippedQty==0><#assign a=0/><#else>
    <tr class="${lineClass}" <#if DISPLAY_SOLINE_SHADDING>style="background-color: ${((lineNo % 2)==0)?string('#ffffff', '#efefef')};"</#if>>
            <td colspan="6" class="itemDetail" 	 			align="left"  ><@printCode itemSKU /></td>
            <td colspan="${colDesc}" class="itemDetail" 	align="left" >${itemDescription}</td>
            <td colspan="4" class="itemDetail" 	 			align="center">${itemQuantity}</td>
            <td colspan="4" class="itemDetail" 	 			align="center">${itemTotalBO}</td>
            <td colspan="4" class="itemDetail${classEnd}" 	align="center">${shippedQty}</td>
  <#if PRICED_PACKINGSLIP>
        	<#assign itemRateLine = "" /><#if itemRate?is_number><#assign itemRateLine = itemRate?string("#,##0.000") /></#if> <!-- Need to assign the parameter itemRate to another variable as the assignment isn't updating the itemRate format -->
         	<#if itemTotalAmount?is_number><#assign itemTotalAmount = itemTotalAmount?string("#,##0.00") /></#if>
            <td colspan="4" class="itemDetail" 	 			align="right" >${itemRateLine}</td>
            <td colspan="5" class="itemDetailEnd"   		align="right" >${itemTotalAmount}</td>
    </#if>
    </tr></#if></#if>
</#macro>

<!-- Line Details-->
<#if record.item?has_content>

  	<!-- NONE - Print Fulfilled items only -->
    <#if record.showAddlItemsPackSlip == 'NONE'>
        <#list record.item as IFLine> <!-- Item Fulfillment lines -->
			<#assign shippedQty = IFLine.quantity />
            <#list salesorder.item as SOLine>
				<!-- There is a bug in NetSuite with transfer orders where the ItemFulfillment orderline # is 1 number less than the Sales Order line # -->
				<#if (SOLine.line == IFLine.orderline) ||
                     	(record.ordertype== "TrnfrOrd" && TRANSFER_ORDER_FIX && (SOLine.line?number == (IFLine.orderline?number-1))) > <!-- NetSuite standard comparison -->
          			 <@printItemDetail IFLine.item, SOLine.description, SOLine.quantity, SOLine.quantitycommitted, SOLine.quantitybackordered, shippedQty, SOLine.rate, SOLine.Amount, lineNo, "rowItem",SOLine.quantitypickpackship,SOLine.quantityfulfilled,SOLine.isclosed />
				</#if>
            </#list>
        </#list>

    <#else> <!-- ALL or UNFULFILLED -->
        <#list salesorder.item as SOLine>
          
            <#assign shippedQty = 0 />
			<#assign isInList = false /> <!-- Used to track if the item is in the fulfilment list or is unfullfilled i.e. on backorder or still has qty not fulfilled -->
           	<#assign itemSKU = SOLine.item />

          	<#list record.item as IFLine> <!-- Item Fulfillment lines -->
				<#if (SOLine.line == IFLine.orderline) ||
                     (record.ordertype== "TrnfrOrd" && TRANSFER_ORDER_FIX && (SOLine.line?number == (IFLine.orderline?number-1))) >
                    <#assign shippedQty = IFLine.quantity />
                    <#assign isInList = true />
                  	<#assign itemSKU = IFLine.item />
                </#if>
            </#list>

         	<!-- Only include back ordered items in the summary of back ordered items is not printed at the bottom of the packing slip -->
          	<!-- Note: This assumes that an item that is NOT on back order AND was picked and packed will still have a committed value. 
					i.e. from the customers point of view it is still on back order since they haven't received it -->
          	<#if (SOLine.quantitybackordered?is_number && SOLine.quantitybackordered != 0) || (SOLine.quantitycommitted?is_number && SOLine.quantitycommitted != 0)>
              	<#assign isInList = true />  <!-- Include items that are on back order or not packed in the UNFULFILLED list -->
            </#if>
  			<#if record.showAddlItemsPackSlip == 'ALL' || (record.showAddlItemsPackSlip == 'UNFULFILLED' && isInList) >
       		   <@printItemDetail itemSKU, SOLine.description, SOLine.quantity, SOLine.quantitycommitted, SOLine.quantitybackordered, shippedQty, SOLine.rate,  SOLine.Amount, lineNo, "rowItem",SOLine.quantitypickpackship,SOLine.quantityfulfilled,SOLine.isclosed />
            </#if>
        </#list><!-- end sales order items -->
    </#if>
</#if>
    <!-- Print Shipping Cost if printed at line level -->
    <#if PRICED_PACKINGSLIP>
         <#if SHIPPING_COST_LINE && record.shippingcost?has_content && record.shippingcost != 0>
           <@printItemDetail "&nbsp;", record.shippingcost@label, "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", salesorder.shippingcost, lineNo, "rowItem","&nbsp;","&nbsp;","&nbsp;" />
          </#if>
    </#if>


    <!-- Back Order List -->
    <#if PRINT_BACKORDER_LIST>
      <#assign firstLine = true />
      <#list salesorder.item as SOLine>
       
        <#if (SOLine.quantitybackordered?is_number && SOLine.quantitybackordered != 0) || (SOLine.quantitycommitted?is_number && SOLine.quantitycommitted != 0)>
          	<#if firstLine>
           		<@printItemDetail "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", lineNo, "rowItem","&nbsp;","&nbsp;","&nbsp;" />
           		<@printItemDetail "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", lineNo, "rowItem","&nbsp;","&nbsp;","&nbsp;" />
           		<@printItemDetail "&nbsp;", "Back Ordered Items", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", "&nbsp;", lineNo, "rowItemBO","&nbsp;","&nbsp;","&nbsp;" />
              	<#assign firstLine = false />
            </#if>
            <@printItemDetail SOLine.item, SOLine.description, "&nbsp;", SOLine.quantitycommitted, SOLine.quantitybackordered, "&nbsp;", "&nbsp;",  "&nbsp;",lineNo, "rowItem",SOLine.quantitypickpackship,SOLine.quantityfulfilled,SOLine.isclosed />
        </#if>
        </#list>
    </#if>
</table>

<table class="rowItem" border-bottom="1px solid #d3d1d1;" style="width: 100%; height: 100px;">
  		<tr>
           <td colspan="6" class="itemDetail" 	 			align="left">&nbsp;</td>
            <td colspan="${colDesc}" class="itemDetail" 	align="left" style="padding-bottom: 10px;" valign="bottom">${record.custbody_packingslipmsg}</td>
            <td colspan="4" class="itemDetail" 	 			align="center">&nbsp;</td>
            <td colspan="4" class="itemDetail" 	 			align="center">&nbsp;</td>
            <td colspan="4" class="itemDetail${classEnd}" 	align="center">&nbsp;</td>
  <#if PRICED_PACKINGSLIP>
          	<td colspan="4" class="itemDetail" 	 			align="right" >&nbsp;</td>
            <td colspan="5" class="itemDetailEnd"   		align="right">&nbsp;</td>
	</#if>
    </tr>
  </table>

  <!-- Final Section -->

     <!-- Shipping Details section -->
        <table class="termsTable">
        <tr>
            <td colspan="10" class="shipHeader"		align="center">Ship Via</td>
            <td colspan="4" class="shipHeaderEnd"	align="center">Ship Date</td>
        </tr>
        <tr>
            <td colspan="10" class="shipDetail"		align="center">${record.custbody_ship_via}</td>
            <td colspan="4" class="shipDetailEnd"	align="center">${record.trandate}</td>
        </tr>
        <tr>
            <td colspan="24" class="termsDetail">All goods supplied in accordance with Waterworks standard <br />Terms and Conditions of Sale. A copy is available upon request.</td>
        </tr>
        <tr>
            <td colspan="24" class="bankDetail">
          	  Account Queries To: ar@waterworksnz.co.nz.</td>
        </tr>
      </table>

</body>
</pdf>

Leave a comment

Your email address will not be published. Required fields are marked *