You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by su...@apache.org on 2019/01/12 06:18:09 UTC

svn commit: r1851137 - in /ofbiz/ofbiz-framework/trunk/framework/common: minilang/CommonServices.xml servicedef/services.xml

Author: surajk
Date: Sat Jan 12 06:18:09 2019
New Revision: 1851137

URL: http://svn.apache.org/viewvc?rev=1851137&view=rev
Log:
Improved:Updated 'convertUom' service, given priority to 'UomConversionDated' entity to fetch conversion factor.
(OFBIZ-10747)
In case if the factor is not available then use 'UomConversion' entity.
Thanks Amit Gadaley for reporting the issue and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/common/minilang/CommonServices.xml
    ofbiz/ofbiz-framework/trunk/framework/common/servicedef/services.xml

Modified: ofbiz/ofbiz-framework/trunk/framework/common/minilang/CommonServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/minilang/CommonServices.xml?rev=1851137&r1=1851136&r2=1851137&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/common/minilang/CommonServices.xml (original)
+++ ofbiz/ofbiz-framework/trunk/framework/common/minilang/CommonServices.xml Sat Jan 12 06:18:09 2019
@@ -80,45 +80,44 @@ under the License.
             </else>
         </if-empty>
 
-        <!-- first try the regular UomConversion entity (no dates) -->
-        <entity-one entity-name="UomConversion" value-field="uomConversion" auto-field-map="true" use-cache="true"/>
-
-        <!-- if not found, try the dated uom conversion entity -->
-        <if-empty field="uomConversion">
-            <entity-condition entity-name="UomConversionDated" list="uomConversions" use-cache="true">
-                <condition-list combine="and">
-                    <condition-expr field-name="uomId" from-field="parameters.uomId"/>
-                    <condition-expr field-name="uomIdTo" from-field="parameters.uomIdTo"/>
-                    <condition-expr field-name="purposeEnumId" operator="equals" from-field="parameters.purposeEnumId" ignore-if-empty="true"/>
-                    <condition-expr field-name="fromDate" operator="less-equals" from-field="asOfDate"/>
-                    <condition-list combine="or">
-                        <condition-expr field-name="thruDate" operator="greater-equals" from-field="asOfDate"/>
-                        <condition-expr field-name="thruDate" operator="equals" from-field="nullField"/>
-                    </condition-list>
+        <!-- first try the UomConversionDated entity -->
+        <entity-condition entity-name="UomConversionDated" list="uomConversions" use-cache="true">
+            <condition-list combine="and">
+                <condition-expr field-name="uomId" from-field="parameters.uomId"/>
+                <condition-expr field-name="uomIdTo" from-field="parameters.uomIdTo"/>
+                <condition-expr field-name="purposeEnumId" operator="equals" from-field="parameters.purposeEnumId" ignore-if-empty="true"/>
+                <condition-expr field-name="fromDate" operator="less-equals" from-field="asOfDate"/>
+                <condition-list combine="or">
+                    <condition-expr field-name="thruDate" operator="greater-equals" from-field="asOfDate"/>
+                    <condition-expr field-name="thruDate" operator="equals" from-field="nullField"/>
                 </condition-list>
-                    <!-- sort by descending fromDate to get newest (biggest) first -->
-                <order-by field-name="-fromDate"/>
-            </entity-condition>
-            <first-from-list list="uomConversions" entry="uomConversion"/>
+            </condition-list>
+            <!-- sort by descending fromDate to get newest (biggest) first -->
+            <order-by field-name="-fromDate"/>
+        </entity-condition>
+        <first-from-list list="uomConversions" entry="uomConversion"/>
 
-            <!-- if no conversion found with specified purpose, try w/o purpose -->
-            <if-empty field="uomConversion">
-                <if-not-empty field="parameters.purposeEnumId">
-                    <entity-condition entity-name="UomConversionDated" list="uomConversions" use-cache="true">
-                        <condition-list combine="and">
-                            <condition-expr field-name="uomId" from-field="parameters.uomId"/>
-                            <condition-expr field-name="uomIdTo" from-field="parameters.uomIdTo"/>
-                            <condition-expr field-name="fromDate" operator="less-equals" from-field="asOfDate"/>
-                            <condition-list combine="or">
-                                <condition-expr field-name="thruDate" operator="greater-equals" from-field="asOfDate"/>
-                                <condition-expr field-name="thruDate" operator="equals" from-field="nullField"/>
-                            </condition-list>
+        <!-- if no conversion found with specified purpose, try w/o purpose -->
+        <if-empty field="uomConversion">
+            <if-not-empty field="parameters.purposeEnumId">
+                <entity-condition entity-name="UomConversionDated" list="uomConversions" use-cache="true">
+                    <condition-list combine="and">
+                        <condition-expr field-name="uomId" from-field="parameters.uomId"/>
+                        <condition-expr field-name="uomIdTo" from-field="parameters.uomIdTo"/>
+                        <condition-expr field-name="fromDate" operator="less-equals" from-field="asOfDate"/>
+                        <condition-list combine="or">
+                            <condition-expr field-name="thruDate" operator="greater-equals" from-field="asOfDate"/>
+                            <condition-expr field-name="thruDate" operator="equals" from-field="nullField"/>
                         </condition-list>
-                        <order-by field-name="-fromDate"/>
-                    </entity-condition>
-                    <first-from-list list="uomConversions" entry="uomConversion"/>
-                </if-not-empty>
-            </if-empty>
+                    </condition-list>
+                    <order-by field-name="-fromDate"/>
+                </entity-condition>
+                <first-from-list list="uomConversions" entry="uomConversion"/>
+            </if-not-empty>
+        </if-empty>
+        <!-- if not found, try the uom conversion entity -->
+        <if-empty field="uomConversion">
+            <entity-one entity-name="UomConversion" value-field="uomConversion" auto-field-map="true" use-cache="true"/>
         </if-empty>
         <log level="verbose" message="using conversion factor=${uomConversion.conversionFactor}"/>
 

Modified: ofbiz/ofbiz-framework/trunk/framework/common/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/servicedef/services.xml?rev=1851137&r1=1851136&r2=1851137&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/common/servicedef/services.xml (original)
+++ ofbiz/ofbiz-framework/trunk/framework/common/servicedef/services.xml Sat Jan 12 06:18:09 2019
@@ -308,7 +308,7 @@ under the License.
     </service>
     <service name="convertUom" default-entity-name="UomConversion" engine="simple"
             location="component://common/minilang/CommonServices.xml" invoke="convertUom" auth="false">
-        <description>Make a unit of measure conversion, first using UomConversion, then with UomConversionDated</description>
+        <description>Make a unit of measure conversion, first using UomConversionDated, then with UomConversion</description>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <attribute name="asOfDate" mode="IN" type="Timestamp" optional="true"/>
         <attribute name="originalValue" mode="IN" type="BigDecimal" optional="false"/>