svn commit: r571525 - /ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r571525 - /ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java

sichen
Author: sichen
Date: Fri Aug 31 10:11:45 2007
New Revision: 571525

URL: http://svn.apache.org/viewvc?rev=571525&view=rev
Log:
Fix bug where dependent production runs were being created for parts which had ProductFacility thresholds but of 0.  Now if it is a WIP or has any ProductFacility records, it is warehouse managed.  Thanks to Jacopo for showing me where this was

Modified:
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java?rev=571525&r1=571524&r2=571525&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java Fri Aug 31 10:11:45 2007
@@ -126,7 +126,8 @@
                         oneChildNode.loadChildren(partBomTypeId, inDate, productFeatures, BOMTree.EXPLOSION);
                     break;
                     case BOMTree.EXPLOSION_MANUFACTURING:
-                        if (!oneChildNode.isWarehouseManaged()) {
+                        // for manfacturing trees, do not look through and create production runs for children unless there is no warehouse stocking of this node item
+        if (!oneChildNode.isWarehouseManaged()) {
                             oneChildNode.loadChildren(partBomTypeId, inDate, productFeatures, type);
                         }
                     break;
@@ -601,6 +602,10 @@
         return minStartDate;
     }
 
+    /**
+     * Returns false if the product of this BOM Node is of type "WIP" or if it has no ProductFacility records defined for it,
+     * meaning that no active stock targets are set for this product.
+     */
     public boolean isWarehouseManaged() {
         boolean isWarehouseManaged = false;
         try {
@@ -608,32 +613,18 @@
                 return false;
             }
             List pfs = getProduct().getRelatedCache("ProductFacility");
-            Iterator pfsIt = pfs.iterator();
-            GenericValue pf = null;
-            boolean found = false;
-            while(pfsIt.hasNext()) {
-                found = true;
-                pf = (GenericValue)pfsIt.next();
-                if (pf.getDouble("minimumStock") != null && pf.getDouble("minimumStock").doubleValue() > 0) {
-                    isWarehouseManaged = true;
-                }
-            }
-            // If no records are found, we try to search for substituted node's records
-            if (!found && getSubstitutedNode() != null) {
+            if (UtilValidate.isNotEmpty(pfs)) {
+                isWarehouseManaged = true;
+            } else {
                 pfs = getSubstitutedNode().getProduct().getRelatedCache("ProductFacility");
-                pfsIt = pfs.iterator();
-                pf = null;
-                while(pfsIt.hasNext()) {
-                    pf = (GenericValue)pfsIt.next();
-                    if (pf.getDouble("minimumStock") != null && pf.getDouble("minimumStock").doubleValue() > 0) {
-                        isWarehouseManaged = true;
-                    }
+                if (UtilValidate.isNotEmpty(pfs)) {
+                    isWarehouseManaged = true;
                 }
             }
         } catch(GenericEntityException gee) {
             Debug.logError("Problem in BOMNode.isWarehouseManaged()", module);
         }
-        return isWarehouseManaged;
+ return isWarehouseManaged;
     }
 
     public boolean isManufactured(boolean ignoreSupplierProducts) {