svn commit: r935330 - in /ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice: InvoiceReport.groovy ListNotAppliedPayments.groovy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r935330 - in /ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice: InvoiceReport.groovy ListNotAppliedPayments.groovy

lektran
Author: lektran
Date: Sun Apr 18 10:41:46 2010
New Revision: 935330

URL: http://svn.apache.org/viewvc?rev=935330&view=rev
Log:
A few more EntityConditionBuilder examples

Modified:
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/InvoiceReport.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/InvoiceReport.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/InvoiceReport.groovy?rev=935330&r1=935329&r2=935330&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/InvoiceReport.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/InvoiceReport.groovy Sun Apr 18 10:41:46 2010
@@ -19,6 +19,7 @@
 
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityConditionBuilder;
 import org.ofbiz.entity.condition.EntityConditionList;
 import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
@@ -26,19 +27,22 @@ import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.entity.util.EntityFindOptions;
 
 import javolution.util.FastList;
+
+exprBldr = new org.ofbiz.entity.condition.EntityConditionBuilder();
+
 if (invoiceTypeId) {
-    List invoiceStatusesCondition = [];
-    invoiceStatusesCondition.add(EntityCondition.makeCondition("invoiceTypeId", EntityOperator.EQUALS, invoiceTypeId));
+    expr = exprBldr.AND() {
+        EQUALS(invoiceTypeId: invoiceTypeId)
+        LESS_THAN(dueDate: UtilDateTime.nowTimestamp())
+    }
     if ("PURCHASE_INVOICE".equals(invoiceTypeId)) {
-        invoiceStatusesCondition.add(EntityCondition.makeCondition("statusId", EntityOperator.IN, ["INVOICE_RECEIVED", "INVOICE_IN_PROCESS"]));
+        invoiceStatusesCondition = exprBldr.IN(statusId, ["INVOICE_RECEIVED", "INVOICE_IN_PROCESS"])
     } else if ("SALES_INVOICE".equals(invoiceTypeId)) {
-        invoiceStatusesCondition.add(EntityCondition.makeCondition("statusId", EntityOperator.IN, ["INVOICE_SENT", "INVOICE_APPROVED"]));
+        invoiceStatusesCondition = exprBldr.IN(statusId, ["INVOICE_SENT", "INVOICE_APPROVED"])
     }
-    List pastDueInvoicesCondition = [];
-    pastDueInvoicesCondition.addAll(invoiceStatusesCondition);
-    pastDueInvoicesCondition.add(EntityCondition.makeCondition("dueDate", EntityOperator.LESS_THAN, UtilDateTime.nowTimestamp()));
-    invoicesCond = EntityCondition.makeCondition(pastDueInvoicesCondition, EntityOperator.AND);
-    PastDueInvoices = delegator.findList("Invoice", invoicesCond, null, ["dueDate DESC"], null, false);
+    expr = exprBldr.AND([expr, invoiceStatusesCondition]);
+
+    PastDueInvoices = delegator.findList("Invoice", expr, null, ["dueDate DESC"], null, false);
     if (PastDueInvoices) {
         invoiceIds = PastDueInvoices.invoiceId;
         totalAmount = dispatcher.runSync("getInvoiceRunningTotal", [invoiceIds: invoiceIds, organizationPartyId: organizationPartyId, userLogin: userLogin]);
@@ -47,11 +51,10 @@ if (invoiceTypeId) {
         }
         context.PastDueInvoices = PastDueInvoices;
     }
-    
-    List invoicesDueSoonCondition = [];
-    invoicesDueSoonCondition.addAll(invoiceStatusesCondition);
-    invoicesDueSoonCondition.add(EntityCondition.makeCondition("dueDate", EntityOperator.GREATER_THAN_EQUAL_TO, UtilDateTime.nowTimestamp()));
-    invoicesCond = EntityCondition.makeCondition(invoicesDueSoonCondition, EntityOperator.AND);
+
+    invoicesCond = exprBldr.AND(invoiceStatusesCondition) {
+        GREATER_THAN_EQUAL_TO(dueDate: UtilDateTime.nowTimestamp())
+    }
     EntityFindOptions findOptions = new EntityFindOptions();
     findOptions.setMaxRows(10);
     InvoicesDueSoon = delegator.findList("Invoice", invoicesCond, null, ["dueDate ASC"], findOptions, false);

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy?rev=935330&r1=935329&r2=935330&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy Sun Apr 18 10:41:46 2010
@@ -25,6 +25,7 @@ import org.ofbiz.accounting.invoice.*;
 import org.ofbiz.accounting.payment.*;
 import org.ofbiz.accounting.util.UtilAccounting;
 import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityConditionBuilder;
 import org.ofbiz.entity.condition.EntityConditionList;
 import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
@@ -36,20 +37,20 @@ invoice = delegator.findByPrimaryKey("In
 decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
 rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
 
-exprList = [EntityCondition.makeCondition("partyIdTo", EntityOperator.EQUALS, invoice.partyIdFrom),
-            EntityCondition.makeCondition("partyIdFrom", EntityOperator.EQUALS, invoice.partyId)];
-partyCond = EntityCondition.makeCondition(exprList, EntityOperator.AND);
-
-exprList1 = [EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PMNT_NOT_PAID"),
-                  EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PMNT_RECEIVED"),
-                  EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PMNT_SENT")];
-statusCond = EntityCondition.makeCondition(exprList1, EntityOperator.OR);
+exprBldr = new EntityConditionBuilder();
+preCurrencyCond = exprBldr.AND() {
+    EQUALS(partyIdTo: invoice.partyIdFrom)
+    EQUALS(partyIdFrom: invoice.partyIdTo)
+    IN(statusId: ["PMNT_NOT_PAID", "PMNT_RECEIVED", "PMNT_SENT"])
+}
 
-currCond = EntityCondition.makeCondition("currencyUomId", EntityOperator.EQUALS, invoice.currencyUomId);
-actualCurrCond = EntityCondition.makeCondition("actualCurrencyUomId", EntityOperator.EQUALS, invoice.currencyUomId);
+topCond = exprBldr.AND(preCurrencyCond) {
+    EQUALS(currencyUomId: invoice.currencyUomId)
+}
 
-topCond = EntityCondition.makeCondition([partyCond, statusCond, currCond], EntityOperator.AND);
-topCondActual = EntityCondition.makeCondition([partyCond, statusCond, actualCurrCond], EntityOperator.AND);
+topCondActual = exprBuilder.AND(preCurrencyCond) {
+    EQUALS(actualCurrencyUomId: invoice.currencyUomId)
+}
 
 payments = delegator.findList("Payment", topCond, null, ["effectiveDate"], null, false);
 context.payments = getPayments(payments, false);