[rules-users] Comparing multiple accumulations

Richard Sherman rsherman315 at hotmail.com
Tue Jul 14 05:41:44 EDT 2009


First I'm new to drools and secondly where I'm working we're using version 4.0.7.

I have a list of accounts and each account contains a list of transactions. I wish to accumulate charge transactions and compare them to an accumulation of payment transactions for a given time period (such as the last month). And it gets slightly more awkward in that if a payment transaction is of a certain type it needs to be converted from a 4 weekly figure to a monthly figure ( using / 4 / 7 * 365 / 12). I've tried to use structures as follows but they are causing the then part of the rule never to fire.

rule "Account in arrears"
    salience 10
    no-loop
    when
        $acc : Account( // balance between £500 and £1000
            accountBalanceInPence >=  50000 &&
            accountBalanceInPence <= 100000
        )

        $s  : MessageInfo( accountNumber == $acc.accountNumber )
               
        Number($charges : intValue) from
                    accumulate(
                        (Transaction(
                               transactionDate > oneMonthAgo &&
                               amountInPence > 0 &&
                               $value : amountInPence)
                       from $acc.transactions),
                        sum($value)
                    )
       
        Number($adjustment : intValue) from  
            accumulate(
                (Transaction(
                           transactionDate > oneMonthAgo &&
                           amountInPence < 0 &&
                           transactionCode == "Type 1" &&
                           $value : amountInPence)
                       from $acc.transactions),
                   sum(($value / 4 / 7 * 365 / 12) - $value)
               )
                   
       
        Number( intValue > ($charges + $adjustment)) from  
                accumulate(
                    (RentTransaction
                            (transactionDate > oneMonthAgo
                            $value : amountInPence)
                        from $acc.transactions),
                    sum($value)
                )

    then
        $s.setMessage( "Account in arrears" );
        update($s); // flag update
end

Thanks
Richard

_________________________________________________________________
With Windows Live, you can organise, edit, and share your photos.
http://clk.atdmt.com/UKM/go/134665338/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090714/aa8caf98/attachment.html 


More information about the rules-users mailing list