Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save infoplus-product-team/4f213f16eba2b74303f9c55e8ccffa63 to your computer and use it in GitHub Desktop.
Save infoplus-product-team/4f213f16eba2b74303f9c55e8ccffa63 to your computer and use it in GitHub Desktop.
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