Approved requirements list now shows the quantity sold of each product. It reports the last 6 months of sales.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@501970 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Si Chen
2007-01-31 20:00:42 +00:00
parent 0053a16e64
commit 25215a95b9
3 changed files with 28 additions and 1 deletions
@@ -766,6 +766,7 @@ under the License.
<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"/>
@@ -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 @@ public class RequirementServices {
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(); ) {
@@ -130,6 +135,26 @@ public class RequirementServices {
}
}
// 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
quantity += requirement.getDouble("quantity").doubleValue();
products.add(productId);
@@ -306,11 +306,12 @@ under the License.
<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>