Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple function to calculate the due date based on an invoice date and terms ID.
function calculateDueDate(termID,invDate){
var dueDate=''
try{
var daysToAdd=search.lookupFields({type:'term',id:termID,columns:['daysuntilnetdue']}).daysuntilnetdue;
dueDate=new Date(format.parse({value:invDate,type:format.Type.DATE}));
dueDate.setDate(dueDate.getDate()+parseInt(daysToAdd));
}catch(err01){
log.error('calculateDueDate.err01',JSON.stringify(err01));
handleErrorAndSendNotification(err01,'calculateDueDate');
}finally{
return dueDate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment