You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/03/13 10:16:42 UTC

svn commit: r517602 - in /ofbiz/trunk/applications/order: script/org/ofbiz/order/order/OrderServices.xml servicedef/services_requirement.xml

Author: jacopoc
Date: Tue Mar 13 02:16:42 2007
New Revision: 517602

URL: http://svn.apache.org/viewvc?view=rev&rev=517602
Log:
Implemented new service that can be scheduled to get a list of (purchase order) requirements for all the items the are low on stock.

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

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?view=diff&rev=517602&r1=517601&r2=517602
==============================================================================
--- ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml (original)
+++ ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml Tue Mar 13 02:16:42 2007
@@ -341,6 +341,79 @@
         </if-compare>
     </simple-method>
 
+    <simple-method method-name="checkCreateProductRequirementForFacility" short-description="Create Requirements for all the products in a facility with QOH under the minimum stock level">
+        <check-permission permission="ORDERMGR" action="_CREATE">
+            <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCheckCreateStockRequirement"/>
+        </check-permission>
+        <check-errors/>
+
+        <entity-and entity-name="ProductFacility" list-name="products">
+            <field-map env-name="parameters.facilityId" field-name="facilityId"/>
+        </entity-and>
+
+        <iterate list-name="products" entry-name="productFacility">
+            <set from-field="productFacility.productId" field="parameters.productId"/>
+            <call-simple-method method-name="getProductRequirementMethod"/>
+            <if>
+                <condition>
+                    <or>
+                        <if-compare field-name="requirementMethodId" operator="equals" value="PRODRQM_STOCK"/>
+                        <if-compare field-name="requirementMethodId" operator="equals" value="PRODRQM_STOCK_ATP"/>
+                    </or>
+                </condition>
+                <then>
+                    <!-- get QOH, ATP and find ProductFacility which has the minimum stock -->
+
+                    <if-not-empty field-name="productFacility.minimumStock">
+                        <!-- Get the product's total quantityOnHand in the facility -->
+                        <clear-field field-name="inputMap"/>
+                        <set from-field="productFacility.productId" field="inputMap.productId"/>
+                        <set from-field="productFacility.facilityId" field="inputMap.facilityId"/>
+                        <call-service service-name="getInventoryAvailableByFacility" in-map-name="inputMap">
+                           <result-to-field field-name="quantityOnHandTotal" result-name="quantityOnHandTotal"/>
+                           <result-to-field field-name="availableToPromiseTotal" result-name="availableToPromiseTotal"/>
+                        </call-service>
+
+                        <if-compare field-name="requirementMethodId" operator="equals" value="PRODRQM_STOCK">
+                            <set from-field="quantityOnHandTotal" field="currentQuantity"/>
+                        <else>
+                            <set from-field="availableToPromiseTotal" field="currentQuantity"/>
+                        </else>
+                        </if-compare>
+
+                        <!-- No requirements are created if we are already under stock -->
+                        <if-compare-field field-name="currentQuantity" to-field-name="productFacility.minimumStock" operator="less" type="Double">
+                            <clear-field field-name="inputMap"/>
+                            <set from-field="productFacility.productId" field="inputMap.productId"/>
+                            <if-not-empty field-name="productFacility.reorderQuantity">
+                                <set from-field="productFacility.reorderQuantity" field="inputMap.quantity" type="Double"/>
+                            <else>
+                                <set value="0" field="inputMap.quantity" type="Double"/>
+                            </else>
+                            </if-not-empty>
+
+                            <calculate field-name="quantityShortfall">
+                                <calcop field-name="productFacility.minimumStock" operator="subtract">
+                                    <calcop operator="get" field-name="currentQuantity"/>
+                                </calcop>
+                            </calculate>
+                            <if-compare-field field-name="inputMap.quantity" to-field-name="quantityShortfall" operator="less" type="Double">
+                                <set from-field="quantityShortfall" field="inputMap.quantity" type="Double"/>
+                            </if-compare-field>
+
+                            <set value="PRODUCT_REQUIREMENT" field="inputMap.requirementTypeId"/>
+                            <set from-field="parameters.facilityId" field="inputMap.facilityId"/>
+                            <call-service service-name="createRequirement" in-map-name="inputMap">
+                                <result-to-field field-name="requirementId" result-name="requirementId"/>
+                            </call-service>
+                            <log level="info" message="Requirement creted with id [${requirementId}] for product with id [${productFacility.productId}]."/>
+                        </if-compare-field>
+                    </if-not-empty>
+                </then>
+            </if>
+        </iterate>
+    </simple-method>
+
     <simple-method method-name="getNextOrderId" short-description="Get Next orderId">
         <!-- try to find PartyAcctgPreference for parameters.partyId, see if we need any special order number sequencing -->
         <entity-one entity-name="PartyAcctgPreference" value-name="partyAcctgPreference"/>

Modified: ofbiz/trunk/applications/order/servicedef/services_requirement.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services_requirement.xml?view=diff&rev=517602&r1=517601&r2=517602
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services_requirement.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services_requirement.xml Tue Mar 13 02:16:42 2007
@@ -148,6 +148,11 @@
         <attribute name="quantity" type="Double" mode="IN" optional="true"/>
         <attribute name="requirementId" type="String" mode="OUT" optional="true"/>
     </service>
+    <service name="checkCreateProductRequirementForFacility" engine="simple" auth="true"
+            location="org/ofbiz/order/order/OrderServices.xml" invoke="checkCreateProductRequirementForFacility">
+        <description>Create Requirements for all the products in a facility with QOH under the minimum stock level</description>
+        <attribute name="facilityId" type="String" mode="IN" optional="false"/>
+    </service>
 
     <service name="approveRequirement" engine="java"
             location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="approveRequirement" auth="true">