You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2011/11/14 23:31:29 UTC

svn commit: r1201941 - /ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy

Author: jleroux
Date: Mon Nov 14 22:31:28 2011
New Revision: 1201941

URL: http://svn.apache.org/viewvc?rev=1201941&view=rev
Log:
A patch from Kiran Gawde https://issues.apache.org/jira/browse/OFBIZ-4526 "ProductDetail page inStock check doesn't take into account Marketing Package"

With http://localhost:8080/ecommerce/gizmo-basket-GZ-BASKET-p, for testing, set requireInventory="Y" for store. You will see 'Out of stock' for marketing package without the fix.

Modified:
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy?rev=1201941&r1=1201940&r2=1201941&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy Mon Nov 14 22:31:28 2011
@@ -91,6 +91,10 @@ if (product) {
     productId = product.productId;
     context.product_id = productId;
     productTypeId = product.productTypeId;
+
+    boolean isMarketingPackage = EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG");
+    context.isMarketingPackage = (isMarketingPackage? "true": "false");
+
     featureTypes = [:];
     featureOrder = [];
 
@@ -548,14 +552,21 @@ if (product) {
         }
     }
 
-    //get last inventory count from product facility for the product
-    facilities = delegator.findList("ProductFacility", EntityCondition.makeCondition([productId : product.productId]), null, null, null, false);
     availableInventory = 0.0;
-    if(facilities) {
-        facilities.each { facility ->
-            lastInventoryCount = facility.lastInventoryCount;
-            if (lastInventoryCount != null && availableInventory.compareTo(lastInventoryCount) != 0) {
-                availableInventory += lastInventoryCount;
+
+    // if the product is a MARKETING_PKG_AUTO/PICK, then also get the quantity which can be produced from components
+    if (isMarketingPackage) {
+        resultOutput = dispatcher.runSync("getMktgPackagesAvailable", [productId : productId]);
+        availableInventory = resultOutput.availableToPromiseTotal;
+    } else {
+        //get last inventory count from product facility for the product
+        facilities = delegator.findList("ProductFacility", EntityCondition.makeCondition([productId : product.productId]), null, null, null, false)
+        if(facilities) {
+            facilities.each { facility ->
+                lastInventoryCount = facility.lastInventoryCount;
+                if (lastInventoryCount != null) {
+                    availableInventory += lastInventoryCount;
+                }
             }
         }
     }