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 2009/11/03 14:57:33 UTC

svn commit: r832420 - /ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml

Author: jacopoc
Date: Tue Nov  3 13:57:33 2009
New Revision: 832420

URL: http://svn.apache.org/viewvc?rev=832420&view=rev
Log:
Improved code to get product costs; now all the costs of the same family are considered.


Modified:
    ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml?rev=832420&r1=832419&r2=832420&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml Tue Nov  3 13:57:33 2009
@@ -76,37 +76,17 @@
 
     <!-- Services to get the product and tasks costs -->
     <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="costsAndMap" list="routeCosts"/>
-        <filter-list-by-date list="routeCosts"/>
-        <first-from-list list="routeCosts" entry="routeCost"/>
-        <!-- Labor costs -->
-        <set value="${parameters.costComponentTypePrefix}_LABOR_COST" field="costsAndMap.costComponentTypeId"/>
-        <find-by-and entity-name="CostComponent" map="costsAndMap" list="laborCosts"/>
-        <filter-list-by-date list="laborCosts"/>
-        <first-from-list list="laborCosts" entry="laborCost"/>
-        <!-- Materials costs -->
-        <set value="${parameters.costComponentTypePrefix}_MAT_COST" field="costsAndMap.costComponentTypeId"/>
-        <find-by-and entity-name="CostComponent" map="costsAndMap" list="materialsCosts"/>
-        <filter-list-by-date list="materialsCosts"/>
-        <first-from-list list="materialsCosts" entry="materialsCost"/>
-        <!-- Other costs -->
-        <set value="${parameters.costComponentTypePrefix}_OTHER_COST" field="costsAndMap.costComponentTypeId"/>
-        <find-by-and entity-name="CostComponent" map="costsAndMap" list="otherCosts"/>
-        <filter-list-by-date list="otherCosts"/>
-        <first-from-list list="otherCosts" entry="otherCost"/>
-
+        <entity-condition list="costComponents" entity-name="CostComponent" filter-by-date="true">
+            <condition-list>
+                <condition-expr field-name="productId" operator="equals" from-field="parameters.productId"/>
+                <condition-expr field-name="costUomId" operator="equals" from-field="parameters.currencyUomId"/>
+                <condition-expr field-name="costComponentTypeId" operator="like" value="${parameters.costComponentTypePrefix}_%"/>
+            </condition-list>
+        </entity-condition>
         <set field="productCost" value="0" type="BigDecimal"/>
-        <calculate field="productCost" decimal-scale="6">
-            <calcop field="laborCost.cost" operator="add">
-                <calcop field="materialsCost.cost" operator="get"/>
-                <calcop field="routeCost.cost" operator="get"/>
-                <calcop field="otherCost.cost" operator="get"/>
-            </calcop>
-        </calculate>
+        <iterate entry="costComponent" list="costComponents">
+            <set field="productCost" value="${costComponent.cost + productCost}" type="BigDecimal"/>
+        </iterate>
         <!-- if the cost is zero, and the product is a variant, get the cost of the virtual -->
         <if-compare field="productCost" operator="equals" value="0" type="BigDecimal">
             <entity-one entity-name="Product" value-field="product"/>