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

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

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

jacopoc
Author: jacopoc
Date: Thu Jun 21 08:31:08 2007
New Revision: 549514

URL: http://svn.apache.org/viewvc?view=rev&rev=549514
Log:
Enhanced the getProductCost method to look at the SupplierProduct entity to get the cost, if nothing else has been found.

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?view=diff&rev=549514&r1=549513&r2=549514
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml Thu Jun 21 08:31:08 2007
@@ -124,6 +124,41 @@
                 </call-service>
             </if-not-empty>
         </if-compare>
+        <!-- if the cost is zero, get the purchase cost from the SupplierProduct -->
+        <if-compare field-name="productCost" operator="equals" value="0" type="Double">
+            <set field="orderByList[]" value="+supplierPrefOrderId"/>
+            <set field="orderByList[]" value="+lastPrice"/>
+            <clear-field field-name="costsAndMap"/>
+            <set from-field="parameters.productId" field="costsAndMap.productId"/>
+            <set from-field="parameters.currencyUomId" field="costsAndMap.currencyUomId"/>
+            <find-by-and entity-name="SupplierProduct" map-name="costsAndMap" list-name="priceCosts" order-by-list-name="orderByList"/>
+            <filter-list-by-date list-name="priceCosts" from-field-name="availableFromDate" thru-field-name="availableThruDate"/>
+            <first-from-list list-name="priceCosts" entry-name="priceCost"/>
+            <if-not-empty field-name="priceCost.lastPrice">
+                <set from-field="priceCost.lastPrice" field="productCost"/>
+            </if-not-empty>
+            <!-- if the cost is zero, get the purchase cost from the SupplierProduct
+                 in a different currency and try to convert
+            -->
+            <if-compare field-name="productCost" operator="equals" value="0" type="Double">
+                <clear-field field-name="costsAndMap"/>
+                <set from-field="parameters.productId" field="costsAndMap.productId"/>
+                <set from-field="parameters.productPriceTypeId" field="costsAndMap.productPriceTypeId"/>
+                <find-by-and entity-name="SupplierProduct" map-name="costsAndMap" list-name="priceCosts" order-by-list-name="orderByList"/>
+                <filter-list-by-date list-name="priceCosts" from-field-name="availableFromDate" thru-field-name="availableThruDate"/>
+                <first-from-list list-name="priceCosts" entry-name="priceCost"/>
+                <if-not-empty field-name="priceCost.lastPrice">
+                    <!-- we try to convert the lastPrice to the desired currency -->
+                    <clear-field field-name="inputMap"/>
+                    <set from-field="priceCost.lastPrice" field="inputMap.originalValue"/>
+                    <set from-field="priceCost.currencyUomId" field="inputMap.uomId"/>
+                    <set from-field="parameters.currencyUomId" field="inputMap.uomIdTo"/>
+                    <call-service service-name="convertUom" in-map-name="inputMap" break-on-error="false">
+                        <result-to-field result-name="convertedValue" field-name="productCost"/>
+                    </call-service>
+                </if-not-empty>
+            </if-compare>
+        </if-compare>
         <!--
         <if-compare field-name="productCost" operator="equals" value="0" type="Double">
             <clear-field field-name="costsAndMap"/>