svn commit: r955571 - in /ofbiz/branches/release10.04: ./ framework/minilang/src/org/ofbiz/minilang/method/otherops/Calculate.java mergefromtrunk.bat

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

svn commit: r955571 - in /ofbiz/branches/release10.04: ./ framework/minilang/src/org/ofbiz/minilang/method/otherops/Calculate.java mergefromtrunk.bat

jleroux@apache.org
Author: jleroux
Date: Thu Jun 17 12:31:20 2010
New Revision: 955571

URL: http://svn.apache.org/viewvc?rev=955571&view=rev
Log:
"Applied fix from trunk for revision: 955568"
------------------------------------------------------------------------
r955568 | jleroux | 2010-06-17 14:26:16 +0200 (jeu. 17 juin 2010) | 16 lignes

A patch from Shubham Dubey "Using number value with calcop operator does not work as thought" (https://issues.apache.org/jira/browse/OFBIZ-3821) - OFBIZ-3821

For instance if you use

<calcop operator="multiply" field="parameters.numberSpecified">
    <number value="${uomConversion.conversionFactor}"/>

and have a value > 1000 in conversionFactor you will get 1,000 for number value. It works well if you replace by

<calcop operator="multiply">
    <calcop operator="get" field="parameters.numberSpecified"/>
    <calcop operator="get" field="uomConversion.conversionFactor"/>

The problem exists in trunk and certainly R10.04 (not tested) maybe in previous release though I don't think so, it looks like something introduced with UEL


------------------------------------------------------------------------


Modified:
    ofbiz/branches/release10.04/   (props changed)
    ofbiz/branches/release10.04/framework/minilang/src/org/ofbiz/minilang/method/otherops/Calculate.java
    ofbiz/branches/release10.04/mergefromtrunk.bat

Propchange: ofbiz/branches/release10.04/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 17 12:31:20 2010
@@ -1,3 +1,3 @@
 /ofbiz/branches/addbirt:831210-885099,885686-886087
 /ofbiz/branches/multitenant20100310:921280-927264
-/ofbiz/trunk:939988,939990,939999,940025,940053,940234,940248,940309,940401,940410,940425,940779,940815,940849,941007,941047,941109,941177,941199,941261,941440,941600,941999,942084,942406,942414,942671,942883-942884,943168,943271-943272,944614,944621,944623,944647,944669,944797,944895,945010,945018,945026,945118,945573,945578,945580,945582,945610,945619,945848,945852,945857,946061,946066,946073,946075,946080,946309,946313,946320,946322,946596,947004-947005,947392,947424,947679,947988,948017,948694,949174,949710,949844,950866,950870,950893,951005,951062,951098,951251,951367,951381,951672,952232,952249,952270,953294,953671,954135,954583,954733,954956
+/ofbiz/trunk:939988,939990,939999,940025,940053,940234,940248,940309,940401,940410,940425,940779,940815,940849,941007,941047,941109,941177,941199,941261,941440,941600,941999,942084,942406,942414,942671,942883-942884,943168,943271-943272,944614,944621,944623,944647,944669,944797,944895,945010,945018,945026,945118,945573,945578,945580,945582,945610,945619,945848,945852,945857,946061,946066,946073,946075,946080,946309,946313,946320,946322,946596,947004-947005,947392,947424,947679,947988,948017,948694,949174,949710,949844,950866,950870,950893,951005,951062,951098,951251,951367,951381,951672,952232,952249,952270,953294,953671,954135,954583,954733,954956,955568

Modified: ofbiz/branches/release10.04/framework/minilang/src/org/ofbiz/minilang/method/otherops/Calculate.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/framework/minilang/src/org/ofbiz/minilang/method/otherops/Calculate.java?rev=955571&r1=955570&r2=955571&view=diff
==============================================================================
--- ofbiz/branches/release10.04/framework/minilang/src/org/ofbiz/minilang/method/otherops/Calculate.java (original)
+++ ofbiz/branches/release10.04/framework/minilang/src/org/ofbiz/minilang/method/otherops/Calculate.java Thu Jun 17 12:31:20 2010
@@ -22,10 +22,12 @@ import java.math.BigDecimal;
 import java.text.DecimalFormat;
 import java.util.List;
 import java.util.Map;
+import java.util.Locale;
 
 import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.minilang.SimpleMethod;
@@ -243,10 +245,14 @@ public class Calculate extends MethodOpe
 
         public BigDecimal calcValue(MethodContext methodContext, int scale, int roundingMode) {
             String valueStr = methodContext.expandString(this.valueStr);
+            Locale locale = (Locale) methodContext.getLocale();
+
+            if (locale == null) locale = Locale.getDefault();
+            
             BigDecimal value;
             try {
-                value = new BigDecimal(valueStr);
-                value = value.setScale(scale, roundingMode);
+                BigDecimal parseVal = (BigDecimal) ObjectType.simpleTypeConvert(valueStr, "BigDecimal", null, null, locale, true);
+                value = parseVal.setScale(scale, roundingMode);
             } catch (Exception e) {
                 Debug.logError(e, "Could not parse the number string: " + valueStr, module);
                 throw new IllegalArgumentException("Could not parse the number string: " + valueStr);

Modified: ofbiz/branches/release10.04/mergefromtrunk.bat
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/mergefromtrunk.bat?rev=955571&r1=955570&r2=955571&view=diff
==============================================================================
--- ofbiz/branches/release10.04/mergefromtrunk.bat (original)
+++ ofbiz/branches/release10.04/mergefromtrunk.bat Thu Jun 17 12:31:20 2010
@@ -1,3 +1,4 @@
+echo off
 rem #####################################################################
 rem Licensed to the Apache Software Foundation (ASF) under one
 rem or more contributor license agreements.  See the NOTICE file
@@ -19,7 +20,6 @@ rem ####################################
 rem interactive DOS version of mergefromtrunk.sh.
 rem to use : launch and pass the trunk version number to merge in release
 
-echo off
 rem since we have now svn:mergeinfo changing root ("."), we need to update before merging
 svn up