Created
March 22, 2021 19:20
-
-
Save infoplus-product-team/4f213f16eba2b74303f9c55e8ccffa63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
utils.log("Running Invoice Worksheet Script..."); | |
utils.log(""); | |
utils.log("Consider a partial case a full case in the estimated cases field"); | |
var totalEstimatedCases = 0; | |
var outputLine = utils.originalLines.get(0); | |
for(var i=0; i<utils.inputEntities.size(); i++) | |
{ | |
var inputEntity = utils.inputEntities.get(i); | |
if(inputEntity.getReceiptQuantityPerCase()) | |
{ | |
var lineQty = inputEntity.getQuantity(); | |
var qtyPerCase = inputEntity.getReceiptQuantityPerCase(); | |
var roundedEstmatedCases = Math.ceil(lineQty/qtyPerCase); | |
utils.log("lineQty: " + lineQty); | |
utils.log("qtyPerCase: " + qtyPerCase); | |
utils.log("Rounded Estimated Cases: " + roundedEstmatedCases); | |
utils.log(""); | |
var thisQuantity = parseInt(roundedEstmatedCases); | |
inputEntity.setEstimatedCases(thisQuantity); | |
totalEstimatedCases += thisQuantity; | |
} | |
} | |
utils.log("Manipulate data in the original lines..."); | |
var outputLines = utils.originalLines; | |
outputLine.quantity = totalEstimatedCases; | |
utils.log("Putting new list as output to be used when generating invoice..."); | |
utils.setOutputLines(outputLines); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment