Print Commercial Invoice from Item Fulfillment

While shipping an order, on some cases it is mandatory to add Commercial Invoice to the package. Especially when the shipment will go through customs process. Depending on the business, actual invoice record is not always created before the shipment. To cover the requirement, Advanced Packing Slip PDF Template can be utilized which is part of NetSuite standard features. However, it may not be sufficient for the business requirements and SuiteScript can be utilized to extend the content of the printed file.

There are 2 main options for SuiteScript to feed data to a printed file. First is to use a User Event script that will calculate and populate the data to custom form fields added during the execution for the record being printed. This approach still uses the standard Advanced Packing Slip PDF Template as the printing option.

Second way is to build a fully scripted solution for printing. This option gives flexibility to generate more structured data that can be manipulated easily. On the other hand, it has more technical debt for the NetSuite Administrator to maintain the solution in case of changes in the requirement. In our solution, we used this option because of partial fulfilling of an order was one of the requirements and data required for printing was easier to build from scratch.

Solution consists of 3 SuiteScript files, where User Event script adds a button for printing which is triggering Client script function that is available while user is viewing the record. Last script is the Suitelet which does the actual processing of the data and generating the PDF file as an output using template XML file.

One key point was to match the correct Sales Order line from the Item Fulfillment line. This is achieved by checking the orderline column from the Item Fulfillment with line column from Sales Order. Another consideration is when a line (item) based discount was added to a Sales Order, it is needed to be added to the printed Commercial Invoice. Suitelet code does a check to the item type of the next line whether it is a Discount line that should be processed or ignored.

Similar approach for printing a record can be used for record types that are supported in SuiteScript but Advanced PDF/HTML Template is not available for printing (e.g. Invoice Group, Vendor Return Authorization, etc.). Source code and SDF Project (SuiteCloud Development Framework) data is available on our GitHub page.

We would like to hear your opinion if you liked this solution or if you discover something missing, something not working properly, a better option, weird coding. If you have any comments on this solution, please use the section below. For any other communication, please use the form on the Contact Us page.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.