I have a task to merge two if statements in JavaScript for a script related to print management software called papercut. I have everything needed in the script provided below but struggling with combining the two if statements into one. Although I am more familiar with Python than JavaScript, I am seeking assistance to rearrange this script as required.
Refer to the PaperCut print script API documentation
Objective:
The aim is to trigger a cost center popup only for print jobs of 10+ pages; otherwise, charge the job automatically to the non-billable firm account (ADM-3900). Additionally, redirect jobs of 50+ pages from HP printer to a larger copier on test_printer3 to Copier – Color.
/*
* Merge large job redirection conditions
*
* Automatically redirect print jobs above a certain page limit to another output device.
* This helps optimize printing efficiency and costs, especially for high-volume jobs.
*/
function printJobHook(inputs, actions) {
if (!inputs.job.isAnalysisComplete) {
// Return if full job details are not available yet.
return;
actions.job.chargeToPersonalAccount();
return;
if (inputs.job.totalPages < 10) {
// Charge job to firm non-bill account
actions.job.chargeToSharedAccount(ADM-3900);
}
var LIMIT = 5; // Redirect jobs over 5 pages.
var HIGH_VOL_PRINTER = "Copier - Color";
if (inputs.job.totalPages > LIMIT) {
actions.job.bypassReleaseQueue();
actions.job.redirect(HIGH_VOL_PRINTER, {allowHoldAtTarget: true});
actions.client.sendMessage("The print job was over " + LIMIT + " pages and was sent to printer: " + HIGH_VOL_PRINTER + ".");
actions.log.info("Large job redirected from printer '" + inputs.job.printerName + "' to printer '" + HIGH_VOL_PRINTER + "'.");
}
}
}