org.drools.examples.process.order.discount.drl Maven / Gradle / Ivy
The newest version!
package org.drools.examples.process.order
import java.util.Date
import java.util.Calendar
function int getHourOfDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(Calendar.HOUR_OF_DAY);
}
rule "5% discount if order includes laptop and order after 18h" ruleflow-group "discount"
when
o: Order( date: date )
eval( getHourOfDate(date) >= 18 )
Order.OrderItem( itemId == "I-5432" ) from o.getOrderItems()
then
System.out.println("Applying a 5% discount");
o.setDiscountPercentage(5);
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy