You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2009/09/03 02:29:04 UTC

svn commit: r810738 - in /ofbiz/trunk/applications/order: script/org/ofbiz/order/order/OrderServices.xml src/org/ofbiz/order/requirement/RequirementServices.java

Author: jonesde
Date: Thu Sep  3 00:29:04 2009
New Revision: 810738

URL: http://svn.apache.org/viewvc?rev=810738&view=rev
Log:
Changed code behind PRODRQM_ATP requirement method type so that if there is no ProductFacility record or if the minimumStock amount is null then 0 will be used so that items on backorder will get requirements by default; note that the requirement method on the ProductStore is NOT working so it must still be set on the Product

Modified:
    ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java

Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml?rev=810738&r1=810737&r2=810738&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml (original)
+++ ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml Thu Sep  3 00:29:04 2009
@@ -334,12 +334,17 @@
             <!-- get the ATP, QOH quantities and the product facility's minimum stock -->
             <call-simple-method method-name="getProductFacilityAndQuantities"/>
 
-            <if-not-empty field="productFacility">
+            <if-empty field="productFacility">
+                <set field="minimumStock" value="0"/>
+                <else>
+                    <set field="minimumStock" from-field="productFacility.minimumStock"/>
+                </else>
+            </if-empty>
             <!-- are we below minimum stock?  this service is supposed to be called after inventory is reserved, so inventory should have been updated already -->
-            <if-compare-field field="availableToPromiseTotal" to-field="productFacility.minimumStock" operator="less" type="BigDecimal">
+            <if-compare-field field="availableToPromiseTotal" to-field="minimumStock" operator="less" type="BigDecimal">
                 <!-- what is the right quantity?  It is the lesser of the actual quantity and the quantity required to bring us back up to minimum stock -->
                 <calculate field="quantityShortfall">
-                    <calcop field="productFacility.minimumStock" operator="subtract">
+                    <calcop field="minimumStock" operator="subtract">
                         <calcop operator="get" field="availableToPromiseTotal"/>
                     </calcop>
                 </calculate>
@@ -361,7 +366,7 @@
                     <condition-list combine="and">
                         <condition-expr field-name="productId" operator="equals" from-field="parameters.productId"/>
                         <condition-expr field-name="requirementTypeId" operator="equals" value="PRODUCT_REQUIREMENT"/>
-                        <condition-expr field-name="facilityId" operator="equals" from-field="productFacility.facilityId"/>
+                        <condition-expr field-name="facilityId" operator="equals" from-field="facilityId"/>
                         <condition-expr field-name="statusId" operator="not-equals" value="REQ_ORDERED"/>
                         <condition-expr field-name="statusId" operator="not-equals" value="REQ_REJECTED"/>
                     </condition-list>
@@ -387,7 +392,6 @@
                 </if-compare>
 
             </if-compare-field>
-            </if-not-empty>
         </if-compare>
     </simple-method>
 

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java?rev=810738&r1=810737&r2=810738&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java Thu Sep  3 00:29:04 2009
@@ -276,10 +276,12 @@
                 BigDecimal ordered = quantity.subtract(cancelQuantity == null ? BigDecimal.ZERO : cancelQuantity);
                 if (ordered.compareTo(BigDecimal.ZERO) <= 0) continue;
 
-                // get the minimum stock for this facility (don't do anything if not configured)
+                // get the minimum stock for this facility (if not configured assume a minimum of zero, ie create requirements when it goes into backorder)
                 GenericValue productFacility = delegator.findByPrimaryKey("ProductFacility", UtilMisc.toMap("facilityId", facilityId, "productId", product.get("productId")));
-                if (productFacility == null || productFacility.get("minimumStock") == null) continue;
-                BigDecimal minimumStock = productFacility.getBigDecimal("minimumStock");
+                BigDecimal minimumStock = BigDecimal.ZERO;
+                if (productFacility != null && productFacility.get("minimumStock") != null) {
+                    minimumStock = productFacility.getBigDecimal("minimumStock");
+                }
 
                 // get the facility ATP for product, which should be updated for this item's reservation
                 Map results = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("userLogin", userLogin, "productId", product.get("productId"), "facilityId", facilityId));