title: calculation in jboss drools
body: <p>I recently encountered below scenario in drools. I want to know how to proceed with the rule design for this.</p>
  
  <pre><code>Class Emp{
   beingDate:Date
   endDate:Date
  }
  </code></pre>
  
  <p>Rule to determine annual income for the employee based on the given dates:</p>
  
  <ul>
  <li>For dates before 3/5/2003 the hourly rate is $3.5 and annual multiplier is 2100</li>
  <li>For dates after 3/5/2003 the hourly rate changes every year (given data) and annual multiplier is 2092.</li>
  </ul>
  
  <p>There might be scenarios where begin date is before 3/5/2003 and end date is after 3/5/2003.</p>
  
  <p>What is the best way to design rules for this scenario.</p>
  
  <p><strong>Update:</strong> added an e.g. for more clarity
  If the object is </p>
  
  <pre><code>empObj={
    beginDate=10/8/2001, 
    endDate=5/10/2005
  }
  </code></pre>
  
  <p>The rule should give the sum of below:</p>
  
  <ol>
  <li>3.5 * (no. of days in 2001 starting 10/8/2001) / (total no. of days in 2001) * 2100</li>
  <li>3.5 * 2100 ==> This is for year 2002</li>
  <li>3.5 * (no. of days in 2003 before 3/5/2003) / (total no. of days in 2003) * 2100</li>
  <li>(2003 hourly rate) * (no. of days in 2003 after 3/5/2003)  / (total no. of days in 2003) * <strong>2092</strong> ==> note the change in yearly multiplier..</li>
  <li>(2004 hourly rate) * 2092</li>
  <li>(2005 hourly rate) * (no. of days in 2005 before 5/10/2005)   / (total no. of days in 2005) * 2092</li>
  </ol>