Author: sichen
Date: Wed Jan 31 12:00:42 2007
New Revision: 501970

URL: http://svn.apache.org/viewvc?view=rev&rev=501970
Log:
Approved requirements list now shows the quantity sold of each product.  It 
reports the last 6 months of sales.

Modified:
    ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml
    
ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
    
ofbiz/trunk/applications/order/webapp/ordermgr/requirement/RequirementForms.xml

Modified: ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml?view=diff&rev=501970&r1=501969&r2=501970
==============================================================================
--- ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml (original)
+++ ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml Wed Jan 31 
12:00:42 2007
@@ -766,6 +766,7 @@
       <member-entity entity-alias="II" entity-name="ItemIssuance"/>
       <alias entity-alias="OH" name="orderTypeId" group-by="true"/>
       <alias entity-alias="OH" name="orderStatusId" field="statusId" 
group-by="false"/>
+      <alias entity-alias="OH" name="orderDate" group-by="false"/>
       <alias entity-alias="OI" name="orderItemStatusId" field="statusId" 
group-by="false"/>
       <alias entity-alias="OI" name="productId" group-by="true"/>
       <alias entity-alias="II" name="issuedDateTime" group-by="false"/>

Modified: 
ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java?view=diff&rev=501970&r1=501969&r2=501970
==============================================================================
--- 
ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
 (original)
+++ 
ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
 Wed Jan 31 12:00:42 2007
@@ -19,6 +19,7 @@
 package org.ofbiz.order.requirement;
 
 import java.util.*;
+import java.sql.Timestamp;
 
 import javolution.util.FastList;
 import javolution.util.FastMap;
@@ -77,11 +78,15 @@
             Map suppliers = FastMap.newInstance();
             Map gids = FastMap.newInstance();
             Map inventories = FastMap.newInstance();
+            Map productsSold = FastMap.newInstance();
 
             // to count quantity and distinct products in list
             double quantity = 0.0;
             Set products = new HashSet();
 
+            // time period to count products ordered from, six months ago and 
the 1st of that month
+            Timestamp timePeriodStart = 
UtilDateTime.getMonthStart(UtilDateTime.nowTimestamp(), 0, -6);
+
             // join in fields with extra data about the suppliers and products
             List requirements = FastList.newInstance();
             for (Iterator iter = requirementAndRoles.iterator(); 
iter.hasNext(); ) {
@@ -128,6 +133,26 @@
                         union.put("qoh", inventory.get("quantityOnHandTotal"));
                         union.put("atp", 
inventory.get("availableToPromiseTotal"));
                     }
+                }
+
+                // how many of the products were sold (note this is for a 
fixed time period across all product stores)
+                Double sold = (Double) productsSold.get(productId);
+                if (sold == null) {
+                    EntityCondition prodConditions = new EntityConditionList( 
UtilMisc.toList(
+                                new EntityExpr("productId", 
EntityOperator.EQUALS, productId),
+                                new EntityExpr("orderTypeId", 
EntityOperator.EQUALS, "SALES_ORDER"),
+                                new EntityExpr("orderStatusId", 
EntityOperator.NOT_IN, UtilMisc.toList("ORDER_REJECTED", "ORDER_CANCELLED")),
+                                new EntityExpr("orderItemStatusId", 
EntityOperator.NOT_IN, UtilMisc.toList("ITEM_REJECTED", "ITEM_CANCELLED")),
+                                new EntityExpr("orderDate", 
EntityOperator.GREATER_THAN_EQUAL_TO, timePeriodStart)
+                                ), EntityOperator.AND);
+                    GenericValue count = EntityUtil.getFirst( 
delegator.findByCondition("OrderItemQuantityReportGroupByProduct", 
prodConditions, UtilMisc.toList("quantityOrdered"), null) );
+                    if (count != null) {
+                        sold = count.getDouble("quantityOrdered");
+                        if (sold != null) productsSold.put(productId, sold);
+                    }
+                }
+                if (sold != null) {
+                    union.put("qtySold", sold);
                 }
 
                 // keep a running total of distinct products and quantity to 
order

Modified: 
ofbiz/trunk/applications/order/webapp/ordermgr/requirement/RequirementForms.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/requirement/RequirementForms.xml?view=diff&rev=501970&r1=501969&r2=501970
==============================================================================
--- 
ofbiz/trunk/applications/order/webapp/ordermgr/requirement/RequirementForms.xml 
(original)
+++ 
ofbiz/trunk/applications/order/webapp/ordermgr/requirement/RequirementForms.xml 
Wed Jan 31 12:00:42 2007
@@ -306,11 +306,12 @@
         <field name="partyId" 
title="${uiLabelMap.ProductSupplier}"><display/></field>
         <field name="supplierProductId" 
title="${uiLabelMap.ProductSupplierProductId}"><display/></field>
         <field name="idValue" title="UPCA"><display/></field>
-        <field name="minimumOrderQuantity" 
widget-area-style="tabletextright"><display/></field>
+        <field name="minimumOrderQuantity" 
title="${uiLabelMap.FormFieldTitle_minimumOrderQuantity}" 
widget-area-style="tabletextright"><display/></field>
         <field name="lastPrice" widget-area-style="tabletextright"><display 
type="currency" currency="${currencyUomId}"/></field>
         <field name="requiredByDate"><display/></field>
         <field name="atp" title="${uiLabelMap.ProductAtp}" 
widget-area-style="tabletextright"><display/></field>
         <field name="qoh" title="${uiLabelMap.ProductQoh}" 
widget-area-style="tabletextright"><display/></field>
+        <field name="qtySold" title="${uiLabelMap.OrderQuantitySold}" 
widget-area-style="tabletextright"><display/></field>
         <field name="quantity"><text size="4"/></field>
         <field name="comments"><display/></field>
         <field name="_rowSubmit" 
title="${uiLabelMap.CommonSelect}"><check/></field>


Reply via email to