Dev - [Fwd: [OFBiz] SVN: r7200 - trunk/applications/order/src/org/ofbiz/order/shoppingcart]

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

Dev - [Fwd: [OFBiz] SVN: r7200 - trunk/applications/order/src/org/ofbiz/order/shoppingcart]

Si Chen-2
Jacopo,

I think this code that you removed is an earlier attempt at rounding to
two decimal places.  It is good to have removed it, but it should be
replaced with BigDecimal rounding.

Si

Author: jacopo
Date: 2006-04-05 07:48:18 -0500 (Wed, 05 Apr 2006)
New Revision: 7200

Modified:
   trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
Log:
Removed code that was formatting a double into a string (using the format defined in the general.properties file) and then was parsing it back to a double:
I'm not sure why it has been implemented in that way and I can't imagine a good reason to keep that code (that probably is rather old) and so now I've simplified it.
If you see something wrong in this commit please let me know and I'll revert this change.


Modified: trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java 2006-04-05 06:34:59 UTC (rev 7199)
+++ trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java 2006-04-05 12:48:18 UTC (rev 7200)
@@ -1443,18 +1443,7 @@
             }
         }
 
-        double availableBalance = (accountLimit.doubleValue() - accountBalance.doubleValue());
-        String currencyFormat = UtilProperties.getPropertyValue("general.properties", "currency.decimal.format", "##0.00");
-        DecimalFormat formatter = new DecimalFormat(currencyFormat);
-        String availableString = formatter.format(availableBalance);
-        Double available = null;
-        try {
-            available = new Double(formatter.parse(availableString).doubleValue());
-        } catch (ParseException e) {
-            Debug.logError(e, "Problem getting parsed available amount", module);
-        }
-        //Debug.logInfo("Billing Account : " + billingAccountId + " - " + available, module);
-        return available.doubleValue();
+        return (accountLimit.doubleValue() - accountBalance.doubleValue());
     }
 
     public Map makeBillingAccountMap(List paymentPrefs) {

 
_______________________________________________
Svn mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/svn



 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Dev - [Fwd: [OFBiz] SVN: r7200 - trunk/applications/order/src/org/ofbiz/order/shoppingcart]

Jacopo Cappellato
Si,

thanks for your comment: now I see the meaning of that code.
Ok, with rev. 7251 I've converted the
BillingAccountWorker.getBillingAccountBalance(...) method to perform
calculations using BigDecimals instead of doubles.
Since both accountLimit and accountBalance have now the same two digits
precision, this should do the trick (waiting for a full migration to bd).

Jacopo

Si Chen wrote:

> Jacopo,
>
> I think this code that you removed is an earlier attempt at rounding to
> two decimal places.  It is good to have removed it, but it should be
> replaced with BigDecimal rounding.
>
> Si
>
> ------------------------------------------------------------------------
>
> Subject:
> [OFBiz] SVN: r7200 -
> trunk/applications/order/src/org/ofbiz/order/shoppingcart
> From:
> [hidden email]
> Date:
> 5 Apr 2006 12:48:24 -0000
> To:
> [hidden email]
>
> To:
> [hidden email]
>
>
> Author: jacopo
> Date: 2006-04-05 07:48:18 -0500 (Wed, 05 Apr 2006)
> New Revision: 7200
>
> Modified:
>    trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
> Log:
> Removed code that was formatting a double into a string (using the format defined in the general.properties file) and then was parsing it back to a double:
> I'm not sure why it has been implemented in that way and I can't imagine a good reason to keep that code (that probably is rather old) and so now I've simplified it.
> If you see something wrong in this commit please let me know and I'll revert this change.
>
>
> Modified: trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
> ===================================================================
> --- trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java 2006-04-05 06:34:59 UTC (rev 7199)
> +++ trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java 2006-04-05 12:48:18 UTC (rev 7200)
> @@ -1443,18 +1443,7 @@
>              }
>          }
>  
> -        double availableBalance = (accountLimit.doubleValue() - accountBalance.doubleValue());
> -        String currencyFormat = UtilProperties.getPropertyValue("general.properties", "currency.decimal.format", "##0.00");
> -        DecimalFormat formatter = new DecimalFormat(currencyFormat);
> -        String availableString = formatter.format(availableBalance);
> -        Double available = null;
> -        try {
> -            available = new Double(formatter.parse(availableString).doubleValue());
> -        } catch (ParseException e) {
> -            Debug.logError(e, "Problem getting parsed available amount", module);
> -        }
> -        //Debug.logInfo("Billing Account : " + billingAccountId + " - " + available, module);
> -        return available.doubleValue();
> +        return (accountLimit.doubleValue() - accountBalance.doubleValue());
>      }
>  
>      public Map makeBillingAccountMap(List paymentPrefs) {
>
>  
> _______________________________________________
> Svn mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/svn
>
>
>
>
> ------------------------------------------------------------------------
>
>  
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev