Created
September 6, 2018 17:56
-
-
Save dperussina/6aaa25db23130c4c7d3f0ad24d7969b6 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
// This key value pair keeps track | |
var TRACKING = {}; | |
// Looping through orders to invoice | |
MyInvoiceData.forEach(function(e, i, a){ | |
// See if PRO is tracked in memory | |
if(TRACKING[e.PartnerPrimaryOrderID]){ | |
// increment number tracked | |
suffix = TRACKING[e.PartnerPrimaryOrderID] + 1; | |
// set the tracked value to inscrement amount | |
TRACKING[e.PartnerPrimaryOrderID] = TRACKING[e.PartnerPrimaryOrderID] + 1 | |
// pad to create proper suffix | |
suffix = leftPad(suffix, '-000'); | |
// create suplmental invoice | |
DoSuplmental(e, suffix); | |
}else{ | |
// run sproc to see if suplmental or standard | |
var InvoiceNum = exec(SPROC); | |
// If no records returned, it is original | |
if(InvoiceNum.length == 0){ | |
// create standard invoice | |
DoStandard(e); | |
// add pro to tracked with value 0 being original | |
TRACKING[e.PartnerPrimaryOrderID] = 0; | |
}else{ | |
// If more than 0 records returned, it is supplemental | |
// Set the suffic to number of invoices sent plus one | |
suffix = InvoiceNum.length + 1; | |
// add pro to tracked with value or suffix | |
TRACKING[e.PartnerPrimaryOrderID] = InvoiceNum.length + 1; | |
// pad to create proper suffix | |
suffix = leftPad(suffix, '-000'); | |
// create suplmental invoice | |
DoSuplmental(e, suffix); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment