Author: jleroux
Date: Fri Mar 23 20:47:20 2012
New Revision: 1304589
URL: http://svn.apache.org/viewvc?rev=1304589&view=rev
Log:
A patch from Kiran Gawde "Category Detail, Out of Stock check doesn't take
into account Marketing Package and multiple facilities"
https://issues.apache.org/jira/browse/OFBIZ-4525
Modified:
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy
Modified:
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy?rev=1304589&r1=1304588&r2=1304589&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy
(original)
+++
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy
Fri Mar 23 20:47:20 2012
@@ -24,6 +24,8 @@
import org.ofbiz.base.util.*;
import org.ofbiz.entity.*;
+import org.ofbiz.entity.condition.*;
+import org.ofbiz.entity.util.*;
import org.ofbiz.service.*;
import org.ofbiz.product.catalog.*;
import org.ofbiz.product.category.CategoryContentWrapper;
@@ -68,10 +70,27 @@ if(productStore) {
if("N".equals(productStore.showOutOfStockProducts)) {
productsInStock = [];
productCategoryMembers.each { productCategoryMember ->
- productFacility = delegator.findOne("ProductFacility", [productId
: productCategoryMember.productId, facilityId :
productStore.inventoryFacilityId], true);
- if(productFacility) {
- if(productFacility.lastInventoryCount >= 1) {
+ product = delegator.findByPrimaryKeyCache("Product", [productId :
productCategoryMember.productId]);
+ boolean isMarketingPackage =
EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId",
product.productTypeId, "parentTypeId", "MARKETING_PKG");
+ context.isMarketingPackage = (isMarketingPackage? "true": "false");
+ if (isMarketingPackage) {
+ resultOutput = dispatcher.runSync("getMktgPackagesAvailable",
[productId : productCategoryMember.productId]);
+ availableInventory = resultOutput.availableToPromiseTotal;
+ if(availableInventory>0)
productsInStock.add(productCategoryMember);
+ } else {
+ facilities = delegator.findList("ProductFacility",
EntityCondition.makeCondition([productId : productCategoryMember.productId]),
null, null, null, false);
+ availableInventory = 0.0;
+ if(facilities) {
+ facilities.each { facility ->
+ lastInventoryCount = facility.lastInventoryCount;
+ if (lastInventoryCount != null) {
+ availableInventory += lastInventoryCount;
+ }
+ }
+ if (availableInventory > 0) {
+ productsInStock.add(productCategoryMember);
+ }
}
}
}