<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
I'm really not on form today the real data does have negatives and thus my example should have been as follows<br><br> Account :<br> accountBalanceInPence : 70000<br> transactions :<br> - transactionDate : 2009/07/10<br> amountInPence : 50000<br> transactionCode : charge<br> - transactionDate : 2009/07/12<br> amountInPence : -45000<br> transactionCode : Type 1<br><br>and<br><br>Account :<br> accountBalanceInPence : 70000<br> transactions :<br> - transactionDate : 2009/07/10<br> amountInPence : 50000<br> transactionCode : charge<br> - transactionDate : 2009/07/12<br> amountInPence : -45000<br> transactionCode : Type 1<br> - transactionDate : 2009/07/13<br> amountInPence : -5000<br> transactionCode : Type 2<br><br>> Date: Tue, 14 Jul 2009 17:05:21 +0200<br>> Subject: Re: [rules-users] Comparing multiple accumulations<br>> From: wolfgang.laun@gmail.com<br>> To: rules-users@lists.jboss.org<br>> <br>> The second accumulate has "amountInPence < 0" but the values in your<br>> data are all positive. Therefore,...<br>> -W<br>> <br>> 2009/7/14 Richard Sherman <rsherman315@hotmail.com>:<br>> > Thanks Wolfgang,<br>> ><br>> > Here's the extra information as requested.<br>> > Firstly the When creating the email I was removing all references to rent<br>> > and missed one hence RentTransaction should read Transaction. I've also<br>> > noticed that the sum($value) in the third accumulation should read<br>> > sum(-$value).<br>> ><br>> > Below is a typical set of Transactions that should cause a message to occur.<br>> ><br>> > Account :<br>> > accountBalanceInPence : 70000<br>> > transactions :<br>> > - transactionDate : 2009/07/10<br>> > amountInPence : 50000<br>> > transactionCode : charge<br>> > - transactionDate : 2009/07/12<br>> > amountInPence : 45000<br>> > transactionCode : Type 1<br>> ><br>> > Below is a similar set of Transactions that shouldn't cause a message to<br>> > occur.<br>> ><br>> > Account :<br>> > accountBalanceInPence : 70000<br>> > transactions :<br>> > - transactionDate : 2009/07/10<br>> > amountInPence : 50000<br>> > transactionCode : charge<br>> > - transactionDate : 2009/07/12<br>> > amountInPence : 45000<br>> > transactionCode : Type 1<br>> > - transactionDate : 2009/07/13<br>> > amountInPence : 5000<br>> > transactionCode : Type 2<br>> ><br>> > Thanks<br>> > Richard<br>> ><br>> ><br>> >>From: wolfgang.laun@gmail.com<br>> >>To: rules-users@lists.jboss.org<br>> >>Date: Tue, 14 Jul 2009 12:43:40 +0200<br>> >>Subject: Re: [rules-users] Comparing multiple accumulations<br>> >><br>> >>You'll have to provide one full set of $acc.transaction values<br>> >>(indicating class and relevant field values) where you think the rule<br>> >>should fire, but doesnt, for people to be able to check what's going<br>> >>on.<br>> >><br>> >>Also, it is necessary to know how the types of Account.transactions<br>> >>(List<???>), Transaction and RentTransaction are related.<br>> >><br>> >>-W<br>> >><br>> >>On 7/14/09, Richard Sherman <rsherman315@hotmail.com> wrote:<br>> >>> First I'm new to drools and secondly where I'm working we're using<br>> >>> version<br>> >>> 4.0.7.<br>> >>><br>> >>> I have a list of accounts and each account contains a list of<br>> >>> transactions.<br>> >>> I wish to accumulate charge transactions and compare them to an<br>> >>> accumulation<br>> >>> of payment transactions for a given time period (such as the last month).<br>> >>> And it gets slightly more awkward in that if a payment transaction is of<br>> >>> a<br>> >>> certain type it needs to be converted from a 4 weekly figure to a monthly<br>> >>> figure ( using / 4 / 7 * 365 / 12). I've tried to use structures as<br>> >>> follows<br>> >>> but they are causing the then part of the rule never to fire.<br>> >>><br>> >>> rule "Account in arrears"<br>> >>> salience 10<br>> >>> no-loop<br>> >>> when<br>> >>> $acc : Account( // balance between £500 and £1000<br>> >>> accountBalanceInPence >= 50000 &&<br>> >>> accountBalanceInPence <= 100000<br>> >>> )<br>> >>><br>> >>> $s : MessageInfo( accountNumber == $acc.accountNumber )<br>> >>><br>> >>> Number($charges : intValue) from<br>> >>> accumulate(<br>> >>> (Transaction(<br>> >>> transactionDate > oneMonthAgo &&<br>> >>> amountInPence > 0 &&<br>> >>> $value : amountInPence)<br>> >>> from $acc.transactions),<br>> >>> sum($value)<br>> >>> )<br>> >>><br>> >>> Number($adjustment : intValue) from<br>> >>> accumulate(<br>> >>> (Transaction(<br>> >>> transactionDate > oneMonthAgo &&<br>> >>> amountInPence < 0 &&<br>> >>> transactionCode == "Type 1" &&<br>> >>> $value : amountInPence)<br>> >>> from $acc.transactions),<br>> >>> sum(($value / 4 / 7 * 365 / 12) - $value)<br>> >>> )<br>> >>><br>> >>><br>> >>> Number( intValue > ($charges + $adjustment)) from<br>> >>> accumulate(<br>> >>> (RentTransaction<br>> >>> (transactionDate > oneMonthAgo<br>> >>> $value : amountInPence)<br>> >>> from $acc.transactions),<br>> >>> sum($value)<br>> >>> )<br>> >>><br>> >>> then<br>> >>> $s.setMessage( "Account in arrears" );<br>> >>> update($s); // flag update<br>> >>> end<br>> >>><br>> >>> Thanks<br>> >>> Richard<br>> >>><br>> >>> ________________________________<br>> >>> Beyond Hotmail - see what else you can do with Windows Live. Find out<br>> >>> more.<br>> >>> _______________________________________________<br>> >>> rules-users mailing list<br>> >>> rules-users@lists.jboss.org<br>> >>> https://lists.jboss.org/mailman/listinfo/rules-users<br>> > ________________________________<br>> > View your Twitter and Flickr updates from one place – Learn more!<br>> > _______________________________________________<br>> > rules-users mailing list<br>> > rules-users@lists.jboss.org<br>> > https://lists.jboss.org/mailman/listinfo/rules-users<br>> ><br>> ><br>> <br>> _______________________________________________<br>> rules-users mailing list<br>> rules-users@lists.jboss.org<br>> https://lists.jboss.org/mailman/listinfo/rules-users<br><br /><hr />View your Twitter and Flickr updates from one place – <a href='http://clk.atdmt.com/UKM/go/137984870/direct/01/' target='_new'>Learn more!</a></body>
</html>