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