[OFBiz] SVN: r6899 - in trunk/applications: manufacturing/data manufacturing/script/org/ofbiz/manufacturing/cost manufacturing/servicedef product/data product/webapp/catalog/product

jacopo@svn.ofbiz.org jacopo at svn.ofbiz.org
Fri Mar 3 04:39:48 CST 2006


Author: jacopo
Date: 2006-03-03 04:39:29 -0600 (Fri, 03 Mar 2006)
New Revision: 6899

Modified:
   trunk/applications/manufacturing/data/ManufacturingScheduledServices.xml
   trunk/applications/manufacturing/script/org/ofbiz/manufacturing/cost/CostServices.xml
   trunk/applications/manufacturing/servicedef/services_cost.xml
   trunk/applications/product/data/ProductTypeData.xml
   trunk/applications/product/webapp/catalog/product/ProductForms.xml
Log:
Reviewed and modified the CostComponentType's seed data (also based on suggestions from Si Chen) to be more meaningful.
Now there are four types:
EST_STD_MAT_COST, the estimated standard cost for the materials
EST_STD_ROUTE_COST, the estimated standard cost for the fixed asset usage (based on routing definition)
EST_STD_LABOR_COST, the estimated standard cost for the employee labor
EST_STD_OTHER_COST, estimated standard cost for other factors

Reviewed and modified the existing costing algorithms that automatically compute these values to reflect these changes;
now the ProductPrice entity is no more considered for raw materials' costs, instead the raw materials' cost is stored in the CostComponent entity.



Modified: trunk/applications/manufacturing/data/ManufacturingScheduledServices.xml
===================================================================
--- trunk/applications/manufacturing/data/ManufacturingScheduledServices.xml	2006-03-03 09:58:19 UTC (rev 6898)
+++ trunk/applications/manufacturing/data/ManufacturingScheduledServices.xml	2006-03-03 10:39:29 UTC (rev 6899)
@@ -29,6 +29,14 @@
         <std-String value="USD"/>
       </map-Value>
     </map-Entry>
+    <map-Entry>
+      <map-Key>
+        <std-String value="costComponentTypePrefix"/>
+      </map-Key>
+      <map-Value>
+        <std-String value="EST_STD"/>
+      </map-Value>
+    </map-Entry>
   </map-HashMap>
 </ofbiz-ser>
         ]]></runtimeInfo>

Modified: trunk/applications/manufacturing/script/org/ofbiz/manufacturing/cost/CostServices.xml
===================================================================
--- trunk/applications/manufacturing/script/org/ofbiz/manufacturing/cost/CostServices.xml	2006-03-03 09:58:19 UTC (rev 6898)
+++ trunk/applications/manufacturing/script/org/ofbiz/manufacturing/cost/CostServices.xml	2006-03-03 10:39:29 UTC (rev 6899)
@@ -43,10 +43,11 @@
     </simple-method>
     <simple-method method-name="calculateProductCosts" short-description="Calculates the product's cost">
         <!-- the existing costs are expired -->
+        <!--
         <set from-field="parameters.productId" field="cancelMap.productId"/>
         <set from-field="parameters.currencyUomId" field="cancelMap.costUomId"/>
         <call-service service-name="cancelCostComponents" in-map-name="cancelMap"/>
-
+        -->
         <!-- calculate the total materials' cost -->
         <set from-field="parameters.productId" field="callSvcMap.productId"/>
         <call-service service-name="getManufacturingComponents" in-map-name="callSvcMap">
@@ -58,7 +59,7 @@
                 <set field="product" from-field="componentMap.product"/>
                 <set field="inputMap.productId" from-field="product.productId"/>
                 <set field="inputMap.currencyUomId" from-field="parameters.currencyUomId"/>
-                <set field="inputMap.productPriceTypeId" value="AVERAGE_COST"/>
+                <set field="inputMap.costComponentTypePrefix" from-field="parameters.costComponentTypePrefix"/>
                 <call-service service-name="getProductCost" in-map-name="inputMap">
                     <result-to-field result-name="productCost"/>
                 </call-service>
@@ -74,7 +75,7 @@
                 <clear-field field-name="inputMap"/>
                 <set field="inputMap.productId" from-field="parameters.productId"/>
                 <set field="inputMap.currencyUomId" from-field="parameters.currencyUomId"/>
-                <set field="inputMap.productPriceTypeId" value="AVERAGE_COST"/>
+                <set field="inputMap.costComponentTypePrefix" from-field="parameters.costComponentTypePrefix"/>
                 <call-service service-name="getProductCost" in-map-name="inputMap">
                     <result-to-field result-name="productCost"/>
                 </call-service>
@@ -82,7 +83,7 @@
                     <calcop field-name="productCost" operator="get"/>
                 </calculate>
             </else>
-        </if-not-empty>        
+        </if-not-empty>
         <!-- calculate the total tasks' cost -->
         <set field="callSvcMap.ignoreDefaultRouting" value="Y"/>
         <call-service service-name="getProductRouting" in-map-name="callSvcMap">
@@ -113,21 +114,21 @@
         <if-not-empty field-name="totalTaskCost">
             <if-compare field-name="totalTaskCost" operator="greater" value="0" type="Double">
                 <clear-field field-name="callSvcMap"/>
-                <set value="ESTIMATED_LABOR_COST" field="callSvcMap.costComponentTypeId"/>
+                <set value="${parameters.costComponentTypePrefix}_ROUTE_COST" field="callSvcMap.costComponentTypeId"/>
                 <set from-field="parameters.productId" field="callSvcMap.productId"/>
                 <set from-field="parameters.currencyUomId" field="callSvcMap.costUomId"/>
                 <set from-field="totalTaskCost" field="callSvcMap.cost"/>
-                <call-service service-name="createCostComponent" in-map-name="callSvcMap"/>
+                <call-service service-name="recreateCostComponent" in-map-name="callSvcMap"/>
             </if-compare>
         </if-not-empty>
         <if-not-empty field-name="totalProductsCost">
             <if-compare field-name="totalProductsCost" operator="greater" value="0" type="Double">
                 <clear-field field-name="callSvcMap"/>
-                <set value="ESTIMATED_MATERIALS_" field="callSvcMap.costComponentTypeId"/>
+                <set value="${parameters.costComponentTypePrefix}_MAT_COST" field="callSvcMap.costComponentTypeId"/>
                 <set from-field="parameters.productId" field="callSvcMap.productId"/>
                 <set from-field="parameters.currencyUomId" field="callSvcMap.costUomId"/>
                 <set from-field="totalProductsCost" field="callSvcMap.cost"/>
-                <call-service service-name="createCostComponent" in-map-name="callSvcMap"/>
+                <call-service service-name="recreateCostComponent" in-map-name="callSvcMap"/>
             </if-compare>
         </if-not-empty>
         
@@ -186,18 +187,23 @@
     <simple-method method-name="getProductCost" short-description="Gets the product's costs (from CostComponent or ProductPrice)">
         <set from-field="parameters.productId" field="costsAndMap.productId"/>
         <set from-field="parameters.currencyUomId" field="costsAndMap.costUomId"/>
+        <!-- Route costs -->
+        <set value="${parameters.costComponentTypePrefix}_ROUTE_COST" field="costsAndMap.costComponentTypeId"/>
+        <find-by-and entity-name="CostComponent" map-name="costsAndMap" list-name="laborCosts"/>
+        <filter-list-by-date list-name="routeCosts"/>
+        <first-from-list list-name="routeCosts" entry-name="routeCost"/>
         <!-- Labor costs -->
-        <set value="ESTIMATED_LABOR_COST" field="costsAndMap.costComponentTypeId"/>
+        <set value="${parameters.costComponentTypePrefix}_LABOR_COST" field="costsAndMap.costComponentTypeId"/>
         <find-by-and entity-name="CostComponent" map-name="costsAndMap" list-name="laborCosts"/>
         <filter-list-by-date list-name="laborCosts"/>
         <first-from-list list-name="laborCosts" entry-name="laborCost"/>
         <!-- Materials costs -->
-        <set value="ESTIMATED_MATERIALS_" field="costsAndMap.costComponentTypeId"/>
+        <set value="${parameters.costComponentTypePrefix}_MAT_COST" field="costsAndMap.costComponentTypeId"/>
         <find-by-and entity-name="CostComponent" map-name="costsAndMap" list-name="materialsCosts"/>
         <filter-list-by-date list-name="materialsCosts"/>
         <first-from-list list-name="materialsCosts" entry-name="materialsCost"/>
         <!-- Other costs -->
-        <set value="ESTIMATED_OTHER_COST" field="costsAndMap.costComponentTypeId"/>
+        <set value="${parameters.costComponentTypePrefix}_OTHER_COST" field="costsAndMap.costComponentTypeId"/>
         <find-by-and entity-name="CostComponent" map-name="costsAndMap" list-name="otherCosts"/>
         <filter-list-by-date list-name="otherCosts"/>
         <first-from-list list-name="otherCosts" entry-name="otherCost"/>
@@ -205,9 +211,11 @@
         <calculate field-name="productCost">
             <calcop field-name="laborCost.cost" operator="add">
                 <calcop field-name="materialsCost.cost" operator="get"/>
+                <calcop field-name="routeCost.cost" operator="get"/>
                 <calcop field-name="otherCost.cost" operator="get"/>
             </calcop>
         </calculate>
+        <!--
         <if-compare field-name="productCost" operator="equals" value="0" type="Double">
             <clear-field field-name="costsAndMap"/>
             <set from-field="parameters.productId" field="costsAndMap.productId"/>
@@ -220,6 +228,7 @@
                 <set from-field="priceCost.price" field="productCost"/>
             </if-not-empty>
         </if-compare>
+        -->
         <field-to-result field-name="productCost"/>
     </simple-method>
     
@@ -235,7 +244,7 @@
             <store-value value-name="existingCost"/>
         </iterate>
     </simple-method>
-    <simple-method method-name="createCostComponent" short-description="Create a CostComponent">
+    <simple-method method-name="recreateCostComponent" short-description="Create a CostComponent and cancel the existing ones">
         <!-- The existing costs of the same type are expired -->
         <set from-field="parameters.productId" field="costsAndMap.productId"/>
         <set from-field="parameters.costUomId" field="costsAndMap.costUomId"/>

Modified: trunk/applications/manufacturing/servicedef/services_cost.xml
===================================================================
--- trunk/applications/manufacturing/servicedef/services_cost.xml	2006-03-03 09:58:19 UTC (rev 6898)
+++ trunk/applications/manufacturing/servicedef/services_cost.xml	2006-03-03 10:39:29 UTC (rev 6899)
@@ -42,7 +42,7 @@
         <description>Gets the product's costs (from CostComponent or ProductPrice)</description>
         <attribute mode="IN" name="productId" optional="false" type="String"/>
         <attribute mode="IN" name="currencyUomId" optional="false" type="String"/>
-        <attribute mode="IN" name="productPriceTypeId" optional="false" type="String"/>
+        <attribute mode="IN" name="costComponentTypePrefix" optional="false" type="String"/>
         <attribute mode="OUT" name="productCost" type="Double" optional="false"/>
     </service>
     <service name="calculateProductCosts" engine="simple" auth="true"
@@ -50,16 +50,18 @@
         <description>Calculates the product's costs</description>
         <attribute mode="IN" name="productId" optional="false" type="String"/>
         <attribute mode="IN" name="currencyUomId" optional="false" type="String"/>
+        <attribute mode="IN" name="costComponentTypePrefix" optional="false" type="String"/>
         <attribute mode="OUT" name="totalCost" type="Double"/>
     </service>
     <service name="calculateAllProductsCosts" engine="simple" auth="true" transaction-timout="7200"
                 location="org/ofbiz/manufacturing/cost/CostServices.xml" invoke="calculateAllProductsCosts">
         <description>Calculates estimated costs for all the products</description>
         <attribute mode="IN" name="currencyUomId" optional="false" type="String"/>
+        <attribute mode="IN" name="costComponentTypePrefix" optional="false" type="String"/>
     </service>
-    <service name="createCostComponent" default-entity-name="CostComponent" engine="simple" 
-                location="org/ofbiz/manufacturing/cost/CostServices.xml" invoke="createCostComponent" auth="true">
-        <description>Create a CostComponent</description>
+    <service name="recreateCostComponent" default-entity-name="CostComponent" engine="simple" 
+                location="org/ofbiz/manufacturing/cost/CostServices.xml" invoke="recreateCostComponent" auth="true">
+        <description>Create a CostComponent and cancel the existing ones</description>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <auto-attributes include="pk" mode="OUT" optional="false"/>
     </service>

Modified: trunk/applications/product/data/ProductTypeData.xml
===================================================================
--- trunk/applications/product/data/ProductTypeData.xml	2006-03-03 09:58:19 UTC (rev 6898)
+++ trunk/applications/product/data/ProductTypeData.xml	2006-03-03 10:39:29 UTC (rev 6899)
@@ -1,8 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <entity-engine-xml>
-    <CostComponentType costComponentTypeId="ESTIMATED_LABOR_COST" description="Estimated Labor" hasTable="N" parentTypeId=""/>
-    <CostComponentType costComponentTypeId="ESTIMATED_MATERIALS_" description="Estimated Materials" hasTable="N" parentTypeId=""/>
-    <CostComponentType costComponentTypeId="ESTIMATED_OTHER_COST" description="Estimated Other" hasTable="N" parentTypeId=""/>
+    <CostComponentType costComponentTypeId="EST_STD_MAT_COST" description="Estimated Standard Materials Cost" hasTable="N" parentTypeId=""/>
+    <CostComponentType costComponentTypeId="EST_STD_ROUTE_COST" description="Estimated Standard Route (fixed asset usage) Cost" hasTable="N" parentTypeId=""/>
+    <CostComponentType costComponentTypeId="EST_STD_LABOR_COST" description="Estimated Standard Labor Cost" hasTable="N" parentTypeId=""/>
+    <CostComponentType costComponentTypeId="EST_STD_OTHER_COST" description="Estimated Standard Other Cost" hasTable="N" parentTypeId=""/>
 
     <EnumerationType description="Product Price Parent Enum Type" enumTypeId="PROD_PRICE" hasTable="N" parentTypeId=""/>
     <EnumerationType description="Product Price Input Parameter" enumTypeId="PROD_PRICE_IN_PARAM" hasTable="N" parentTypeId="PROD_PRICE"/>

Modified: trunk/applications/product/webapp/catalog/product/ProductForms.xml
===================================================================
--- trunk/applications/product/webapp/catalog/product/ProductForms.xml	2006-03-03 09:58:19 UTC (rev 6898)
+++ trunk/applications/product/webapp/catalog/product/ProductForms.xml	2006-03-03 10:39:29 UTC (rev 6899)
@@ -960,6 +960,11 @@
             default-title-style="tableheadtext" default-widget-style="inputBox" default-tooltip-style="tabletext">
         <auto-fields-service service-name="calculateProductCosts" map-name=""/>
         <field name="productId"><hidden value="${productId}"/></field>
+        <field name="costComponentTypePrefix" widget-style="selectBox">
+            <drop-down allow-empty="false">
+                <option key="EST_STD" description="Estimated Standard Costs"/>
+            </drop-down>
+        </field>
         <field name="currencyUomId" title="${uiLabelMap.ProductCurrencyUomId}" widget-style="selectBox">
             <drop-down allow-empty="false" no-current-selected-key="${defaultCurrencyUomId}">
                 <entity-options entity-name="Uom" key-field-name="uomId" description="${description} [${uomId}]">



More information about the Svn mailing list