svn commit: r450266 - in /incubator/ofbiz/trunk/applications: order/config/ order/webapp/ordermgr/WEB-INF/ order/webapp/ordermgr/WEB-INF/actions/reports/ order/widget/ordermgr/ product/config/

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

svn commit: r450266 - in /incubator/ofbiz/trunk/applications: order/config/ order/webapp/ordermgr/WEB-INF/ order/webapp/ordermgr/WEB-INF/actions/reports/ order/widget/ordermgr/ product/config/

sichen
Author: sichen
Date: Tue Sep 26 17:26:12 2006
New Revision: 450266

URL: http://svn.apache.org/viewvc?view=rev&rev=450266
Log:
Added report for open order items.  Basically allows one to see what orders have unshipped items.

Added:
    incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh
Modified:
    incubator/ofbiz/trunk/applications/order/config/OrderUiLabels.properties
    incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportForms.xml
    incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportScreens.xml
    incubator/ofbiz/trunk/applications/product/config/ProductUiLabels.properties

Modified: incubator/ofbiz/trunk/applications/order/config/OrderUiLabels.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/config/OrderUiLabels.properties?view=diff&rev=450266&r1=450265&r2=450266
==============================================================================
--- incubator/ofbiz/trunk/applications/order/config/OrderUiLabels.properties (original)
+++ incubator/ofbiz/trunk/applications/order/config/OrderUiLabels.properties Tue Sep 26 17:26:12 2006
@@ -335,6 +335,7 @@
 OrderRemainingSubTotal = Remaining SubTotal
 OrderRemoveSelected=Remove Selected
 OrderReports=Order Reports
+OrderReportOpenOrderItems=Open Order Items Report
 OrderReportPurchasesByOrganization=Purchases by Organization Report
 OrderReportPurchasesByPaymentMethod=Purchases by Payment Method Report
 OrderReportPurchasesByProduct=Purchases by Product Report

Added: 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=auto&rev=450266
==============================================================================
--- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh (added)
+++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh Tue Sep 26 17:26:12 2006
@@ -0,0 +1,116 @@
+/*
+ *
+ * Copyright 2001-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * 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.
+ *
+ * @author Leon Torres ([hidden email])
+ */
+
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.entity.condition.*;
+
+productStoreId = parameters.get("productStoreId");
+orderTypeId = parameters.get("orderTypeId");
+orderStatusId = parameters.get("orderStatusId");
+
+// search by orderTypeId is mandatory
+conditions = UtilMisc.toList(new EntityExpr("orderTypeId", EntityOperator.EQUALS, orderTypeId));
+if (productStoreId != null && productStoreId.length() > 0) {
+    conditions.add(new EntityExpr("productStoreId", EntityOperator.EQUALS, productStoreId));
+    // for generating a title (given product store)
+    context.put("productStore", delegator.findByPrimaryKeyCache("ProductStore", UtilMisc.toMap("productStoreId", productStoreId)));
+} else {
+    // for generating a title (all stores)  TODO: use UtilProperties to internationalize
+    context.put("productStore", UtilMisc.toMap("storeName", "All Stores"));
+}
+if (orderStatusId != null && orderStatusId.length() > 0) {
+    conditions.add(new EntityExpr("statusId", EntityOperator.EQUALS, orderStatusId));
+} else {
+    // 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")
+                    ), 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);
+
+// build a list of orderItem maps for reporting that is a union of OrderItem, OrderHeader, and other info
+reportData = FastList.newInstance();
+for (iter = orderItems.iterator(); iter.hasNext(); ) {
+    orderItem = iter.next();
+
+    // add order item 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");
+    quantityNet = 0;
+    if (quantity != null) quantityNet += quantity.doubleValue();
+    if (cancelQuantity != null) quantityNet -= cancelQuantity.doubleValue();
+    data.put("quantityNet", new Double(quantityNet));
+
+    // compute issued
+    issuances = orderItem.getRelated("ItemIssuance", UtilMisc.toList("quantity"));
+    double quantityIssued = 0;
+    for (subiter = issuances.iterator(); subiter.hasNext(); ) {
+        quantityIssued += subiter.next().getDouble("quantity").doubleValue();
+    }
+    data.put("quantityIssued", new Double(quantityIssued));
+
+    // compute open
+    data.put("quantityOpen", new Double(quantityNet - quantityIssued));
+
+    reportData.add(data);
+}
+
+context.put("orderItems", reportData);

Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?view=diff&rev=450266&r1=450265&r2=450266
==============================================================================
--- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original)
+++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Tue Sep 26 17:26:12 2006
@@ -943,6 +943,9 @@
     <request-map uri="SalesByStoreReport.pdf"><security https="true" auth="true"/>
         <response name="success" type="view" value="SalesByStoreReport"/>
     </request-map>
+    <request-map uri="OpenOrderItemsReport"><security https="true" auth="true"/>
+        <response name="success" type="view" value="OpenOrderItemsReport"/>
+    </request-map>
     <request-map uri="PurchasesByOrganizationReport.pdf"><security https="true" auth="true"/>
         <response name="success" type="view" value="PurchasesByOrganizationReport"/>
     </request-map>
@@ -1436,6 +1439,7 @@
     <view-map name="OrderPurchaseReportPayment" type="screenfop" page="component://order/widget/ordermgr/ReportScreens.xml#OrderPurchaseReportPayment" content-type="application/pdf" encoding="none"/>
     <view-map name="OrderPurchaseReportProduct" type="screenfop" page="component://order/widget/ordermgr/ReportScreens.xml#OrderPurchaseReportProduct" content-type="application/pdf" encoding="none"/>
     <view-map name="SalesByStoreReport" type="screenfop" page="component://order/widget/ordermgr/ReportScreens.xml#SalesByStoreReport" content-type="application/pdf" encoding="none"/>
+    <view-map name="OpenOrderItemsReport" type="screen" page="component://order/widget/ordermgr/ReportScreens.xml#OpenOrderItemsReport"/>
     <view-map name="PurchasesByOrganizationReport" type="screenfop" page="component://order/widget/ordermgr/ReportScreens.xml#PurchasesByOrganizationReport" content-type="application/pdf" encoding="none"/>
 
     <view-map name="FindRequirements" type="screen" page="component://order/widget/ordermgr/RequirementScreens.xml#FindRequirements"/>

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=450266&r1=450265&r2=450266
==============================================================================
--- incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportForms.xml (original)
+++ incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportForms.xml Tue Sep 26 17:26:12 2006
@@ -99,6 +99,49 @@
         <field name="submitButton" title="${uiLabelMap.CommonRun}" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
 
+    <!-- form for generating a report of open order items -->
+    <form name="OpenOrderItemsReport" type="single" target="OpenOrderItemsReport" title=""
+            default-title-style="tableheadtext" default-widget-style="inputBox" default-tooltip-style="tabletext">
+        <field name="productStoreId">
+            <drop-down allow-empty="false">
+                <option key="" description="- ${uiLabelMap.CommonSelectAny} -"/>
+                <entity-options entity-name="ProductStore" description="${storeName} [${productStoreId}]">
+                    <entity-order-by field-name="storeName"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="orderTypeId">
+            <drop-down allow-empty="false">
+                <option key="SALES_ORDER" description="${uiLabelMap.OrderSalesOrder}"/>
+                <option key="PURCHASE_ORDER" description="${uiLabelMap.OrderPurchaseOrder}"/>
+            </drop-down>
+        </field>
+        <field name="orderStatusId">
+            <drop-down allow-empty="false">
+                <option key="" description="- ${uiLabelMap.CommonSelectAny} -"/>
+                <entity-options entity-name="StatusItem" description="${description}" key-field-name="statusId">
+                    <entity-constraint name="statusTypeId" operator="equals" value="ORDER_STATUS"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="submitButton" title="${uiLabelMap.CommonRun}" widget-style="smallSubmit"><submit button-type="button"/></field>
+    </form>
+
+    <!-- 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="orderId" title="${uiLabelMap.OrderOrderId}" widget-style="buttontext">
+             <hyperlink target="orderview?$orderId=${orderId}" description="${orderId}"/>
+         </field>
+         <field name="productId" title="${uiLabelMap.ProductProduct}"><display/></field>
+         <field name="quantityNet" title="${uiLabelMap.ProductQuantity}"><display/></field>
+         <field name="quantityIssued" title="${uiLabelMap.OrderQtyShipped}"><display/></field>
+         <field name="quantityOpen" title="${uiLabelMap.ProductOpenQuantity}"><display/></field>
+         <field name="shipAfterDate" title="${uiLabelMap.OrderShipAfterDate}"><display/></field>
+         <field name="shipBeforeDate" title="${uiLabelMap.OrderShipBeforeDate}"><display/></field>
+         <field name="comments" title="${uiLabelMap.CommonComments}"><display/></field>
+    </form>
+
     <!-- form for generating a report of total product purchases (quantity and value) -->
     <form name="PurchasesByOrganizationReport" type="single" target="PurchasesByOrganizationReport.pdf" title=""
             default-title-style="tableheadtext" default-widget-style="inputBox" default-tooltip-style="tabletext">

Modified: incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportScreens.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportScreens.xml?view=diff&rev=450266&r1=450265&r2=450266
==============================================================================
--- incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportScreens.xml (original)
+++ incubator/ofbiz/trunk/applications/order/widget/ordermgr/ReportScreens.xml Tue Sep 26 17:26:12 2006
@@ -36,6 +36,10 @@
                             <include-form name="SalesByStoreReport" location="component://order/widget/ordermgr/ReportForms.xml"/>
                         </container>
                         <container>
+                            <label style="head2" text="${uiLabelMap.OrderReportOpenOrderItems}"/>
+                            <include-form name="OpenOrderItemsReport" location="component://order/widget/ordermgr/ReportForms.xml"/>
+                        </container>
+                        <container>
                             <label style="head2" text="${uiLabelMap.OrderReportPurchasesByOrganization}"/>
                             <include-form name="PurchasesByOrganizationReport" location="component://order/widget/ordermgr/ReportForms.xml"/>
                         </container>
@@ -171,6 +175,25 @@
                     <!-- NOTE: this is really generating XSL:FO, but the HTML oriented renderer should do fine, the screen will need to be called differently though to get binary output from it -->
                     <html><html-template location="component://order/webapp/ordermgr/reports/SalesByStoreReport.fo.ftl"/></html>
                 </platform-specific>
+            </widgets>
+        </section>
+    </screen>
+
+    <!-- generates report of open order items -->
+    <screen name="OpenOrderItemsReport">
+        <section>
+            <actions>
+                <set field="titleProperty" value="OrderReportOpenOrderItems"/>
+                <set field="headerItem" value="reports"/>
+                <script location="component://order/webapp/ordermgr/WEB-INF/actions/reports/OpenOrderItemsReport.bsh"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
+                    <decorator-section name="body">
+                        <label style="head2" text="${uiLabelMap.OrderReportOpenOrderItems} - ${productStore.storeName}"/>
+                        <include-form name="OpenOrderItemsList" location="component://order/widget/ordermgr/ReportForms.xml"/>
+                    </decorator-section>
+                </decorator-screen>
             </widgets>
         </section>
     </screen>

Modified: incubator/ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=450266&r1=450265&r2=450266
==============================================================================
--- incubator/ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ incubator/ofbiz/trunk/applications/product/config/ProductUiLabels.properties Tue Sep 26 17:26:12 2006
@@ -846,6 +846,7 @@
 ProductOemProductId=ID at the manufacturer
 ProductOneInventoryFacility=One Inventory Facility
 ProductOnlyAppliesWithinSpan=only applies if within span
+ProductOpenQuantity=Open
 ProductOptional=Optional
 ProductOptionalCreateNew=optional will create new if empty
 ProductOptionalExpirationDate=Optional Expiration Date