svn commit: r448979 - /incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml

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

svn commit: r448979 - /incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml

jacopoc
Author: jacopoc
Date: Fri Sep 22 09:16:02 2006
New Revision: 448979

URL: http://svn.apache.org/viewvc?view=rev&rev=448979
Log:
Cleaned up the service for automatic requirement creation based on QOH and minimum on stock.

Modified:
    incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml

Modified: incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml?view=diff&rev=448979&r1=448978&r2=448979
==============================================================================
--- incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml (original)
+++ incubator/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml Fri Sep 22 09:16:02 2006
@@ -216,59 +216,33 @@
             <call-simple-method method-name="getProductFacilityAndQuantities"/>
 
             <if-not-empty field-name="productFacility.minimumStock">
-                <!-- calculate the quantity after this item is issued -->
-                <calculate field-name="newQuantityOnHand">
-                    <calcop field-name="quantityOnHandTotal" operator="subtract">
-                        <calcop operator="get" field-name="parameters.quantity"/>
-                    </calcop>
-                </calculate>
-                <!-- If this new issuance will cause the quantityOnHandTotal to go below the minimumStock, create a new requirement -->
-                <if-compare-field field-name="newQuantityOnHand" to-field-name="productFacility.minimumStock" operator="less" type="Double">
-                    <!-- have requirements already been created for this item? -->
-                    <set from-field="inventoryItem.productId" field="lookupParams.productId"/>
-                    <set from-field="inventoryItem.facilityId" field="lookupParams.facilityId"/>
-                    <set value="REQ_CREATED" field="lookupParams.statusId"/>
-                    <find-by-and entity-name="Requirement" map-name="lookupParams" list-name="existingRequirements"/>
-                    <if-not-empty field-name="existingRequirements">
-                        <!-- if existing requirements exist, the quantity is based on the total already requested:
-                            quantity still required = minimum stock - (new QOH on hand + quantity already in existing requirements)
-                            This number can be negative so we'll have to check for it later-->
-                        <find-by-and entity-name="RequirementByProductFacility" map-name="lookupParams" list-name="existingRequirementQuantities"/>
-                        <first-from-list list-name="existingRequirementQuantities" entry-name="existingRequirementQuantity"/>
-                        <calculate field-name="quantity" map-name="inputMap">
-                            <calcop field-name="minimumStock" map-name="productFacility" operator="subtract">
-                                <calcop field-name="newQuantityOnHand" operator="add">
-                                    <calcop operator="get" field-name="quantity" map-name="existingRequirementQuantity"/>
-                                </calcop>
-                            </calcop>
-                        </calculate>
-                    <else>
-                        <!-- if not, then we may have to create a requirement with a quantity equal to the facility's minimum quanity -->
+                <!-- No requirements are created if we are already under stock -->
+                <if-compare-field field-name="quantityOnHandTotal" to-field-name="productFacility.minimumStock" operator="greater-equals" type="Double">
+                    <calculate field-name="newQuantityOnHand">
+                        <calcop field-name="quantityOnHandTotal" operator="subtract">
+                            <calcop operator="get" field-name="parameters.quantity"/>
+                        </calcop>
+                    </calculate>
+                    <!-- If this new issuance will cause the quantityOnHandTotal to go below the minimumStock, create a new requirement -->
+                    <if-compare-field field-name="newQuantityOnHand" to-field-name="productFacility.minimumStock" operator="less" type="Double">
+                        <field-to-field field-name="inventoryItem.productId" to-map-name="inputMap" to-field-name="productId"/>
                         <if-not-empty field-name="productFacility.reorderQuantity">
-                            <set from-field="productFacility.reorderQuantity" field="inputMap.quantity"/>
+                            <field-to-field field-name="productFacility.reorderQuantity" to-map-name="inputMap" to-field-name="quantity"/>
                         <else>
-                            <set from-field="parameters.quantity" field="inputMap.quantity"/>
+                            <field-to-field field-name="parameters.quantity" to-map-name="inputMap" to-field-name="quantity"/>
                         </else>
                         </if-not-empty>
-                    </else>
-                    </if-not-empty>
-
-                    <!-- if the amount required due to this item issuance is greater than zero, ie not covered by existing requirements,
-                        then create a new requirement -->
-                    <if-compare field-name="quantity" map-name="inputMap" operator="greater" type="Double" value="0">
-                        <set from-field="inventoryItem.productId" field="inputMap.productId"/>
-                        <set value="PRODUCT_REQUIREMENT" field="inputMap.requirementTypeId"/>
-                        <set from-field="productFacility.facilityId" field="inputMap.facilityId"/>
+                        <string-to-field string="PRODUCT_REQUIREMENT" map-name="inputMap" field-name="requirementTypeId"/>
                         <call-service service-name="createRequirement" in-map-name="inputMap">
                             <result-to-field field-name="parameters.requirementId" result-name="requirementId"/>
                         </call-service>
                         <field-to-result field-name="parameters.requirementId" result-name="requirementId"/>
-                    </if-compare>
+                    </if-compare-field>
                 </if-compare-field>
             </if-not-empty>
         </if-compare>
     </simple-method>
-    
+
     <simple-method method-name="createRequirementFromItemATP" short-description="Create a Requirement for an item based on ATP inventory quantity and minimum">
         <check-permission permission="ORDERMGR" action="_CREATE">
             <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCreateRequirementFromItemATP"/>