<br> I would say, this is one of those cases where it is best to use the right tool for the right job. A programmer can implement this in pure DRL using a few rules, but I don't like the idea, because it will be hard for others to quickly grasp the meaning of the rules. So, I would implement a function (either simple or an accumulate function) to calculate the number of free items and use the rules for what they do best: act on the results.<br>
<br> The rule would be like:<br><br>rule "add free items"<br>where<br> Brand( $name : name, includedInPromotion == true )<br> Number( $free : intValue > 0 ) from accumulate(<br> $i : Item( brand == $name ),<br>
calculateFree( $i ) )<br>then<br> // add $free items to the order<br>end<br><br> Take a look at the docs on how to implement the function to calculate the number of free items. It is very simple.<br> This way, your business rule above is clear and easy to understand/maintain.<br>
<br> Hope it helps.<br><br> []s<br> Edson<br><br><div class="gmail_quote">2009/1/23 niraj manandhar <span dir="ltr"><<a href="mailto:regniraj@gmail.com">regniraj@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have following plan for the free item distribution<br><br>purchase of 3 items under a same brands will get 1 gift item free<br>purchase of 5 items under a same brands will get 2 gift item free<br>purchase of 10 items under a same brands will get 4 gift item free<br>
<br><br>now if some buyer buys 13 items then he wil get free ites<br>4 for first 10 <br>1 for the remaining 3<br><br>tell me how to make a drl with this thing'<br><br><br><br>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>