svn commit: r450271 - in /incubator/ofbiz/trunk/applications/order: webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh widget/ordermgr/ReportForms.xml

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

svn commit: r450271 - in /incubator/ofbiz/trunk/applications/order: webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh widget/ordermgr/ReportForms.xml

sichen
Author: sichen
Date: Tue Sep 26 18:05:33 2006
New Revision: 450271

URL: http://svn.apache.org/viewvc?view=rev&rev=450271
Log:
Added orderDate field to report of open order items.  Use OrderHeaderAndItem instead for this report.

Modified:
    incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh
    incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportForms.xml

Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh?view=diff&rev=450271&r1=450270&r2=450271
==============================================================================
--- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh (original)
+++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh Tue Sep 26 18:05:33 2006
@@ -17,10 +17,8 @@
 
 /*
  * Script to build the open order item report.
- *
- * The idea is to fetch the OrderHeaders of the search criteria,
- * then show the open quantities of the related OrderItems that
- * have not been completed, cancelled or rejected.
+ * Uses OrderHeaderAndItem, then computes the quantities
+ * to display.
  *
  * @author Leon Torres ([hidden email])
  */
@@ -51,46 +49,31 @@
     // search all orders that are not completed, cancelled or rejected
     conditions.add(
             new EntityConditionList( UtilMisc.toList(
-                    new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"),
-                    new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED"),
-                    new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED")
+                    new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"),
+                    new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED"),
+                    new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED")
                     ), EntityOperator.AND)
             );
 }
 
-// First get all orders given the conditions
-orderConditions = new EntityConditionList(conditions, EntityOperator.AND);
-orders = delegator.findByCondition("OrderHeader", orderConditions, null, null);
-orderMap = FastMap.newInstance();
-for (iter = orders.iterator(); iter.hasNext(); ) {
-    order = iter.next();
-    orderMap.put(order.get("orderId"), order);
-}
-if (orderMap.size() == 0) return;
-
-// get all related order items
-itemConditions = new EntityConditionList( UtilMisc.toList(
-            new EntityExpr("orderId", EntityOperator.IN, orderMap.keySet()),
-            new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ITEM_COMPLETED"),
-            new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED"),
-            new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED")
-            ), EntityOperator.AND);
-orderItems = delegator.findByCondition("OrderItem", itemConditions, null, null);
+// item conditions
+conditions.add(new EntityExpr("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_COMPLETED"));
+conditions.add(new EntityExpr("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED"));
+conditions.add(new EntityExpr("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED"));
+
+// get the orderHeaderAndItems
+allConditions = new EntityConditionList( conditions, EntityOperator.AND );
+orderHeaderAndItems = delegator.findByCondition("OrderHeaderAndItems", allConditions, null, UtilMisc.toList("orderDate DESC"));
 
-// build a list of orderItem maps for reporting that is a union of OrderItem, OrderHeader, and other info
+// make a Map for each orderHeaderAndItem that includes the quantities for the report
 reportData = FastList.newInstance();
-for (iter = orderItems.iterator(); iter.hasNext(); ) {
+for (iter = orderHeaderAndItems.iterator(); iter.hasNext(); ) {
     orderItem = iter.next();
 
-    // add order item fields
+    // add all fields
     data = FastMap.newInstance();
     data.putAll( orderItem.getAllFields() );
     
-    // add order header fields
-    order = orderMap.get(orderItem.get("orderId"));
-    data.put("productStoreId", order.get("productStoreId"));
-    data.put("orderDate", order.get("orderDate"));
-
     // compute quantity
     quantity = orderItem.getDouble("quantity");
     cancelQuantity = orderItem.getDouble("cancelQuantity");
@@ -100,7 +83,7 @@
     data.put("quantityNet", new Double(quantityNet));
 
     // compute issued
-    issuances = orderItem.getRelated("ItemIssuance", UtilMisc.toList("quantity"));
+    issuances = delegator.findByAnd("ItemIssuance", UtilMisc.toMap("orderId", orderItem.get("orderId"), "orderItemSeqId", orderItem.get("orderItemSeqId")), UtilMisc.toList("quantity"));
     double quantityIssued = 0;
     for (subiter = issuances.iterator(); subiter.hasNext(); ) {
         quantityIssued += subiter.next().getDouble("quantity").doubleValue();

Modified: incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportForms.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportForms.xml?view=diff&rev=450271&r1=450270&r2=450271
==============================================================================
--- incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportForms.xml (original)
+++ incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportForms.xml Tue Sep 26 18:05:33 2006
@@ -130,6 +130,7 @@
     <!-- list open order items -->
     <form name="OpenOrderItemsList" type="list" list-name="orderItems"
             default-title-style="tableheadtext" default-widget-style="tabletext" default-tooltip-style="tabletext">
+         <field name="orderDate" title="${uiLabelMap.OrderDate}"><display/></field>
          <field name="orderId" title="${uiLabelMap.OrderOrderId}" widget-style="buttontext">
              <hyperlink target="orderview?$orderId=${orderId}" description="${orderId}"/>
          </field>