<br>&nbsp;&nbsp;&nbsp; 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&#39;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>&nbsp;&nbsp;&nbsp; The rule would be like:<br><br>rule &quot;add free items&quot;<br>where<br>&nbsp;&nbsp;&nbsp; Brand( $name : name, includedInPromotion == true )<br>&nbsp;&nbsp;&nbsp; Number( $free : intValue &gt; 0 ) from accumulate(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $i : Item( brand == $name ),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; calculateFree( $i ) )<br>then<br>&nbsp;&nbsp;&nbsp; // add $free items to the order<br>end<br><br>&nbsp;&nbsp;&nbsp; Take a look at the docs on how to implement the function to calculate the number of free items. It is very simple.<br>&nbsp;&nbsp;&nbsp; This way, your business rule above is clear and easy to understand/maintain.<br>
<br>&nbsp;&nbsp;&nbsp; Hope it helps.<br><br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">2009/1/23 niraj manandhar <span dir="ltr">&lt;<a href="mailto:regniraj@gmail.com">regniraj@gmail.com</a>&gt;</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&nbsp; brands will get 1 gift item free<br>purchase of 5 items under a same&nbsp; brands will get 2&nbsp; gift item free<br>purchase of 10 items under a same&nbsp; brands will get 4&nbsp; 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&#39;<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> &nbsp;Edson Tirelli<br> &nbsp;JBoss Drools Core Development<br> &nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>