Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
719 posts
|
Author: sichen
Date: Wed Sep 20 18:28:10 2006 New Revision: 448425 URL: http://svn.apache.org/viewvc?view=rev&rev=448425 Log: New InventoryWorker class to figure out quantity of product on outstanding POs. Re-factored product inventory page in catalog manager to use it. Added column to show quantity on order for facility inventory Added: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java Modified: incubator/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.bsh incubator/ofbiz/trunk/applications/product/webapp/catalog/product/ProductForms.xml incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh incubator/ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml Modified: incubator/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml?view=diff&rev=448425&r1=448424&r2=448425 ============================================================================== --- incubator/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml (original) +++ incubator/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml Wed Sep 20 18:28:10 2006 @@ -57,6 +57,7 @@ <alias entity-alias="OI" name="orderItemSeqId"/> <alias entity-alias="OI" name="productId"/> <alias entity-alias="OI" name="quantity"/> + <alias entity-alias="OI" name="cancelQuantity"/> <alias entity-alias="OI" name="unitPrice"/> <alias entity-alias="OI" name="unitListPrice"/> <alias entity-alias="OI" name="itemDescription"/> Added: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java?view=auto&rev=448425 ============================================================================== --- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java (added) +++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java Wed Sep 20 18:28:10 2006 @@ -0,0 +1,92 @@ +/* + * 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. + */ + +package org.ofbiz.product.inventory; + +import java.util.List; +import java.util.Iterator; + +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.condition.EntityConditionList; +import org.ofbiz.entity.condition.EntityExpr; +import org.ofbiz.entity.condition.EntityOperator; + +public class InventoryWorker { + + public final static String module = InventoryWorker.class.getName(); + + /** + * Finds all outstanding Purchase orders for a productId. The orders and the items cannot be completed, cancelled, or rejected + * @param productId + * @param delegator + * @return + */ + public static List getOutstandingPurchaseOrders(String productId, GenericDelegator delegator) { + try { + List purchaseOrderConditions = UtilMisc.toList(new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"), + new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED"), + new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"), + new EntityExpr("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_COMPLETED"), + new EntityExpr("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED"), + new EntityExpr("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED")); + purchaseOrderConditions.add(new EntityExpr("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER")); + purchaseOrderConditions.add(new EntityExpr("productId", EntityOperator.EQUALS, productId)); + List purchaseOrders = delegator.findByCondition("OrderHeaderAndItems", new EntityConditionList(purchaseOrderConditions, EntityOperator.AND), + null, UtilMisc.toList("estimatedDeliveryDate DESC", "orderDate")); + return purchaseOrders; + } catch (GenericEntityException ex) { + Debug.logError("Unable to find outstanding purchase orders for product [" + productId + "] due to " + ex.getMessage() + " - returning null", module); + return null; + } + } + + /** + * Finds the net outstanding ordered quantity for a productId, netting quantity on outstanding purchase orders against cancelQuantity + * @param productId + * @param delegator + * @return + */ + public static double getOutstandingPurchasedQuantity(String productId, GenericDelegator delegator) { + double qty = 0.0; + List purchaseOrders = getOutstandingPurchaseOrders(productId, delegator); + if (UtilValidate.isEmpty(purchaseOrders)) { + return qty; + } else { + for (Iterator pOi = purchaseOrders.iterator(); pOi.hasNext();) { + GenericValue nextOrder = (GenericValue) pOi.next(); + if (nextOrder.get("quantity") != null) { + double itemQuantity = nextOrder.getDouble("quantity").doubleValue(); + double cancelQuantity = 0.0; + if (nextOrder.get("cancelQuantity") != null) { + cancelQuantity = nextOrder.getDouble("cancelQuantity").doubleValue(); + } + itemQuantity -= cancelQuantity; + if (itemQuantity >= 0.0) { + qty += itemQuantity; + } + } + } + } + + return qty; + } + +} \ No newline at end of file Modified: incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.bsh?view=diff&rev=448425&r1=448424&r2=448425 ============================================================================== --- incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.bsh (original) +++ incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.bsh Wed Sep 20 18:28:10 2006 @@ -22,6 +22,7 @@ import org.ofbiz.base.util.*; import org.ofbiz.widget.html.*; import org.ofbiz.securityext.login.*; +import org.ofbiz.product.inventory.InventoryWorker; //If product is virtual gather summary data from variants if (product.getString("isVirtual") != null && product.getString("isVirtual").equals("Y")) { @@ -152,17 +153,8 @@ showEmpty = "true".equals(request.getParameter("showEmpty")); - // Find oustanding purchase orders for this item. The orders and the items cannot be completed, cancelled, or rejected - purchaseOrderConditions = UtilMisc.toList(new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"), - new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED"), - new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"), - new EntityExpr("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_COMPLETED"), - new EntityExpr("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED"), - new EntityExpr("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED")); - purchaseOrderConditions.add(new EntityExpr("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER")); - purchaseOrderConditions.add(new EntityExpr("productId", EntityOperator.EQUALS, productId)); - purchaseOrders = delegator.findByCondition("OrderHeaderAndItems", new EntityConditionList(purchaseOrderConditions, EntityOperator.AND), - null, UtilMisc.toList("estimatedDeliveryDate DESC", "orderDate")); + // Find oustanding purchase orders for this item. + purchaseOrders = InventoryWorker.getOutstandingPurchaseOrders(productId, delegator); context.put("productInventoryItems", productInventoryItems); context.put("quantitySummaryByFacility", quantitySummaryByFacility); Modified: incubator/ofbiz/trunk/applications/product/webapp/catalog/product/ProductForms.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/catalog/product/ProductForms.xml?view=diff&rev=448425&r1=448424&r2=448425 ============================================================================== --- incubator/ofbiz/trunk/applications/product/webapp/catalog/product/ProductForms.xml (original) +++ incubator/ofbiz/trunk/applications/product/webapp/catalog/product/ProductForms.xml Wed Sep 20 18:28:10 2006 @@ -920,6 +920,7 @@ <field name="orderId"><hyperlink also-hidden="false" description="${orderId}" target="/ordermgr/control/orderview?orderId=${orderId}" target-type="inter-app"/></field> <field name="orderItemSeqId"><display/></field> <field name="quantity"><display/></field> + <field name="cancelQuantity"><display/></field> <field name="itemStatusId"><display/></field> <field name="estimatedShipDate"><display/></field> <field name="estimatedDeliveryDate"><display/></field> Modified: incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh?view=diff&rev=448425&r1=448424&r2=448425 ============================================================================== --- incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh (original) +++ incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh Wed Sep 20 18:28:10 2006 @@ -24,6 +24,7 @@ import org.ofbiz.entity.model.DynamicViewEntity; import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.util.EntityFindOptions; +import org.ofbiz.product.inventory.*; import org.ofbiz.widget.html.*; @@ -173,7 +174,9 @@ } offsetATPQtyAvailable = availableToPromiseTotalInt - minimumStockInt; if (hasOffsetATP && offsetATPQtyAvailable > offsetATP) continue; - + + quantityOnOrder = InventoryWorker.getOutstandingPurchasedQuantity(oneProd.getString("productId"), delegator); + oneInventory = new HashMap(); oneInventory.put("productId", oneProd.getString("productId")); oneInventory.put("minimumStock", oneProd.getString("minimumStock")); @@ -183,6 +186,7 @@ oneInventory.put("totalAvailableToPromise", resultOutput.get("availableToPromiseTotal")); oneInventory.put("offsetQOHQtyAvailable", offsetQOHQtyAvailable); oneInventory.put("offsetATPQtyAvailable", offsetATPQtyAvailable); + oneInventory.put("quantityOnOrder", quantityOnOrder); rows.add(oneInventory); } Modified: incubator/ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml?view=diff&rev=448425&r1=448424&r2=448425 ============================================================================== --- incubator/ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml (original) +++ incubator/ofbiz/trunk/applications/product/webapp/facility/facility/FacilityForms.xml Wed Sep 20 18:28:10 2006 @@ -80,6 +80,7 @@ <field name="totalQuantityOnHand" title="${uiLabelMap.CommonTotal} ${uiLabelMap.ProductQoh}" widget-area-style="tabletextright"><display/></field> <field name="offsetQOHQtyAvailable" title="${uiLabelMap.ProductQtyOffsetQOH}" widget-area-style="tabletextright"><display/></field> <field name="offsetATPQtyAvailable" title="${uiLabelMap.ProductQtyOffsetATP}" widget-area-style="tabletextright"><display/></field> + <field name="quantityOnOrder" title="${uiLabelMap.ProductOrderedQuantity}" widget-area-style="tabletextright"><display/></field> </form> <form name="SearchInventoryItemsParams" type="single" target="SearchInventoryItems" |
Free forum by Nabble | Edit this page |