Skip to content

Instantly share code, notes, and snippets.

@W3BGUY
Last active August 6, 2020 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save W3BGUY/0c68be045e65e543d3f57a76ead92c3f to your computer and use it in GitHub Desktop.
Save W3BGUY/0c68be045e65e543d3f57a76ead92c3f to your computer and use it in GitHub Desktop.
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