As explained in our Using an Infoplus Script to Customize 3PL Billing Invoice Worksheets article, Infoplus scripts can be used to customize 3PL Billing Invoice worksheets. Please refer to that article for the general variables and objects that are available when creating this script type.
The content that follows in this article is an example script that looks at every input row that would go into an Invoice Worksheet & corresponding backup file then rounds each Extended Charge field to 2 decimal places.
The script starts by using a for loop to loop through all input rows and rounds the extendedCharge field to 2 decimal places. After the loop is finished, these changes are applied to the invoice worksheet by using utils.setOutputLines();
utils.log("Running Invoice Worksheet Script..."); utils.log(""); utils.log("Round the extended charge to 2 decimal places for all inputEntity lines"); for(var i=0; i<utils.inputEntities.size(); i++) { var inputEntity = utils.inputEntities.get(i); var extendedCharge = +(Number(inputEntity.extendedCharge).toFixed(2)); utils.log("New extended charge field: " + extendedCharge); inputEntity.setExtendedCharge(extendedCharge); } utils.log(""); utils.log("Manipulate data in the original lines..."); var outputLines = utils.originalLines; utils.log("Putting new list as output to be used when generating invoice..."); utils.setOutputLines(outputLines);
For more information about 3PL Billing scripts and how to apply them to Customer Invoice templates, see this article.