Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save infoplus-product-team/c8883521e1903ec9376014cacae74439 to your computer and use it in GitHub Desktop.
Save infoplus-product-team/c8883521e1903ec9376014cacae74439 to your computer and use it in GitHub Desktop.
utils.log("Running Invoice Worksheet Script...");
var carrierMap = {};
carrierMap["RPS - RALSTON 3RD PARTY"] = 1;
carrierMap["FEDERAL EXPRESS/3RD PARTY"] = 1;
carrierMap["FED.EXP.2DAY 3RD PARTY"] = 1;
carrierMap["USF Holland 3rd Party"] = 1;
carrierMap["Amazon 3rd Party - LTL"] = 1;
carrierMap["LTL-3rd Pty Walgreens/NCS"] = 1;
carrierMap["UPS 3rd Party - Quidsi"] = 1;
carrierMap["MMB 3rd Party LTL-FW"] = 1;
carrierMap["Cascio 3rd Pty LTL-UPSFRT"] = 1;
carrierMap["UPS 3rd Party GND - MFI"] = 1;
carrierMap["LTL 3rd Party - MFI"] = 1;
carrierMap["UPS 3rd Party GND- Cascio"] = 1;
carrierMap["UPS 3rd Party GND- Skip's"] = 1;
carrierMap["Estes - 3rd Party"] = 1;
carrierMap["R+L Carriers 3rd Party"] = 1;
carrierMap["FEDEX INTL-3rd PARTY"] = 1;
carrierMap["FED EX/PRI.ONE-3rd Party"] = 1;
carrierMap["FED-EX/STD-3rd Party"] = 1;
carrierMap["FED-EX/ECO/2DAY-3rd Party"] = 1;
carrierMap["UPS 3rd Party"] = 1;
carrierMap["FEDEX 3rd Party"] = 1;
carrierMap["FED-EX ECONOMY 2-DAY/3RD"] = 1;
carrierMap["ROADWAY EXPRESS INC-3RD P"] = 1;
carrierMap["FED-EX FREIGHT 3rd Party"] = 1;
carrierMap["FedEx FRT 2day GUAR 3rd P"] = 1;
carrierMap["Old Dominion- 3rd Party"] = 1;
carrierMap["All American Transprt-3rd"] = 1;
carrierMap["HYMAN FRT-3RD PARTY-PRE"] = 1;
carrierMap["UPS FREIGHT 3rd PARTY"] = 1;
carrierMap["YELLOW FREIGHT/3RD PARTY"] = 1;
carrierMap["CENTRAL TRANSPORT/3RD PAR"] = 1;
carrierMap["1st Choice - 3rd Party"] = 1;
carrierMap["Freight Watchers 3rd Prty"] = 1;
carrierMap["DOD Fees - 3rd Party"] = 1;
carrierMap["PILOT FREIGHT-3RD PARTY"] = 1;
carrierMap["AD 3RD PARTY TRUCK"] = 1;
carrierMap["C.H. ROBINSON/3RD PARTY"] = 1;
carrierMap["ROADWAY-3RD PARTY COLLECT"] = 1;
carrierMap["HOLMES-3RD PARTY COLLECT"] = 1;
carrierMap["HYMAN-3RD PARTY COLLECT"] = 1;
carrierMap["FDX Smartpost- 3rd Party"] = 1;
var outputLine = utils.originalLines.get(0);
var quantity = 0;
/////////////////////////////////////////////////////
// uncomment these three lines to produce an error //
/////////////////////////////////////////////////////
// var outOfBounds = utils.inputEntities.size();
// outOfBounds++;
// var outputLineBad = utils.originalLines.get(outOfBounds);
utils.log("Viewing Input Entities");
for(var i=0; i<utils.inputEntities.size(); i++)
{
var inputEntity = utils.inputEntities.get(i);
var isMatch = false;
var carrier = inputEntity.getCarrierName();
if(carrierMap[carrier] > -1)
{
utils.log("Carrier [" + carrier + "] matches the test for 3rd party.");
isMatch = true;
}
else
{
// can turn this log line on for debugging.
// utils.log("Carrier [" + carrier + "] does NOT match the test for 3rd party.");
}
if(inputEntity.getThirdPartyParcelAccountId() != null)
{
utils.log("Has a third party parcel account, so it's a match!");
isMatch = true;
}
//////////////////////////////////////////////////////////////////
//set the charge for this line in the backup file charge details//
//////////////////////////////////////////////////////////////////
if(isMatch && inputEntity.getNumberOfCartons())
{
if(inputEntity.getNumberOfCartons())
{
inputEntity.setExtendedCharge(inputEntity.getNumberOfCartons() * outputLine.chargeRate);
quantity += Number(inputEntity.getNumberOfCartons());
}
}
else
{
inputEntity.setExtendedCharge(0);
}
}
utils.log("");
utils.log("Manipulate data in the original invoice lines...");
outputLine.quantity = quantity;
outputLine.extendedCharge = quantity * outputLine.chargeRate;
var outputLines = utils.originalLines;
utils.setOutputLines(outputLines);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment