Author: jacopoc
Date: Mon Jul 31 03:48:58 2006 New Revision: 427070 URL: http://svn.apache.org/viewvc?rev=427070&view=rev Log: Refactored the way the units of marketing packages that can be assembled from components in warehouse are computed; there is now a separate service "getMktgPackagesAvailable" that must be explicitly invoked. This should solve the issues recently reported by Si Chen. Modified: incubator/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml incubator/ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml incubator/ofbiz/trunk/applications/product/servicedef/services_facility.xml incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductInventoryItems.bsh incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh Modified: incubator/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml?rev=427070&r1=427069&r2=427070&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml (original) +++ incubator/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml Mon Jul 31 03:48:58 2006 @@ -402,43 +402,6 @@ <!-- we might get away with a cache here since real serious errors will occur during the reservation service... but only if we need the speed --> <find-by-and entity-name="InventoryItem" map-name="lookupFieldMap" list-name="inventoryItems"/> <!-- use-cache="true" --> - <!-- first check if this item is a MARKETING_PKG_AUTO and, if so, call another service to get the results --> - <if-not-empty field-name="productId" map-name="parameters"> - <!-- find components of the MARKETING_PKG_AUTO for this product --> - <set from-field="parameters.productId" field="lookupMktgPkgParams.productId"/> - <set value="MARKETING_PKG_AUTO" field="lookupMktgPkgParams.type"/> - <call-service service-name="getAssociatedProducts" in-map-name="lookupMktgPkgParams"> - <result-to-field result-name="assocProducts"/> - </call-service> - <!-- if there are any MARKETING_PKG_AUTO components, then the ATP and QOH are based on the quantities of those component - products and found with another service --> - <if-not-empty field-name="assocProducts"> - <set from-field="assocProducts" field="inventoryByAssocProductsParams.assocProducts"/> - <call-service service-name="getProductInventoryAvailablefromAssocProducts" in-map-name="inventoryByAssocProductsParams"> - <result-to-result result-name="quantityOnHandTotal"/> - <result-to-result result-name="availableToPromiseTotal"/> - </call-service> - <return response-code="success"/> <!-- all done --> - </if-not-empty> - <!-- see if the product is of type MARKETING_PKG_AUTO, this is another type of marketing package --> - <entity-one entity-name="Product" value-name="product"/> - <set from-field="parameters.productId" field="lookupMktgPkgParams.productId"/> - <set value="MANUF_COMPONENT" field="lookupMktgPkgParams.type"/> - <call-service service-name="getAssociatedProducts" in-map-name="lookupMktgPkgParams"> - <result-to-field result-name="assocProducts"/> - </call-service> - <!-- if there are any MANUF_COMPONENT components, then the ATP and QOH are based on the quantities of those component - products and found with another service --> - <if-not-empty field-name="assocProducts"> - <set from-field="assocProducts" field="inventoryByAssocProductsParams.assocProducts"/> - <call-service service-name="getProductInventoryAvailablefromAssocProducts" in-map-name="inventoryByAssocProductsParams"> - <result-to-result result-name="quantityOnHandTotal"/> - <result-to-result result-name="availableToPromiseTotal"/> - </call-service> - <return response-code="success"/> <!-- all done --> - </if-not-empty> - </if-not-empty> - <set field="parameters.availableToPromiseTotal" value="0" type="Double"/> <set field="parameters.quantityOnHandTotal" value="0" type="Double"/> <iterate entry-name="inventoryItem" list-name="inventoryItems"> @@ -480,6 +443,28 @@ <field-to-result field-name="availableToPromiseTotal" map-name="parameters"/> <field-to-result field-name="quantityOnHandTotal" map-name="parameters"/> + </simple-method> + + <simple-method method-name="getMktgPackagesAvailable" short-description="Get Marketing Packages Available From Components In Inventory" login-required="false" use-transaction="false"> + <set field="availableToPromiseTotal" value="0" type="Double"/> + <set field="quantityOnHandTotal" value="0" type="Double"/> + <set from-field="parameters.productId" field="lookupMktgPkgParams.productId"/> + <set value="MANUF_COMPONENT" field="lookupMktgPkgParams.type"/> + <call-service service-name="getAssociatedProducts" in-map-name="lookupMktgPkgParams"> + <result-to-field result-name="assocProducts"/> + </call-service> + <!-- if there are any MANUF_COMPONENT components, then the ATP and QOH are based on the quantities of those component + products and found with another service --> + <if-not-empty field-name="assocProducts"> + <set from-field="assocProducts" field="inventoryByAssocProductsParams.assocProducts"/> + <set from-field="parameters.facilityId" field="inventoryByAssocProductsParams.facilityId"/> + <call-service service-name="getProductInventoryAvailableFromAssocProducts" in-map-name="inventoryByAssocProductsParams"> + <result-to-field result-name="quantityOnHandTotal"/> + <result-to-field result-name="availableToPromiseTotal"/> + </call-service> + </if-not-empty> + <field-to-result field-name="availableToPromiseTotal"/> + <field-to-result field-name="quantityOnHandTotal"/> </simple-method> <simple-method method-name="getInventoryAlerts" short-description="getInventoryAlerts" login-required="false"> Modified: incubator/ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml?rev=427070&r1=427069&r2=427070&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml (original) +++ incubator/ofbiz/trunk/applications/product/script/org/ofbiz/product/store/ProductStoreServices.xml Mon Jul 31 03:48:58 2006 @@ -477,9 +477,16 @@ <set from-field="parameters.productId" field="callServiceMap.productId"/> <set from-field="productStore.inventoryFacilityId" field="callServiceMap.facilityId"/> - <call-service service-name="getInventoryAvailableByFacility" in-map-name="callServiceMap"> - <result-to-field result-name="availableToPromiseTotal"/> - </call-service> + <if-compare field-name="product.productTypeId" value="MARKETING_PKG_AUTO" operator="equals"> + <call-service service-name="getMktgPackagesAvailable" in-map-name="callServiceMap"> + <result-to-field result-name="availableToPromiseTotal"/> + </call-service> + <else> + <call-service service-name="getInventoryAvailableByFacility" in-map-name="callServiceMap"> + <result-to-field result-name="availableToPromiseTotal"/> + </call-service> + </else> + </if-compare> <!-- check to see if we got enough back... --> <if-compare-field field-name="availableToPromiseTotal" operator="greater-equals" to-field-name="parameters.quantity" type="Double"> @@ -503,9 +510,16 @@ <!-- Right now the answer is yes, it only succeeds if one facility has sufficient inventory for the order. --> <set from-field="parameters.productId" field="callServiceMap.productId"/> <set from-field="productStoreFacility.facilityId" field="callServiceMap.facilityId"/> - <call-service service-name="getInventoryAvailableByFacility" in-map-name="callServiceMap"> - <result-to-field result-name="availableToPromiseTotal"/> - </call-service> + <if-compare field-name="product.productTypeId" value="MARKETING_PKG_AUTO" operator="equals"> + <call-service service-name="getMktgPackagesAvailable" in-map-name="callServiceMap"> + <result-to-field result-name="availableToPromiseTotal"/> + </call-service> + <else> + <call-service service-name="getInventoryAvailableByFacility" in-map-name="callServiceMap"> + <result-to-field result-name="availableToPromiseTotal"/> + </call-service> + </else> + </if-compare> <clear-field field-name="callServiceMap"/> <if-compare-field field-name="availableToPromiseTotal" operator="greater-equals" to-field-name="parameters.quantity" type="Double"> Modified: incubator/ofbiz/trunk/applications/product/servicedef/services_facility.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/servicedef/services_facility.xml?rev=427070&r1=427069&r2=427070&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/product/servicedef/services_facility.xml (original) +++ incubator/ofbiz/trunk/applications/product/servicedef/services_facility.xml Mon Jul 31 03:48:58 2006 @@ -102,6 +102,14 @@ <override name="physicalInventoryId" mode="OUT"/> </service> + <service name="getMktgPackagesAvailable" engine="simple" + location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="getMktgPackagesAvailable" auth="false"> + <description>Get Marketing Packages Available From Components In Inventory</description> + <attribute name="productId" type="String" mode="IN" optional="false"/> + <attribute name="facilityId" type="String" mode="IN" optional="true"/> + <attribute name="quantityOnHandTotal" type="Double" mode="OUT" optional="false"/> + <attribute name="availableToPromiseTotal" type="Double" mode="OUT" optional="false"/> + </service> <service name="getProductInventoryAvailable" engine="simple" location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="getProductInventoryAvailable" auth="false"> <description>Get Inventory Availability for a Product</description> @@ -132,12 +140,13 @@ <attribute name="quantityOnHandTotal" type="Double" mode="OUT" optional="false"/> <attribute name="availableToPromiseTotal" type="Double" mode="OUT" optional="false"/> </service> - <service name="getProductInventoryAvailablefromAssocProducts" engine="java" - location="org.ofbiz.product.inventory.InventoryServices" invoke="getProductInventoryAvailablefromAssocProducts" auth="false"> + <service name="getProductInventoryAvailableFromAssocProducts" engine="java" + location="org.ofbiz.product.inventory.InventoryServices" invoke="getProductInventoryAvailableFromAssocProducts" auth="false"> <description> Get Inventory Availability for a product based on List of associated products, usually marketing package components. </description> + <attribute name="facilityId" type="String" mode="IN" optional="true"/> <attribute name="assocProducts" type="List" mode="IN" optional="false"/> <attribute name="quantityOnHandTotal" type="Double" mode="OUT" optional="false"/> <attribute name="availableToPromiseTotal" type="Double" mode="OUT" optional="false"/> Modified: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java?rev=427070&r1=427069&r2=427070&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java (original) +++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java Mon Jul 31 03:48:58 2006 @@ -629,11 +629,12 @@ * Get Inventory Available for a Product based on the list of associated products. The final ATP and QOH will * be the minimum of all the associated products' inventory divided by their ProductAssoc.quantity * */ - public static Map getProductInventoryAvailablefromAssocProducts(DispatchContext dctx, Map context) { + public static Map getProductInventoryAvailableFromAssocProducts(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); List productAssocList = (List) context.get("assocProducts"); - + String facilityId = (String)context.get("facilityId"); + Double availableToPromiseTotal = new Double(0); Double quantityOnHandTotal = new Double(0); @@ -657,7 +658,13 @@ // figure out the inventory available for this associated product Map resultOutput = null; try { - resultOutput = dispatcher.runSync("getProductInventoryAvailable", UtilMisc.toMap("productId", productIdTo)); + Map inputMap = UtilMisc.toMap("productId", productIdTo); + if (facilityId != null) { + inputMap.put("facilityId", facilityId); + resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", inputMap); + } else { + resultOutput = dispatcher.runSync("getProductInventoryAvailable", inputMap); + } } catch (GenericServiceException e) { Debug.logError(e, "Problems getting inventory available by facility", module); return ServiceUtil.returnError(e.getMessage()); @@ -721,6 +728,14 @@ String productId = orderItem.getString("productId"); if ((productId == null) || productId.equals("")) continue; + + GenericValue product = null; + try { + product = orderItem.getRelatedOne("Product"); + } catch (GenericEntityException e) { + Debug.logError(e, "Couldn't get product.", module); + return ServiceUtil.returnError("Unable to retrive product with id [" + productId + "]"); + } double atp = 0.0; double qoh = 0.0; @@ -730,7 +745,11 @@ Map params = UtilMisc.toMap("productId", productId, "facilityId", facility.getString("facilityId")); Map invResult = null; try { - invResult = dispatcher.runSync("getInventoryAvailableByFacility", params); + if ("MARKETING_PKG_AUTO".equals(product.getString("productTypeId"))) { + invResult = dispatcher.runSync("getMktgPackagesAvailable", params); + } else { + invResult = dispatcher.runSync("getInventoryAvailableByFacility", params); + } } catch (GenericServiceException e) { String msg = "Could not find inventory for facility [" + facility.getString("facilityId") + "]"; Debug.logError(e, msg, module); 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?rev=427070&r1=427069&r2=427070&view=diff ============================================================================== --- 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 Mon Jul 31 03:48:58 2006 @@ -77,8 +77,12 @@ // are obtained (calling the "getInventoryAvailableByFacility" service) while (facilityIterator.hasNext()) { facility = facilityIterator.next(); - contextInput = UtilMisc.toMap("productId",productId, "facilityId", facility.getString("facilityId")); - resultOutput = dispatcher.runSync("getInventoryAvailableByFacility",contextInput); + contextInput = UtilMisc.toMap("productId", productId, "facilityId", facility.getString("facilityId")); + if ("MARKETING_PKG_AUTO".equals(product.getString("productTypeId"))) { + resultOutput = dispatcher.runSync("getMktgPackagesAvailable", contextInput); + } else { + resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", contextInput); + } quantitySummary = new HashMap(); quantitySummary.put("facilityId", facility.getString("facilityId")); quantitySummary.put("totalQuantityOnHand", resultOutput.get("quantityOnHandTotal")); 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?rev=427070&r1=427069&r2=427070&view=diff ============================================================================== --- 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 Mon Jul 31 03:48:58 2006 @@ -109,7 +109,12 @@ while (prodsIt.hasNext()) { oneProd = prodsIt.next(); contextInput = UtilMisc.toMap("productId",oneProd.getString("productId"), "facilityId", facilityId); - resultOutput = dispatcher.runSync("getInventoryAvailableByFacility",contextInput); + GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId",oneProd.getString("productId"))); + if ("MARKETING_PKG_AUTO".equals(product.getString("productTypeId"))) { + resultOutput = dispatcher.runSync("getMktgPackagesAvailable", contextInput); + } else { + resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", contextInput); + } // qty minimumStockInt = 0; if (oneProd.get("minimumStock") != null) { |
Free forum by Nabble | Edit this page |