Author: sichen
Date: Tue Dec 19 16:56:20 2006
New Revision: 488878

URL: http://svn.apache.org/viewvc?view=rev&rev=488878
Log:
refactored billing account worker to produce a getBillingAccountOpenOrders 
method

Modified:
    
incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java

Modified: 
incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java
URL: 
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java?view=diff&rev=488878&r1=488877&r2=488878
==============================================================================
--- 
incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java
 (original)
+++ 
incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java
 Tue Dec 19 16:56:20 2006
@@ -137,14 +137,7 @@
         BigDecimal balance = getBillingAccountNetBalance(delegator, 
billingAccountId);
         
         // now the amounts of all the pending orders (not cancelled, rejected 
or completed)
-        List orderHeaders = null;
-        List exprs1 = new LinkedList();
-        exprs1.add(new EntityExpr("billingAccountId", EntityOperator.EQUALS, 
billingAccountId));
-        exprs1.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, 
"ORDER_REJECTED"));
-        exprs1.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, 
"ORDER_CANCELLED"));
-        exprs1.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, 
"ORDER_COMPLETED"));
-
-        orderHeaders = delegator.findByAnd("OrderHeader", exprs1);
+        List orderHeaders = getBillingAccountOpenOrders(delegator, 
billingAccountId); 
 
         if (orderHeaders != null) {
             Iterator ohi = orderHeaders.iterator();
@@ -166,6 +159,17 @@
         }
         return balance;
     }
+    
+    /**
+     * Returns list of orders which are currently open against a billing 
account
+     */ 
+    public static List getBillingAccountOpenOrders(GenericDelegator delegator, 
String billingAccountId) throws GenericEntityException {
+        return delegator.findByAnd("OrderHeader", UtilMisc.toList( 
+                    new EntityExpr("billingAccountId", EntityOperator.EQUALS, 
billingAccountId),
+                    new EntityExpr("statusId", EntityOperator.NOT_EQUAL, 
"ORDER_REJECTED"),
+                    new EntityExpr("statusId", EntityOperator.NOT_EQUAL, 
"ORDER_CANCELLED"),
+                    new EntityExpr("statusId", EntityOperator.NOT_EQUAL, 
"ORDER_COMPLETED")));
+    } 
     
     public static BigDecimal getBillingAccountBalance(GenericDelegator 
delegator, String billingAccountId) throws GenericEntityException {
         GenericValue billingAccount = 
delegator.findByPrimaryKey("BillingAccount", UtilMisc.toMap("billingAccountId", 
billingAccountId));


Reply via email to