Author: jonesde
Date: Wed Mar 7 09:01:23 2007 New Revision: 515648 URL: http://svn.apache.org/viewvc?view=rev&rev=515648 Log: Applied patch from Anil Patel in OFBIZ-693; small improvement in lead time display when not in stock changed to use availableToPromiseTotal; added caching support for productsummary call to make it perform reasonably Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productdetail.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productsummary.bsh ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml ofbiz/trunk/applications/product/servicedef/services_facility.xml Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productdetail.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productdetail.bsh?view=diff&rev=515648&r1=515647&r2=515648 ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productdetail.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productdetail.bsh Wed Mar 7 09:01:23 2007 @@ -206,9 +206,26 @@ // get the days to ship facilityId = productStore.getString("inventoryFacilityId"); - productFacility = delegator.findByPrimaryKeyCache("ProductFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId)); + /*productFacility = delegator.findByPrimaryKeyCache("ProductFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId)); if (productFacility != null && productFacility.get("daysToShip") != null) { context.put("daysToShip", productFacility.get("daysToShip")); + }*/ + + resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId",productId, "facilityId", facilityId, "useCache", false)); + totalAvailableToPromise = resultOutput.get("availableToPromiseTotal"); + if(totalAvailableToPromise != null && totalAvailableToPromise.doubleValue() > 0) { + productFacility = delegator.findByPrimaryKeyCache("ProductFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId)); + if (productFacility != null && productFacility.get("daysToShip") != null) { + context.put("daysToShip", productFacility.get("daysToShip")); + } + } else { + supplierProducts=delegator.findByAndCache("SupplierProduct", UtilMisc.toMap("productId", productId),UtilMisc.toList("-availableFromDate")); + supplierProduct = EntityUtil.getFirst(supplierProducts); + if (supplierProduct != null && supplierProduct.get("standardLeadTimeDays") != null) { + Double standardLeadTimeDays = supplierProduct.get("standardLeadTimeDays"); + double daysToShip = standardLeadTimeDays.doubleValue()+1; + context.put("daysToShip", new Double(daysToShip)); + } } // get the product distinguishing features Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productsummary.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productsummary.bsh?view=diff&rev=515648&r1=515647&r2=515648 ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productsummary.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productsummary.bsh Wed Mar 7 09:01:23 2007 @@ -24,12 +24,14 @@ import org.ofbiz.base.util.*; import org.ofbiz.entity.*; +import org.ofbiz.entity.util.*; import org.ofbiz.service.*; import org.ofbiz.product.product.ProductContentWrapper; import org.ofbiz.product.catalog.*; import org.ofbiz.product.store.*; import org.ofbiz.order.shoppingcart.*; + //either optProduct, optProductId or productId must be specified product = request.getAttribute("optProduct"); optProductId = request.getAttribute("optProductId"); @@ -60,12 +62,23 @@ if (product == null && productId != null) { product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId)); } -if (product != null) { - productFacility = delegator.findByPrimaryKeyCache("ProductFacility", UtilMisc.toMap("productId", product.get("productId"), "facilityId", facilityId)); - if (productFacility != null && productFacility.get("daysToShip") != null) { - context.put("daysToShip", productFacility.get("daysToShip")); +if (product != null) { + resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId",product.get("productId"), "facilityId", facilityId, "useCache", true)); + totalAvailableToPromise = resultOutput.get("availableToPromiseTotal"); + if(totalAvailableToPromise != null && totalAvailableToPromise.doubleValue() > 0) { + productFacility = delegator.findByPrimaryKeyCache("ProductFacility", UtilMisc.toMap("productId", product.get("productId"), "facilityId", facilityId)); + if (productFacility != null && productFacility.get("daysToShip") != null) { + context.put("daysToShip", productFacility.get("daysToShip")); + } + } else { + supplierProducts=delegator.findByAndCache("SupplierProduct", UtilMisc.toMap("productId", product.get("productId")),UtilMisc.toList("-availableFromDate")); + supplierProduct = EntityUtil.getFirst(supplierProducts); + if (supplierProduct != null && supplierProduct.get("standardLeadTimeDays") != null) { + Double standardLeadTimeDays = supplierProduct.get("standardLeadTimeDays"); + double daysToShip = standardLeadTimeDays.doubleValue()+1; + context.put("daysToShip", new Double(daysToShip)); + } } - // make the productContentWrapper ProductContentWrapper productContentWrapper = new ProductContentWrapper(product, request); context.put("productContentWrapper", productContentWrapper); Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml?view=diff&rev=515648&r1=515647&r2=515648 ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml Wed Mar 7 09:01:23 2007 @@ -417,7 +417,12 @@ </if-compare> <!-- 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" --> + <if-compare field-name="parameters.useCache" operator="equals" value="true" type="Boolean"> + <find-by-and entity-name="InventoryItem" map-name="lookupFieldMap" list-name="inventoryItems" use-cache="true"/> + <else> + <find-by-and entity-name="InventoryItem" map-name="lookupFieldMap" list-name="inventoryItems" use-cache="false"/> + </else> + </if-compare> <set field="parameters.availableToPromiseTotal" value="0" type="Double"/> <set field="parameters.quantityOnHandTotal" value="0" type="Double"/> Modified: ofbiz/trunk/applications/product/servicedef/services_facility.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_facility.xml?view=diff&rev=515648&r1=515647&r2=515648 ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_facility.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_facility.xml Wed Mar 7 09:01:23 2007 @@ -119,6 +119,7 @@ <attribute name="productId" type="String" mode="IN" optional="false"/> <attribute name="quantityOnHandTotal" type="Double" mode="OUT" optional="false"/> <attribute name="availableToPromiseTotal" type="Double" mode="OUT" optional="false"/> + <attribute name="useCache" type="Boolean" mode="IN" optional="true"/> </service> <service name="getInventoryAvailableByFacility" engine="simple" location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="getProductInventoryAvailable" auth="false" use-transaction="false"> @@ -127,6 +128,7 @@ <attribute name="facilityId" type="String" mode="IN" optional="false"/> <attribute name="quantityOnHandTotal" type="Double" mode="OUT" optional="false"/> <attribute name="availableToPromiseTotal" type="Double" mode="OUT" optional="false"/> + <attribute name="useCache" type="Boolean" mode="IN" optional="true"/> </service> <service name="getInventoryAvailableByLocation" engine="simple" location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="getProductInventoryAvailable" auth="false"> @@ -136,6 +138,7 @@ <attribute name="locationSeqId" type="String" mode="IN" optional="false"/> <attribute name="quantityOnHandTotal" type="Double" mode="OUT" optional="false"/> <attribute name="availableToPromiseTotal" type="Double" mode="OUT" optional="false"/> + <attribute name="useCache" type="Boolean" mode="IN" optional="true"/> </service> <service name="getInventoryAvailableByContainer" engine="simple" location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="getProductInventoryAvailable" auth="false" use-transaction="false"> @@ -151,6 +154,7 @@ <attribute name="inventoryItemId" type="String" mode="IN" optional="false"/> <attribute name="quantityOnHandTotal" type="Double" mode="OUT" optional="false"/> <attribute name="availableToPromiseTotal" type="Double" mode="OUT" optional="false"/> + <attribute name="useCache" type="Boolean" mode="IN" optional="true"/> </service> <service name="getProductInventoryAvailableFromAssocProducts" engine="java" location="org.ofbiz.product.inventory.InventoryServices" invoke="getProductInventoryAvailableFromAssocProducts" auth="false" use-transaction="false"> |
Free forum by Nabble | Edit this page |