You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by si...@apache.org on 2006/11/08 19:50:21 UTC
svn commit: r472587 - in /incubator/ofbiz/trunk/framework/common:
script/org/ofbiz/common/CommonServices.xml servicedef/services.xml
Author: sichen
Date: Wed Nov 8 10:50:20 2006
New Revision: 472587
URL: http://svn.apache.org/viewvc?view=rev&rev=472587
Log:
Added parameter asOfDate to convertUom which will select the conversion for that date. Useful for time-varying conversion rates.
Modified:
incubator/ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml
incubator/ofbiz/trunk/framework/common/servicedef/services.xml
Modified: incubator/ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml?view=diff&rev=472587&r1=472586&r2=472587
==============================================================================
--- incubator/ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml (original)
+++ incubator/ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml Wed Nov 8 10:50:20 2006
@@ -59,6 +59,14 @@
<return/>
</if-compare-field>
+ <if-empty field-name="parameters.asOfDate">
+ <now-timestamp-to-env env-name="nowTimestamp"/>
+ <set field="asOfDate" from-field="nowTimestamp"/>
+ <else>
+ <set field="asOfDate" from-field="parameters.asOfDate"/>
+ </else>
+ </if-empty>
+
<!-- first try the regular UomConversion entity (no dates) -->
<entity-one entity-name="UomConversion" value-name="uomConversion" auto-field-map="true" use-cache="true"/>
@@ -68,11 +76,15 @@
<condition-list combine="and">
<condition-expr field-name="uomId" env-name="parameters.uomId"/>
<condition-expr field-name="uomIdTo" env-name="parameters.uomIdTo"/>
+ <condition-expr field-name="fromDate" operator="less-equals" env-name="asOfDate"/>
+ <condition-list combine="or">
+ <condition-expr field-name="thruDate" operator="greater-equals" env-name="asOfDate"/>
+ <condition-expr field-name="thruDate" operator="equals" env-name="nullField"/>
+ </condition-list>
</condition-list>
<!-- sort by descending fromDate to get newest (biggest) first -->
<order-by field-name="-fromDate"/>
</entity-condition>
- <filter-list-by-date list-name="uomConversions"/>
<first-from-list list-name="uomConversions" entry-name="uomConversion"/>
</if-empty>
<log level="verbose" message="using conversion factor=${uomConversion.conversionFactor}"/>
Modified: incubator/ofbiz/trunk/framework/common/servicedef/services.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/common/servicedef/services.xml?view=diff&rev=472587&r1=472586&r2=472587
==============================================================================
--- incubator/ofbiz/trunk/framework/common/servicedef/services.xml (original)
+++ incubator/ofbiz/trunk/framework/common/servicedef/services.xml Wed Nov 8 10:50:20 2006
@@ -283,6 +283,7 @@
location="org/ofbiz/common/CommonServices.xml" invoke="convertUom" auth="false">
<description>Make a unit of measure conversion, first using UomConversion, then with UomConversionDated</description>
<auto-attributes include="pk" mode="IN" optional="false"/>
+ <attribute name="asOfDate" mode="IN" type="Timestamp" optional="true"/>
<attribute name="originalValue" mode="IN" type="Double" optional="false"/>
<attribute name="conversionParameters" mode="IN" type="Map" optional="true"/>
<attribute name="convertedValue" mode="OUT" type="Double" optional="false"/>