You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacques Le Roux <ja...@les7arts.com> on 2007/05/29 21:45:11 UTC

Re: svn commit: r542435 - /ofbiz/branches/release4.0/applications/product/src/org/ofbiz/product/price/PriceServices.java

Hi Scott,

It's my mistake, but I'm a bit surprised because if you look at
https://issues.apache.org/jira/browse/OFBIZ-1035 you will see that I had
spotted this issues. At this time we were still using ant build files
with source="1.4". And the changes Nicolas made allowed compilation,
hence I did not look closer at the code. I should, obviously, looking at
"BigDecimal valueOf(double)" from http://tinyurl.com/34y4j3.

I wonder why the ant build accepted to compile but there is certainly an
explanation I'm not aware. This is not the most inportant and the reason
of my reply.

Now that we use source="1.5, should it not be better to restrict usage
of the release 4.0 to jdk 1.5. This because such errors will become more
and more difficult to spot while the time will pass.

What do you think, folks ?

Jacques

De : <le...@apache.org>
> Author: lektran
> Date: Tue May 29 00:11:12 2007
> New Revision: 542435
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=542435
> Log:
> Fixed some code that was incompatible with Java 1.4
> Committers, please watch out for this when applying fixes to the
release branch
>
> Modified:
>
ofbiz/branches/release4.0/applications/product/src/org/ofbiz/product/pri
ce/PriceServices.java
>
> Modified:
ofbiz/branches/release4.0/applications/product/src/org/ofbiz/product/pri
ce/PriceServices.java
> URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/product/src/org/ofbiz/product/price/PriceServices.java?view=diff&rev=542435&r1=542434&r2=542435
>
========================================================================
======
> --- 
ofbiz/branches/release4.0/applications/product/src/org/ofbiz/product/pri
ce/PriceServices.java (original)
> +++
ofbiz/branches/release4.0/applications/product/src/org/ofbiz/product/pri
ce/PriceServices.java Tue May 29 00:11:12 2007
> @@ -621,8 +621,8 @@
>          // okay, now we have the calculated price, see if we should
add in tax and if so do it
>          if ("Y".equals(checkIncludeVat) && productStore != null &&
"Y".equals(productStore.getString("showPricesWithVatTax"))) {
>              Map calcTaxForDisplayContext =
UtilMisc.toMap("productStoreId", productStore.get("productStoreId"),
> -                    "productId", productId, "quantity",
BigDecimal.valueOf(quantity),
> -                    "basePrice", BigDecimal.valueOf(((Double)
result.get("price")).doubleValue()));
> +                    "productId", productId, "quantity", new
BigDecimal(quantity),
> +                    "basePrice", new BigDecimal(((Double)
result.get("price")).doubleValue()));
>              if (UtilValidate.isNotEmpty(partyId)) {
>                  calcTaxForDisplayContext.put("billToPartyId",
partyId);
>              }
> @@ -633,25 +633,25 @@
>                      return ServiceUtil.returnError("Error calculating
VAT tax (with calcTaxForDisplay service)", null, null,
calcTaxForDisplayResult);
>                  }
>                  // taxTotal, taxPercentage, priceWithTax
> -                result.put("price", Double.valueOf(((BigDecimal)
calcTaxForDisplayResult.get("priceWithTax")).doubleValue()));
> +                result.put("price", new Double(((BigDecimal)
calcTaxForDisplayResult.get("priceWithTax")).doubleValue()));
>
>                  // based on the taxPercentage calculate the other
amounts, including: listPrice, defaultPrice, averageCost, promoPrice,
competitivePrice
>                  BigDecimal taxPercentage = (BigDecimal)
calcTaxForDisplayResult.get("taxPercentage");
>                  BigDecimal taxMultiplier =
ONE_BASE.add(taxPercentage.divide(PERCENT_SCALE, taxCalcScale));
>                  if (result.get("listPrice") != null) {
> -                    result.put("listPrice", Double.valueOf(
BigDecimal.valueOf(((Double)
result.get("listPrice")).doubleValue()).multiply(taxMultiplier).setScale
( taxFinalScale, taxRounding ).doubleValue()));
> +                    result.put("listPrice", new Double( new
BigDecimal(((Double)
result.get("listPrice")).doubleValue()).multiply(taxMultiplier).setScale
( taxFinalScale, taxRounding ).doubleValue()));
>                  }
>                  if (result.get("defaultPrice") != null) {
> -                    result.put("defaultPrice", Double.valueOf(
BigDecimal.valueOf(((Double)
result.get("defaultPrice")).doubleValue()).multiply(taxMultiplier).setSc
ale( taxFinalScale, taxRounding ).doubleValue()));
> +                    result.put("defaultPrice", new Double( new
BigDecimal(((Double)
result.get("defaultPrice")).doubleValue()).multiply(taxMultiplier).setSc
ale( taxFinalScale, taxRounding ).doubleValue()));
>                  }
>                  if (result.get("averageCost") != null) {
> -                    result.put("averageCost", Double.valueOf(
BigDecimal.valueOf(((Double)
result.get("averageCost")).doubleValue()).multiply(taxMultiplier).setSca
le( taxFinalScale, taxRounding ).doubleValue()));
> +                    result.put("averageCost", new Double( new
BigDecimal(((Double)
result.get("averageCost")).doubleValue()).multiply(taxMultiplier).setSca
le( taxFinalScale, taxRounding ).doubleValue()));
>                  }
>                  if (result.get("promoPrice") != null) {
> -                    result.put("promoPrice", Double.valueOf(
BigDecimal.valueOf(((Double)
result.get("promoPrice")).doubleValue()).multiply(taxMultiplier).setScal
e( taxFinalScale, taxRounding ).doubleValue()));
> +                    result.put("promoPrice", new Double( new
BigDecimal(((Double)
result.get("promoPrice")).doubleValue()).multiply(taxMultiplier).setScal
e( taxFinalScale, taxRounding ).doubleValue()));
>                  }
>                  if (result.get("competitivePrice") != null) {
> -                    result.put("competitivePrice", Double.valueOf(
BigDecimal.valueOf(((Double)
result.get("competitivePrice")).doubleValue()).multiply(taxMultiplier).s
etScale( taxFinalScale, taxRounding ).doubleValue()));
> +                    result.put("competitivePrice", new Double( new
BigDecimal(((Double)
result.get("competitivePrice")).doubleValue()).multiply(taxMultiplier).s
etScale( taxFinalScale, taxRounding ).doubleValue()));
>                  }
>              } catch (GenericServiceException e) {
>                  String errMsg = "Error calculating VAT tax (with
calcTaxForDisplay service): " + e.toString();
>


Re: svn commit: r542435 - /ofbiz/branches/release4.0/applications/product/src/org/ofbiz/product/price/PriceServices.java

Posted by Tim Ruppert <ti...@hotwaxmedia.com>.
+1 for updating release 4.0 to 1.5 only.

Cheers,
Tim
--
Tim Ruppert
HotWax Media
http://www.hotwaxmedia.com

o:801.649.6594
f:801.649.6595


On May 29, 2007, at 1:45 PM, Jacques Le Roux wrote:

> Hi Scott,
>
> It's my mistake, but I'm a bit surprised because if you look at
> https://issues.apache.org/jira/browse/OFBIZ-1035 you will see that  
> I had
> spotted this issues. At this time we were still using ant build files
> with source="1.4". And the changes Nicolas made allowed compilation,
> hence I did not look closer at the code. I should, obviously,  
> looking at
> "BigDecimal valueOf(double)" from http://tinyurl.com/34y4j3.
>
> I wonder why the ant build accepted to compile but there is  
> certainly an
> explanation I'm not aware. This is not the most inportant and the  
> reason
> of my reply.
>
> Now that we use source="1.5, should it not be better to restrict usage
> of the release 4.0 to jdk 1.5. This because such errors will become  
> more
> and more difficult to spot while the time will pass.
>
> What do you think, folks ?
>
> Jacques
>
> De : <le...@apache.org>
>> Author: lektran
>> Date: Tue May 29 00:11:12 2007
>> New Revision: 542435
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=542435
>> Log:
>> Fixed some code that was incompatible with Java 1.4
>> Committers, please watch out for this when applying fixes to the
> release branch
>>
>> Modified:
>>
> ofbiz/branches/release4.0/applications/product/src/org/ofbiz/ 
> product/pri
> ce/PriceServices.java
>>
>> Modified:
> ofbiz/branches/release4.0/applications/product/src/org/ofbiz/ 
> product/pri
> ce/PriceServices.java
>> URL:
> http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/ 
> product/src/org/ofbiz/product/price/PriceServices.java? 
> view=diff&rev=542435&r1=542434&r2=542435
>>
> ====================================================================== 
> ==
> ======
>> ---
> ofbiz/branches/release4.0/applications/product/src/org/ofbiz/ 
> product/pri
> ce/PriceServices.java (original)
>> +++
> ofbiz/branches/release4.0/applications/product/src/org/ofbiz/ 
> product/pri
> ce/PriceServices.java Tue May 29 00:11:12 2007
>> @@ -621,8 +621,8 @@
>>          // okay, now we have the calculated price, see if we should
> add in tax and if so do it
>>          if ("Y".equals(checkIncludeVat) && productStore != null &&
> "Y".equals(productStore.getString("showPricesWithVatTax"))) {
>>              Map calcTaxForDisplayContext =
> UtilMisc.toMap("productStoreId", productStore.get("productStoreId"),
>> -                    "productId", productId, "quantity",
> BigDecimal.valueOf(quantity),
>> -                    "basePrice", BigDecimal.valueOf(((Double)
> result.get("price")).doubleValue()));
>> +                    "productId", productId, "quantity", new
> BigDecimal(quantity),
>> +                    "basePrice", new BigDecimal(((Double)
> result.get("price")).doubleValue()));
>>              if (UtilValidate.isNotEmpty(partyId)) {
>>                  calcTaxForDisplayContext.put("billToPartyId",
> partyId);
>>              }
>> @@ -633,25 +633,25 @@
>>                      return ServiceUtil.returnError("Error  
>> calculating
> VAT tax (with calcTaxForDisplay service)", null, null,
> calcTaxForDisplayResult);
>>                  }
>>                  // taxTotal, taxPercentage, priceWithTax
>> -                result.put("price", Double.valueOf(((BigDecimal)
> calcTaxForDisplayResult.get("priceWithTax")).doubleValue()));
>> +                result.put("price", new Double(((BigDecimal)
> calcTaxForDisplayResult.get("priceWithTax")).doubleValue()));
>>
>>                  // based on the taxPercentage calculate the other
> amounts, including: listPrice, defaultPrice, averageCost, promoPrice,
> competitivePrice
>>                  BigDecimal taxPercentage = (BigDecimal)
> calcTaxForDisplayResult.get("taxPercentage");
>>                  BigDecimal taxMultiplier =
> ONE_BASE.add(taxPercentage.divide(PERCENT_SCALE, taxCalcScale));
>>                  if (result.get("listPrice") != null) {
>> -                    result.put("listPrice", Double.valueOf(
> BigDecimal.valueOf(((Double)
> result.get("listPrice")).doubleValue()).multiply 
> (taxMultiplier).setScale
> ( taxFinalScale, taxRounding ).doubleValue()));
>> +                    result.put("listPrice", new Double( new
> BigDecimal(((Double)
> result.get("listPrice")).doubleValue()).multiply 
> (taxMultiplier).setScale
> ( taxFinalScale, taxRounding ).doubleValue()));
>>                  }
>>                  if (result.get("defaultPrice") != null) {
>> -                    result.put("defaultPrice", Double.valueOf(
> BigDecimal.valueOf(((Double)
> result.get("defaultPrice")).doubleValue()).multiply 
> (taxMultiplier).setSc
> ale( taxFinalScale, taxRounding ).doubleValue()));
>> +                    result.put("defaultPrice", new Double( new
> BigDecimal(((Double)
> result.get("defaultPrice")).doubleValue()).multiply 
> (taxMultiplier).setSc
> ale( taxFinalScale, taxRounding ).doubleValue()));
>>                  }
>>                  if (result.get("averageCost") != null) {
>> -                    result.put("averageCost", Double.valueOf(
> BigDecimal.valueOf(((Double)
> result.get("averageCost")).doubleValue()).multiply 
> (taxMultiplier).setSca
> le( taxFinalScale, taxRounding ).doubleValue()));
>> +                    result.put("averageCost", new Double( new
> BigDecimal(((Double)
> result.get("averageCost")).doubleValue()).multiply 
> (taxMultiplier).setSca
> le( taxFinalScale, taxRounding ).doubleValue()));
>>                  }
>>                  if (result.get("promoPrice") != null) {
>> -                    result.put("promoPrice", Double.valueOf(
> BigDecimal.valueOf(((Double)
> result.get("promoPrice")).doubleValue()).multiply 
> (taxMultiplier).setScal
> e( taxFinalScale, taxRounding ).doubleValue()));
>> +                    result.put("promoPrice", new Double( new
> BigDecimal(((Double)
> result.get("promoPrice")).doubleValue()).multiply 
> (taxMultiplier).setScal
> e( taxFinalScale, taxRounding ).doubleValue()));
>>                  }
>>                  if (result.get("competitivePrice") != null) {
>> -                    result.put("competitivePrice", Double.valueOf(
> BigDecimal.valueOf(((Double)
> result.get("competitivePrice")).doubleValue()).multiply 
> (taxMultiplier).s
> etScale( taxFinalScale, taxRounding ).doubleValue()));
>> +                    result.put("competitivePrice", new Double( new
> BigDecimal(((Double)
> result.get("competitivePrice")).doubleValue()).multiply 
> (taxMultiplier).s
> etScale( taxFinalScale, taxRounding ).doubleValue()));
>>                  }
>>              } catch (GenericServiceException e) {
>>                  String errMsg = "Error calculating VAT tax (with
> calcTaxForDisplay service): " + e.toString();
>>
>