PDF Template for Packing slip from Supplier Return Authorization.

Scenario 1:

Printing the Terms on the packing slip PDF wasn’t possible since the purchase order terms is not accessible from the advanced PDF/HTML markup.

Solution:

In the Advance PDF template, not possible to get the terms value directly from Purchase order. We need to create two custom fields ( custbody_jj_po, custbody_jj_terms ) in packing slip for getting terms from purchase order. 

The Purchase order( custbody_jj_po) custom field is source from SRA ->created from(field)

The term (custbody_jj_terms ) custom field is source from Purchase order( custbody_jj_po) custom field -> Terms(terms)

Scenario 2:

Printing the rate on the packing slip PDF wasn’t possible since the supplier return authorization’s rate is not accessible from the advanced PDF/HTML markup. This is because the packing slip is not a record in itself and is just referencing fields from the supplier return authorization.

Solution

It is possible to show custom fields on the packing slip.

  1. Create a script that executes before a sales order is saved.
  2. On the script, loop through the line items and set the custom field to reference the rate value. 
  3. With this, the custom field can now be referenced in the PDF/HTML. 

Below is a sample code for reference.  

var rec      = context.newRecord;
var intCount = rec.getLineCount('item');

for (var x = 0; x < intCount; x++) {
    var rate = rec.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: x  }); 
    rec.setSublistValue({ sublistId: 'item', fieldId: 'custcol1', line: x, value: newRate  }); 
}

Advance PDF Template for Packing slip from SRA

Source Code:

<?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: 				70%;
        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">Supplier SRA</td>
                <td colspan="4" class="detailsHeader"			align="center">Supplier PO</td>
                <td colspan="4" class="detailsHeader"			align="center">Job Ref.</td>
                <td colspan="4" class="detailsHeader"			align="center">Account No.</td>
                <td colspan="6" class="detailsHeaderEnd"		align="center">Terms</td>
            </tr>
            <tr>
                <td colspan="4" class="detailsHeaderBottom"		align="center"><p style="align:left">${salesorder.tranid}</p></td>
                <td colspan="4" class="detailsHeaderBottom"		align="center"><p style="align:left">${salesorder.otherrefnum}</p></td>
                <td colspan="4" class="detailsHeaderBottom"		align="center"><p style="align:left">${salesorder.custbody_project}</p></td>
                <td colspan="4" class="detailsHeaderBottom"		align="center"><p style="align:left">${salesorder.custbody_account_no}</p></td>
                <td colspan="6" class="detailsHeaderBottomEnd"	align="center"><p style="align:left">${record.custbody_jj_terms}</p></td>
            </tr>
        </table>
    </macro>


</macrolist>
</head>

<body header="nlheader" header-height="270pt"  padding="5mm 10mm 5mm 10mm" size="A4">
<#if salesorder.item?has_content>
<table class="itemtable" style="width: 100%">
    <thead>
    <tr>
        <th colspan="6"  class="itemHeader" 	 			align="center">Stockcode</th>
        <th colspan="21" 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="itemHeaderEnd"	        align="center">Qty Sply</th>

        <#if PRICED_PACKINGSLIP>
        <th colspan="5"  class="itemHeader"	 			align="center">Rate</th>
        <th colspan="5"  class="itemHeaderEnd" 			align="center">Amount</th>
    </#if>
    </tr>
    </thead>

    <#list  salesorder.item as SOLine >
    <#assign itemSKU = SOLine.item />
    <#assign itemDescription = SOLine.description />
    <#assign itemQuantity = SOLine.quantityordered />
    <#assign shippedQty = SOLine.quantity />
    <#assign itemTotalBO = SOLine.quantityremaining/>

    <#assign itemRateLine = "-" />
    <#list record.item as IFLine>
    <#if (SOLine.line == IFLine.orderline) >
    <#assign itemRate = IFLine.rate />
    <#assign itemRateLine = itemRate?replace("$","") />
</#if>
</#list>

<#if itemRate?has_content ><#else><#assign itemRate=0/></#if>
<#assign itemTotalAmount = itemRate * shippedQty />

<#if itemTotalBO?has_content ><#else><#assign itemTotalBO=0/></#if>
<#if shippedQty?has_content ><#else><#assign shippedQty=0/> <#assign itemTotalAmount=0/> </#if>
<#if itemRateLine?has_content ><#else><#assign itemRateLine=0/> <#assign itemTotalAmount=0/> </#if>
<#if itemTotalAmount?has_content ><#else><#assign itemTotalAmount=0/></#if>
<tr>
    <td colspan="6" class="itemDetail" 	 			align="left"  >${itemSKU}</td>
    <td colspan="21" 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="itemDetailEnd" 	        align="center">${shippedQty}</td>

    <#if PRICED_PACKINGSLIP>
    <td colspan="5" class="itemDetail" 	 			align="right" >${itemRateLine}</td>
    <td colspan="5" class="itemDetailEnd"   		align="right" >${itemTotalAmount?string("0.##")}</td>
</#if>
</tr>
</#list>
</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="21" 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="itemDetailEnd" 	        align="center">&nbsp;</td>
        <#if PRICED_PACKINGSLIP>
        <td colspan="5" class="itemDetail" 	 			align="right" >&nbsp;</td>
        <td colspan="5" class="itemDetailEnd"   		align="right">&nbsp;</td>
    </#if>
    </tr>
</table>
</#if>


<!-- 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 *