<h2>The request...</h2>
Recently we were asked if it was possible to make print jobs sent to a particular printer free of charge during exam time. This is fairly standard practice (at least here, in the UK), exam time means extra user accounts (individual exam accounts) and free printing, oh and stress... lots and lots of stress.

We thought a simple way to achieve this would be to apply a 100% discount to jobs submitted to the queue based on a date range and give the user a little note to let them know how much they'd not been charged. As always, we put on our thinking caps, grabbed some <a href="http://amzn.eu/8iIkADp" rel="noopener">roast ox crisps</a> and came up with the following script.
<h2>The solution...</h2>
To begin with, we need to declare our variables and work out what our date range is for the Exams.
<pre class="">var day = inputs.job.date.getDate();
var month = inputs.job.date.getMonth();

if ((day &gt;= 19 &amp;&amp; month == 5) || (day &lt;= 23 &amp;&amp; month == 5)) {
</pre>
So in the above example, we will be looking for any jobs submitted between the 19th and 23rd of June, (Yes June is 5, we start counting with January = 0, remember developers invented this system and they work in mysterious ways).

Then we must declare the cost and saving variables.
<pre class="">var newCost = inputs.job.cost * 0.00;
var saving = inputs.job.cost - newCost;
</pre>
Once we have done this, we need to add the actions to set the new job cost and define the message we will send to the user.
<pre class="">actions.job.setCost(newCost);
actions.job.addComment("100% Exam time discount applied.");
</pre>
Finally, we'd like to send the message to the user via the PaperCut client tool.
<pre class="">actions.client.sendMessage("You saved "
  + inputs.utils.formatCost(saving)
  + " printing your exam related job.");
</pre>
The full script is below, feel free to tweak as needed. That, as they say, is a wrap, and as always if you need any further help with the above, or indeed any other scripts you may be working on then please, do drop us a line.
<h3>Get in touch today | <a href="mailto:sales@selectec.com">sales@selectec.com</a></h3>
<pre class="">function printJobHook(inputs, actions) {

  if (!inputs.job.isAnalysisComplete) {
    return;
  }

  var day = inputs.job.date.getDate();
  var month = inputs.job.date.getMonth();

  if ((day &gt;= 19 &amp;&amp; month == 5) || (day &lt;= 23 &amp;&amp; month == 5)) {

    var newCost = inputs.job.cost * 0.00;
    var saving = inputs.job.cost - newCost;
    actions.job.setCost(newCost);
    actions.job.addComment("100% Exam time discount applied.");

    actions.client.sendMessage("You saved "
      + inputs.utils.formatCost(saving)
      + " printing your exam related job.");
  }
}
</pre>
<img class="aligncenter" src="https://i.imgflip.com/2cayrx.jpg" alt="" width="510" height="382" />